From 40bd7c89abbdf79493e2ea20dd80d9eb657dc82e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 12 Nov 2018 16:27:38 -0800 Subject: [PATCH] Update LKG. --- lib/enu/diagnosticMessages.generated.json.lcg | 154 +- lib/ko/diagnosticMessages.generated.json | 6 +- lib/lib.dom.d.ts | 816 +- lib/lib.es2015.collection.d.ts | 3 +- lib/lib.es2015.iterable.d.ts | 2 +- lib/lib.es2015.symbol.wellknown.d.ts | 22 +- lib/lib.esnext.bigint.d.ts | 629 + lib/lib.esnext.d.ts | 1 + lib/lib.webworker.d.ts | 1309 +- lib/protocol.d.ts | 18 +- lib/tsc.js | 19654 ++++++----- lib/tsserver.js | 29406 +++++++-------- lib/tsserverlibrary.d.ts | 1043 +- lib/tsserverlibrary.js | 29448 ++++++++-------- lib/typescript.d.ts | 1001 +- lib/typescript.js | 28988 +++++++-------- lib/typescriptServices.d.ts | 1001 +- lib/typescriptServices.js | 28988 +++++++-------- lib/typingsInstaller.js | 21482 +++++------ lib/zh-tw/diagnosticMessages.generated.json | 12 +- 20 files changed, 87389 insertions(+), 76594 deletions(-) create mode 100644 lib/lib.esnext.bigint.d.ts diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg index 58166339abe..e4080a9bb37 100644 --- a/lib/enu/diagnosticMessages.generated.json.lcg +++ b/lib/enu/diagnosticMessages.generated.json.lcg @@ -741,6 +741,18 @@ + + + + + + + + + + + + @@ -873,9 +885,9 @@ - + - + @@ -1107,6 +1119,12 @@ + + + + + + @@ -1215,6 +1233,12 @@ + + + + + + @@ -1433,19 +1457,19 @@ - + - + - + - + - + @@ -2049,6 +2073,12 @@ + + + {1}'?]]> + + + @@ -2763,12 +2793,24 @@ + + + + + + + + + + + + @@ -2847,6 +2889,12 @@ + + + + + + @@ -3573,6 +3621,12 @@ + + + + + + @@ -3939,6 +3993,12 @@ + + + + + + @@ -4095,6 +4155,12 @@ + + + + + + @@ -4299,6 +4365,12 @@ + + + + + + @@ -4413,6 +4485,18 @@ + + + + + + + + + + + + @@ -4455,6 +4539,12 @@ + + + + + + @@ -4869,6 +4959,12 @@ + + + + + + @@ -5487,9 +5583,9 @@ - + - + @@ -5577,9 +5673,9 @@ - + - + @@ -5781,6 +5877,18 @@ + + + + + + + + + + + + @@ -6249,6 +6357,12 @@ + + + + + + @@ -6273,6 +6387,18 @@ + + + + + + + + + + + + @@ -6357,6 +6483,12 @@ + + + + + + diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index 1003d62329c..a1b1320115a 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -3,7 +3,7 @@ "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045": "'{0}' 한정자는 인터페이스 선언에서 사용할 수 없습니다.", "A_0_parameter_must_be_the_first_parameter_2680": "'{0}' 매개 변수는 첫 번째 매개 변수여야 합니다.", "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463": "바인딩 패턴 매개 변수는 구현 서명에서 선택 사항이 될 수 없습니다.", - "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105": "'break' 문은 이 문을 둘러싼 반복 문 또는 switch 문 내에서만 사용할 수 있습니다.", + "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105": "'break' 문은 이 문을 둘러싼 반복문 또는 switch 문 내에서만 사용할 수 있습니다.", "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116": "'break' 문은 이 문을 둘러싼 문의 레이블로만 이동할 수 있습니다.", "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500": "클래스는 선택적 형식 인수가 포함된 식별자/정규화된 이름만 구현할 수 있습니다.", "A_class_declaration_without_the_default_modifier_must_have_a_name_1211": "'default' 한정자를 사용하지 않는 클래스 선언에는 이름이 있어야 합니다.", @@ -23,8 +23,8 @@ "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254": "앰비언트 컨텍스트의 'const' 이니셜라이저는 문자열 또는 숫자 리터럴이어야 합니다.", "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005": "생성자는 해당 클래스가 'null'을 확장하는 경우 'super' 호출을 포함할 수 없습니다.", "A_constructor_cannot_have_a_this_parameter_2681": "생성자에는 'this' 매개 변수를 사용할 수 없습니다.", - "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104": "'continue' 문은 이 문을 둘러싼 반복 문 내에서만 사용할 수 있습니다.", - "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115": "'continue' 문은 이 문을 둘러싼 반복 문의 레이블로만 이동할 수 있습니다.", + "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104": "'continue' 문은 이 문을 둘러싼 반복문 내에서만 사용할 수 있습니다.", + "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115": "'continue' 문은 이 문을 둘러싼 반복문의 레이블로만 이동할 수 있습니다.", "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038": "'declare' 한정자는 이미 존재하는 앰비언트 컨텍스트에서 사용할 수 없습니다.", "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046": "'declare' 한정자는 .d.ts 파일의 최상위 선언에 필요합니다.", "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249": "데코레이터는 오버로드가 아니라 메서드 구현만 데코레이팅할 수 있습니다.", diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index f08e5d55677..464dea83926 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -162,6 +162,7 @@ interface BiquadFilterOptions extends AudioNodeOptions { } interface BlobPropertyBag { + endings?: EndingType; type?: string; } @@ -220,11 +221,12 @@ interface ComputedEffectTiming extends EffectTiming { progress?: number | null; } -interface ComputedKeyframe extends Record { - composite?: CompositeOperation | null; - computedOffset?: number; - easing?: string; - offset?: number | null; +interface ComputedKeyframe { + composite: CompositeOperationOrAuto; + computedOffset: number; + easing: string; + offset: number | null; + [property: string]: string | number | null | undefined; } interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { @@ -586,10 +588,11 @@ interface KeyboardEventInit extends EventModifierInit { repeat?: boolean; } -interface Keyframe extends Record { - composite?: CompositeOperation | null; +interface Keyframe { + composite?: CompositeOperationOrAuto; easing?: string; offset?: number | null; + [property: string]: string | number | null | undefined; } interface KeyframeAnimationOptions extends KeyframeEffectOptions { @@ -907,6 +910,12 @@ interface PeriodicWaveOptions extends PeriodicWaveConstraints { real?: number[] | Float32Array; } +interface PipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + preventClose?: boolean; +} + interface PointerEventInit extends MouseEventInit { height?: number; isPrimary?: boolean; @@ -941,10 +950,11 @@ interface PromiseRejectionEventInit extends EventInit { reason?: any; } -interface PropertyIndexedKeyframes extends Record { - composite?: CompositeOperation | (CompositeOperation | null)[]; +interface PropertyIndexedKeyframes { + composite?: CompositeOperationOrAuto | CompositeOperationOrAuto[]; easing?: string | string[]; offset?: number | (number | null)[]; + [property: string]: string | string[] | number | null | (number | null)[] | undefined; } interface PushSubscriptionJSON { @@ -958,9 +968,9 @@ interface PushSubscriptionOptionsInit { userVisibleOnly?: boolean; } -interface QueuingStrategy { +interface QueuingStrategy { highWaterMark?: number; - size?: WritableStreamChunkCallback; + size?: QueuingStrategySizeCallback; } interface RTCAnswerOptions extends RTCOfferAnswerOptions { @@ -1516,6 +1526,14 @@ interface TrackEventInit extends EventInit { track?: VideoTrack | AudioTrack | TextTrack | null; } +interface Transformer { + flush?: TransformStreamDefaultControllerCallback; + readableType?: undefined; + start?: TransformStreamDefaultControllerCallback; + transform?: TransformStreamDefaultControllerTransformCallback; + writableType?: undefined; +} + interface TransitionEventInit extends EventInit { elapsedTime?: number; propertyName?: string; @@ -1527,11 +1545,27 @@ interface UIEventInit extends EventInit { view?: Window | null; } -interface UnderlyingSink { +interface UnderlyingByteSource { + autoAllocateChunkSize?: number; + cancel?: ReadableStreamErrorCallback; + pull?: ReadableByteStreamControllerCallback; + start?: ReadableByteStreamControllerCallback; + type: "bytes"; +} + +interface UnderlyingSink { abort?: WritableStreamErrorCallback; - close?: WritableStreamDefaultControllerCallback; - start: WritableStreamDefaultControllerCallback; - write?: WritableStreamChunkCallback; + close?: WritableStreamDefaultControllerCloseCallback; + start?: WritableStreamDefaultControllerStartCallback; + type?: undefined; + write?: WritableStreamDefaultControllerWriteCallback; +} + +interface UnderlyingSource { + cancel?: ReadableStreamErrorCallback; + pull?: ReadableStreamDefaultControllerCallback; + start?: ReadableStreamDefaultControllerCallback; + type?: undefined; } interface VRDisplayEventInit extends EventInit { @@ -1581,6 +1615,12 @@ interface WheelEventInit extends MouseEventInit { deltaZ?: number; } +interface WorkerOptions { + credentials?: RequestCredentials; + name?: string; + type?: WorkerType; +} + interface WorkletOptions { credentials?: RequestCredentials; } @@ -1590,18 +1630,12 @@ interface EventListener { } interface ANGLE_instanced_arrays { - drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; - drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; - vertexAttribDivisorANGLE(index: number, divisor: number): void; - readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; + drawArraysInstancedANGLE(mode: GLenum, first: GLint, count: GLsizei, primcount: GLsizei): void; + drawElementsInstancedANGLE(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, primcount: GLsizei): void; + vertexAttribDivisorANGLE(index: GLuint, divisor: GLuint): void; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: GLenum; } -declare var ANGLE_instanced_arrays: { - prototype: ANGLE_instanced_arrays; - new(): ANGLE_instanced_arrays; - readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; -}; - interface AbortController { /** * Returns the AbortSignal object associated with this object. @@ -2188,7 +2222,7 @@ declare var Blob: { }; interface Body { - readonly body: ReadableStream | null; + readonly body: ReadableStream | null; readonly bodyUsed: boolean; arrayBuffer(): Promise; blob(): Promise; @@ -2233,14 +2267,14 @@ interface BroadcastChannelEventMap { messageerror: MessageEvent; } -interface ByteLengthQueuingStrategy { +interface ByteLengthQueuingStrategy extends QueuingStrategy { highWaterMark: number; - size(chunk?: any): number; + size(chunk: ArrayBufferView): number; } declare var ByteLengthQueuingStrategy: { prototype: ByteLengthQueuingStrategy; - new(strategy: QueuingStrategy): ByteLengthQueuingStrategy; + new(options: { highWaterMark: number }): ByteLengthQueuingStrategy; }; interface CDATASection extends Text { @@ -2403,15 +2437,15 @@ interface CSSStyleDeclaration { alignItems: string | null; alignSelf: string | null; alignmentBaseline: string | null; - animation: string | null; - animationDelay: string | null; - animationDirection: string | null; - animationDuration: string | null; - animationFillMode: string | null; - animationIterationCount: string | null; - animationName: string | null; - animationPlayState: string | null; - animationTimingFunction: string | null; + animation: string; + animationDelay: string; + animationDirection: string; + animationDuration: string; + animationFillMode: string; + animationIterationCount: string; + animationName: string; + animationPlayState: string; + animationTimingFunction: string; backfaceVisibility: string | null; background: string | null; backgroundAttachment: string | null; @@ -2654,6 +2688,7 @@ interface CSSStyleDeclaration { rubyOverhang: string | null; rubyPosition: string | null; scale: string | null; + scrollBehavior: string; stopColor: string | null; stopOpacity: string | null; stroke: string | null; @@ -2679,50 +2714,79 @@ interface CSSStyleDeclaration { textTransform: string | null; textUnderlinePosition: string | null; top: string | null; - touchAction: string | null; + touchAction: string; transform: string | null; transformOrigin: string | null; transformStyle: string | null; - transition: string | null; - transitionDelay: string | null; - transitionDuration: string | null; - transitionProperty: string | null; - transitionTimingFunction: string | null; + transition: string; + transitionDelay: string; + transitionDuration: string; + transitionProperty: string; + transitionTimingFunction: string; translate: string | null; unicodeBidi: string | null; userSelect: string | null; verticalAlign: string | null; visibility: string | null; - webkitAlignContent: string | null; - webkitAlignItems: string | null; - webkitAlignSelf: string | null; - webkitAnimation: string | null; - webkitAnimationDelay: string | null; - webkitAnimationDirection: string | null; - webkitAnimationDuration: string | null; - webkitAnimationFillMode: string | null; - webkitAnimationIterationCount: string | null; - webkitAnimationName: string | null; - webkitAnimationPlayState: string | null; - webkitAnimationTimingFunction: string | null; - webkitAppearance: string | null; - webkitBackfaceVisibility: string | null; - webkitBackgroundClip: string | null; - webkitBackgroundOrigin: string | null; - webkitBackgroundSize: string | null; - webkitBorderBottomLeftRadius: string | null; - webkitBorderBottomRightRadius: string | null; + /** @deprecated */ + webkitAlignContent: string; + /** @deprecated */ + webkitAlignItems: string; + /** @deprecated */ + webkitAlignSelf: string; + /** @deprecated */ + webkitAnimation: string; + /** @deprecated */ + webkitAnimationDelay: string; + /** @deprecated */ + webkitAnimationDirection: string; + /** @deprecated */ + webkitAnimationDuration: string; + /** @deprecated */ + webkitAnimationFillMode: string; + /** @deprecated */ + webkitAnimationIterationCount: string; + /** @deprecated */ + webkitAnimationName: string; + /** @deprecated */ + webkitAnimationPlayState: string; + /** @deprecated */ + webkitAnimationTimingFunction: string; + /** @deprecated */ + webkitAppearance: string; + /** @deprecated */ + webkitBackfaceVisibility: string; + /** @deprecated */ + webkitBackgroundClip: string; + /** @deprecated */ + webkitBackgroundOrigin: string; + /** @deprecated */ + webkitBackgroundSize: string; + /** @deprecated */ + webkitBorderBottomLeftRadius: string; + /** @deprecated */ + webkitBorderBottomRightRadius: string; webkitBorderImage: string | null; - webkitBorderRadius: string | null; - webkitBorderTopLeftRadius: string | null; - webkitBorderTopRightRadius: string | null; - webkitBoxAlign: string | null; + /** @deprecated */ + webkitBorderRadius: string; + /** @deprecated */ + webkitBorderTopLeftRadius: string; + /** @deprecated */ + webkitBorderTopRightRadius: string; + /** @deprecated */ + webkitBoxAlign: string; webkitBoxDirection: string | null; - webkitBoxFlex: string | null; - webkitBoxOrdinalGroup: string | null; + /** @deprecated */ + webkitBoxFlex: string; + /** @deprecated */ + webkitBoxOrdinalGroup: string; webkitBoxOrient: string | null; - webkitBoxPack: string | null; - webkitBoxSizing: string | null; + /** @deprecated */ + webkitBoxPack: string; + /** @deprecated */ + webkitBoxShadow: string; + /** @deprecated */ + webkitBoxSizing: string; webkitColumnBreakAfter: string | null; webkitColumnBreakBefore: string | null; webkitColumnBreakInside: string | null; @@ -2735,32 +2799,85 @@ interface CSSStyleDeclaration { webkitColumnSpan: string | null; webkitColumnWidth: any; webkitColumns: string | null; - webkitFilter: string | null; - webkitFlex: string | null; - webkitFlexBasis: string | null; - webkitFlexDirection: string | null; - webkitFlexFlow: string | null; - webkitFlexGrow: string | null; - webkitFlexShrink: string | null; - webkitFlexWrap: string | null; - webkitJustifyContent: string | null; - webkitOrder: string | null; - webkitPerspective: string | null; - webkitPerspectiveOrigin: string | null; + /** @deprecated */ + webkitFilter: string; + /** @deprecated */ + webkitFlex: string; + /** @deprecated */ + webkitFlexBasis: string; + /** @deprecated */ + webkitFlexDirection: string; + /** @deprecated */ + webkitFlexFlow: string; + /** @deprecated */ + webkitFlexGrow: string; + /** @deprecated */ + webkitFlexShrink: string; + /** @deprecated */ + webkitFlexWrap: string; + /** @deprecated */ + webkitJustifyContent: string; + /** @deprecated */ + webkitMask: string; + /** @deprecated */ + webkitMaskBoxImage: string; + /** @deprecated */ + webkitMaskBoxImageOutset: string; + /** @deprecated */ + webkitMaskBoxImageRepeat: string; + /** @deprecated */ + webkitMaskBoxImageSlice: string; + /** @deprecated */ + webkitMaskBoxImageSource: string; + /** @deprecated */ + webkitMaskBoxImageWidth: string; + /** @deprecated */ + webkitMaskClip: string; + /** @deprecated */ + webkitMaskComposite: string; + /** @deprecated */ + webkitMaskImage: string; + /** @deprecated */ + webkitMaskOrigin: string; + /** @deprecated */ + webkitMaskPosition: string; + /** @deprecated */ + webkitMaskRepeat: string; + /** @deprecated */ + webkitMaskSize: string; + /** @deprecated */ + webkitOrder: string; + /** @deprecated */ + webkitPerspective: string; + /** @deprecated */ + webkitPerspectiveOrigin: string; webkitTapHighlightColor: string | null; - webkitTextFillColor: string | null; - webkitTextSizeAdjust: any; - webkitTextStroke: string | null; - webkitTextStrokeColor: string | null; - webkitTextStrokeWidth: string | null; - webkitTransform: string | null; - webkitTransformOrigin: string | null; - webkitTransformStyle: string | null; - webkitTransition: string | null; - webkitTransitionDelay: string | null; - webkitTransitionDuration: string | null; - webkitTransitionProperty: string | null; - webkitTransitionTimingFunction: string | null; + /** @deprecated */ + webkitTextFillColor: string; + /** @deprecated */ + webkitTextSizeAdjust: string; + /** @deprecated */ + webkitTextStroke: string; + /** @deprecated */ + webkitTextStrokeColor: string; + /** @deprecated */ + webkitTextStrokeWidth: string; + /** @deprecated */ + webkitTransform: string; + /** @deprecated */ + webkitTransformOrigin: string; + /** @deprecated */ + webkitTransformStyle: string; + /** @deprecated */ + webkitTransition: string; + /** @deprecated */ + webkitTransitionDelay: string; + /** @deprecated */ + webkitTransitionDuration: string; + /** @deprecated */ + webkitTransitionProperty: string; + /** @deprecated */ + webkitTransitionTimingFunction: string; webkitUserModify: string | null; webkitUserSelect: string | null; webkitWritingMode: string | null; @@ -3241,14 +3358,14 @@ interface Coordinates { readonly speed: number | null; } -interface CountQueuingStrategy { +interface CountQueuingStrategy extends QueuingStrategy { highWaterMark: number; - size(): number; + size(chunk: any): 1; } declare var CountQueuingStrategy: { prototype: CountQueuingStrategy; - new(strategy: QueuingStrategy): CountQueuingStrategy; + new(options: { highWaterMark: number }): CountQueuingStrategy; }; interface Crypto { @@ -4004,7 +4121,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par /** * Gets a reference to the root node of the document. */ - readonly documentElement: HTMLElement | null; + readonly documentElement: HTMLElement; /** * Returns document's URL. */ @@ -4036,7 +4153,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par /** * Returns the head element. */ - readonly head: HTMLHeadElement | null; + readonly head: HTMLHeadElement; readonly hidden: boolean; /** * Retrieves a collection, in source order, of img objects in the document. @@ -4066,7 +4183,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par /** * Contains information about the current URL. */ - location: Location | null; + location: Location; onfullscreenchange: ((this: Document, ev: Event) => any) | null; onfullscreenerror: ((this: Document, ev: Event) => any) | null; /** @@ -4116,6 +4233,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par /** @deprecated */ captureEvents(): void; caretPositionFromPoint(x: number, y: number): CaretPosition | null; + /** @deprecated */ caretRangeFromPoint(x: number, y: number): Range; /** @deprecated */ clear(): void; @@ -4169,6 +4287,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "clipPath"): SVGClipPathElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "componentTransferFunction"): SVGComponentTransferFunctionElement; + createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "cursor"): SVGCursorElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "defs"): SVGDefsElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "desc"): SVGDescElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "ellipse"): SVGEllipseElement; @@ -4341,7 +4460,9 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par * @param filter A custom NodeFilter function to use. * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. */ - createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null, entityReferenceExpansion?: boolean): TreeWalker; + createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker; + /** @deprecated */ + createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter | null, entityReferenceExpansion?: boolean): TreeWalker; /** * Returns the element for the specified x coordinate and the specified y coordinate. * @param x The x-offset @@ -4349,7 +4470,7 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par */ elementFromPoint(x: number, y: number): Element | null; elementsFromPoint(x: number, y: number): Element[]; - evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver | null, type: number, result: XPathResult | null): XPathResult; + evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver | ((prefix: string) => string | null) | null, type: number, result: XPathResult | null): XPathResult; /** * Executes a command on the current document, current selection, or the given range. * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. @@ -4570,6 +4691,9 @@ interface DocumentOrShadowRoot { * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. */ readonly styleSheets: StyleSheetList; + caretPositionFromPoint(x: number, y: number): CaretPosition | null; + /** @deprecated */ + caretRangeFromPoint(x: number, y: number): Range; elementFromPoint(x: number, y: number): Element | null; elementsFromPoint(x: number, y: number): Element[]; getSelection(): Selection | null; @@ -4621,35 +4745,28 @@ declare var DynamicsCompressorNode: { }; interface EXT_blend_minmax { - readonly MAX_EXT: number; - readonly MIN_EXT: number; + readonly MAX_EXT: GLenum; + readonly MIN_EXT: GLenum; } interface EXT_frag_depth { } interface EXT_sRGB { - readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: number; - readonly SRGB8_ALPHA8_EXT: number; - readonly SRGB_ALPHA_EXT: number; - readonly SRGB_EXT: number; + readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: GLenum; + readonly SRGB8_ALPHA8_EXT: GLenum; + readonly SRGB_ALPHA_EXT: GLenum; + readonly SRGB_EXT: GLenum; } interface EXT_shader_texture_lod { } interface EXT_texture_filter_anisotropic { - readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; - readonly TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: GLenum; + readonly TEXTURE_MAX_ANISOTROPY_EXT: GLenum; } -declare var EXT_texture_filter_anisotropic: { - prototype: EXT_texture_filter_anisotropic; - new(): EXT_texture_filter_anisotropic; - readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; - readonly TEXTURE_MAX_ANISOTROPY_EXT: number; -}; - interface ElementEventMap { "fullscreenchange": Event; "fullscreenerror": Event; @@ -4867,6 +4984,7 @@ interface Event { */ readonly isTrusted: boolean; returnValue: boolean; + /** @deprecated */ readonly srcElement: Element | null; /** * Returns the object to which event is dispatched (its target). @@ -5033,7 +5151,7 @@ interface FileReader extends EventTarget { readAsArrayBuffer(blob: Blob): void; readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, label?: string): void; + readAsText(blob: Blob, encoding?: string): void; readonly DONE: number; readonly EMPTY: number; readonly LOADING: number; @@ -6520,6 +6638,7 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { * Sets or retrieves the frame name. */ name: string; + readonly referrerPolicy: ReferrerPolicy; readonly sandbox: DOMTokenList; /** * Sets or retrieves whether the frame can be scrolled. @@ -7155,7 +7274,7 @@ interface HTMLMediaElement extends HTMLElement { */ readonly seekable: TimeRanges; /** - * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + * Gets a flag that indicates whether the client is currently moving to a new playback position in the media resource. */ readonly seeking: boolean; /** @@ -9304,7 +9423,9 @@ interface Location { /** * Reloads the current page. */ - reload(forcedReload?: boolean): void; + reload(): void; + /** @deprecated */ + reload(forcedReload: boolean): void; /** * Removes the current page from the session history and navigates to the given URL. */ @@ -9725,7 +9846,7 @@ interface MediaQueryList extends EventTarget { /** @deprecated */ addListener(listener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null): void; /** @deprecated */ - removeListener(listener: EventListenerOrEventListenerObject | null): void; + removeListener(listener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null): void; addEventListener(type: K, listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -10278,6 +10399,7 @@ interface Node extends EventTarget { * Returns the last child. */ readonly lastChild: ChildNode | null; + /** @deprecated */ readonly namespaceURI: string | null; /** * Returns the next sibling. @@ -10550,61 +10672,29 @@ declare var Notification: { interface OES_element_index_uint { } -declare var OES_element_index_uint: { - prototype: OES_element_index_uint; - new(): OES_element_index_uint; -}; - interface OES_standard_derivatives { - readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; + readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: GLenum; } -declare var OES_standard_derivatives: { - prototype: OES_standard_derivatives; - new(): OES_standard_derivatives; - readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; -}; - interface OES_texture_float { } -declare var OES_texture_float: { - prototype: OES_texture_float; - new(): OES_texture_float; -}; - interface OES_texture_float_linear { } -declare var OES_texture_float_linear: { - prototype: OES_texture_float_linear; - new(): OES_texture_float_linear; -}; - interface OES_texture_half_float { - readonly HALF_FLOAT_OES: number; + readonly HALF_FLOAT_OES: GLenum; } -declare var OES_texture_half_float: { - prototype: OES_texture_half_float; - new(): OES_texture_half_float; - readonly HALF_FLOAT_OES: number; -}; - interface OES_texture_half_float_linear { } -declare var OES_texture_half_float_linear: { - prototype: OES_texture_half_float_linear; - new(): OES_texture_half_float_linear; -}; - interface OES_vertex_array_object { - readonly VERTEX_ARRAY_BINDING_OES: number; - bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): void; - createVertexArrayOES(): WebGLVertexArrayObjectOES; - deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): void; - isVertexArrayOES(value: any): value is WebGLVertexArrayObjectOES; + bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void; + createVertexArrayOES(): WebGLVertexArrayObjectOES | null; + deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void; + isVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): GLboolean; + readonly VERTEX_ARRAY_BINDING_OES: GLenum; } interface OfflineAudioCompletionEvent extends Event { @@ -11794,20 +11884,70 @@ declare var Range: { readonly START_TO_START: number; }; -interface ReadableStream { +interface ReadableByteStreamController { + readonly byobRequest: ReadableStreamBYOBRequest | undefined; + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: ArrayBufferView): void; + error(error?: any): void; +} + +interface ReadableStream { readonly locked: boolean; - cancel(): Promise; - getReader(): ReadableStreamReader; + cancel(reason?: any): Promise; + getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; + getReader(): ReadableStreamDefaultReader; + pipeThrough({ writable, readable }: { writable: WritableStream, readable: ReadableStream }, options?: PipeOptions): ReadableStream; + pipeTo(dest: WritableStream, options?: PipeOptions): Promise; + tee(): [ReadableStream, ReadableStream]; } declare var ReadableStream: { prototype: ReadableStream; - new(): ReadableStream; + new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number, size?: undefined }): ReadableStream; + new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; }; -interface ReadableStreamReader { +interface ReadableStreamBYOBReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + read(view: T): Promise>; + releaseLock(): void; +} + +declare var ReadableStreamBYOBReader: { + prototype: ReadableStreamBYOBReader; + new(stream: ReadableStream): ReadableStreamBYOBReader; +}; + +interface ReadableStreamBYOBRequest { + readonly view: ArrayBufferView; + respond(bytesWritten: number): void; + respondWithNewView(view: ArrayBufferView): void; +} + +interface ReadableStreamDefaultController { + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: R): void; + error(error?: any): void; +} + +interface ReadableStreamDefaultReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + read(): Promise>; + releaseLock(): void; +} + +interface ReadableStreamReadResult { + done: boolean; + value: T; +} + +interface ReadableStreamReader { cancel(): Promise; - read(): Promise; + read(): Promise>; releaseLock(): void; } @@ -11819,7 +11959,7 @@ declare var ReadableStreamReader: { interface Request extends Body { /** * Returns the cache mode associated with request, which is a string indicating - * how the the request will interact with the browser's cache when fetching. + * how the request will interact with the browser's cache when fetching. */ readonly cache: RequestCache; /** @@ -11957,6 +12097,42 @@ declare var SVGAngle: { readonly SVG_ANGLETYPE_UNSPECIFIED: number; }; +interface SVGAnimateElement extends SVGAnimationElement { + addEventListener(type: K, listener: (this: SVGAnimateElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + removeEventListener(type: K, listener: (this: SVGAnimateElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var SVGAnimateElement: { + prototype: SVGAnimateElement; + new(): SVGAnimateElement; +}; + +interface SVGAnimateMotionElement extends SVGAnimationElement { + addEventListener(type: K, listener: (this: SVGAnimateMotionElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + removeEventListener(type: K, listener: (this: SVGAnimateMotionElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var SVGAnimateMotionElement: { + prototype: SVGAnimateMotionElement; + new(): SVGAnimateMotionElement; +}; + +interface SVGAnimateTransformElement extends SVGAnimationElement { + addEventListener(type: K, listener: (this: SVGAnimateTransformElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + removeEventListener(type: K, listener: (this: SVGAnimateTransformElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var SVGAnimateTransformElement: { + prototype: SVGAnimateTransformElement; + new(): SVGAnimateTransformElement; +}; + interface SVGAnimatedAngle { readonly animVal: SVGAngle; readonly baseVal: SVGAngle; @@ -12082,6 +12258,22 @@ declare var SVGAnimatedTransformList: { new(): SVGAnimatedTransformList; }; +interface SVGAnimationElement extends SVGElement { + readonly targetElement: SVGElement; + getCurrentTime(): number; + getSimpleDuration(): number; + getStartTime(): number; + addEventListener(type: K, listener: (this: SVGAnimationElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + removeEventListener(type: K, listener: (this: SVGAnimationElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var SVGAnimationElement: { + prototype: SVGAnimationElement; + new(): SVGAnimationElement; +}; + interface SVGCircleElement extends SVGGraphicsElement { readonly cx: SVGAnimatedLength; readonly cy: SVGAnimatedLength; @@ -12141,6 +12333,20 @@ declare var SVGComponentTransferFunctionElement: { readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; }; +interface SVGCursorElement extends SVGElement { + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGCursorElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + removeEventListener(type: K, listener: (this: SVGCursorElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var SVGCursorElement: { + prototype: SVGCursorElement; + new(): SVGCursorElement; +}; + interface SVGDefsElement extends SVGGraphicsElement { addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -14798,6 +15004,23 @@ declare var TrackEvent: { new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; }; +interface TransformStream { + readonly readable: ReadableStream; + readonly writable: WritableStream; +} + +declare var TransformStream: { + prototype: TransformStream; + new(transformer?: Transformer, writableStrategy?: QueuingStrategy, readableStrategy?: QueuingStrategy): TransformStream; +}; + +interface TransformStreamDefaultController { + readonly desiredSize: number | null; + enqueue(chunk: O): void; + error(reason?: any): void; + terminate(): void; +} + interface TransitionEvent extends Event { readonly elapsedTime: number; readonly propertyName: string; @@ -15115,129 +15338,106 @@ declare var VideoTrackList: { }; interface WEBGL_color_buffer_float { - readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: number; - readonly RGB32F_EXT: number; - readonly RGBA32F_EXT: number; - readonly UNSIGNED_NORMALIZED_EXT: number; + readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum; + readonly RGBA32F_EXT: GLenum; + readonly UNSIGNED_NORMALIZED_EXT: GLenum; } interface WEBGL_compressed_texture_astc { - readonly COMPRESSED_RGBA_ASTC_10x10_KHR: number; - readonly COMPRESSED_RGBA_ASTC_10x5_KHR: number; - readonly COMPRESSED_RGBA_ASTC_10x6_KHR: number; - readonly COMPRESSED_RGBA_ASTC_10x8_KHR: number; - readonly COMPRESSED_RGBA_ASTC_12x10_KHR: number; - readonly COMPRESSED_RGBA_ASTC_12x12_KHR: number; - readonly COMPRESSED_RGBA_ASTC_4x4_KHR: number; - readonly COMPRESSED_RGBA_ASTC_5x4_KHR: number; - readonly COMPRESSED_RGBA_ASTC_5x5_KHR: number; - readonly COMPRESSED_RGBA_ASTC_6x5_KHR: number; - readonly COMPRESSED_RGBA_ASTC_6x6_KHR: number; - readonly COMPRESSED_RGBA_ASTC_8x5_KHR: number; - readonly COMPRESSED_RGBA_ASTC_8x6_KHR: number; - readonly COMPRESSED_RGBA_ASTC_8x8_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: number; - readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: number; getSupportedProfiles(): string[]; + readonly COMPRESSED_RGBA_ASTC_10x10_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_10x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_10x6_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_10x8_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_12x10_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_12x12_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_4x4_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_5x4_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_5x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_6x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_6x6_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_8x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_8x6_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_8x8_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: GLenum; } interface WEBGL_compressed_texture_s3tc { - readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; - readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; - readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; - readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: GLenum; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: GLenum; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: GLenum; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: GLenum; } -declare var WEBGL_compressed_texture_s3tc: { - prototype: WEBGL_compressed_texture_s3tc; - new(): WEBGL_compressed_texture_s3tc; - readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; - readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; - readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; - readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; -}; - interface WEBGL_compressed_texture_s3tc_srgb { - readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: number; - readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: number; - readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: number; - readonly COMPRESSED_SRGB_S3TC_DXT1_EXT: number; + readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: GLenum; + readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: GLenum; + readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: GLenum; + readonly COMPRESSED_SRGB_S3TC_DXT1_EXT: GLenum; } interface WEBGL_debug_renderer_info { - readonly UNMASKED_RENDERER_WEBGL: number; - readonly UNMASKED_VENDOR_WEBGL: number; + readonly UNMASKED_RENDERER_WEBGL: GLenum; + readonly UNMASKED_VENDOR_WEBGL: GLenum; } -declare var WEBGL_debug_renderer_info: { - prototype: WEBGL_debug_renderer_info; - new(): WEBGL_debug_renderer_info; - readonly UNMASKED_RENDERER_WEBGL: number; - readonly UNMASKED_VENDOR_WEBGL: number; -}; - interface WEBGL_debug_shaders { getTranslatedShaderSource(shader: WebGLShader): string; } interface WEBGL_depth_texture { - readonly UNSIGNED_INT_24_8_WEBGL: number; + readonly UNSIGNED_INT_24_8_WEBGL: GLenum; } -declare var WEBGL_depth_texture: { - prototype: WEBGL_depth_texture; - new(): WEBGL_depth_texture; - readonly UNSIGNED_INT_24_8_WEBGL: number; -}; - interface WEBGL_draw_buffers { - readonly COLOR_ATTACHMENT0_WEBGL: number; - readonly COLOR_ATTACHMENT10_WEBGL: number; - readonly COLOR_ATTACHMENT11_WEBGL: number; - readonly COLOR_ATTACHMENT12_WEBGL: number; - readonly COLOR_ATTACHMENT13_WEBGL: number; - readonly COLOR_ATTACHMENT14_WEBGL: number; - readonly COLOR_ATTACHMENT15_WEBGL: number; - readonly COLOR_ATTACHMENT1_WEBGL: number; - readonly COLOR_ATTACHMENT2_WEBGL: number; - readonly COLOR_ATTACHMENT3_WEBGL: number; - readonly COLOR_ATTACHMENT4_WEBGL: number; - readonly COLOR_ATTACHMENT5_WEBGL: number; - readonly COLOR_ATTACHMENT6_WEBGL: number; - readonly COLOR_ATTACHMENT7_WEBGL: number; - readonly COLOR_ATTACHMENT8_WEBGL: number; - readonly COLOR_ATTACHMENT9_WEBGL: number; - readonly DRAW_BUFFER0_WEBGL: number; - readonly DRAW_BUFFER10_WEBGL: number; - readonly DRAW_BUFFER11_WEBGL: number; - readonly DRAW_BUFFER12_WEBGL: number; - readonly DRAW_BUFFER13_WEBGL: number; - readonly DRAW_BUFFER14_WEBGL: number; - readonly DRAW_BUFFER15_WEBGL: number; - readonly DRAW_BUFFER1_WEBGL: number; - readonly DRAW_BUFFER2_WEBGL: number; - readonly DRAW_BUFFER3_WEBGL: number; - readonly DRAW_BUFFER4_WEBGL: number; - readonly DRAW_BUFFER5_WEBGL: number; - readonly DRAW_BUFFER6_WEBGL: number; - readonly DRAW_BUFFER7_WEBGL: number; - readonly DRAW_BUFFER8_WEBGL: number; - readonly DRAW_BUFFER9_WEBGL: number; - readonly MAX_COLOR_ATTACHMENTS_WEBGL: number; - readonly MAX_DRAW_BUFFERS_WEBGL: number; - drawBuffersWEBGL(buffers: number[]): void; + drawBuffersWEBGL(buffers: GLenum[]): void; + readonly COLOR_ATTACHMENT0_WEBGL: GLenum; + readonly COLOR_ATTACHMENT10_WEBGL: GLenum; + readonly COLOR_ATTACHMENT11_WEBGL: GLenum; + readonly COLOR_ATTACHMENT12_WEBGL: GLenum; + readonly COLOR_ATTACHMENT13_WEBGL: GLenum; + readonly COLOR_ATTACHMENT14_WEBGL: GLenum; + readonly COLOR_ATTACHMENT15_WEBGL: GLenum; + readonly COLOR_ATTACHMENT1_WEBGL: GLenum; + readonly COLOR_ATTACHMENT2_WEBGL: GLenum; + readonly COLOR_ATTACHMENT3_WEBGL: GLenum; + readonly COLOR_ATTACHMENT4_WEBGL: GLenum; + readonly COLOR_ATTACHMENT5_WEBGL: GLenum; + readonly COLOR_ATTACHMENT6_WEBGL: GLenum; + readonly COLOR_ATTACHMENT7_WEBGL: GLenum; + readonly COLOR_ATTACHMENT8_WEBGL: GLenum; + readonly COLOR_ATTACHMENT9_WEBGL: GLenum; + readonly DRAW_BUFFER0_WEBGL: GLenum; + readonly DRAW_BUFFER10_WEBGL: GLenum; + readonly DRAW_BUFFER11_WEBGL: GLenum; + readonly DRAW_BUFFER12_WEBGL: GLenum; + readonly DRAW_BUFFER13_WEBGL: GLenum; + readonly DRAW_BUFFER14_WEBGL: GLenum; + readonly DRAW_BUFFER15_WEBGL: GLenum; + readonly DRAW_BUFFER1_WEBGL: GLenum; + readonly DRAW_BUFFER2_WEBGL: GLenum; + readonly DRAW_BUFFER3_WEBGL: GLenum; + readonly DRAW_BUFFER4_WEBGL: GLenum; + readonly DRAW_BUFFER5_WEBGL: GLenum; + readonly DRAW_BUFFER6_WEBGL: GLenum; + readonly DRAW_BUFFER7_WEBGL: GLenum; + readonly DRAW_BUFFER8_WEBGL: GLenum; + readonly DRAW_BUFFER9_WEBGL: GLenum; + readonly MAX_COLOR_ATTACHMENTS_WEBGL: GLenum; + readonly MAX_DRAW_BUFFERS_WEBGL: GLenum; } interface WEBGL_lose_context { @@ -16139,7 +16339,7 @@ declare var WebGLUniformLocation: { new(): WebGLUniformLocation; }; -interface WebGLVertexArrayObjectOES { +interface WebGLVertexArrayObjectOES extends WebGLObject { } interface WebKitPoint { @@ -16196,9 +16396,6 @@ interface WheelEvent extends MouseEvent { readonly deltaX: number; readonly deltaY: number; readonly deltaZ: number; - readonly wheelDelta: number; - readonly wheelDeltaX: number; - readonly wheelDeltaY: number; getCurrentPoint(element: Element): void; initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; readonly DOM_DELTA_LINE: number; @@ -16545,7 +16742,7 @@ interface Worker extends EventTarget, AbstractWorker { declare var Worker: { prototype: Worker; - new(stringUrl: string): Worker; + new(stringUrl: string, options?: WorkerOptions): Worker; }; interface Worklet { @@ -16557,41 +16754,31 @@ declare var Worklet: { new(): Worklet; }; -interface WritableStream { +interface WritableStream { readonly locked: boolean; abort(reason?: any): Promise; - getWriter(): WritableStreamDefaultWriter; + getWriter(): WritableStreamDefaultWriter; } declare var WritableStream: { prototype: WritableStream; - new(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy): WritableStream; + new(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy): WritableStream; }; interface WritableStreamDefaultController { error(error?: any): void; } -declare var WritableStreamDefaultController: { - prototype: WritableStreamDefaultController; - new(): WritableStreamDefaultController; -}; - -interface WritableStreamDefaultWriter { +interface WritableStreamDefaultWriter { readonly closed: Promise; - readonly desiredSize: number; + readonly desiredSize: number | null; readonly ready: Promise; abort(reason?: any): Promise; close(): Promise; releaseLock(): void; - write(chunk?: any): Promise; + write(chunk: W): Promise; } -declare var WritableStreamDefaultWriter: { - prototype: WritableStreamDefaultWriter; - new(): WritableStreamDefaultWriter; -}; - interface XMLDocument extends Document { addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -16772,7 +16959,7 @@ declare var XMLSerializer: { interface XPathEvaluator { createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; createNSResolver(nodeResolver?: Node): XPathNSResolver; - evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver | null, type: number, result: XPathResult | null): XPathResult; + evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver | ((prefix: string) => string | null) | null, type: number, result: XPathResult | null): XPathResult; } declare var XPathEvaluator: { @@ -16790,7 +16977,7 @@ declare var XPathExpression: { }; interface XPathNSResolver { - lookupNamespaceURI(prefix: string): string; + lookupNamespaceURI(prefix: string): string | null; } declare var XPathNSResolver: { @@ -16941,6 +17128,10 @@ interface PositionErrorCallback { (positionError: PositionError): void; } +interface QueuingStrategySizeCallback { + (chunk: T): number; +} + interface RTCPeerConnectionErrorCallback { (error: DOMException): void; } @@ -16953,20 +17144,44 @@ interface RTCStatsCallback { (report: RTCStatsReport): void; } +interface ReadableByteStreamControllerCallback { + (controller: ReadableByteStreamController): void | PromiseLike; +} + +interface ReadableStreamDefaultControllerCallback { + (controller: ReadableStreamDefaultController): void | PromiseLike; +} + +interface ReadableStreamErrorCallback { + (reason: any): void | PromiseLike; +} + +interface TransformStreamDefaultControllerCallback { + (controller: TransformStreamDefaultController): void | PromiseLike; +} + +interface TransformStreamDefaultControllerTransformCallback { + (chunk: I, controller: TransformStreamDefaultController): void | PromiseLike; +} + interface VoidFunction { (): void; } -interface WritableStreamChunkCallback { - (chunk: any, controller: WritableStreamDefaultController): void; +interface WritableStreamDefaultControllerCloseCallback { + (): void | PromiseLike; } -interface WritableStreamDefaultControllerCallback { - (controller: WritableStreamDefaultController): void; +interface WritableStreamDefaultControllerStartCallback { + (controller: WritableStreamDefaultController): void | PromiseLike; +} + +interface WritableStreamDefaultControllerWriteCallback { + (chunk: W, controller: WritableStreamDefaultController): void | PromiseLike; } interface WritableStreamErrorCallback { - (reason: string): void; + (reason: any): void | PromiseLike; } interface HTMLElementTagNameMap { @@ -17600,7 +17815,7 @@ declare function removeEventListener(type: K, li declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; type BlobPart = BufferSource | Blob | string; type HeadersInit = Headers | string[][] | Record; -type BodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string; +type BodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string; type RequestInfo = Request | string; type DOMHighResTimeStamp = number; type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext; @@ -17646,6 +17861,7 @@ type IDBKeyPath = string; type Transferable = ArrayBuffer | MessagePort | ImageBitmap; type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +/** @deprecated */ type MouseWheelEvent = WheelEvent; type WindowProxy = Window; type AlignSetting = "start" | "center" | "end" | "left" | "right"; @@ -17668,11 +17884,13 @@ type ChannelCountMode = "max" | "clamped-max" | "explicit"; type ChannelInterpretation = "speakers" | "discrete"; type ClientTypes = "window" | "worker" | "sharedworker" | "all"; type CompositeOperation = "replace" | "add" | "accumulate"; +type CompositeOperationOrAuto = "replace" | "add" | "accumulate" | "auto"; type DirectionSetting = "" | "rl" | "lr"; type DisplayCaptureSurfaceType = "monitor" | "window" | "application" | "browser"; type DistanceModelType = "linear" | "inverse" | "exponential"; type DocumentReadyState = "loading" | "interactive" | "complete"; type EndOfStreamError = "network" | "decode"; +type EndingType = "transparent" | "native"; type FillMode = "none" | "forwards" | "backwards" | "both" | "auto"; type GamepadHand = "" | "left" | "right"; type GamepadHapticActuatorType = "vibration"; @@ -17751,7 +17969,7 @@ type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; type RequestRedirect = "follow" | "error" | "manual"; type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; type ScopedCredentialType = "ScopedCred"; -type ScrollBehavior = "auto" | "instant" | "smooth"; +type ScrollBehavior = "auto" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type ScrollRestoration = "auto" | "manual"; type ScrollSetting = "" | "up"; diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index c6a02b32cc2..2c19919dd20 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -29,7 +29,8 @@ interface Map { } interface MapConstructor { - new (entries?: ReadonlyArray<[K, V]> | null): Map; + new(): Map; + new(entries?: ReadonlyArray<[K, V]> | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 793f587059b..43b021a197d 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -155,7 +155,7 @@ interface MapConstructor { interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index 922cbb35a82..400f70a7f4d 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -83,7 +83,7 @@ interface SymbolConstructor { } interface Symbol { - readonly [Symbol.toStringTag]: "Symbol"; + readonly [Symbol.toStringTag]: string; } interface Array { @@ -127,23 +127,23 @@ interface Date { } interface Map { - readonly [Symbol.toStringTag]: "Map"; + readonly [Symbol.toStringTag]: string; } interface WeakMap { - readonly [Symbol.toStringTag]: "WeakMap"; + readonly [Symbol.toStringTag]: string; } interface Set { - readonly [Symbol.toStringTag]: "Set"; + readonly [Symbol.toStringTag]: string; } interface WeakSet { - readonly [Symbol.toStringTag]: "WeakSet"; + readonly [Symbol.toStringTag]: string; } interface JSON { - readonly [Symbol.toStringTag]: "JSON"; + readonly [Symbol.toStringTag]: string; } interface Function { @@ -158,15 +158,15 @@ interface Function { } interface GeneratorFunction { - readonly [Symbol.toStringTag]: "GeneratorFunction"; + readonly [Symbol.toStringTag]: string; } interface Math { - readonly [Symbol.toStringTag]: "Math"; + readonly [Symbol.toStringTag]: string; } interface Promise { - readonly [Symbol.toStringTag]: "Promise"; + readonly [Symbol.toStringTag]: string; } interface PromiseConstructor { @@ -261,11 +261,11 @@ interface String { } interface ArrayBuffer { - readonly [Symbol.toStringTag]: "ArrayBuffer"; + readonly [Symbol.toStringTag]: string; } interface DataView { - readonly [Symbol.toStringTag]: "DataView"; + readonly [Symbol.toStringTag]: string; } interface Int8Array { diff --git a/lib/lib.esnext.bigint.d.ts b/lib/lib.esnext.bigint.d.ts new file mode 100644 index 00000000000..ccb73bee761 --- /dev/null +++ b/lib/lib.esnext.bigint.d.ts @@ -0,0 +1,629 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +interface BigInt { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. + */ + toString(radix?: number): string; + + /** Returns a string representation appropriate to the host environment's current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): bigint; + + readonly [Symbol.toStringTag]: "BigInt"; +} + +interface BigIntConstructor { + (value?: any): bigint; + readonly prototype: BigInt; + + /** + * Interprets the low bits of a BigInt as a 2's-complement signed integer. + * All higher bits are discarded. + * @param bits The number of low bits to use + * @param int The BigInt whose bits to extract + */ + asIntN(bits: number, int: bigint): bigint; + /** + * Interprets the low bits of a BigInt as an unsigned integer. + * All higher bits are discarded. + * @param bits The number of low bits to use + * @param int The BigInt whose bits to extract + */ + asUintN(bits: number, int: bigint): bigint; +} + +declare const BigInt: BigIntConstructor; + +/** + * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated, an exception is raised. + */ +interface BigInt64Array { + /** The size in bytes of each element in the array. */ + readonly BYTES_PER_ELEMENT: number; + + /** The ArrayBuffer instance referenced by the array. */ + readonly buffer: ArrayBufferLike; + + /** The length in bytes of the array. */ + readonly byteLength: number; + + /** The offset in bytes of the array. */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; + + /** Yields index, value pairs for every entry in the array. */ + entries(): IterableIterator<[number, bigint]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: bigint, start?: number, end?: number): this; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void; + + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: bigint, fromIndex?: number): boolean; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: bigint, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** Yields each index in the array. */ + keys(): IterableIterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: bigint, fromIndex?: number): number; + + /** The length of the array. */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; + + /** Reverses the elements in the array. */ + reverse(): this; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): BigInt64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in the array until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts the array. + * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. + */ + sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; + + /** + * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): BigInt64Array; + + /** Converts the array to a string by using the current locale. */ + toLocaleString(): string; + + /** Returns a string representation of the array. */ + toString(): string; + + /** Yields each value in the array. */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; + + readonly [Symbol.toStringTag]: "BigInt64Array"; + + [index: number]: bigint; +} + +interface BigInt64ArrayConstructor { + readonly prototype: BigInt64Array; + new(length?: number): BigInt64Array; + new(array: Iterable): BigInt64Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigInt64Array; + + /** The size in bytes of each element in the array. */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: bigint[]): BigInt64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike): BigInt64Array; + from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; +} + +declare const BigInt64Array: BigInt64ArrayConstructor; + +/** + * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated, an exception is raised. + */ +interface BigUint64Array { + /** The size in bytes of each element in the array. */ + readonly BYTES_PER_ELEMENT: number; + + /** The ArrayBuffer instance referenced by the array. */ + readonly buffer: ArrayBufferLike; + + /** The length in bytes of the array. */ + readonly byteLength: number; + + /** The offset in bytes of the array. */ + readonly byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): this; + + /** Yields index, value pairs for every entry in the array. */ + entries(): IterableIterator<[number, bigint]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: bigint, start?: number, end?: number): this; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void; + + /** + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ + includes(searchElement: bigint, fromIndex?: number): boolean; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: bigint, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** Yields each index in the array. */ + keys(): IterableIterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: bigint, fromIndex?: number): number; + + /** The length of the array. */ + readonly length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; + + /** Reverses the elements in the array. */ + reverse(): this; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): BigUint64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in the array until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts the array. + * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. + */ + sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; + + /** + * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): BigUint64Array; + + /** Converts the array to a string by using the current locale. */ + toLocaleString(): string; + + /** Returns a string representation of the array. */ + toString(): string; + + /** Yields each value in the array. */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; + + readonly [Symbol.toStringTag]: "BigUint64Array"; + + [index: number]: bigint; +} + +interface BigUint64ArrayConstructor { + readonly prototype: BigUint64Array; + new(length?: number): BigUint64Array; + new(array: Iterable): BigUint64Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array; + + /** The size in bytes of each element in the array. */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: bigint[]): BigUint64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike): BigUint64Array; + from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; +} + +declare const BigUint64Array: BigUint64ArrayConstructor; + +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. + */ + getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; + + /** + * 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. + */ + getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; + + /** + * 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. + */ + setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; + + /** + * 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. + */ + setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; +} \ No newline at end of file diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index 8e8592bd61a..f213999684d 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -21,5 +21,6 @@ and limitations under the License. /// /// /// +/// /// /// diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 2fa70fb2a6b..238702731fd 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -59,6 +59,7 @@ interface Algorithm { } interface BlobPropertyBag { + endings?: EndingType; type?: string; } @@ -302,6 +303,12 @@ interface PerformanceObserverInit { entryTypes: string[]; } +interface PipeOptions { + preventAbort?: boolean; + preventCancel?: boolean; + preventClose?: boolean; +} + interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -333,6 +340,11 @@ interface PushSubscriptionOptionsInit { userVisibleOnly?: boolean; } +interface QueuingStrategy { + highWaterMark?: number; + size?: QueuingStrategySizeCallback; +} + interface RegistrationOptions { scope?: string; type?: WorkerType; @@ -407,10 +419,69 @@ interface TextDecoderOptions { ignoreBOM?: boolean; } +interface Transformer { + flush?: TransformStreamDefaultControllerCallback; + readableType?: undefined; + start?: TransformStreamDefaultControllerCallback; + transform?: TransformStreamDefaultControllerTransformCallback; + writableType?: undefined; +} + +interface UnderlyingByteSource { + autoAllocateChunkSize?: number; + cancel?: ReadableStreamErrorCallback; + pull?: ReadableByteStreamControllerCallback; + start?: ReadableByteStreamControllerCallback; + type: "bytes"; +} + +interface UnderlyingSink { + abort?: WritableStreamErrorCallback; + close?: WritableStreamDefaultControllerCloseCallback; + start?: WritableStreamDefaultControllerStartCallback; + type?: undefined; + write?: WritableStreamDefaultControllerWriteCallback; +} + +interface UnderlyingSource { + cancel?: ReadableStreamErrorCallback; + pull?: ReadableStreamDefaultControllerCallback; + start?: ReadableStreamDefaultControllerCallback; + type?: undefined; +} + +interface WebGLContextAttributes { + alpha?: GLboolean; + antialias?: GLboolean; + depth?: GLboolean; + failIfMajorPerformanceCaveat?: boolean; + powerPreference?: WebGLPowerPreference; + premultipliedAlpha?: GLboolean; + preserveDrawingBuffer?: GLboolean; + stencil?: GLboolean; +} + +interface WebGLContextEventInit extends EventInit { + statusMessage?: string; +} + +interface WorkerOptions { + credentials?: RequestCredentials; + name?: string; + type?: WorkerType; +} + interface EventListener { (evt: Event): void; } +interface ANGLE_instanced_arrays { + drawArraysInstancedANGLE(mode: GLenum, first: GLint, count: GLsizei, primcount: GLsizei): void; + drawElementsInstancedANGLE(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, primcount: GLsizei): void; + vertexAttribDivisorANGLE(index: GLuint, divisor: GLuint): void; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: GLenum; +} + interface AbortController { /** * Returns the AbortSignal object associated with this object. @@ -482,7 +553,7 @@ declare var Blob: { }; interface Body { - readonly body: ReadableStream | null; + readonly body: ReadableStream | null; readonly bodyUsed: boolean; arrayBuffer(): Promise; blob(): Promise; @@ -527,6 +598,16 @@ interface BroadcastChannelEventMap { messageerror: MessageEvent; } +interface ByteLengthQueuingStrategy extends QueuingStrategy { + highWaterMark: number; + size(chunk: ArrayBufferView): number; +} + +declare var ByteLengthQueuingStrategy: { + prototype: ByteLengthQueuingStrategy; + new(options: { highWaterMark: number }): ByteLengthQueuingStrategy; +}; + interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; @@ -675,6 +756,16 @@ declare var Console: { new(): Console; }; +interface CountQueuingStrategy extends QueuingStrategy { + highWaterMark: number; + size(chunk: any): 1; +} + +declare var CountQueuingStrategy: { + prototype: CountQueuingStrategy; + new(options: { highWaterMark: number }): CountQueuingStrategy; +}; + interface Crypto { readonly subtle: SubtleCrypto; getRandomValues(array: T): T; @@ -1002,6 +1093,29 @@ interface DhKeyGenParams extends Algorithm { prime: Uint8Array; } +interface EXT_blend_minmax { + readonly MAX_EXT: GLenum; + readonly MIN_EXT: GLenum; +} + +interface EXT_frag_depth { +} + +interface EXT_sRGB { + readonly FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: GLenum; + readonly SRGB8_ALPHA8_EXT: GLenum; + readonly SRGB_ALPHA_EXT: GLenum; + readonly SRGB_EXT: GLenum; +} + +interface EXT_shader_texture_lod { +} + +interface EXT_texture_filter_anisotropic { + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: GLenum; + readonly TEXTURE_MAX_ANISOTROPY_EXT: GLenum; +} + interface ErrorEvent extends Event { readonly colno: number; readonly error: any; @@ -1039,7 +1153,6 @@ interface Event { */ readonly isTrusted: boolean; returnValue: boolean; - readonly srcElement: object | null; /** * Returns the object to which event is dispatched (its target). */ @@ -1217,7 +1330,7 @@ interface FileReader extends EventTarget { readAsArrayBuffer(blob: Blob): void; readAsBinaryString(blob: Blob): void; readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, label?: string): void; + readAsText(blob: Blob, encoding?: string): void; readonly DONE: number; readonly EMPTY: number; readonly LOADING: number; @@ -1239,7 +1352,7 @@ interface FileReaderSync { readAsArrayBuffer(blob: Blob): ArrayBuffer; readAsBinaryString(blob: Blob): string; readAsDataURL(blob: Blob): string; - readAsText(blob: Blob, label?: string): string; + readAsText(blob: Blob, encoding?: string): string; } declare var FileReaderSync: { @@ -1994,6 +2107,34 @@ declare var NotificationEvent: { new(type: string, eventInitDict: NotificationEventInit): NotificationEvent; }; +interface OES_element_index_uint { +} + +interface OES_standard_derivatives { + readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: GLenum; +} + +interface OES_texture_float { +} + +interface OES_texture_float_linear { +} + +interface OES_texture_half_float { + readonly HALF_FLOAT_OES: GLenum; +} + +interface OES_texture_half_float_linear { +} + +interface OES_vertex_array_object { + bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void; + createVertexArrayOES(): WebGLVertexArrayObjectOES | null; + deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void; + isVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): GLboolean; + readonly VERTEX_ARRAY_BINDING_OES: GLenum; +} + interface Path2D extends CanvasPath { addPath(path: Path2D, transform?: DOMMatrix2DInit): void; } @@ -2197,20 +2338,70 @@ declare var PushSubscriptionOptions: { new(): PushSubscriptionOptions; }; -interface ReadableStream { +interface ReadableByteStreamController { + readonly byobRequest: ReadableStreamBYOBRequest | undefined; + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: ArrayBufferView): void; + error(error?: any): void; +} + +interface ReadableStream { readonly locked: boolean; - cancel(): Promise; - getReader(): ReadableStreamReader; + cancel(reason?: any): Promise; + getReader(options: { mode: "byob" }): ReadableStreamBYOBReader; + getReader(): ReadableStreamDefaultReader; + pipeThrough({ writable, readable }: { writable: WritableStream, readable: ReadableStream }, options?: PipeOptions): ReadableStream; + pipeTo(dest: WritableStream, options?: PipeOptions): Promise; + tee(): [ReadableStream, ReadableStream]; } declare var ReadableStream: { prototype: ReadableStream; - new(): ReadableStream; + new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number, size?: undefined }): ReadableStream; + new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream; }; -interface ReadableStreamReader { +interface ReadableStreamBYOBReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + read(view: T): Promise>; + releaseLock(): void; +} + +declare var ReadableStreamBYOBReader: { + prototype: ReadableStreamBYOBReader; + new(stream: ReadableStream): ReadableStreamBYOBReader; +}; + +interface ReadableStreamBYOBRequest { + readonly view: ArrayBufferView; + respond(bytesWritten: number): void; + respondWithNewView(view: ArrayBufferView): void; +} + +interface ReadableStreamDefaultController { + readonly desiredSize: number | null; + close(): void; + enqueue(chunk: R): void; + error(error?: any): void; +} + +interface ReadableStreamDefaultReader { + readonly closed: Promise; + cancel(reason?: any): Promise; + read(): Promise>; + releaseLock(): void; +} + +interface ReadableStreamReadResult { + done: boolean; + value: T; +} + +interface ReadableStreamReader { cancel(): Promise; - read(): Promise; + read(): Promise>; releaseLock(): void; } @@ -2222,7 +2413,7 @@ declare var ReadableStreamReader: { interface Request extends Body { /** * Returns the cache mode associated with request, which is a string indicating - * how the the request will interact with the browser's cache when fetching. + * how the request will interact with the browser's cache when fetching. */ readonly cache: RequestCache; /** @@ -2544,6 +2735,46 @@ declare var TextEncoder: { new(): TextEncoder; }; +interface TextMetrics { + readonly actualBoundingBoxAscent: number; + readonly actualBoundingBoxDescent: number; + readonly actualBoundingBoxLeft: number; + readonly actualBoundingBoxRight: number; + readonly alphabeticBaseline: number; + readonly emHeightAscent: number; + readonly emHeightDescent: number; + readonly fontBoundingBoxAscent: number; + readonly fontBoundingBoxDescent: number; + readonly hangingBaseline: number; + /** + * Returns the measurement described below. + */ + readonly ideographicBaseline: number; + readonly width: number; +} + +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +}; + +interface TransformStream { + readonly readable: ReadableStream; + readonly writable: WritableStream; +} + +declare var TransformStream: { + prototype: TransformStream; + new(transformer?: Transformer, writableStrategy?: QueuingStrategy, readableStrategy?: QueuingStrategy): TransformStream; +}; + +interface TransformStreamDefaultController { + readonly desiredSize: number | null; + enqueue(chunk: O): void; + error(reason?: any): void; + terminate(): void; +} + interface URL { hash: string; host: string; @@ -2601,6 +2832,978 @@ declare var URLSearchParams: { new(init?: string[][] | Record | string | URLSearchParams): URLSearchParams; }; +interface WEBGL_color_buffer_float { + readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum; + readonly RGBA32F_EXT: GLenum; + readonly UNSIGNED_NORMALIZED_EXT: GLenum; +} + +interface WEBGL_compressed_texture_astc { + getSupportedProfiles(): string[]; + readonly COMPRESSED_RGBA_ASTC_10x10_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_10x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_10x6_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_10x8_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_12x10_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_12x12_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_4x4_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_5x4_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_5x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_6x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_6x6_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_8x5_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_8x6_KHR: GLenum; + readonly COMPRESSED_RGBA_ASTC_8x8_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: GLenum; + readonly COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: GLenum; +} + +interface WEBGL_compressed_texture_s3tc { + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: GLenum; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: GLenum; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: GLenum; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: GLenum; +} + +interface WEBGL_compressed_texture_s3tc_srgb { + readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: GLenum; + readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: GLenum; + readonly COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: GLenum; + readonly COMPRESSED_SRGB_S3TC_DXT1_EXT: GLenum; +} + +interface WEBGL_debug_renderer_info { + readonly UNMASKED_RENDERER_WEBGL: GLenum; + readonly UNMASKED_VENDOR_WEBGL: GLenum; +} + +interface WEBGL_debug_shaders { + getTranslatedShaderSource(shader: WebGLShader): string; +} + +interface WEBGL_depth_texture { + readonly UNSIGNED_INT_24_8_WEBGL: GLenum; +} + +interface WEBGL_draw_buffers { + drawBuffersWEBGL(buffers: GLenum[]): void; + readonly COLOR_ATTACHMENT0_WEBGL: GLenum; + readonly COLOR_ATTACHMENT10_WEBGL: GLenum; + readonly COLOR_ATTACHMENT11_WEBGL: GLenum; + readonly COLOR_ATTACHMENT12_WEBGL: GLenum; + readonly COLOR_ATTACHMENT13_WEBGL: GLenum; + readonly COLOR_ATTACHMENT14_WEBGL: GLenum; + readonly COLOR_ATTACHMENT15_WEBGL: GLenum; + readonly COLOR_ATTACHMENT1_WEBGL: GLenum; + readonly COLOR_ATTACHMENT2_WEBGL: GLenum; + readonly COLOR_ATTACHMENT3_WEBGL: GLenum; + readonly COLOR_ATTACHMENT4_WEBGL: GLenum; + readonly COLOR_ATTACHMENT5_WEBGL: GLenum; + readonly COLOR_ATTACHMENT6_WEBGL: GLenum; + readonly COLOR_ATTACHMENT7_WEBGL: GLenum; + readonly COLOR_ATTACHMENT8_WEBGL: GLenum; + readonly COLOR_ATTACHMENT9_WEBGL: GLenum; + readonly DRAW_BUFFER0_WEBGL: GLenum; + readonly DRAW_BUFFER10_WEBGL: GLenum; + readonly DRAW_BUFFER11_WEBGL: GLenum; + readonly DRAW_BUFFER12_WEBGL: GLenum; + readonly DRAW_BUFFER13_WEBGL: GLenum; + readonly DRAW_BUFFER14_WEBGL: GLenum; + readonly DRAW_BUFFER15_WEBGL: GLenum; + readonly DRAW_BUFFER1_WEBGL: GLenum; + readonly DRAW_BUFFER2_WEBGL: GLenum; + readonly DRAW_BUFFER3_WEBGL: GLenum; + readonly DRAW_BUFFER4_WEBGL: GLenum; + readonly DRAW_BUFFER5_WEBGL: GLenum; + readonly DRAW_BUFFER6_WEBGL: GLenum; + readonly DRAW_BUFFER7_WEBGL: GLenum; + readonly DRAW_BUFFER8_WEBGL: GLenum; + readonly DRAW_BUFFER9_WEBGL: GLenum; + readonly MAX_COLOR_ATTACHMENTS_WEBGL: GLenum; + readonly MAX_DRAW_BUFFERS_WEBGL: GLenum; +} + +interface WEBGL_lose_context { + loseContext(): void; + restoreContext(): void; +} + +interface WebGLActiveInfo { + readonly name: string; + readonly size: GLint; + readonly type: GLenum; +} + +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +}; + +interface WebGLBuffer extends WebGLObject { +} + +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +}; + +interface WebGLContextEvent extends Event { + readonly statusMessage: string; +} + +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(type: string, eventInit?: WebGLContextEventInit): WebGLContextEvent; +}; + +interface WebGLFramebuffer extends WebGLObject { +} + +declare var WebGLFramebuffer: { + prototype: WebGLFramebuffer; + new(): WebGLFramebuffer; +}; + +interface WebGLObject { +} + +declare var WebGLObject: { + prototype: WebGLObject; + new(): WebGLObject; +}; + +interface WebGLProgram extends WebGLObject { +} + +declare var WebGLProgram: { + prototype: WebGLProgram; + new(): WebGLProgram; +}; + +interface WebGLRenderbuffer extends WebGLObject { +} + +declare var WebGLRenderbuffer: { + prototype: WebGLRenderbuffer; + new(): WebGLRenderbuffer; +}; + +interface WebGLRenderingContext extends WebGLRenderingContextBase { +} + +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + readonly ACTIVE_ATTRIBUTES: GLenum; + readonly ACTIVE_TEXTURE: GLenum; + readonly ACTIVE_UNIFORMS: GLenum; + readonly ALIASED_LINE_WIDTH_RANGE: GLenum; + readonly ALIASED_POINT_SIZE_RANGE: GLenum; + readonly ALPHA: GLenum; + readonly ALPHA_BITS: GLenum; + readonly ALWAYS: GLenum; + readonly ARRAY_BUFFER: GLenum; + readonly ARRAY_BUFFER_BINDING: GLenum; + readonly ATTACHED_SHADERS: GLenum; + readonly BACK: GLenum; + readonly BLEND: GLenum; + readonly BLEND_COLOR: GLenum; + readonly BLEND_DST_ALPHA: GLenum; + readonly BLEND_DST_RGB: GLenum; + readonly BLEND_EQUATION: GLenum; + readonly BLEND_EQUATION_ALPHA: GLenum; + readonly BLEND_EQUATION_RGB: GLenum; + readonly BLEND_SRC_ALPHA: GLenum; + readonly BLEND_SRC_RGB: GLenum; + readonly BLUE_BITS: GLenum; + readonly BOOL: GLenum; + readonly BOOL_VEC2: GLenum; + readonly BOOL_VEC3: GLenum; + readonly BOOL_VEC4: GLenum; + readonly BROWSER_DEFAULT_WEBGL: GLenum; + readonly BUFFER_SIZE: GLenum; + readonly BUFFER_USAGE: GLenum; + readonly BYTE: GLenum; + readonly CCW: GLenum; + readonly CLAMP_TO_EDGE: GLenum; + readonly COLOR_ATTACHMENT0: GLenum; + readonly COLOR_BUFFER_BIT: GLenum; + readonly COLOR_CLEAR_VALUE: GLenum; + readonly COLOR_WRITEMASK: GLenum; + readonly COMPILE_STATUS: GLenum; + readonly COMPRESSED_TEXTURE_FORMATS: GLenum; + readonly CONSTANT_ALPHA: GLenum; + readonly CONSTANT_COLOR: GLenum; + readonly CONTEXT_LOST_WEBGL: GLenum; + readonly CULL_FACE: GLenum; + readonly CULL_FACE_MODE: GLenum; + readonly CURRENT_PROGRAM: GLenum; + readonly CURRENT_VERTEX_ATTRIB: GLenum; + readonly CW: GLenum; + readonly DECR: GLenum; + readonly DECR_WRAP: GLenum; + readonly DELETE_STATUS: GLenum; + readonly DEPTH_ATTACHMENT: GLenum; + readonly DEPTH_BITS: GLenum; + readonly DEPTH_BUFFER_BIT: GLenum; + readonly DEPTH_CLEAR_VALUE: GLenum; + readonly DEPTH_COMPONENT: GLenum; + readonly DEPTH_COMPONENT16: GLenum; + readonly DEPTH_FUNC: GLenum; + readonly DEPTH_RANGE: GLenum; + readonly DEPTH_STENCIL: GLenum; + readonly DEPTH_STENCIL_ATTACHMENT: GLenum; + readonly DEPTH_TEST: GLenum; + readonly DEPTH_WRITEMASK: GLenum; + readonly DITHER: GLenum; + readonly DONT_CARE: GLenum; + readonly DST_ALPHA: GLenum; + readonly DST_COLOR: GLenum; + readonly DYNAMIC_DRAW: GLenum; + readonly ELEMENT_ARRAY_BUFFER: GLenum; + readonly ELEMENT_ARRAY_BUFFER_BINDING: GLenum; + readonly EQUAL: GLenum; + readonly FASTEST: GLenum; + readonly FLOAT: GLenum; + readonly FLOAT_MAT2: GLenum; + readonly FLOAT_MAT3: GLenum; + readonly FLOAT_MAT4: GLenum; + readonly FLOAT_VEC2: GLenum; + readonly FLOAT_VEC3: GLenum; + readonly FLOAT_VEC4: GLenum; + readonly FRAGMENT_SHADER: GLenum; + readonly FRAMEBUFFER: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: GLenum; + readonly FRAMEBUFFER_BINDING: GLenum; + readonly FRAMEBUFFER_COMPLETE: GLenum; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLenum; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: GLenum; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLenum; + readonly FRAMEBUFFER_UNSUPPORTED: GLenum; + readonly FRONT: GLenum; + readonly FRONT_AND_BACK: GLenum; + readonly FRONT_FACE: GLenum; + readonly FUNC_ADD: GLenum; + readonly FUNC_REVERSE_SUBTRACT: GLenum; + readonly FUNC_SUBTRACT: GLenum; + readonly GENERATE_MIPMAP_HINT: GLenum; + readonly GEQUAL: GLenum; + readonly GREATER: GLenum; + readonly GREEN_BITS: GLenum; + readonly HIGH_FLOAT: GLenum; + readonly HIGH_INT: GLenum; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: GLenum; + readonly IMPLEMENTATION_COLOR_READ_TYPE: GLenum; + readonly INCR: GLenum; + readonly INCR_WRAP: GLenum; + readonly INT: GLenum; + readonly INT_VEC2: GLenum; + readonly INT_VEC3: GLenum; + readonly INT_VEC4: GLenum; + readonly INVALID_ENUM: GLenum; + readonly INVALID_FRAMEBUFFER_OPERATION: GLenum; + readonly INVALID_OPERATION: GLenum; + readonly INVALID_VALUE: GLenum; + readonly INVERT: GLenum; + readonly KEEP: GLenum; + readonly LEQUAL: GLenum; + readonly LESS: GLenum; + readonly LINEAR: GLenum; + readonly LINEAR_MIPMAP_LINEAR: GLenum; + readonly LINEAR_MIPMAP_NEAREST: GLenum; + readonly LINES: GLenum; + readonly LINE_LOOP: GLenum; + readonly LINE_STRIP: GLenum; + readonly LINE_WIDTH: GLenum; + readonly LINK_STATUS: GLenum; + readonly LOW_FLOAT: GLenum; + readonly LOW_INT: GLenum; + readonly LUMINANCE: GLenum; + readonly LUMINANCE_ALPHA: GLenum; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: GLenum; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: GLenum; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: GLenum; + readonly MAX_RENDERBUFFER_SIZE: GLenum; + readonly MAX_TEXTURE_IMAGE_UNITS: GLenum; + readonly MAX_TEXTURE_SIZE: GLenum; + readonly MAX_VARYING_VECTORS: GLenum; + readonly MAX_VERTEX_ATTRIBS: GLenum; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: GLenum; + readonly MAX_VERTEX_UNIFORM_VECTORS: GLenum; + readonly MAX_VIEWPORT_DIMS: GLenum; + readonly MEDIUM_FLOAT: GLenum; + readonly MEDIUM_INT: GLenum; + readonly MIRRORED_REPEAT: GLenum; + readonly NEAREST: GLenum; + readonly NEAREST_MIPMAP_LINEAR: GLenum; + readonly NEAREST_MIPMAP_NEAREST: GLenum; + readonly NEVER: GLenum; + readonly NICEST: GLenum; + readonly NONE: GLenum; + readonly NOTEQUAL: GLenum; + readonly NO_ERROR: GLenum; + readonly ONE: GLenum; + readonly ONE_MINUS_CONSTANT_ALPHA: GLenum; + readonly ONE_MINUS_CONSTANT_COLOR: GLenum; + readonly ONE_MINUS_DST_ALPHA: GLenum; + readonly ONE_MINUS_DST_COLOR: GLenum; + readonly ONE_MINUS_SRC_ALPHA: GLenum; + readonly ONE_MINUS_SRC_COLOR: GLenum; + readonly OUT_OF_MEMORY: GLenum; + readonly PACK_ALIGNMENT: GLenum; + readonly POINTS: GLenum; + readonly POLYGON_OFFSET_FACTOR: GLenum; + readonly POLYGON_OFFSET_FILL: GLenum; + readonly POLYGON_OFFSET_UNITS: GLenum; + readonly RED_BITS: GLenum; + readonly RENDERBUFFER: GLenum; + readonly RENDERBUFFER_ALPHA_SIZE: GLenum; + readonly RENDERBUFFER_BINDING: GLenum; + readonly RENDERBUFFER_BLUE_SIZE: GLenum; + readonly RENDERBUFFER_DEPTH_SIZE: GLenum; + readonly RENDERBUFFER_GREEN_SIZE: GLenum; + readonly RENDERBUFFER_HEIGHT: GLenum; + readonly RENDERBUFFER_INTERNAL_FORMAT: GLenum; + readonly RENDERBUFFER_RED_SIZE: GLenum; + readonly RENDERBUFFER_STENCIL_SIZE: GLenum; + readonly RENDERBUFFER_WIDTH: GLenum; + readonly RENDERER: GLenum; + readonly REPEAT: GLenum; + readonly REPLACE: GLenum; + readonly RGB: GLenum; + readonly RGB565: GLenum; + readonly RGB5_A1: GLenum; + readonly RGBA: GLenum; + readonly RGBA4: GLenum; + readonly SAMPLER_2D: GLenum; + readonly SAMPLER_CUBE: GLenum; + readonly SAMPLES: GLenum; + readonly SAMPLE_ALPHA_TO_COVERAGE: GLenum; + readonly SAMPLE_BUFFERS: GLenum; + readonly SAMPLE_COVERAGE: GLenum; + readonly SAMPLE_COVERAGE_INVERT: GLenum; + readonly SAMPLE_COVERAGE_VALUE: GLenum; + readonly SCISSOR_BOX: GLenum; + readonly SCISSOR_TEST: GLenum; + readonly SHADER_TYPE: GLenum; + readonly SHADING_LANGUAGE_VERSION: GLenum; + readonly SHORT: GLenum; + readonly SRC_ALPHA: GLenum; + readonly SRC_ALPHA_SATURATE: GLenum; + readonly SRC_COLOR: GLenum; + readonly STATIC_DRAW: GLenum; + readonly STENCIL_ATTACHMENT: GLenum; + readonly STENCIL_BACK_FAIL: GLenum; + readonly STENCIL_BACK_FUNC: GLenum; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: GLenum; + readonly STENCIL_BACK_PASS_DEPTH_PASS: GLenum; + readonly STENCIL_BACK_REF: GLenum; + readonly STENCIL_BACK_VALUE_MASK: GLenum; + readonly STENCIL_BACK_WRITEMASK: GLenum; + readonly STENCIL_BITS: GLenum; + readonly STENCIL_BUFFER_BIT: GLenum; + readonly STENCIL_CLEAR_VALUE: GLenum; + readonly STENCIL_FAIL: GLenum; + readonly STENCIL_FUNC: GLenum; + readonly STENCIL_INDEX8: GLenum; + readonly STENCIL_PASS_DEPTH_FAIL: GLenum; + readonly STENCIL_PASS_DEPTH_PASS: GLenum; + readonly STENCIL_REF: GLenum; + readonly STENCIL_TEST: GLenum; + readonly STENCIL_VALUE_MASK: GLenum; + readonly STENCIL_WRITEMASK: GLenum; + readonly STREAM_DRAW: GLenum; + readonly SUBPIXEL_BITS: GLenum; + readonly TEXTURE: GLenum; + readonly TEXTURE0: GLenum; + readonly TEXTURE1: GLenum; + readonly TEXTURE10: GLenum; + readonly TEXTURE11: GLenum; + readonly TEXTURE12: GLenum; + readonly TEXTURE13: GLenum; + readonly TEXTURE14: GLenum; + readonly TEXTURE15: GLenum; + readonly TEXTURE16: GLenum; + readonly TEXTURE17: GLenum; + readonly TEXTURE18: GLenum; + readonly TEXTURE19: GLenum; + readonly TEXTURE2: GLenum; + readonly TEXTURE20: GLenum; + readonly TEXTURE21: GLenum; + readonly TEXTURE22: GLenum; + readonly TEXTURE23: GLenum; + readonly TEXTURE24: GLenum; + readonly TEXTURE25: GLenum; + readonly TEXTURE26: GLenum; + readonly TEXTURE27: GLenum; + readonly TEXTURE28: GLenum; + readonly TEXTURE29: GLenum; + readonly TEXTURE3: GLenum; + readonly TEXTURE30: GLenum; + readonly TEXTURE31: GLenum; + readonly TEXTURE4: GLenum; + readonly TEXTURE5: GLenum; + readonly TEXTURE6: GLenum; + readonly TEXTURE7: GLenum; + readonly TEXTURE8: GLenum; + readonly TEXTURE9: GLenum; + readonly TEXTURE_2D: GLenum; + readonly TEXTURE_BINDING_2D: GLenum; + readonly TEXTURE_BINDING_CUBE_MAP: GLenum; + readonly TEXTURE_CUBE_MAP: GLenum; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: GLenum; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: GLenum; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: GLenum; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: GLenum; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: GLenum; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: GLenum; + readonly TEXTURE_MAG_FILTER: GLenum; + readonly TEXTURE_MIN_FILTER: GLenum; + readonly TEXTURE_WRAP_S: GLenum; + readonly TEXTURE_WRAP_T: GLenum; + readonly TRIANGLES: GLenum; + readonly TRIANGLE_FAN: GLenum; + readonly TRIANGLE_STRIP: GLenum; + readonly UNPACK_ALIGNMENT: GLenum; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: GLenum; + readonly UNPACK_FLIP_Y_WEBGL: GLenum; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: GLenum; + readonly UNSIGNED_BYTE: GLenum; + readonly UNSIGNED_INT: GLenum; + readonly UNSIGNED_SHORT: GLenum; + readonly UNSIGNED_SHORT_4_4_4_4: GLenum; + readonly UNSIGNED_SHORT_5_5_5_1: GLenum; + readonly UNSIGNED_SHORT_5_6_5: GLenum; + readonly VALIDATE_STATUS: GLenum; + readonly VENDOR: GLenum; + readonly VERSION: GLenum; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: GLenum; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: GLenum; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: GLenum; + readonly VERTEX_ATTRIB_ARRAY_POINTER: GLenum; + readonly VERTEX_ATTRIB_ARRAY_SIZE: GLenum; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: GLenum; + readonly VERTEX_ATTRIB_ARRAY_TYPE: GLenum; + readonly VERTEX_SHADER: GLenum; + readonly VIEWPORT: GLenum; + readonly ZERO: GLenum; +}; + +interface WebGLRenderingContextBase { + readonly drawingBufferHeight: GLsizei; + readonly drawingBufferWidth: GLsizei; + activeTexture(texture: GLenum): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + bindAttribLocation(program: WebGLProgram, index: GLuint, name: string): void; + bindBuffer(target: GLenum, buffer: WebGLBuffer | null): void; + bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer | null): void; + bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer | null): void; + bindTexture(target: GLenum, texture: WebGLTexture | null): void; + blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void; + blendEquation(mode: GLenum): void; + blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum): void; + blendFunc(sfactor: GLenum, dfactor: GLenum): void; + blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum): void; + bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum): void; + bufferData(target: GLenum, data: BufferSource | null, usage: GLenum): void; + bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource): void; + checkFramebufferStatus(target: GLenum): GLenum; + clear(mask: GLbitfield): void; + clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void; + clearDepth(depth: GLclampf): void; + clearStencil(s: GLint): void; + colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean): void; + compileShader(shader: WebGLShader): void; + compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView): void; + compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView): void; + copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint): void; + copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; + createBuffer(): WebGLBuffer | null; + createFramebuffer(): WebGLFramebuffer | null; + createProgram(): WebGLProgram | null; + createRenderbuffer(): WebGLRenderbuffer | null; + createShader(type: GLenum): WebGLShader | null; + createTexture(): WebGLTexture | null; + cullFace(mode: GLenum): void; + deleteBuffer(buffer: WebGLBuffer | null): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer | null): void; + deleteProgram(program: WebGLProgram | null): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer | null): void; + deleteShader(shader: WebGLShader | null): void; + deleteTexture(texture: WebGLTexture | null): void; + depthFunc(func: GLenum): void; + depthMask(flag: GLboolean): void; + depthRange(zNear: GLclampf, zFar: GLclampf): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + disable(cap: GLenum): void; + disableVertexAttribArray(index: GLuint): void; + drawArrays(mode: GLenum, first: GLint, count: GLsizei): void; + drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr): void; + enable(cap: GLenum): void; + enableVertexAttribArray(index: GLuint): void; + finish(): void; + flush(): void; + framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer | null): void; + framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture | null, level: GLint): void; + frontFace(mode: GLenum): void; + generateMipmap(target: GLenum): void; + getActiveAttrib(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null; + getActiveUniform(program: WebGLProgram, index: GLuint): WebGLActiveInfo | null; + getAttachedShaders(program: WebGLProgram): WebGLShader[] | null; + getAttribLocation(program: WebGLProgram, name: string): GLint; + getBufferParameter(target: GLenum, pname: GLenum): any; + getContextAttributes(): WebGLContextAttributes | null; + getError(): GLenum; + getExtension(extensionName: "EXT_blend_minmax"): EXT_blend_minmax | null; + getExtension(extensionName: "EXT_texture_filter_anisotropic"): EXT_texture_filter_anisotropic | null; + getExtension(extensionName: "EXT_frag_depth"): EXT_frag_depth | null; + getExtension(extensionName: "EXT_shader_texture_lod"): EXT_shader_texture_lod | null; + getExtension(extensionName: "EXT_sRGB"): EXT_sRGB | null; + getExtension(extensionName: "OES_vertex_array_object"): OES_vertex_array_object | null; + getExtension(extensionName: "WEBGL_color_buffer_float"): WEBGL_color_buffer_float | null; + getExtension(extensionName: "WEBGL_compressed_texture_astc"): WEBGL_compressed_texture_astc | 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; + getExtension(extensionName: "WEBGL_lose_context"): WEBGL_lose_context | null; + getExtension(extensionName: "WEBGL_depth_texture"): WEBGL_depth_texture | null; + getExtension(extensionName: "WEBGL_debug_renderer_info"): WEBGL_debug_renderer_info | null; + getExtension(extensionName: "WEBGL_compressed_texture_s3tc"): WEBGL_compressed_texture_s3tc | null; + getExtension(extensionName: "OES_texture_half_float_linear"): OES_texture_half_float_linear | null; + getExtension(extensionName: "OES_texture_half_float"): OES_texture_half_float | null; + getExtension(extensionName: "OES_texture_float_linear"): OES_texture_float_linear | null; + getExtension(extensionName: "OES_texture_float"): OES_texture_float | null; + getExtension(extensionName: "OES_standard_derivatives"): OES_standard_derivatives | null; + getExtension(extensionName: "OES_element_index_uint"): OES_element_index_uint | null; + getExtension(extensionName: "ANGLE_instanced_arrays"): ANGLE_instanced_arrays | null; + getExtension(extensionName: string): any; + getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum): any; + getParameter(pname: GLenum): any; + getProgramInfoLog(program: WebGLProgram): string | null; + getProgramParameter(program: WebGLProgram, pname: GLenum): any; + getRenderbufferParameter(target: GLenum, pname: GLenum): any; + getShaderInfoLog(shader: WebGLShader): string | null; + getShaderParameter(shader: WebGLShader, pname: GLenum): any; + getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum): WebGLShaderPrecisionFormat | null; + getShaderSource(shader: WebGLShader): string | null; + getSupportedExtensions(): string[] | null; + getTexParameter(target: GLenum, pname: GLenum): any; + getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; + getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation | null; + getVertexAttrib(index: GLuint, pname: GLenum): any; + getVertexAttribOffset(index: GLuint, pname: GLenum): GLintptr; + hint(target: GLenum, mode: GLenum): void; + isBuffer(buffer: WebGLBuffer | null): GLboolean; + isContextLost(): boolean; + isEnabled(cap: GLenum): GLboolean; + isFramebuffer(framebuffer: WebGLFramebuffer | null): GLboolean; + isProgram(program: WebGLProgram | null): GLboolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer | null): GLboolean; + isShader(shader: WebGLShader | null): GLboolean; + isTexture(texture: WebGLTexture | null): GLboolean; + lineWidth(width: GLfloat): void; + linkProgram(program: WebGLProgram): void; + pixelStorei(pname: GLenum, param: GLint): void; + polygonOffset(factor: GLfloat, units: GLfloat): void; + readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void; + renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei): void; + sampleCoverage(value: GLclampf, invert: GLboolean): void; + scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; + shaderSource(shader: WebGLShader, source: string): void; + stencilFunc(func: GLenum, ref: GLint, mask: GLuint): void; + stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint): void; + stencilMask(mask: GLuint): void; + stencilMaskSeparate(face: GLenum, mask: GLuint): void; + stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum): void; + stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum): void; + texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void; + texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource): void; + texParameterf(target: GLenum, pname: GLenum, param: GLfloat): void; + texParameteri(target: GLenum, pname: GLenum, param: GLint): void; + texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void; + texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource): void; + uniform1f(location: WebGLUniformLocation | null, x: GLfloat): void; + uniform1fv(location: WebGLUniformLocation | null, v: Float32List): void; + uniform1i(location: WebGLUniformLocation | null, x: GLint): void; + uniform1iv(location: WebGLUniformLocation | null, v: Int32List): void; + uniform2f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat): void; + uniform2fv(location: WebGLUniformLocation | null, v: Float32List): void; + uniform2i(location: WebGLUniformLocation | null, x: GLint, y: GLint): void; + uniform2iv(location: WebGLUniformLocation | null, v: Int32List): void; + uniform3f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat, z: GLfloat): void; + uniform3fv(location: WebGLUniformLocation | null, v: Float32List): void; + uniform3i(location: WebGLUniformLocation | null, x: GLint, y: GLint, z: GLint): void; + uniform3iv(location: WebGLUniformLocation | null, v: Int32List): void; + uniform4f(location: WebGLUniformLocation | null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat): void; + uniform4fv(location: WebGLUniformLocation | null, v: Float32List): void; + uniform4i(location: WebGLUniformLocation | null, x: GLint, y: GLint, z: GLint, w: GLint): void; + uniform4iv(location: WebGLUniformLocation | null, v: Int32List): void; + uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void; + uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void; + uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void; + useProgram(program: WebGLProgram | null): void; + validateProgram(program: WebGLProgram): void; + vertexAttrib1f(index: GLuint, x: GLfloat): void; + vertexAttrib1fv(index: GLuint, values: Float32List): void; + vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat): void; + vertexAttrib2fv(index: GLuint, values: Float32List): void; + vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat): void; + vertexAttrib3fv(index: GLuint, values: Float32List): void; + vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat): void; + vertexAttrib4fv(index: GLuint, values: Float32List): void; + vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr): void; + viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; + readonly ACTIVE_ATTRIBUTES: GLenum; + readonly ACTIVE_TEXTURE: GLenum; + readonly ACTIVE_UNIFORMS: GLenum; + readonly ALIASED_LINE_WIDTH_RANGE: GLenum; + readonly ALIASED_POINT_SIZE_RANGE: GLenum; + readonly ALPHA: GLenum; + readonly ALPHA_BITS: GLenum; + readonly ALWAYS: GLenum; + readonly ARRAY_BUFFER: GLenum; + readonly ARRAY_BUFFER_BINDING: GLenum; + readonly ATTACHED_SHADERS: GLenum; + readonly BACK: GLenum; + readonly BLEND: GLenum; + readonly BLEND_COLOR: GLenum; + readonly BLEND_DST_ALPHA: GLenum; + readonly BLEND_DST_RGB: GLenum; + readonly BLEND_EQUATION: GLenum; + readonly BLEND_EQUATION_ALPHA: GLenum; + readonly BLEND_EQUATION_RGB: GLenum; + readonly BLEND_SRC_ALPHA: GLenum; + readonly BLEND_SRC_RGB: GLenum; + readonly BLUE_BITS: GLenum; + readonly BOOL: GLenum; + readonly BOOL_VEC2: GLenum; + readonly BOOL_VEC3: GLenum; + readonly BOOL_VEC4: GLenum; + readonly BROWSER_DEFAULT_WEBGL: GLenum; + readonly BUFFER_SIZE: GLenum; + readonly BUFFER_USAGE: GLenum; + readonly BYTE: GLenum; + readonly CCW: GLenum; + readonly CLAMP_TO_EDGE: GLenum; + readonly COLOR_ATTACHMENT0: GLenum; + readonly COLOR_BUFFER_BIT: GLenum; + readonly COLOR_CLEAR_VALUE: GLenum; + readonly COLOR_WRITEMASK: GLenum; + readonly COMPILE_STATUS: GLenum; + readonly COMPRESSED_TEXTURE_FORMATS: GLenum; + readonly CONSTANT_ALPHA: GLenum; + readonly CONSTANT_COLOR: GLenum; + readonly CONTEXT_LOST_WEBGL: GLenum; + readonly CULL_FACE: GLenum; + readonly CULL_FACE_MODE: GLenum; + readonly CURRENT_PROGRAM: GLenum; + readonly CURRENT_VERTEX_ATTRIB: GLenum; + readonly CW: GLenum; + readonly DECR: GLenum; + readonly DECR_WRAP: GLenum; + readonly DELETE_STATUS: GLenum; + readonly DEPTH_ATTACHMENT: GLenum; + readonly DEPTH_BITS: GLenum; + readonly DEPTH_BUFFER_BIT: GLenum; + readonly DEPTH_CLEAR_VALUE: GLenum; + readonly DEPTH_COMPONENT: GLenum; + readonly DEPTH_COMPONENT16: GLenum; + readonly DEPTH_FUNC: GLenum; + readonly DEPTH_RANGE: GLenum; + readonly DEPTH_STENCIL: GLenum; + readonly DEPTH_STENCIL_ATTACHMENT: GLenum; + readonly DEPTH_TEST: GLenum; + readonly DEPTH_WRITEMASK: GLenum; + readonly DITHER: GLenum; + readonly DONT_CARE: GLenum; + readonly DST_ALPHA: GLenum; + readonly DST_COLOR: GLenum; + readonly DYNAMIC_DRAW: GLenum; + readonly ELEMENT_ARRAY_BUFFER: GLenum; + readonly ELEMENT_ARRAY_BUFFER_BINDING: GLenum; + readonly EQUAL: GLenum; + readonly FASTEST: GLenum; + readonly FLOAT: GLenum; + readonly FLOAT_MAT2: GLenum; + readonly FLOAT_MAT3: GLenum; + readonly FLOAT_MAT4: GLenum; + readonly FLOAT_VEC2: GLenum; + readonly FLOAT_VEC3: GLenum; + readonly FLOAT_VEC4: GLenum; + readonly FRAGMENT_SHADER: GLenum; + readonly FRAMEBUFFER: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: GLenum; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: GLenum; + readonly FRAMEBUFFER_BINDING: GLenum; + readonly FRAMEBUFFER_COMPLETE: GLenum; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLenum; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: GLenum; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLenum; + readonly FRAMEBUFFER_UNSUPPORTED: GLenum; + readonly FRONT: GLenum; + readonly FRONT_AND_BACK: GLenum; + readonly FRONT_FACE: GLenum; + readonly FUNC_ADD: GLenum; + readonly FUNC_REVERSE_SUBTRACT: GLenum; + readonly FUNC_SUBTRACT: GLenum; + readonly GENERATE_MIPMAP_HINT: GLenum; + readonly GEQUAL: GLenum; + readonly GREATER: GLenum; + readonly GREEN_BITS: GLenum; + readonly HIGH_FLOAT: GLenum; + readonly HIGH_INT: GLenum; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: GLenum; + readonly IMPLEMENTATION_COLOR_READ_TYPE: GLenum; + readonly INCR: GLenum; + readonly INCR_WRAP: GLenum; + readonly INT: GLenum; + readonly INT_VEC2: GLenum; + readonly INT_VEC3: GLenum; + readonly INT_VEC4: GLenum; + readonly INVALID_ENUM: GLenum; + readonly INVALID_FRAMEBUFFER_OPERATION: GLenum; + readonly INVALID_OPERATION: GLenum; + readonly INVALID_VALUE: GLenum; + readonly INVERT: GLenum; + readonly KEEP: GLenum; + readonly LEQUAL: GLenum; + readonly LESS: GLenum; + readonly LINEAR: GLenum; + readonly LINEAR_MIPMAP_LINEAR: GLenum; + readonly LINEAR_MIPMAP_NEAREST: GLenum; + readonly LINES: GLenum; + readonly LINE_LOOP: GLenum; + readonly LINE_STRIP: GLenum; + readonly LINE_WIDTH: GLenum; + readonly LINK_STATUS: GLenum; + readonly LOW_FLOAT: GLenum; + readonly LOW_INT: GLenum; + readonly LUMINANCE: GLenum; + readonly LUMINANCE_ALPHA: GLenum; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: GLenum; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: GLenum; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: GLenum; + readonly MAX_RENDERBUFFER_SIZE: GLenum; + readonly MAX_TEXTURE_IMAGE_UNITS: GLenum; + readonly MAX_TEXTURE_SIZE: GLenum; + readonly MAX_VARYING_VECTORS: GLenum; + readonly MAX_VERTEX_ATTRIBS: GLenum; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: GLenum; + readonly MAX_VERTEX_UNIFORM_VECTORS: GLenum; + readonly MAX_VIEWPORT_DIMS: GLenum; + readonly MEDIUM_FLOAT: GLenum; + readonly MEDIUM_INT: GLenum; + readonly MIRRORED_REPEAT: GLenum; + readonly NEAREST: GLenum; + readonly NEAREST_MIPMAP_LINEAR: GLenum; + readonly NEAREST_MIPMAP_NEAREST: GLenum; + readonly NEVER: GLenum; + readonly NICEST: GLenum; + readonly NONE: GLenum; + readonly NOTEQUAL: GLenum; + readonly NO_ERROR: GLenum; + readonly ONE: GLenum; + readonly ONE_MINUS_CONSTANT_ALPHA: GLenum; + readonly ONE_MINUS_CONSTANT_COLOR: GLenum; + readonly ONE_MINUS_DST_ALPHA: GLenum; + readonly ONE_MINUS_DST_COLOR: GLenum; + readonly ONE_MINUS_SRC_ALPHA: GLenum; + readonly ONE_MINUS_SRC_COLOR: GLenum; + readonly OUT_OF_MEMORY: GLenum; + readonly PACK_ALIGNMENT: GLenum; + readonly POINTS: GLenum; + readonly POLYGON_OFFSET_FACTOR: GLenum; + readonly POLYGON_OFFSET_FILL: GLenum; + readonly POLYGON_OFFSET_UNITS: GLenum; + readonly RED_BITS: GLenum; + readonly RENDERBUFFER: GLenum; + readonly RENDERBUFFER_ALPHA_SIZE: GLenum; + readonly RENDERBUFFER_BINDING: GLenum; + readonly RENDERBUFFER_BLUE_SIZE: GLenum; + readonly RENDERBUFFER_DEPTH_SIZE: GLenum; + readonly RENDERBUFFER_GREEN_SIZE: GLenum; + readonly RENDERBUFFER_HEIGHT: GLenum; + readonly RENDERBUFFER_INTERNAL_FORMAT: GLenum; + readonly RENDERBUFFER_RED_SIZE: GLenum; + readonly RENDERBUFFER_STENCIL_SIZE: GLenum; + readonly RENDERBUFFER_WIDTH: GLenum; + readonly RENDERER: GLenum; + readonly REPEAT: GLenum; + readonly REPLACE: GLenum; + readonly RGB: GLenum; + readonly RGB565: GLenum; + readonly RGB5_A1: GLenum; + readonly RGBA: GLenum; + readonly RGBA4: GLenum; + readonly SAMPLER_2D: GLenum; + readonly SAMPLER_CUBE: GLenum; + readonly SAMPLES: GLenum; + readonly SAMPLE_ALPHA_TO_COVERAGE: GLenum; + readonly SAMPLE_BUFFERS: GLenum; + readonly SAMPLE_COVERAGE: GLenum; + readonly SAMPLE_COVERAGE_INVERT: GLenum; + readonly SAMPLE_COVERAGE_VALUE: GLenum; + readonly SCISSOR_BOX: GLenum; + readonly SCISSOR_TEST: GLenum; + readonly SHADER_TYPE: GLenum; + readonly SHADING_LANGUAGE_VERSION: GLenum; + readonly SHORT: GLenum; + readonly SRC_ALPHA: GLenum; + readonly SRC_ALPHA_SATURATE: GLenum; + readonly SRC_COLOR: GLenum; + readonly STATIC_DRAW: GLenum; + readonly STENCIL_ATTACHMENT: GLenum; + readonly STENCIL_BACK_FAIL: GLenum; + readonly STENCIL_BACK_FUNC: GLenum; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: GLenum; + readonly STENCIL_BACK_PASS_DEPTH_PASS: GLenum; + readonly STENCIL_BACK_REF: GLenum; + readonly STENCIL_BACK_VALUE_MASK: GLenum; + readonly STENCIL_BACK_WRITEMASK: GLenum; + readonly STENCIL_BITS: GLenum; + readonly STENCIL_BUFFER_BIT: GLenum; + readonly STENCIL_CLEAR_VALUE: GLenum; + readonly STENCIL_FAIL: GLenum; + readonly STENCIL_FUNC: GLenum; + readonly STENCIL_INDEX8: GLenum; + readonly STENCIL_PASS_DEPTH_FAIL: GLenum; + readonly STENCIL_PASS_DEPTH_PASS: GLenum; + readonly STENCIL_REF: GLenum; + readonly STENCIL_TEST: GLenum; + readonly STENCIL_VALUE_MASK: GLenum; + readonly STENCIL_WRITEMASK: GLenum; + readonly STREAM_DRAW: GLenum; + readonly SUBPIXEL_BITS: GLenum; + readonly TEXTURE: GLenum; + readonly TEXTURE0: GLenum; + readonly TEXTURE1: GLenum; + readonly TEXTURE10: GLenum; + readonly TEXTURE11: GLenum; + readonly TEXTURE12: GLenum; + readonly TEXTURE13: GLenum; + readonly TEXTURE14: GLenum; + readonly TEXTURE15: GLenum; + readonly TEXTURE16: GLenum; + readonly TEXTURE17: GLenum; + readonly TEXTURE18: GLenum; + readonly TEXTURE19: GLenum; + readonly TEXTURE2: GLenum; + readonly TEXTURE20: GLenum; + readonly TEXTURE21: GLenum; + readonly TEXTURE22: GLenum; + readonly TEXTURE23: GLenum; + readonly TEXTURE24: GLenum; + readonly TEXTURE25: GLenum; + readonly TEXTURE26: GLenum; + readonly TEXTURE27: GLenum; + readonly TEXTURE28: GLenum; + readonly TEXTURE29: GLenum; + readonly TEXTURE3: GLenum; + readonly TEXTURE30: GLenum; + readonly TEXTURE31: GLenum; + readonly TEXTURE4: GLenum; + readonly TEXTURE5: GLenum; + readonly TEXTURE6: GLenum; + readonly TEXTURE7: GLenum; + readonly TEXTURE8: GLenum; + readonly TEXTURE9: GLenum; + readonly TEXTURE_2D: GLenum; + readonly TEXTURE_BINDING_2D: GLenum; + readonly TEXTURE_BINDING_CUBE_MAP: GLenum; + readonly TEXTURE_CUBE_MAP: GLenum; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: GLenum; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: GLenum; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: GLenum; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: GLenum; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: GLenum; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: GLenum; + readonly TEXTURE_MAG_FILTER: GLenum; + readonly TEXTURE_MIN_FILTER: GLenum; + readonly TEXTURE_WRAP_S: GLenum; + readonly TEXTURE_WRAP_T: GLenum; + readonly TRIANGLES: GLenum; + readonly TRIANGLE_FAN: GLenum; + readonly TRIANGLE_STRIP: GLenum; + readonly UNPACK_ALIGNMENT: GLenum; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: GLenum; + readonly UNPACK_FLIP_Y_WEBGL: GLenum; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: GLenum; + readonly UNSIGNED_BYTE: GLenum; + readonly UNSIGNED_INT: GLenum; + readonly UNSIGNED_SHORT: GLenum; + readonly UNSIGNED_SHORT_4_4_4_4: GLenum; + readonly UNSIGNED_SHORT_5_5_5_1: GLenum; + readonly UNSIGNED_SHORT_5_6_5: GLenum; + readonly VALIDATE_STATUS: GLenum; + readonly VENDOR: GLenum; + readonly VERSION: GLenum; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: GLenum; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: GLenum; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: GLenum; + readonly VERTEX_ATTRIB_ARRAY_POINTER: GLenum; + readonly VERTEX_ATTRIB_ARRAY_SIZE: GLenum; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: GLenum; + readonly VERTEX_ATTRIB_ARRAY_TYPE: GLenum; + readonly VERTEX_SHADER: GLenum; + readonly VIEWPORT: GLenum; + readonly ZERO: GLenum; +} + +interface WebGLShader extends WebGLObject { +} + +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +}; + +interface WebGLShaderPrecisionFormat { + readonly precision: GLint; + readonly rangeMax: GLint; + readonly rangeMin: GLint; +} + +declare var WebGLShaderPrecisionFormat: { + prototype: WebGLShaderPrecisionFormat; + new(): WebGLShaderPrecisionFormat; +}; + +interface WebGLTexture extends WebGLObject { +} + +declare var WebGLTexture: { + prototype: WebGLTexture; + new(): WebGLTexture; +}; + +interface WebGLUniformLocation { +} + +declare var WebGLUniformLocation: { + prototype: WebGLUniformLocation; + new(): WebGLUniformLocation; +}; + +interface WebGLVertexArrayObjectOES extends WebGLObject { +} + interface WebSocketEventMap { "close": CloseEvent; "error": Event; @@ -2696,7 +3899,7 @@ interface Worker extends EventTarget, AbstractWorker { declare var Worker: { prototype: Worker; - new(stringUrl: string): Worker; + new(stringUrl: string, options?: WorkerOptions): Worker; }; interface WorkerGlobalScopeEventMap { @@ -2756,6 +3959,31 @@ interface WorkerUtils extends WindowBase64 { importScripts(...urls: string[]): void; } +interface WritableStream { + readonly locked: boolean; + abort(reason?: any): Promise; + getWriter(): WritableStreamDefaultWriter; +} + +declare var WritableStream: { + prototype: WritableStream; + new(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy): WritableStream; +}; + +interface WritableStreamDefaultController { + error(error?: any): void; +} + +interface WritableStreamDefaultWriter { + readonly closed: Promise; + readonly desiredSize: number | null; + readonly ready: Promise; + abort(reason?: any): Promise; + close(): Promise; + releaseLock(): void; + write(chunk: W): Promise; +} + interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap { "readystatechange": Event; } @@ -2917,6 +4145,46 @@ interface PerformanceObserverCallback { (entries: PerformanceObserverEntryList, observer: PerformanceObserver): void; } +interface QueuingStrategySizeCallback { + (chunk: T): number; +} + +interface ReadableByteStreamControllerCallback { + (controller: ReadableByteStreamController): void | PromiseLike; +} + +interface ReadableStreamDefaultControllerCallback { + (controller: ReadableStreamDefaultController): void | PromiseLike; +} + +interface ReadableStreamErrorCallback { + (reason: any): void | PromiseLike; +} + +interface TransformStreamDefaultControllerCallback { + (controller: TransformStreamDefaultController): void | PromiseLike; +} + +interface TransformStreamDefaultControllerTransformCallback { + (chunk: I, controller: TransformStreamDefaultController): void | PromiseLike; +} + +interface WritableStreamDefaultControllerCloseCallback { + (): void | PromiseLike; +} + +interface WritableStreamDefaultControllerStartCallback { + (controller: WritableStreamDefaultController): void | PromiseLike; +} + +interface WritableStreamDefaultControllerWriteCallback { + (chunk: W, controller: WritableStreamDefaultController): void | PromiseLike; +} + +interface WritableStreamErrorCallback { + (reason: any): void | PromiseLike; +} + declare var onmessage: ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) | null; declare function close(): void; declare function postMessage(message: any, transfer?: Transferable[]): void; @@ -2966,7 +4234,7 @@ declare function removeEventListener; -type BodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string; +type BodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string; type RequestInfo = Request | string; type DOMHighResTimeStamp = number; type CanvasImageSource = ImageBitmap; @@ -2980,6 +4248,19 @@ type AlgorithmIdentifier = string | Algorithm; type HashAlgorithmIdentifier = AlgorithmIdentifier; type BigInteger = Uint8Array; type NamedCurve = string; +type GLenum = number; +type GLboolean = boolean; +type GLbitfield = number; +type GLint = number; +type GLsizei = number; +type GLintptr = number; +type GLsizeiptr = number; +type GLuint = number; +type GLfloat = number; +type GLclampf = number; +type TexImageSource = ImageBitmap | ImageData; +type Float32List = Float32Array | GLfloat[]; +type Int32List = Int32Array | GLint[]; type BufferSource = ArrayBufferView | ArrayBuffer; type DOMTimeStamp = number; type FormDataEntryValue = File | string; @@ -2987,6 +4268,7 @@ type IDBValidKey = number | string | Date | BufferSource | IDBArrayKey; type Transferable = ArrayBuffer | MessagePort | ImageBitmap; type BinaryType = "blob" | "arraybuffer"; type ClientTypes = "window" | "worker" | "sharedworker" | "all"; +type EndingType = "transparent" | "native"; type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; type IDBRequestReadyState = "pending" | "done"; type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; @@ -3007,5 +4289,6 @@ type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaquer type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; type ServiceWorkerUpdateViaCache = "imports" | "all" | "none"; type VisibilityState = "hidden" | "visible" | "prerender"; +type WebGLPowerPreference = "default" | "low-power" | "high-performance"; type WorkerType = "classic" | "module"; type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 5823233a25b..49a507b9881 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -61,7 +61,8 @@ declare namespace ts.server.protocol { GetApplicableRefactors = "getApplicableRefactors", GetEditsForRefactor = "getEditsForRefactor", OrganizeImports = "organizeImports", - GetEditsForFileRename = "getEditsForFileRename" + GetEditsForFileRename = "getEditsForFileRename", + ConfigurePlugin = "configurePlugin" } /** * A TypeScript Server message @@ -136,6 +137,10 @@ declare namespace ts.server.protocol { * Contains message body if success === true. */ body?: any; + /** + * Contains extra information that plugin can include to be passed on + */ + metadata?: unknown; } /** * Arguments for FileRequest messages. @@ -781,7 +786,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReferencesResponseItem[]; + refs: ReadonlyArray; /** * The name of the symbol. */ @@ -1010,6 +1015,14 @@ declare namespace ts.server.protocol { */ interface ConfigureResponse extends Response { } + interface ConfigurePluginRequestArguments { + pluginName: string; + configuration: any; + } + interface ConfigurePluginRequest extends Request { + command: CommandTypes.ConfigurePlugin; + arguments: ConfigurePluginRequestArguments; + } /** * Information found in an "open" request. */ @@ -1847,6 +1860,7 @@ declare namespace ts.server.protocol { */ interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; + event: DiagnosticEventKind; } interface ConfigFileDiagnosticEventBody { /** diff --git a/lib/tsc.js b/lib/tsc.js index 6309a02f3fe..f04ae41349c 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -429,7 +429,24 @@ var ts; function flatMap(array, mapfn) { var result; if (array) { - result = []; + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || ts.emptyArray; + } + ts.flatMap = flatMap; + function flatMapToMutable(array, mapfn) { + var result = []; + if (array) { for (var i = 0; i < array.length; i++) { var v = mapfn(array[i], i); if (v) { @@ -444,7 +461,7 @@ var ts; } return result; } - ts.flatMap = flatMap; + ts.flatMapToMutable = flatMapToMutable; function flatMapIterator(iter, mapfn) { var first = iter.next(); if (first.done) { @@ -670,7 +687,7 @@ var ts; ts.deduplicate = deduplicate; function deduplicateSorted(array, comparer) { if (array.length === 0) - return []; + return ts.emptyArray; var last = array[0]; var deduplicated = [last]; for (var i = 1; i < array.length; i++) { @@ -698,7 +715,7 @@ var ts; } ts.insertSorted = insertSorted; function sortAndDeduplicate(array, comparer, equalityComparer) { - return deduplicateSorted(sort(array, comparer), equalityComparer || comparer); + return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive); } ts.sortAndDeduplicate = sortAndDeduplicate; function arrayIsEqualTo(array1, array2, equalityComparer) { @@ -821,7 +838,7 @@ var ts; indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); }); } function sort(array, comparer) { - return array.slice().sort(comparer); + return (array.length === 0 ? array : array.slice().sort(comparer)); } ts.sort = sort; function arrayIterator(array) { @@ -900,12 +917,15 @@ var ts; } ts.replaceElement = replaceElement; function binarySearch(array, value, keySelector, keyComparer, offset) { - if (!array || array.length === 0) { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); + } + ts.binarySearch = binarySearch; + function binarySearchKey(array, key, keySelector, keyComparer, offset) { + if (!some(array)) { return -1; } var low = offset || 0; var high = array.length - 1; - var key = keySelector(value); while (low <= high) { var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle]); @@ -922,7 +942,7 @@ var ts; } return ~low; } - ts.binarySearch = binarySearch; + ts.binarySearchKey = binarySearchKey; function reduceLeft(array, f, initial, start, count) { if (array && array.length > 0) { var size = array.length; @@ -1695,6 +1715,33 @@ var ts; var counts; var marks; var measures; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; function mark(markName) { if (enabled) { marks.set(markName, ts.timestamp()); @@ -2040,13 +2087,14 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -3208,6 +3256,7 @@ var ts; use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), 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."), @@ -3264,14 +3313,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number' or an enum type."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), @@ -3478,9 +3527,9 @@ var ts; No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), @@ -3578,6 +3627,13 @@ var ts; Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), It_is_highly_likely_that_you_are_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "It_is_highly_likely_that_you_are_missing_a_semicolon_2734", "It is highly likely that you are missing a semicolon."), + Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), + Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), + BigInt_literals_are_not_available_when_targeting_lower_than_ESNext: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ESNext_2737", "BigInt literals are not available when targeting lower than ESNext."), + An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, ts.DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."), + Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."), 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}'."), @@ -3894,6 +3950,9 @@ var ts; Did_you_mean_to_call_this_expression: diag(6212, ts.DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"), Did_you_mean_to_use_new_with_this_expression: diag(6213, ts.DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"), Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, ts.DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."), + Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."), + Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."), + Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -3934,6 +3993,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."), Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."), Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."), + Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, ts.DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."), Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."), Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."), Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."), @@ -3961,6 +4021,14 @@ var ts; If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any_7041", "The containing arrow function captures the global value of 'this' which implicitly has type 'any'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), + Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, ts.DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, ts.DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."), + Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, ts.DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."), + _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."), 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_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -4122,98 +4190,101 @@ var ts; Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), Generate_types_for_0: diag(95067, ts.DiagnosticCategory.Message, "Generate_types_for_0_95067", "Generate types for '{0}'"), Generate_types_for_all_packages_without_types: diag(95068, ts.DiagnosticCategory.Message, "Generate_types_for_all_packages_without_types_95068", "Generate types for all packages without types"), + Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), + Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), }; })(ts || (ts = {})); var ts; (function (ts) { var _a; function tokenIsIdentifierOrKeyword(token) { - return token >= 71; + return token >= 72; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 29 || tokenIsIdentifierOrKeyword(token); + return token === 30 || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 117, - any: 119, - as: 118, - boolean: 122, - break: 72, - case: 73, - catch: 74, - class: 75, - continue: 77, - const: 76 + abstract: 118, + any: 120, + as: 119, + bigint: 146, + boolean: 123, + break: 73, + case: 74, + catch: 75, + class: 76, + continue: 78, + const: 77 }, - _a["" + "constructor"] = 123, - _a.debugger = 78, - _a.declare = 124, - _a.default = 79, - _a.delete = 80, - _a.do = 81, - _a.else = 82, - _a.enum = 83, - _a.export = 84, - _a.extends = 85, - _a.false = 86, - _a.finally = 87, - _a.for = 88, - _a.from = 143, - _a.function = 89, - _a.get = 125, - _a.if = 90, - _a.implements = 108, - _a.import = 91, - _a.in = 92, - _a.infer = 126, - _a.instanceof = 93, - _a.interface = 109, - _a.is = 127, - _a.keyof = 128, - _a.let = 110, - _a.module = 129, - _a.namespace = 130, - _a.never = 131, - _a.new = 94, - _a.null = 95, - _a.number = 134, - _a.object = 135, - _a.package = 111, - _a.private = 112, - _a.protected = 113, - _a.public = 114, - _a.readonly = 132, - _a.require = 133, - _a.global = 144, - _a.return = 96, - _a.set = 136, - _a.static = 115, - _a.string = 137, - _a.super = 97, - _a.switch = 98, - _a.symbol = 138, - _a.this = 99, - _a.throw = 100, - _a.true = 101, - _a.try = 102, - _a.type = 139, - _a.typeof = 103, - _a.undefined = 140, - _a.unique = 141, - _a.unknown = 142, - _a.var = 104, - _a.void = 105, - _a.while = 106, - _a.with = 107, - _a.yield = 116, - _a.async = 120, - _a.await = 121, - _a.of = 145, + _a["" + "constructor"] = 124, + _a.debugger = 79, + _a.declare = 125, + _a.default = 80, + _a.delete = 81, + _a.do = 82, + _a.else = 83, + _a.enum = 84, + _a.export = 85, + _a.extends = 86, + _a.false = 87, + _a.finally = 88, + _a.for = 89, + _a.from = 144, + _a.function = 90, + _a.get = 126, + _a.if = 91, + _a.implements = 109, + _a.import = 92, + _a.in = 93, + _a.infer = 127, + _a.instanceof = 94, + _a.interface = 110, + _a.is = 128, + _a.keyof = 129, + _a.let = 111, + _a.module = 130, + _a.namespace = 131, + _a.never = 132, + _a.new = 95, + _a.null = 96, + _a.number = 135, + _a.object = 136, + _a.package = 112, + _a.private = 113, + _a.protected = 114, + _a.public = 115, + _a.readonly = 133, + _a.require = 134, + _a.global = 145, + _a.return = 97, + _a.set = 137, + _a.static = 116, + _a.string = 138, + _a.super = 98, + _a.switch = 99, + _a.symbol = 139, + _a.this = 100, + _a.throw = 101, + _a.true = 102, + _a.try = 103, + _a.type = 140, + _a.typeof = 104, + _a.undefined = 141, + _a.unique = 142, + _a.unknown = 143, + _a.var = 105, + _a.void = 106, + _a.while = 107, + _a.with = 108, + _a.yield = 117, + _a.async = 121, + _a.await = 122, + _a.of = 147, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17, "}": 18, "(": 19, ")": 20, "[": 21, "]": 22, ".": 23, "...": 24, ";": 25, ",": 26, "<": 27, ">": 29, "<=": 30, ">=": 31, "==": 32, "!=": 33, "===": 34, "!==": 35, "=>": 36, "+": 37, "-": 38, "**": 40, "*": 39, "/": 41, "%": 42, "++": 43, "--": 44, "<<": 45, ">": 46, ">>>": 47, "&": 48, "|": 49, "^": 50, "!": 51, "~": 52, "&&": 53, "||": 54, "?": 55, ":": 56, "=": 58, "+=": 59, "-=": 60, "*=": 61, "**=": 62, "/=": 63, "%=": 64, "<<=": 65, ">>=": 66, ">>>=": 67, "&=": 68, "|=": 69, "^=": 70, "@": 57 })); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 28, ">": 30, "<=": 31, ">=": 32, "==": 33, "!=": 34, "===": 35, "!==": 36, "=>": 37, "+": 38, "-": 39, "**": 41, "*": 40, "/": 42, "%": 43, "++": 44, "--": 45, "<<": 46, ">": 47, ">>>": 48, "&": 49, "|": 50, "^": 51, "!": 52, "~": 53, "&&": 54, "||": 55, "?": 56, ":": 57, "=": 59, "+=": 60, "-=": 61, "*=": 62, "**=": 63, "/=": 64, "%=": 65, "<<=": 66, ">>=": 67, ">>>=": 68, "&=": 69, "|=": 70, "^=": 71, "@": 58 })); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -4685,8 +4756,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; }, - isIdentifier: function () { return token === 71 || token > 107; }, - isReservedWord: function () { return token >= 72 && token <= 107; }, + isIdentifier: function () { return token === 72 || token > 108; }, + isReservedWord: function () { return token >= 73 && token <= 108; }, isUnterminated: function () { return (tokenFlags & 4) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -4780,18 +4851,29 @@ var ts; end = pos; } } + var result; if (tokenFlags & 512) { - var result = mainFragment; + result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; } if (scientificFragment) { result += scientificFragment; } - return "" + +result; } else { - return "" + +(text.substring(start, end)); + result = text.substring(start, end); + } + if (decimalFragment !== undefined || tokenFlags & 16) { + return { + type: 8, + value: "" + +result + }; + } + else { + tokenValue = result; + var type = checkBigIntSuffix(); + return { type: type, value: tokenValue }; } } function scanOctalDigits() { @@ -4802,17 +4884,17 @@ var ts; return +(text.substring(start, pos)); } function scanExactNumberOfHexDigits(count, canHaveSeparators) { - return scanHexDigits(count, false, canHaveSeparators); + var valueString = scanHexDigits(count, false, canHaveSeparators); + return valueString ? parseInt(valueString, 16) : -1; } function scanMinimumNumberOfHexDigits(count, canHaveSeparators) { return scanHexDigits(count, true, canHaveSeparators); } function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) { - var digits = 0; - var value = 0; + var valueChars = []; var allowSeparator = false; var isPreviousTokenSeparator = false; - while (digits < minCount || scanAsManyAsPossible) { + while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); if (canHaveSeparators && ch === 95) { tokenFlags |= 512; @@ -4830,29 +4912,24 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 48 && ch <= 57) { - value = value * 16 + ch - 48; + if (ch >= 65 && ch <= 70) { + ch += 97 - 65; } - else if (ch >= 65 && ch <= 70) { - value = value * 16 + ch - 65 + 10; - } - else if (ch >= 97 && ch <= 102) { - value = value * 16 + ch - 97 + 10; - } - else { + else if (!((ch >= 48 && ch <= 57) || + (ch >= 97 && ch <= 102))) { break; } + valueChars.push(ch); pos++; - digits++; isPreviousTokenSeparator = false; } - if (digits < minCount) { - value = -1; + if (valueChars.length < minCount) { + valueChars = []; } if (text.charCodeAt(pos - 1) === 95) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } - return value; + return String.fromCharCode.apply(String, valueChars); } function scanString(jsxAttributeString) { if (jsxAttributeString === void 0) { jsxAttributeString = false; } @@ -4900,20 +4977,20 @@ var ts; contents += text.substring(start, pos); tokenFlags |= 4; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 13 : 16; + resultingToken = startedWithBacktick ? 14 : 17; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 13 : 16; + resultingToken = startedWithBacktick ? 14 : 17; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 14 : 15; + resultingToken = startedWithBacktick ? 15 : 16; break; } if (currChar === 92) { @@ -4997,7 +5074,8 @@ var ts; } } function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1, false); + var escapedValueString = scanMinimumNumberOfHexDigits(1, false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; var isInvalidExtendedEscape = false; if (escapedValue < 0) { error(ts.Diagnostics.Hexadecimal_digit_expected); @@ -5078,12 +5156,10 @@ var ts; } } } - return token = 71; + return token = 72; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; - var numberOfDigits = 0; + var value = ""; var separatorAllowed = false; var isPreviousTokenSeparator = false; while (true) { @@ -5104,25 +5180,39 @@ var ts; continue; } separatorAllowed = true; - var valueOfCh = ch - 48; - if (!isDigit(ch) || valueOfCh >= base) { + if (!isDigit(ch) || ch - 48 >= base) { break; } - value = value * base + valueOfCh; + value += text[pos]; pos++; - numberOfDigits++; isPreviousTokenSeparator = false; } - if (numberOfDigits === 0) { - return -1; - } if (text.charCodeAt(pos - 1) === 95) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); - return value; } return value; } + function checkBigIntSuffix() { + if (text.charCodeAt(pos) === 110) { + tokenValue += "n"; + if (tokenFlags & 384) { + tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; + } + pos++; + return 9; + } + else { + var numericValue = tokenFlags & 128 + ? parseInt(tokenValue.slice(2), 2) + : tokenFlags & 256 + ? parseInt(tokenValue.slice(2), 8) + : +tokenValue; + tokenValue = "" + numericValue; + return 8; + } + } function scan() { + var _a; startPos = pos; tokenFlags = 0; var asteriskSeen = false; @@ -5193,69 +5283,57 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 35; + return pos += 3, token = 36; } - return pos += 2, token = 33; + return pos += 2, token = 34; } pos++; - return token = 51; + return token = 52; case 34: case 39: tokenValue = scanString(); - return token = 9; + return token = 10; case 96: return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } pos++; - return token = 42; + return token = 43; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 53; + return pos += 2, token = 54; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; + return pos += 2, token = 69; } pos++; - return token = 48; + return token = 49; case 40: pos++; - return token = 19; + return token = 20; case 41: pos++; - return token = 20; + return token = 21; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 62; + return pos += 3, token = 63; } - return pos += 2, token = 40; + return pos += 2, token = 41; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) { asteriskSeen = true; continue; } - return token = 39; + return token = 40; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 43; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; - } - pos++; - return token = 37; - case 44: - pos++; - return token = 26; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { @@ -5263,16 +5341,28 @@ var ts; } pos++; return token = 38; + case 44: + pos++; + return token = 27; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 45; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 61; + } + pos++; + return token = 39; case 46: if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); + tokenValue = scanNumber().value; return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 24; + return pos += 3, token = 25; } pos++; - return token = 23; + return token = 24; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -5321,43 +5411,43 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } pos++; - return token = 41; + return token = 42; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; - var value = scanMinimumNumberOfHexDigits(1, true); - if (value < 0) { + tokenValue = scanMinimumNumberOfHexDigits(1, true); + if (!tokenValue) { error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0x" + tokenValue; tokenFlags |= 64; - return token = 8; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; - var value = scanBinaryOrOctalDigits(2); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(2); + if (!tokenValue) { error(ts.Diagnostics.Binary_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0b" + tokenValue; tokenFlags |= 128; - return token = 8; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; - var value = scanBinaryOrOctalDigits(8); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(8); + if (!tokenValue) { error(ts.Diagnostics.Octal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0o" + tokenValue; tokenFlags |= 256; - return token = 8; + return token = checkBigIntSuffix(); } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); @@ -5373,14 +5463,14 @@ var ts; case 55: case 56: case 57: - tokenValue = scanNumber(); - return token = 8; + (_a = scanNumber(), token = _a.type, tokenValue = _a.value); + return token; case 58: pos++; - return token = 56; + return token = 57; case 59: pos++; - return token = 25; + return token = 26; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5393,20 +5483,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; + return pos += 3, token = 66; } - return pos += 2, token = 45; + return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 30; + return pos += 2, token = 31; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 28; + return pos += 2, token = 29; } pos++; - return token = 27; + return token = 28; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5419,15 +5509,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 34; + return pos += 3, token = 35; } - return pos += 2, token = 32; + return pos += 2, token = 33; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 36; + return pos += 2, token = 37; } pos++; - return token = 58; + return token = 59; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5439,25 +5529,25 @@ var ts; } } pos++; - return token = 29; + return token = 30; case 63: pos++; - return token = 55; + return token = 56; case 91: pos++; - return token = 21; + return token = 22; case 93: pos++; - return token = 22; + return token = 23; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 70; + return pos += 2, token = 71; } pos++; - return token = 50; + return token = 51; case 123: pos++; - return token = 17; + return token = 18; case 124: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5469,22 +5559,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 54; + return pos += 2, token = 55; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 69; + return pos += 2, token = 70; } pos++; - return token = 49; + return token = 50; case 125: pos++; - return token = 18; + return token = 19; case 126: pos++; - return token = 52; + return token = 53; case 64: pos++; - return token = 57; + return token = 58; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -5522,29 +5612,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 29) { + if (token === 30) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 67; + return pos += 3, token = 68; } - return pos += 2, token = 47; + return pos += 2, token = 48; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 67; } pos++; - return token = 46; + return token = 47; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 31; + return token = 32; } } return token; } function reScanSlashToken() { - if (token === 41 || token === 63) { + if (token === 42 || token === 64) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -5583,12 +5673,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 12; + token = 13; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 18, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -5605,14 +5695,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 28; + return token = 29; } pos++; - return token = 27; + return token = 28; } if (char === 123) { pos++; - return token = 17; + return token = 18; } var firstNonWhitespace = 0; while (pos < end) { @@ -5635,7 +5725,7 @@ var ts; } pos++; } - return firstNonWhitespace === -1 ? 11 : 10; + return firstNonWhitespace === -1 ? 12 : 11; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -5659,7 +5749,7 @@ var ts; case 34: case 39: tokenValue = scanString(true); - return token = 9; + return token = 10; default: return scan(); } @@ -5682,36 +5772,36 @@ var ts; } return token = 5; case 64: - return token = 57; + return token = 58; case 10: case 13: tokenFlags |= 1; return token = 4; case 42: - return token = 39; + return token = 40; case 123: - return token = 17; - case 125: return token = 18; + case 125: + return token = 19; case 91: - return token = 21; - case 93: return token = 22; - case 60: - return token = 27; - case 61: - return token = 58; - case 44: - return token = 26; - case 46: + case 93: return token = 23; + case 60: + return token = 28; + case 61: + return token = 59; + case 44: + return token = 27; + case 46: + return token = 24; case 96: while (pos < end && text.charCodeAt(pos) !== 96) { pos++; } tokenValue = text.substring(tokenPos + 1, pos); pos++; - return token = 13; + return token = 14; } if (isIdentifierStart(ch, 6)) { while (isIdentifierPart(text.charCodeAt(pos), 6) && pos < end) { @@ -5856,7 +5946,6 @@ var ts; getText: function () { return str; }, write: writeText, rawWrite: writeText, - writeTextOfNode: writeText, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -5865,7 +5954,9 @@ var ts; writeLiteral: writeText, writeParameter: writeText, writeProperty: writeText, - writeSymbol: writeText, + writeSymbol: function (s, _) { return writeText(s); }, + writeTrailingSemicolon: writeText, + writeComment: writeText, getTextPos: function () { return str.length; }, getLine: function () { return 0; }, getColumn: function () { return 0; }, @@ -6054,7 +6145,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 277) { + while (node && node.kind !== 279) { node = node.parent; } return node; @@ -6062,11 +6153,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 216: - case 244: - case 223: - case 224: + case 218: + case 246: case 225: + case 226: + case 227: return true; } return false; @@ -6159,7 +6250,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 304 && node._children.length > 0) { + if (node.kind === 306 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -6178,7 +6269,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 281 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 283 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -6210,28 +6301,30 @@ var ts; } ts.getEmitFlags = getEmitFlags; function getLiteralText(node, sourceFile, neverAsciiEscape) { - if (!nodeIsSynthesized(node) && node.parent && !(ts.isNumericLiteral(node) && node.numericLiteralFlags & 512)) { + if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) || + ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString : escapeNonAsciiString; switch (node.kind) { - case 9: + case 10: if (node.singleQuote) { return "'" + escapeText(node.text, 39) + "'"; } else { return '"' + escapeText(node.text, 34) + '"'; } - case 13: - return "`" + escapeText(node.text, 96) + "`"; case 14: - return "`" + escapeText(node.text, 96) + "${"; + return "`" + escapeText(node.text, 96) + "`"; case 15: - return "}" + escapeText(node.text, 96) + "${"; + return "`" + escapeText(node.text, 96) + "${"; case 16: + return "}" + escapeText(node.text, 96) + "${"; + case 17: return "}" + escapeText(node.text, 96) + "`"; case 8: - case 12: + case 9: + case 13: return node.text; } return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -6252,15 +6345,15 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 235 && node.parent.kind === 272; + return node.kind === 237 && node.parent.kind === 274; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 9; + return ts.isModuleDeclaration(node) && node.name.kind === 10; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -6276,11 +6369,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 242 && (!node.body); + return node && node.kind === 244 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 277 || - node.kind === 242 || + return node.kind === 279 || + node.kind === 244 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6294,9 +6387,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 277: + case 279: return ts.isExternalModule(node.parent); - case 243: + case 245: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6312,22 +6405,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 277: + case 279: + case 246: + case 274: case 244: - case 272: - case 242: - case 223: - case 224: case 225: - case 155: - case 154: - case 156: + case 226: + case 227: case 157: - case 237: - case 194: - case 195: + case 156: + case 158: + case 159: + case 239: + case 196: + case 197: return true; - case 216: + case 218: return !ts.isFunctionLike(parentNode); } return false; @@ -6335,9 +6428,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 295: - case 302: - case 291: + case 297: + case 304: + case 293: return true; default: ts.assertType(node); @@ -6347,25 +6440,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 158: - case 159: - case 153: case 160: - case 163: - case 164: - case 287: - case 238: - case 207: - case 239: - case 240: - case 301: - case 237: - case 154: + case 161: case 155: + case 162: + case 165: + case 166: + case 289: + case 240: + case 209: + case 241: + case 242: + case 303: + case 239: case 156: case 157: - case 194: - case 195: + case 158: + case 159: + case 196: + case 197: return true; default: ts.assertType(node); @@ -6375,8 +6468,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 247: - case 246: + case 249: + case 248: return true; default: return false; @@ -6385,15 +6478,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 247: - case 246: - case 217: - case 238: - case 237: - case 242: + case 249: + case 248: + case 219: case 240: case 239: + case 244: + case 242: case 241: + case 243: return true; default: return false; @@ -6418,12 +6511,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 71: + case 72: return name.escapedText; - case 9: + case 10: case 8: + case 14: return ts.escapeLeadingUnderscores(name.text); - case 147: + case 149: return isStringOrNumericLiteralLike(name.expression) ? ts.escapeLeadingUnderscores(name.expression.text) : undefined; default: return ts.Debug.assertNever(name); @@ -6432,11 +6526,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 71: + case 72: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 146: + case 148: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 187: + case 189: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -6481,7 +6575,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 216) { + if (node.body && node.body.kind === 218) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6493,31 +6587,31 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 277: + case 279: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 235: - case 184: - case 238: - case 207: - case 239: - case 242: - case 241: - case 276: case 237: - case 194: - case 154: - case 156: - case 157: + case 186: case 240: - case 152: - case 151: + case 209: + case 241: + case 244: + case 243: + case 278: + case 239: + case 196: + case 156: + case 158: + case 159: + case 242: + case 154: + case 153: errorNode = node.name; break; - case 195: + case 197: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6563,11 +6657,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 189 && n.expression.kind === 97; + return n.kind === 191 && n.expression.kind === 98; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 189 && n.expression.kind === 91; + return n.kind === 191 && n.expression.kind === 92; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { @@ -6575,20 +6669,20 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 219 - && node.expression.kind === 9; + return node.kind === 221 + && node.expression.kind === 10; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 10 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 149 || - node.kind === 148 || - node.kind === 194 || - node.kind === 195 || - node.kind === 193) ? + var commentRanges = (node.kind === 151 || + node.kind === 150 || + node.kind === 196 || + node.kind === 197 || + node.kind === 195) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -6603,78 +6697,79 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 <= node.kind && node.kind <= 181) { + if (163 <= node.kind && node.kind <= 183) { return true; } switch (node.kind) { - case 119: - case 142: - case 134: - case 137: - case 122: - case 138: + case 120: + case 143: case 135: - case 140: - case 131: - return true; - case 105: - return node.parent.kind !== 198; - case 209: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 148: - return node.parent.kind === 179 || node.parent.kind === 174; - case 71: - if (node.parent.kind === 146 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 187 && node.parent.name === node) { - node = node.parent; - } - ts.Debug.assert(node.kind === 71 || node.kind === 146 || node.kind === 187, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); case 146: - case 187: - case 99: { + case 138: + case 123: + case 139: + case 136: + case 141: + case 132: + return true; + case 106: + return node.parent.kind !== 200; + case 211: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 150: + return node.parent.kind === 181 || node.parent.kind === 176; + case 72: + if (node.parent.kind === 148 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 189 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 72 || node.kind === 148 || node.kind === 189, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 148: + case 189: + case 100: { var parent = node.parent; - if (parent.kind === 165) { + if (parent.kind === 167) { return false; } - if (parent.kind === 181) { + if (parent.kind === 183) { return !parent.isTypeOf; } - if (161 <= parent.kind && parent.kind <= 181) { + if (163 <= parent.kind && parent.kind <= 183) { return true; } switch (parent.kind) { - case 209: + case 211: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 148: + case 150: return node === parent.constraint; - case 301: + case 303: return node === parent.constraint; - case 152: - case 151: - case 149: - case 235: - return node === parent.type; - case 237: - case 194: - case 195: - case 155: case 154: case 153: - case 156: - case 157: + case 151: + case 237: return node === parent.type; + case 239: + case 196: + case 197: + case 157: + case 156: + case 155: case 158: case 159: + return node === parent.type; case 160: + case 161: + case 162: return node === parent.type; - case 192: + case 194: return node === parent.type; - case 189: - case 190: - return ts.contains(parent.typeArguments, node); case 191: + case 192: + return ts.contains(parent.typeArguments, node); + case 193: return false; } } @@ -6696,23 +6791,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 228: + case 230: return visitor(node); - case 244: - case 216: - case 220: - case 221: + case 246: + case 218: case 222: case 223: case 224: case 225: - case 229: - case 230: - case 269: - case 270: + case 226: + case 227: case 231: - case 233: + case 232: + case 271: case 272: + case 233: + case 235: + case 274: return ts.forEachChild(node, traverse); } } @@ -6722,23 +6817,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 205: + case 207: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; + case 243: case 241: - case 239: + case 244: case 242: case 240: - case 238: - case 207: + case 209: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 147) { + if (node.name && node.name.kind === 149) { traverse(node.name.expression); return; } @@ -6751,10 +6846,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 167) { + if (node && node.kind === 169) { return node.elementType; } - else if (node && node.kind === 162) { + else if (node && node.kind === 164) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -6764,12 +6859,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 239: - case 238: - case 207: - case 166: + case 241: + case 240: + case 209: + case 168: return node.members; - case 186: + case 188: return node.properties; } } @@ -6777,14 +6872,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 184: - case 276: - case 149: - case 273: - case 152: + case 186: + case 278: case 151: - case 274: - case 235: + case 275: + case 154: + case 153: + case 276: + case 237: return true; } } @@ -6796,8 +6891,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 236 - && node.parent.parent.kind === 217; + return node.parent.kind === 238 + && node.parent.parent.kind === 219; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -6808,13 +6903,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 154: - case 153: - case 155: case 156: + case 155: case 157: - case 237: - case 194: + case 158: + case 159: + case 239: + case 196: return true; } return false; @@ -6825,7 +6920,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 231) { + if (node.statement.kind !== 233) { return node.statement; } node = node.statement; @@ -6833,17 +6928,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 216 && ts.isFunctionLike(node.parent); + return node && node.kind === 218 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 && node.parent.kind === 186; + return node && node.kind === 156 && node.parent.kind === 188; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 154 && - (node.parent.kind === 186 || - node.parent.kind === 207); + return node.kind === 156 && + (node.parent.kind === 188 || + node.parent.kind === 209); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6856,7 +6951,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 273) { + if (property.kind === 275) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -6893,46 +6988,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 277); + ts.Debug.assert(node.kind !== 279); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); } switch (node.kind) { - case 147: + case 149: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 150: - if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { + case 152: + if (node.parent.kind === 151 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 195: + case 197: if (!includeArrowFunctions) { continue; } - case 237: - case 194: - case 242: - case 152: - case 151: + case 239: + case 196: + case 244: case 154: case 153: - case 155: case 156: + case 155: case 157: case 158: case 159: case 160: - case 241: - case 277: + case 161: + case 162: + case 243: + case 279: return node; } } @@ -6942,9 +7037,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 155: - case 237: - case 194: + case 157: + case 239: + case 196: return container; } } @@ -6958,25 +7053,25 @@ var ts; return node; } switch (node.kind) { - case 147: + case 149: node = node.parent; break; - case 237: - case 194: - case 195: + case 239: + case 196: + case 197: if (!stopOnFunctions) { continue; } - case 152: - case 151: case 154: case 153: - case 155: case 156: + case 155: case 157: + case 158: + case 159: return node; - case 150: - if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { + case 152: + if (node.parent.kind === 151 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -6988,14 +7083,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 194 || func.kind === 195) { + if (func.kind === 196 || func.kind === 197) { var prev = func; var parent = func.parent; - while (parent.kind === 193) { + while (parent.kind === 195) { prev = parent; parent = parent.parent; } - if (parent.kind === 189 && parent.expression === prev) { + if (parent.kind === 191 && parent.expression === prev) { return parent; } } @@ -7003,26 +7098,26 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 187 || kind === 188) - && node.expression.kind === 97; + return (kind === 189 || kind === 190) + && node.expression.kind === 98; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 187 || kind === 188) - && node.expression.kind === 99; + return (kind === 189 || kind === 190) + && node.expression.kind === 100; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 162: + case 164: return node.typeName; - case 209: + case 211: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 71: - case 146: + case 72: + case 148: return node; } return undefined; @@ -7030,10 +7125,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 191: + case 193: return node.tag; - case 260: - case 259: + case 262: + case 261: return node.tagName; default: return node.expression; @@ -7042,21 +7137,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 238: + case 240: return true; - case 152: - return parent.kind === 238; - case 156: - case 157: case 154: + return parent.kind === 240; + case 158: + case 159: + case 156: return node.body !== undefined - && parent.kind === 238; - case 149: + && parent.kind === 240; + case 151: return parent.body !== undefined - && (parent.kind === 155 - || parent.kind === 154 - || parent.kind === 157) - && grandparent.kind === 238; + && (parent.kind === 157 + || parent.kind === 156 + || parent.kind === 159) + && grandparent.kind === 240; } return false; } @@ -7072,10 +7167,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 238: + case 240: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 154: - case 157: + case 156: + case 159: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); default: return false; @@ -7084,9 +7179,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 260 || - parent.kind === 259 || - parent.kind === 261) { + if (parent.kind === 262 || + parent.kind === 261 || + parent.kind === 263) { return parent.tagName === node; } return false; @@ -7094,55 +7189,56 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 97: - case 95: - case 101: - case 86: - case 12: - case 185: - case 186: + case 98: + case 96: + case 102: + case 87: + case 13: case 187: case 188: case 189: case 190: case 191: - case 210: case 192: - case 211: case 193: + case 212: case 194: - case 207: + case 213: case 195: - case 198: case 196: + case 209: case 197: case 200: - case 201: + case 198: + case 199: case 202: case 203: - case 206: case 204: - case 13: - case 208: - case 258: - case 259: - case 262: case 205: - case 199: - case 212: + case 208: + case 206: + case 14: + case 210: + case 260: + case 261: + case 264: + case 207: + case 201: + case 214: return true; - case 146: - while (node.parent.kind === 146) { + case 148: + while (node.parent.kind === 148) { node = node.parent; } - return node.parent.kind === 165 || isJSXTagName(node); - case 71: - if (node.parent.kind === 165 || isJSXTagName(node)) { + return node.parent.kind === 167 || isJSXTagName(node); + case 72: + if (node.parent.kind === 167 || isJSXTagName(node)) { return true; } case 8: case 9: - case 99: + case 10: + case 100: return isInExpressionContext(node); default: return false; @@ -7152,49 +7248,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 235: - case 149: - case 152: + case 237: case 151: - case 276: - case 273: - case 184: + case 154: + case 153: + case 278: + case 275: + case 186: return parent.initializer === node; - case 219: - case 220: case 221: case 222: - case 228: - case 229: - case 230: - case 269: - case 232: - return parent.expression === node; case 223: + case 224: + case 230: + case 231: + case 232: + case 271: + case 234: + return parent.expression === node; + case 225: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 236) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 238) || forStatement.condition === node || forStatement.incrementor === node; - case 224: - case 225: + case 226: + case 227: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 238) || forInStatement.expression === node; - case 192: - case 210: + case 194: + case 212: return node === parent.expression; - case 214: + case 216: return node === parent.expression; - case 147: + case 149: return node === parent.expression; - case 150: - case 268: - case 267: - case 275: + case 152: + case 270: + case 269: + case 277: return true; - case 209: + case 211: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 274: + case 276: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -7202,7 +7298,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 && node.moduleReference.kind === 257; + return node.kind === 248 && node.moduleReference.kind === 259; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7211,7 +7307,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 && node.moduleReference.kind !== 257; + return node.kind === 248 && node.moduleReference.kind !== 259; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -7239,15 +7335,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 137 || node.typeArguments[0].kind === 134); + (node.typeArguments[0].kind === 138 || node.typeArguments[0].kind === 135); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 189) { + if (callExpression.kind !== 191) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 71 || expression.escapedText !== "require") { + if (expression.kind !== 72 || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -7278,16 +7374,16 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 && node.parent.right === node) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 && node.parent.right === node) { name = node.parent.left; decl = name; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55) { if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { name = node.parent.parent.name; decl = node.parent.parent; } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 && node.parent.parent.right === node.parent) { + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 59 && node.parent.parent.right === node.parent) { name = node.parent.parent.left; decl = name; } @@ -7302,12 +7398,12 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl); + return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -7319,22 +7415,31 @@ var ts; return init && getExpandoInitializer(init, isPrototypeAccess(node.name)); } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; + function hasExpandoValueProperty(node, isPrototypeAssignment) { + return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + } function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); } + if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) { + var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype"); + if (result) { + return result; + } + } } ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 194 || e.kind === 195 ? initializer : undefined; + return e.kind === 196 || e.kind === 197 ? initializer : undefined; } - if (initializer.kind === 194 || - initializer.kind === 207 || - initializer.kind === 195) { + if (initializer.kind === 196 || + initializer.kind === 209 || + initializer.kind === 197) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -7343,22 +7448,22 @@ var ts; } ts.getExpandoInitializer = getExpandoInitializer; function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 54 && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer; function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = (node.parent.operatorToken.kind === 54 && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 58 && ts.isIdentifier(parent.left)) { + var parent = (node.parent.operatorToken.kind === 55 && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 59 && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -7372,7 +7477,7 @@ var ts; return name.escapedText === initializer.escapedText; } if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 99 || + return (initializer.expression.kind === 100 || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -7404,8 +7509,31 @@ var ts; return special === 5 || isInJSFile(expr) ? special : 0; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; + function isBindableObjectDefinePropertyCall(expr) { + return ts.length(expr.arguments) === 3 && + ts.isPropertyAccessExpression(expr.expression) && + ts.isIdentifier(expr.expression.expression) && + ts.idText(expr.expression.expression) === "Object" && + ts.idText(expr.expression.name) === "defineProperty" && + isStringOrNumericLiteralLike(expr.arguments[1]) && + isEntityNameExpression(expr.arguments[0]); + } + ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; function getAssignmentDeclarationKindWorker(expr) { - if (expr.operatorToken.kind !== 58 || + if (ts.isCallExpression(expr)) { + if (!isBindableObjectDefinePropertyCall(expr)) { + return 0; + } + var entityName = expr.arguments[0]; + if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + return 8; + } + if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + return 9; + } + return 7; + } + if (expr.operatorToken.kind !== 59 || !ts.isPropertyAccessExpression(expr.left)) { return 0; } @@ -7416,10 +7544,10 @@ var ts; return getAssignmentDeclarationPropertyAccessKind(lhs); } function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 99) { + if (lhs.expression.kind === 100) { return 4; } - else if (ts.isIdentifier(lhs.expression) && lhs.expression.escapedText === "module" && lhs.name.escapedText === "exports") { + else if (isModuleExportsPropertyAccessExpression(lhs)) { return 2; } else if (isEntityNameExpression(lhs.expression)) { @@ -7454,7 +7582,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 219 && + expr.parent && expr.parent.kind === 221 && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -7463,7 +7591,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 237 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 239 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -7472,14 +7600,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 247: - case 253: + case 249: + case 255: return node.parent; - case 257: + case 259: return node.parent.parent; - case 189: - return node.parent; - case 180: + case 191: + return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined; + case 182: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -7489,12 +7617,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 247: - case 253: + case 249: + case 255: return node.moduleSpecifier; - case 246: - return node.moduleReference.kind === 257 ? node.moduleReference.expression : undefined; - case 181: + case 248: + return node.moduleReference.kind === 259 ? node.moduleReference.expression : undefined; + case 183: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -7503,11 +7631,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 247: + case 249: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 246: + case 248: return node; - case 253: + case 255: return undefined; default: return ts.Debug.assertNever(node); @@ -7515,19 +7643,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 247 && !!node.importClause && !!node.importClause.name; + return node.kind === 249 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 149: + case 151: + case 156: + case 155: + case 276: + case 275: case 154: case 153: - case 274: - case 273: - case 152: - case 151: return node.questionToken !== undefined; } } @@ -7535,14 +7663,13 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 287 && - node.parameters.length > 0 && - node.parameters[0].name && - node.parameters[0].name.escapedText === "new"; + var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined; + var name = ts.tryCast(param && param.name, ts.isIdentifier); + return !!name && name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 302 || node.kind === 295; + return node.kind === 304 || node.kind === 297; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -7552,7 +7679,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 + node.expression.operatorToken.kind === 59 ? node.expression.right : undefined; } @@ -7561,18 +7688,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 + node.expression.right.operatorToken.kind === 55 ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 217: + case 219: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 152: + case 154: return node.initializer; - case 273: + case 275: return node.initializer; } } @@ -7582,7 +7709,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 242 + node.body.kind === 244 ? node.body : undefined; } @@ -7596,11 +7723,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } - if (node.kind === 149) { + if (node.kind === 151) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 148) { + if (node.kind === 150) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -7611,16 +7738,16 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 273 || - parent.kind === 152 || - parent.kind === 219 && node.kind === 187 || + if (parent.kind === 275 || + parent.kind === 154 || + parent.kind === 221 && node.kind === 189 || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 58) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 59) { return parent; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -7642,7 +7769,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 71 && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 72 && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -7677,38 +7804,38 @@ 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 === 288; + return node.dotDotDotToken !== undefined || !!type && type.kind === 290; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 202: + case 204: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 58 ? 1 : 2 : + binaryOperator === 59 ? 1 : 2 : 0; - case 200: - case 201: + case 202: + case 203: var unaryOperator = parent.operator; - return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; - case 224: - case 225: + return unaryOperator === 44 || unaryOperator === 45 ? 2 : 0; + case 226: + case 227: return parent.initializer === node ? 1 : 0; - case 193: - case 185: - case 206: - case 211: + case 195: + case 187: + case 208: + case 213: node = parent; break; - case 274: + case 276: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 273: + case 275: if (parent.name === node) { return 0; } @@ -7727,22 +7854,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 216: - case 217: - case 229: - case 220: - case 230: - case 244: - case 269: - case 270: + case 218: + case 219: case 231: + case 222: + case 232: + case 246: + case 271: + case 272: + case 233: + case 225: + case 226: + case 227: case 223: case 224: - case 225: - case 221: - case 222: - case 233: - case 272: + case 235: + case 274: return true; } return false; @@ -7759,32 +7886,32 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 175); + return walkUp(node, 177); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 193); + return walkUp(node, 195); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 193) { + while (node.kind === 195) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 193) { + while (node.kind === 195) { node = node.parent; } return node; } function isDeleteTarget(node) { - if (node.kind !== 187 && node.kind !== 188) { + if (node.kind !== 189 && node.kind !== 190) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 196; + return node && node.kind === 198; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -7803,11 +7930,11 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 9: + case 10: case 8: if (ts.isComputedPropertyName(parent)) return parent.parent; - case 71: + case 72: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -7830,51 +7957,51 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 147 && + return (node.kind === 10 || node.kind === 8) && + node.parent.kind === 149 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 152: - case 151: case 154: case 153: case 156: - case 157: - case 276: - case 273: - case 187: + case 155: + case 158: + case 159: + case 278: + case 275: + case 189: return parent.name === node; - case 146: + case 148: if (parent.right === node) { - while (parent.kind === 146) { + while (parent.kind === 148) { parent = parent.parent; } - return parent.kind === 165 || parent.kind === 162; + return parent.kind === 167 || parent.kind === 164; } return false; - case 184: - case 251: + case 186: + case 253: return parent.propertyName === node; - case 255: - case 265: + case 257: + case 267: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 246 || - node.kind === 245 || - node.kind === 248 && !!node.name || - node.kind === 249 || + return node.kind === 248 || + node.kind === 247 || + node.kind === 250 && !!node.name || node.kind === 251 || - node.kind === 255 || - node.kind === 252 && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2; + node.kind === 253 || + node.kind === 257 || + node.kind === 254 && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7893,12 +8020,12 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85); + var heritageClause = getHeritageClause(node.heritageClauses, 86); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 108); + var heritageClause = getHeritageClause(node.heritageClauses, 109); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; @@ -7909,7 +8036,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85); + var heritageClause = getHeritageClause(node.heritageClauses, 86); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -7943,11 +8070,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 <= token && token <= 145; + return 73 <= token && token <= 147; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 <= token && token <= 145; + return 118 <= token && token <= 147; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -7959,6 +8086,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isIdentifierANonContextualKeyword(_a) { + var originalKeywordKind = _a.originalKeywordKind; + return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); + } + ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { return 2 <= token && token <= 7; } @@ -7969,13 +8101,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 237: - case 194: - case 154: + case 239: + case 196: + case 156: if (node.asteriskToken) { flags |= 1; } - case 195: + case 197: if (hasModifier(node, 256)) { flags |= 2; } @@ -7989,10 +8121,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 237: - case 194: - case 195: - case 154: + case 239: + case 196: + case 197: + case 156: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256); @@ -8010,7 +8142,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 147 && + return name.kind === 149 && !isStringOrNumericLiteralLike(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8021,12 +8153,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 71: + case 72: return name.escapedText; - case 9: + case 10: case 8: return ts.escapeLeadingUnderscores(name.text); - case 147: + case 149: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -8042,9 +8174,9 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 71: - case 9: - case 13: + case 72: + case 10: + case 14: case 8: return true; default: @@ -8053,11 +8185,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 71 ? ts.idText(node) : node.text; + return node.kind === 72 ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 71 ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 72 ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -8069,7 +8201,7 @@ var ts; } ts.isKnownSymbol = isKnownSymbol; function isESSymbolIdentifier(node) { - return node.kind === 71 && node.escapedText === "Symbol"; + return node.kind === 72 && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -8078,11 +8210,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 149; + return root.kind === 151; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 184) { + while (node.kind === 186) { node = node.parent.parent; } return node; @@ -8090,15 +8222,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 155 - || kind === 194 - || kind === 237 - || kind === 195 - || kind === 154 + return kind === 157 + || kind === 196 + || kind === 239 + || kind === 197 || kind === 156 - || kind === 157 - || kind === 242 - || kind === 277; + || kind === 158 + || kind === 159 + || kind === 244 + || kind === 279; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -8112,38 +8244,38 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 190: + case 192: return hasArguments ? 0 : 1; - case 200: - case 197: - case 198: - case 196: - case 199: - case 203: - case 205: - return 1; case 202: + case 199: + case 200: + case 198: + case 201: + case 205: + case 207: + return 1; + case 204: switch (operator) { - case 40: - case 58: + case 41: case 59: case 60: - case 62: case 61: case 63: + case 62: case 64: case 65: case 66: case 67: case 68: - case 70: case 69: + case 71: + case 70: return 1; } } @@ -8152,15 +8284,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 202) { + if (expression.kind === 204) { return expression.operatorToken.kind; } - else if (expression.kind === 200 || expression.kind === 201) { + else if (expression.kind === 202 || expression.kind === 203) { return expression.operator; } else { @@ -8170,72 +8302,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 307: + case 309: return 0; - case 206: + case 208: return 1; - case 205: + case 207: return 2; - case 203: + case 205: return 4; - case 202: + case 204: switch (operatorKind) { - case 26: + case 27: return 0; - case 58: case 59: case 60: - case 62: case 61: case 63: + case 62: case 64: case 65: case 66: case 67: case 68: - case 70: case 69: + case 71: + case 70: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 200: - case 197: - case 198: - case 196: + case 202: case 199: - return 16; + case 200: + case 198: case 201: + return 16; + case 203: return 17; - case 189: - return 18; - case 190: - return hasArguments ? 19 : 18; case 191: - case 187: - case 188: + return 18; + case 192: + return hasArguments ? 19 : 18; + case 193: + case 189: + case 190: return 19; - case 99: - case 97: - case 71: - case 95: - case 101: - case 86: + case 100: + case 98: + case 72: + case 96: + case 102: + case 87: case 8: case 9: - case 185: - case 186: - case 194: - case 195: - case 207: - case 258: - case 259: - case 262: - case 12: + case 10: + case 187: + case 188: + case 196: + case 197: + case 209: + case 260: + case 261: + case 264: case 13: - case 204: - case 193: - case 208: + case 14: + case 206: + case 195: + case 210: return 20; default: return -1; @@ -8244,41 +8377,41 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 54: + case 55: return 5; - case 53: + case 54: return 6; - case 49: - return 7; case 50: + return 7; + case 51: return 8; - case 48: + case 49: return 9; - case 32: case 33: case 34: case 35: + case 36: return 10; - case 27: - case 29: + case 28: case 30: case 31: + case 32: + case 94: case 93: - case 92: - case 118: + case 119: return 11; - case 45: case 46: case 47: + case 48: return 12; - case 37: case 38: - return 13; case 39: - case 41: - case 42: - return 14; + return 13; case 40: + case 42: + case 43: + return 14; + case 41: return 15; } return -1; @@ -8343,7 +8476,7 @@ var ts; if (fileName) { return fileDiagnostics.get(fileName) || []; } - var fileDiags = ts.flatMap(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); + var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); if (!nonFileDiagnostics.length) { return fileDiags; } @@ -8389,7 +8522,7 @@ var ts; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 && ch <= 122) || name.indexOf("-") > -1; + return (ch >= 97 && ch <= 122) || ts.stringContains(name, "-"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { @@ -8470,16 +8603,10 @@ var ts; lineStart = true; } } - function writeTextOfNode(text, node) { - var s = getTextOfNodeFromSourceText(text, node); - write(s); - updateLineCountAndPosFor(s); - } reset(); return { write: write, rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, writeLiteral: writeLiteral, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -8502,10 +8629,77 @@ var ts; writePunctuation: write, writeSpace: write, writeStringLiteral: write, - writeSymbol: write + writeSymbol: function (s, _) { return write(s); }, + writeTrailingSemicolon: write, + writeComment: write }; } ts.createTextWriter = createTextWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var pendingTrailingSemicolon = false; + function commitPendingTrailingSemicolon() { + if (pendingTrailingSemicolon) { + writer.writeTrailingSemicolon(";"); + pendingTrailingSemicolon = false; + } + } + return __assign({}, writer, { writeTrailingSemicolon: function () { + pendingTrailingSemicolon = true; + }, + writeLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeLiteral(s); + }, + writeStringLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeStringLiteral(s); + }, + writeSymbol: function (s, sym) { + commitPendingTrailingSemicolon(); + writer.writeSymbol(s, sym); + }, + writePunctuation: function (s) { + commitPendingTrailingSemicolon(); + writer.writePunctuation(s); + }, + writeKeyword: function (s) { + commitPendingTrailingSemicolon(); + writer.writeKeyword(s); + }, + writeOperator: function (s) { + commitPendingTrailingSemicolon(); + writer.writeOperator(s); + }, + writeParameter: function (s) { + commitPendingTrailingSemicolon(); + writer.writeParameter(s); + }, + writeSpace: function (s) { + commitPendingTrailingSemicolon(); + writer.writeSpace(s); + }, + writeProperty: function (s) { + commitPendingTrailingSemicolon(); + writer.writeProperty(s); + }, + writeComment: function (s) { + commitPendingTrailingSemicolon(); + writer.writeComment(s); + }, + writeLine: function () { + commitPendingTrailingSemicolon(); + writer.writeLine(); + }, + increaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.increaseIndent(); + }, + decreaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.decreaseIndent(); + } }); + } + ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -8625,11 +8819,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 71 && identifierIsThisKeyword(node); + return !!node && node.kind === 72 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 99; + return id.originalKeywordKind === 100; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -8639,10 +8833,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 156) { + if (accessor.kind === 158) { getAccessor = accessor; } - else if (accessor.kind === 157) { + else if (accessor.kind === 159) { setAccessor = accessor; } else { @@ -8662,10 +8856,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 156 && !getAccessor) { + if (member.kind === 158 && !getAccessor) { getAccessor = member; } - if (member.kind === 157 && !setAccessor) { + if (member.kind === 159 && !setAccessor) { setAccessor = member; } } @@ -8702,7 +8896,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -8730,13 +8924,13 @@ var ts; function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { if (comments && comments.length > 0) { if (leadingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } var emitInterveningSeparator = false; for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var comment = comments_1[_i]; if (emitInterveningSeparator) { - writer.write(" "); + writer.writeSpace(" "); emitInterveningSeparator = false; } writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); @@ -8748,7 +8942,7 @@ var ts; } } if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } } } @@ -8828,7 +9022,7 @@ var ts; } } else { - writer.write(text.substring(commentPos, commentEnd)); + writer.writeComment(text.substring(commentPos, commentEnd)); } } ts.writeCommentRange = writeCommentRange; @@ -8836,13 +9030,13 @@ var ts; var end = Math.min(commentEnd, nextLineStart - 1); var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { - writer.write(currentLineText); + writer.writeComment(currentLineText); if (end !== commentEnd) { writer.writeLine(); } } else { - writer.writeLiteral(newLine); + writer.rawWrite(newLine); } } function calculateIndent(text, pos, end) { @@ -8894,7 +9088,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 || (node.kind === 71 && node.isInJSDocNamespace)) { + if (node.flags & 4 || (node.kind === 72 && node.isInJSDocNamespace)) { flags |= 1; } return flags; @@ -8902,29 +9096,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 115: return 32; - case 114: return 4; - case 113: return 16; - case 112: return 8; - case 117: return 128; - case 84: return 1; - case 124: return 2; - case 76: return 2048; - case 79: return 512; - case 120: return 256; - case 132: return 64; + case 116: return 32; + case 115: return 4; + case 114: return 16; + case 113: return 8; + case 118: return 128; + case 85: return 1; + case 125: return 2; + case 77: return 2048; + case 80: return 512; + case 121: return 256; + case 133: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 54 - || token === 53 - || token === 51; + return token === 55 + || token === 54 + || token === 52; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 58 && token <= 70; + return token >= 59 && token <= 71; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { @@ -8936,14 +9130,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 108 } + ? { class: node.parent.parent, isImplements: node.parent.token === 109 } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 58 + ? node.operatorToken.kind === 59 : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -8951,8 +9145,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 186 - || kind === 185; + return kind === 188 + || kind === 187; } return false; } @@ -8962,7 +9156,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 71 || isPropertyAccessEntityNameExpression(node); + return node.kind === 72 || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function isPropertyAccessEntityNameExpression(node) { @@ -8974,17 +9168,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 146 && node.parent.right === node) || - (node.parent.kind === 187 && node.parent.name === node); + return (node.parent.kind === 148 && node.parent.right === node) || + (node.parent.kind === 189 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 186 && + return expression.kind === 188 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 185 && + return expression.kind === 187 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -9286,8 +9480,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 241: - case 242: + case 243: + case 244: return parseNode === parseNode.parent.name; } } @@ -9353,32 +9547,32 @@ var ts; if (!parent) return 0; switch (parent.kind) { - case 193: + case 195: return accessKind(parent); - case 201: - case 200: - var operator = parent.operator; - return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; + case 203: case 202: + var operator = parent.operator; + return operator === 44 || operator === 45 ? writeOrReadWrite() : 0; + case 204: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 58 ? 1 : writeOrReadWrite() + operatorToken.kind === 59 ? 1 : writeOrReadWrite() : 0; - case 187: + case 189: return parent.name !== node ? 0 : accessKind(parent); - case 273: { + case 275: { var parentAccess = accessKind(parent.parent); return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 274: + case 276: return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent); - case 185: + case 187: return accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && skipParenthesesUp(parent.parent).kind === 219 ? 1 : 2; + return parent.parent && skipParenthesesUp(parent.parent).kind === 221 ? 1 : 2; } } function reverseAccessKind(a) { @@ -9467,7 +9661,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 131072 ? type.objectFlags : 0; + return type.flags & 524288 ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -9646,9 +9840,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 148) { + if (d && d.kind === 150) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 241) { return current; } } @@ -9656,7 +9850,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 155; + return ts.hasModifier(node, 92) && node.parent.kind === 157; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -9686,14 +9880,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 235) { + if (node.kind === 237) { node = node.parent; } - if (node && node.kind === 236) { + if (node && node.kind === 238) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 217) { + if (node && node.kind === 219) { flags |= getFlags(node); } return flags; @@ -9804,27 +9998,27 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 217: + case 219: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 219: + case 221: var expr = hostNode.expression; switch (expr.kind) { - case 187: + case 189: return expr.name; - case 188: + case 190: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 193: { + case 195: { return getDeclarationIdentifier(hostNode.expression); } - case 231: { + case 233: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -9846,17 +10040,18 @@ var ts; ts.isNamedDeclaration = isNamedDeclaration; function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 71: + case 72: return declaration; - case 303: - case 297: { + case 305: + case 299: { var name = declaration.name; - if (name.kind === 146) { + if (name.kind === 148) { return name.right; } break; } - case 202: { + case 191: + case 204: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1: @@ -9864,13 +10059,17 @@ var ts; case 5: case 3: return expr.left.name; + case 7: + case 8: + case 9: + return expr.arguments[1]; default: return undefined; } } - case 302: + case 304: return getNameOfJSDocTypedef(declaration); - case 252: { + case 254: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -10010,7 +10209,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 289); + ts.Debug.assert(node.parent.kind === 291); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -10042,673 +10241,677 @@ var ts; return node.kind === 8; } ts.isNumericLiteral = isNumericLiteral; - function isStringLiteral(node) { + function isBigIntLiteral(node) { return node.kind === 9; } + ts.isBigIntLiteral = isBigIntLiteral; + function isStringLiteral(node) { + return node.kind === 10; + } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 10; + return node.kind === 11; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 12; + return node.kind === 13; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 13; + return node.kind === 14; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isTemplateHead(node) { - return node.kind === 14; + return node.kind === 15; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 15; + return node.kind === 16; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 16; + return node.kind === 17; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 71; + return node.kind === 72; } ts.isIdentifier = isIdentifier; function isQualifiedName(node) { - return node.kind === 146; + return node.kind === 148; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 147; + return node.kind === 149; } ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 148; + return node.kind === 150; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 149; + return node.kind === 151; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 150; + return node.kind === 152; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 151; + return node.kind === 153; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 152; + return node.kind === 154; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 153; + return node.kind === 155; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 154; + return node.kind === 156; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 155; + return node.kind === 157; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 156; + return node.kind === 158; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 157; + return node.kind === 159; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 158; + return node.kind === 160; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 159; + return node.kind === 161; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 160; + return node.kind === 162; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 157 || node.kind === 156; + return node.kind === 159 || node.kind === 158; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isTypePredicateNode(node) { - return node.kind === 161; + return node.kind === 163; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 162; + return node.kind === 164; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 163; + return node.kind === 165; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 164; + return node.kind === 166; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 165; + return node.kind === 167; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 166; + return node.kind === 168; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 167; + return node.kind === 169; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 168; + return node.kind === 170; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 171; + return node.kind === 173; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 172; + return node.kind === 174; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 173; + return node.kind === 175; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 174; + return node.kind === 176; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 175; + return node.kind === 177; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 176; + return node.kind === 178; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 177; + return node.kind === 179; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 178; + return node.kind === 180; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 179; + return node.kind === 181; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 180; + return node.kind === 182; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 181; + return node.kind === 183; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 182; + return node.kind === 184; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 183; + return node.kind === 185; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 184; + return node.kind === 186; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 185; + return node.kind === 187; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 186; + return node.kind === 188; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 187; + return node.kind === 189; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 188; + return node.kind === 190; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 189; + return node.kind === 191; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 190; + return node.kind === 192; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 191; + return node.kind === 193; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 192; + return node.kind === 194; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 193; + return node.kind === 195; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 306) { + while (node.kind === 308) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 194; + return node.kind === 196; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 195; + return node.kind === 197; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 196; + return node.kind === 198; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 197; + return node.kind === 199; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 198; + return node.kind === 200; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 199; + return node.kind === 201; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 200; + return node.kind === 202; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 201; + return node.kind === 203; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 202; + return node.kind === 204; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 203; + return node.kind === 205; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 204; + return node.kind === 206; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 205; + return node.kind === 207; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 206; + return node.kind === 208; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 207; + return node.kind === 209; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 208; + return node.kind === 210; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 209; + return node.kind === 211; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 210; + return node.kind === 212; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 211; + return node.kind === 213; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 212; + return node.kind === 214; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 214; + return node.kind === 216; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 215; + return node.kind === 217; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 216; + return node.kind === 218; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 217; + return node.kind === 219; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 218; + return node.kind === 220; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 219; + return node.kind === 221; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 220; + return node.kind === 222; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 221; + return node.kind === 223; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 222; + return node.kind === 224; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 223; + return node.kind === 225; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 224; + return node.kind === 226; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 225; + return node.kind === 227; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 226; + return node.kind === 228; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 227; + return node.kind === 229; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 227 || node.kind === 226; + return node.kind === 229 || node.kind === 228; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 228; + return node.kind === 230; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 229; + return node.kind === 231; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 230; + return node.kind === 232; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 231; + return node.kind === 233; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 232; + return node.kind === 234; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 233; + return node.kind === 235; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 234; + return node.kind === 236; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 235; + return node.kind === 237; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 236; + return node.kind === 238; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 237; + return node.kind === 239; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 238; + return node.kind === 240; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 239; + return node.kind === 241; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 240; + return node.kind === 242; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 241; + return node.kind === 243; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 242; + return node.kind === 244; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 243; + return node.kind === 245; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 244; + return node.kind === 246; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 245; + return node.kind === 247; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 246; + return node.kind === 248; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 247; + return node.kind === 249; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 248; + return node.kind === 250; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 249; + return node.kind === 251; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 250; + return node.kind === 252; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 251; + return node.kind === 253; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 252; + return node.kind === 254; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 253; + return node.kind === 255; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 254; + return node.kind === 256; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 255; + return node.kind === 257; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 256; + return node.kind === 258; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 257; + return node.kind === 259; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 258; + return node.kind === 260; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 259; + return node.kind === 261; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 260; + return node.kind === 262; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 261; + return node.kind === 263; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 262; + return node.kind === 264; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 263; + return node.kind === 265; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 264; + return node.kind === 266; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 265; + return node.kind === 267; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 266; + return node.kind === 268; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 267; + return node.kind === 269; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 268; + return node.kind === 270; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 269; + return node.kind === 271; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 270; + return node.kind === 272; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 271; + return node.kind === 273; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 272; + return node.kind === 274; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 273; + return node.kind === 275; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 274; + return node.kind === 276; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 275; + return node.kind === 277; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 276; + return node.kind === 278; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 277; + return node.kind === 279; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 278; + return node.kind === 280; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 279; + return node.kind === 281; } ts.isUnparsedSource = isUnparsedSource; function isJSDocTypeExpression(node) { - return node.kind === 281; + return node.kind === 283; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 282; + return node.kind === 284; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 283; + return node.kind === 285; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 284; + return node.kind === 286; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 285; + return node.kind === 287; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 286; + return node.kind === 288; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 287; + return node.kind === 289; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 288; + return node.kind === 290; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 289; + return node.kind === 291; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 293; + return node.kind === 295; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 294; + return node.kind === 296; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 296; + return node.kind === 298; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 299; + return node.kind === 301; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 297; + return node.kind === 299; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 298; + return node.kind === 300; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 300; + return node.kind === 302; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 301; + return node.kind === 303; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 302; + return node.kind === 304; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 303; + return node.kind === 305; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 303 || node.kind === 297; + return node.kind === 305 || node.kind === 299; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 290; + return node.kind === 292; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 295; + return node.kind === 297; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 291; + return node.kind === 293; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 304; + return n.kind === 306; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -10716,11 +10919,11 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 146; + return kind >= 148; } ts.isNodeKind = isNodeKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 145; + return n.kind >= 0 && n.kind <= 147; } ts.isToken = isToken; function isNodeArray(array) { @@ -10728,7 +10931,7 @@ var ts; } ts.isNodeArray = isNodeArray; function isLiteralKind(kind) { - return 8 <= kind && kind <= 13; + return 8 <= kind && kind <= 14; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -10736,7 +10939,7 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 13 <= kind && kind <= 16; + return 14 <= kind && kind <= 17; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -10745,12 +10948,12 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 15 - || kind === 16; + return kind === 16 + || kind === 17; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isStringTextContainingNode(node) { - return node.kind === 9 || isTemplateLiteralKind(node.kind); + return node.kind === 10 || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; function isGeneratedIdentifier(node) { @@ -10759,17 +10962,17 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; function isModifierKind(token) { switch (token) { - case 117: - case 120: - case 76: - case 124: - case 79: - case 84: - case 114: - case 112: - case 113: - case 132: + case 118: + case 121: + case 77: + case 125: + case 80: + case 85: case 115: + case 113: + case 114: + case 133: + case 116: return true; } return false; @@ -10780,7 +10983,7 @@ var ts; } ts.isParameterPropertyModifier = isParameterPropertyModifier; function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 115; + return isParameterPropertyModifier(idToken) || idToken === 116; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -10789,23 +10992,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 146 - || kind === 71; + return kind === 148 + || kind === 72; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 71 - || kind === 9 + return kind === 72 + || kind === 10 || kind === 8 - || kind === 147; + || kind === 149; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 71 - || kind === 182 - || kind === 183; + return kind === 72 + || kind === 184 + || kind === 185; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -10818,13 +11021,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 237: - case 154: - case 155: + case 239: case 156: case 157: - case 194: - case 195: + case 158: + case 159: + case 196: + case 197: return true; default: return false; @@ -10832,14 +11035,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 153: - case 158: - case 291: - case 159: + case 155: case 160: - case 163: - case 287: - case 164: + case 293: + case 161: + case 162: + case 165: + case 289: + case 166: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -10852,28 +11055,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 155 - || kind === 152 + return kind === 157 || kind === 154 || kind === 156 - || kind === 157 - || kind === 160 - || kind === 215; + || kind === 158 + || kind === 159 + || kind === 162 + || kind === 217; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 238 || node.kind === 207); + return node && (node.kind === 240 || node.kind === 209); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 156 || node.kind === 157); + return node && (node.kind === 158 || node.kind === 159); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 154: case 156: - case 157: + case 158: + case 159: return true; default: return false; @@ -10882,11 +11085,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 159 - || kind === 158 - || kind === 151 + return kind === 161 + || kind === 160 || kind === 153 - || kind === 160; + || kind === 155 + || kind === 162; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -10895,36 +11098,37 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 273 - || kind === 274 - || kind === 275 - || kind === 154 + return kind === 275 + || kind === 276 + || kind === 277 || kind === 156 - || kind === 157; + || kind === 158 + || kind === 159; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 161 && kind <= 181) - || kind === 119 - || kind === 142 - || kind === 134 + return (kind >= 163 && kind <= 183) + || kind === 120 + || kind === 143 || kind === 135 - || kind === 122 - || kind === 137 + || kind === 146 + || kind === 136 + || kind === 123 || kind === 138 - || kind === 99 - || kind === 105 - || kind === 140 - || kind === 95 - || kind === 131 - || kind === 209 - || kind === 282 - || kind === 283 + || kind === 139 + || kind === 100 + || kind === 106 + || kind === 141 + || kind === 96 + || kind === 132 + || kind === 211 || kind === 284 || kind === 285 || kind === 286 || kind === 287 - || kind === 288; + || kind === 288 + || kind === 289 + || kind === 290; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -10932,8 +11136,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 163: - case 164: + case 165: + case 166: return true; } return false; @@ -10942,29 +11146,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 183 - || kind === 182; + return kind === 185 + || kind === 184; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 185 - || kind === 186; + return kind === 187 + || kind === 188; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 184 - || kind === 208; + return kind === 186 + || kind === 210; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 235: - case 149: - case 184: + case 237: + case 151: + case 186: return true; } return false; @@ -10977,8 +11181,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 182: - case 186: + case 184: + case 188: return true; } return false; @@ -10986,8 +11190,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 183: case 185: + case 187: return true; } return false; @@ -10995,25 +11199,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 187 - || kind === 146 - || kind === 181; + return kind === 189 + || kind === 148 + || kind === 183; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 187 - || kind === 146; + return kind === 189 + || kind === 148; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 260: - case 259: - case 189: - case 190: + case 262: + case 261: case 191: - case 150: + case 192: + case 193: + case 152: return true; default: return false; @@ -11021,13 +11225,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 189 || node.kind === 190; + return node.kind === 191 || node.kind === 192; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 204 - || kind === 13; + return kind === 206 + || kind === 14; } ts.isTemplateLiteral = isTemplateLiteral; function isLeftHandSideExpression(node) { @@ -11036,33 +11240,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 187: - case 188: - case 190: case 189: - case 258: - case 259: - case 262: + case 190: + case 192: case 191: - case 185: + case 260: + case 261: + case 264: case 193: - case 186: - case 207: - case 194: - case 71: - case 12: + case 187: + case 195: + case 188: + case 209: + case 196: + case 72: + case 13: case 8: case 9: - case 13: - case 204: - case 86: - case 95: - case 99: - case 101: - case 97: - case 211: - case 212: - case 91: + case 10: + case 14: + case 206: + case 87: + case 96: + case 100: + case 102: + case 98: + case 213: + case 214: + case 92: return true; default: return false; @@ -11074,13 +11279,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 200: - case 201: - case 196: - case 197: + case 202: + case 203: case 198: case 199: - case 192: + case 200: + case 201: + case 194: return true; default: return isLeftHandSideExpressionKind(kind); @@ -11088,11 +11293,11 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 201: + case 203: return true; - case 200: - return expr.operator === 43 || - expr.operator === 44; + case 202: + return expr.operator === 44 || + expr.operator === 45; default: return false; } @@ -11104,15 +11309,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 203: case 205: - case 195: - case 202: - case 206: - case 210: + case 207: + case 197: + case 204: case 208: - case 307: - case 306: + case 212: + case 210: + case 309: + case 308: return true; default: return isUnaryExpressionKind(kind); @@ -11120,16 +11325,16 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 192 - || kind === 210; + return kind === 194 + || kind === 212; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 306; + return node.kind === 308; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 305; + return node.kind === 307; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -11139,20 +11344,20 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 225: + case 226: + case 227: case 223: case 224: - case 225: - case 221: - case 222: return true; - case 231: + case 233: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isForInOrOfStatement(node) { - return node.kind === 224 || node.kind === 225; + return node.kind === 226 || node.kind === 227; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -11171,108 +11376,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 243 - || kind === 242 - || kind === 71; + return kind === 245 + || kind === 244 + || kind === 72; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 243 - || kind === 242; + return kind === 245 + || kind === 244; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 71 - || kind === 242; + return kind === 72 + || kind === 244; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 250 - || kind === 249; + return kind === 252 + || kind === 251; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 242 || node.kind === 241; + return node.kind === 244 || node.kind === 243; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 195 - || kind === 184 - || kind === 238 - || kind === 207 - || kind === 155 - || kind === 241 - || kind === 276 - || kind === 255 - || kind === 237 - || kind === 194 - || kind === 156 - || kind === 248 - || kind === 246 - || kind === 251 + return kind === 197 + || kind === 186 + || kind === 240 + || kind === 209 + || kind === 157 + || kind === 243 + || kind === 278 + || kind === 257 || kind === 239 - || kind === 265 + || kind === 196 + || kind === 158 + || kind === 250 + || kind === 248 + || kind === 253 + || kind === 241 + || kind === 267 + || kind === 156 + || kind === 155 + || kind === 244 + || kind === 247 + || kind === 251 + || kind === 151 + || kind === 275 || kind === 154 || kind === 153 + || kind === 159 + || kind === 276 || kind === 242 - || kind === 245 - || kind === 249 - || kind === 149 - || kind === 273 - || kind === 152 - || kind === 151 - || kind === 157 - || kind === 274 - || kind === 240 - || kind === 148 - || kind === 235 - || kind === 302 - || kind === 295 - || kind === 303; + || kind === 150 + || kind === 237 + || kind === 304 + || kind === 297 + || kind === 305; } function isDeclarationStatementKind(kind) { - return kind === 237 - || kind === 256 - || kind === 238 - || kind === 239 + return kind === 239 + || kind === 258 || kind === 240 || kind === 241 || kind === 242 - || kind === 247 - || kind === 246 - || kind === 253 - || kind === 252 - || kind === 245; + || kind === 243 + || kind === 244 + || kind === 249 + || kind === 248 + || kind === 255 + || kind === 254 + || kind === 247; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 227 - || kind === 226 - || kind === 234 - || kind === 221 - || kind === 219 - || kind === 218 - || kind === 224 - || kind === 225 - || kind === 223 - || kind === 220 - || kind === 231 + return kind === 229 || kind === 228 + || kind === 236 + || kind === 223 + || kind === 221 + || kind === 220 + || kind === 226 + || kind === 227 + || kind === 225 + || kind === 222 + || kind === 233 || kind === 230 || kind === 232 - || kind === 233 - || kind === 217 - || kind === 222 - || kind === 229 - || kind === 305 - || kind === 309 - || kind === 308; + || kind === 234 + || kind === 235 + || kind === 219 + || kind === 224 + || kind === 231 + || kind === 307 + || kind === 311 + || kind === 310; } function isDeclaration(node) { - if (node.kind === 148) { - return node.parent.kind !== 301 || ts.isInJSFile(node); + if (node.kind === 150) { + return node.parent.kind !== 303 || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -11293,10 +11498,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 216) + if (node.kind !== 218) return false; if (node.parent !== undefined) { - if (node.parent.kind === 233 || node.parent.kind === 272) { + if (node.parent.kind === 235 || node.parent.kind === 274) { return false; } } @@ -11304,69 +11509,69 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 257 - || kind === 146 - || kind === 71; + return kind === 259 + || kind === 148 + || kind === 72; } ts.isModuleReference = isModuleReference; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 99 - || kind === 71 - || kind === 187; + return kind === 100 + || kind === 72 + || kind === 189; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 258 - || kind === 268 - || kind === 259 - || kind === 10 - || kind === 262; + return kind === 260 + || kind === 270 + || kind === 261 + || kind === 11 + || kind === 264; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 265 - || kind === 267; + return kind === 267 + || kind === 269; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 9 - || kind === 268; + return kind === 10 + || kind === 270; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 260 - || kind === 259; + return kind === 262 + || kind === 261; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 269 - || kind === 270; + return kind === 271 + || kind === 272; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 281 && node.kind <= 303; + return node.kind >= 283 && node.kind <= 305; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 289 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 291 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 292 && node.kind <= 303; + return node.kind >= 294 && node.kind <= 305; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 157; + return node.kind === 159; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 156; + return node.kind === 158; } ts.isGetAccessor = isGetAccessor; function hasJSDocNodes(node) { @@ -11387,11 +11592,11 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 265 || node.kind === 267 || isObjectLiteralElementLike(node); + return node.kind === 267 || node.kind === 269 || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 162 || node.kind === 209; + return node.kind === 164 || node.kind === 211; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -11419,13 +11624,13 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 9 || node.kind === 13; + return node.kind === 10 || node.kind === 14; } ts.isStringLiteralLike = isStringLiteralLike; })(ts || (ts = {})); (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 250 || node.kind === 254; + return node.kind === 252 || node.kind === 256; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -11472,7 +11677,7 @@ var ts; }; function formatStringFromArgs(text, args, baseIndex) { if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return ts.Debug.assertDefined(args[+index + baseIndex]); }); + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; function getLocaleSpecificMessage(message) { @@ -12629,6 +12834,71 @@ var ts; } } ts.getOrUpdate = getOrUpdate; + function parsePseudoBigInt(stringValue) { + var log2Base; + switch (stringValue.charCodeAt(1)) { + case 98: + case 66: + log2Base = 1; + break; + case 111: + case 79: + log2Base = 3; + break; + case 120: + case 88: + log2Base = 4; + break; + default: + var nIndex = stringValue.length - 1; + var nonZeroStart = 0; + while (stringValue.charCodeAt(nonZeroStart) === 48) { + nonZeroStart++; + } + return stringValue.slice(nonZeroStart, nIndex) || "0"; + } + var startIndex = 2, endIndex = stringValue.length - 1; + var bitsNeeded = (endIndex - startIndex) * log2Base; + var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0)); + for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) { + var segment = bitOffset >>> 4; + var digitChar = stringValue.charCodeAt(i); + var digit = digitChar <= 57 + ? digitChar - 48 + : 10 + digitChar - + (digitChar <= 70 ? 65 : 97); + var shiftedDigit = digit << (bitOffset & 15); + segments[segment] |= shiftedDigit; + var residual = shiftedDigit >>> 16; + if (residual) + segments[segment + 1] |= residual; + } + var base10Value = ""; + var firstNonzeroSegment = segments.length - 1; + var segmentsRemaining = true; + while (segmentsRemaining) { + var mod10 = 0; + segmentsRemaining = false; + for (var segment = firstNonzeroSegment; segment >= 0; segment--) { + var newSegment = mod10 << 16 | segments[segment]; + var segmentValue = (newSegment / 10) | 0; + segments[segment] = segmentValue; + mod10 = newSegment - segmentValue * 10; + if (segmentValue && !segmentsRemaining) { + firstNonzeroSegment = segment; + segmentsRemaining = true; + } + } + base10Value = mod10 + base10Value; + } + return base10Value; + } + ts.parsePseudoBigInt = parsePseudoBigInt; + function pseudoBigIntToString(_a) { + var negative = _a.negative, base10Value = _a.base10Value; + return (negative && base10Value !== "0" ? "-" : "") + base10Value; + } + ts.pseudoBigIntToString = pseudoBigIntToString; })(ts || (ts = {})); var ts; (function (ts) { @@ -12637,10 +12907,10 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 277) { + if (kind === 279) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 71) { + else if (kind === 72) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -12675,19 +12945,19 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 145) { + if (!node || node.kind <= 147) { return; } switch (node.kind) { - case 146: + case 148: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 148: + case 150: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 274: + case 276: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12695,9 +12965,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 275: + case 277: return visitNode(cbNode, node.expression); - case 149: + case 151: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -12705,7 +12975,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152: + case 154: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12713,51 +12983,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151: + case 153: 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 273: + case 275: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 235: + case 237: 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 184: + case 186: 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 163: - case 164: - case 158: - case 159: + case 165: + case 166: case 160: + case 161: + case 162: 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 154: - case 153: - case 155: case 156: + case 155: case 157: - case 194: - case 237: - case 195: + case 158: + case 159: + case 196: + case 239: + case 197: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12769,302 +13039,302 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 162: + case 164: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 161: + case 163: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 165: - return visitNode(cbNode, node.exprName); - case 166: - return visitNodes(cbNode, cbNodes, node.members); case 167: - return visitNode(cbNode, node.elementType); + return visitNode(cbNode, node.exprName); case 168: + return visitNodes(cbNode, cbNodes, node.members); + case 169: + return visitNode(cbNode, node.elementType); + case 170: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 171: - case 172: - return visitNodes(cbNode, cbNodes, node.types); case 173: + case 174: + return visitNodes(cbNode, cbNodes, node.types); + case 175: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 174: + case 176: return visitNode(cbNode, node.typeParameter); - case 181: + case 183: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 175: case 177: + case 179: return visitNode(cbNode, node.type); - case 178: + case 180: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 179: + case 181: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 180: - return visitNode(cbNode, node.literal); case 182: - case 183: - return visitNodes(cbNode, cbNodes, node.elements); + return visitNode(cbNode, node.literal); + case 184: case 185: return visitNodes(cbNode, cbNodes, node.elements); - case 186: - return visitNodes(cbNode, cbNodes, node.properties); case 187: + return visitNodes(cbNode, cbNodes, node.elements); + case 188: + return visitNodes(cbNode, cbNodes, node.properties); + case 189: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 188: + case 190: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 189: - case 190: + case 191: + case 192: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 191: + case 193: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 192: + case 194: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 193: - return visitNode(cbNode, node.expression); - case 196: - return visitNode(cbNode, node.expression); - case 197: + case 195: return visitNode(cbNode, node.expression); case 198: return visitNode(cbNode, node.expression); - case 200: - return visitNode(cbNode, node.operand); - case 205: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 199: return visitNode(cbNode, node.expression); - case 201: - return visitNode(cbNode, node.operand); + case 200: + return visitNode(cbNode, node.expression); case 202: + return visitNode(cbNode, node.operand); + case 207: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 201: + return visitNode(cbNode, node.expression); + case 203: + return visitNode(cbNode, node.operand); + case 204: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 210: + case 212: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 211: + case 213: return visitNode(cbNode, node.expression); - case 212: + case 214: return visitNode(cbNode, node.name); - case 203: + case 205: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 206: + case 208: return visitNode(cbNode, node.expression); - case 216: - case 243: + case 218: + case 245: return visitNodes(cbNode, cbNodes, node.statements); - case 277: + case 279: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 217: + case 219: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 236: + case 238: return visitNodes(cbNode, cbNodes, node.declarations); - case 219: + case 221: return visitNode(cbNode, node.expression); - case 220: + case 222: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 221: + case 223: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 222: + case 224: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223: + case 225: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 224: + case 226: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 225: + case 227: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226: - case 227: - return visitNode(cbNode, node.label); case 228: - return visitNode(cbNode, node.expression); case 229: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); + return visitNode(cbNode, node.label); case 230: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 244: - return visitNodes(cbNode, cbNodes, node.clauses); - case 269: - return visitNode(cbNode, node.expression) || - visitNodes(cbNode, cbNodes, node.statements); - case 270: - return visitNodes(cbNode, cbNodes, node.statements); + return visitNode(cbNode, node.expression); case 231: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 232: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 246: + return visitNodes(cbNode, cbNodes, node.clauses); + case 271: + return visitNode(cbNode, node.expression) || + visitNodes(cbNode, cbNodes, node.statements); + case 272: + return visitNodes(cbNode, cbNodes, node.statements); case 233: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 234: + return visitNode(cbNode, node.expression); + case 235: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 272: + case 274: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 150: + case 152: return visitNode(cbNode, node.expression); - case 238: - case 207: - 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 239: - 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 240: + case 209: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNode, cbNodes, node.heritageClauses) || + visitNodes(cbNode, cbNodes, node.members); case 241: 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 276: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 242: + 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 243: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.members); + case 278: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 244: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 246: + case 248: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 247: + case 249: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 248: + case 250: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 245: + case 247: return visitNode(cbNode, node.name); - case 249: + case 251: return visitNode(cbNode, node.name); - case 250: - case 254: + case 252: + case 256: return visitNodes(cbNode, cbNodes, node.elements); - case 253: + case 255: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 251: - case 255: + case 253: + case 257: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 252: + case 254: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 204: + case 206: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 214: + case 216: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 147: + case 149: return visitNode(cbNode, node.expression); - case 271: + case 273: return visitNodes(cbNode, cbNodes, node.types); - case 209: + case 211: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 257: + case 259: return visitNode(cbNode, node.expression); - case 256: - return visitNodes(cbNode, cbNodes, node.decorators); - case 307: - return visitNodes(cbNode, cbNodes, node.elements); case 258: + return visitNodes(cbNode, cbNodes, node.decorators); + case 309: + return visitNodes(cbNode, cbNodes, node.elements); + case 260: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 262: + case 264: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 259: - case 260: + case 261: + case 262: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 266: + case 268: return visitNodes(cbNode, cbNodes, node.properties); - case 265: + case 267: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 267: + case 269: return visitNode(cbNode, node.expression); - case 268: + case 270: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 261: + case 263: return visitNode(cbNode, node.tagName); - case 169: - case 170: - case 281: - case 285: - case 284: + case 171: + case 172: + case 283: + case 287: case 286: case 288: + case 290: return visitNode(cbNode, node.type); - case 287: + case 289: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 289: + case 291: return visitNodes(cbNode, cbNodes, node.tags); - case 297: - case 303: + case 299: + case 305: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -13073,17 +13343,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 298: - return visitNode(cbNode, node.typeExpression); case 300: return visitNode(cbNode, node.typeExpression); - case 293: - return visitNode(cbNode, node.class); - case 301: - return visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); case 302: + return visitNode(cbNode, node.typeExpression); + case 295: + return visitNode(cbNode, node.class); + case 303: + return visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); + case 304: if (node.typeExpression && - node.typeExpression.kind === 281) { + node.typeExpression.kind === 283) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -13091,20 +13361,20 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 295: + case 297: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 299: + case 301: return visitNode(cbNode, node.typeExpression); - case 296: + case 298: return visitNode(cbNode, node.typeExpression); - case 291: + case 293: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 290: + case 292: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -13112,7 +13382,7 @@ var ts; } } return; - case 306: + case 308: return visitNode(cbNode, node.expression); } } @@ -13223,18 +13493,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(219); + var statement = createNode(221); switch (token()) { - case 21: + case 22: statement.expression = parseArrayLiteralExpression(); break; - case 101: - case 86: - case 95: + case 102: + case 87: + case 96: statement.expression = parseTokenNode(); break; - case 38: - if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 56; })) { + case 39: + if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 57; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -13242,8 +13512,8 @@ var ts; } break; case 8: - case 9: - if (lookAhead(function () { return nextToken() !== 56; })) { + case 10: + if (lookAhead(function () { return nextToken() !== 57; })) { statement.expression = parseLiteralNode(); break; } @@ -13363,7 +13633,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(277, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(279, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13520,16 +13790,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 71) { + if (token() === 72) { return true; } - if (token() === 116 && inYieldContext()) { + if (token() === 117 && inYieldContext()) { return false; } - if (token() === 121 && inAwaitContext()) { + if (token() === 122 && inAwaitContext()) { return false; } - return token() > 107; + return token() > 108; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13570,27 +13840,27 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 25) { + if (token() === 26) { return true; } - return token() === 18 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 19 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 25) { + if (token() === 26) { nextToken(); } return true; } else { - return parseExpected(25); + return parseExpected(26); } } function createNode(kind, pos) { nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 ? new NodeConstructor(kind, p, p) : - kind === 71 ? new IdentifierConstructor(kind, p, p) : + kind === 72 ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -13626,7 +13896,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 71) { + if (kind === 72) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -13644,8 +13914,8 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(71); - if (token() !== 71) { + var node = createNode(72); + if (token() !== 72) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -13653,7 +13923,7 @@ var ts; return finishNode(node); } var reportAtCurrentPosition = token() === 1; - return createMissingNode(71, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(72, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13663,16 +13933,16 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 9 || + token() === 10 || token() === 8; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 9 || token() === 8) { + if (token() === 10 || token() === 8) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 21) { + if (allowComputedPropertyNames && token() === 22) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13681,10 +13951,10 @@ var ts; return parsePropertyNameWorker(true); } function parseComputedPropertyName() { - var node = createNode(147); - parseExpected(21); - node.expression = allowInAnd(parseExpression); + var node = createNode(149); parseExpected(22); + node.expression = allowInAnd(parseExpression); + parseExpected(23); return finishNode(node); } function parseContextualModifier(t) { @@ -13699,19 +13969,19 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 76: - return nextToken() === 83; - case 84: + case 77: + return nextToken() === 84; + case 85: nextToken(); - if (token() === 79) { + if (token() === 80) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 39 && token() !== 118 && token() !== 17 && canFollowModifier(); - case 79: + return token() !== 40 && token() !== 119 && token() !== 18 && canFollowModifier(); + case 80: return nextTokenCanFollowDefaultKeyword(); - case 115: - case 125: - case 136: + case 116: + case 126: + case 137: nextToken(); return canFollowModifier(); default: @@ -13722,18 +13992,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 21 - || token() === 17 - || token() === 39 - || token() === 24 + return token() === 22 + || token() === 18 + || token() === 40 + || token() === 25 || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 75 || token() === 89 || - token() === 109 || - (token() === 117 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 120 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 76 || token() === 90 || + token() === 110 || + (token() === 118 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 121 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -13744,21 +14014,21 @@ var ts; case 0: case 1: case 3: - return !(token() === 25 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 26 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 73 || token() === 79; + return token() === 74 || token() === 80; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 25 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 26 && !inErrorRecovery); case 6: - return token() === 21 || isLiteralPropertyName(); + return token() === 22 || isLiteralPropertyName(); case 12: switch (token()) { - case 21: - case 39: + case 22: + case 40: + case 25: case 24: - case 23: return true; default: return isLiteralPropertyName(); @@ -13766,9 +14036,9 @@ var ts; case 18: return isLiteralPropertyName(); case 9: - return token() === 21 || token() === 24 || isLiteralPropertyName(); + return token() === 22 || token() === 25 || isLiteralPropertyName(); case 7: - if (token() === 17) { + if (token() === 18) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13780,38 +14050,40 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 26 || token() === 24 || isIdentifierOrPattern(); + return token() === 27 || token() === 25 || isIdentifierOrPattern(); case 19: return isIdentifier(); case 15: - if (token() === 26) { - return true; + switch (token()) { + case 27: + case 24: + return true; } case 11: - return token() === 24 || isStartOfExpression(); + return token() === 25 || isStartOfExpression(); case 16: return isStartOfParameter(false); case 17: return isStartOfParameter(true); case 20: case 21: - return token() === 26 || isStartOfType(); + return token() === 27 || isStartOfType(); case 22: return isHeritageClause(); case 23: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18; case 14: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 17); - if (nextToken() === 18) { + ts.Debug.assert(token() === 18); + if (nextToken() === 19) { var next = nextToken(); - return next === 26 || next === 17 || next === 85 || next === 108; + return next === 27 || next === 18 || next === 86 || next === 109; } return true; } @@ -13828,8 +14100,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 108 || - token() === 85) { + if (token() === 109 || + token() === 86) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -13855,33 +14127,33 @@ var ts; case 12: case 9: case 23: - return token() === 18; + return token() === 19; case 3: - return token() === 18 || token() === 73 || token() === 79; + return token() === 19 || token() === 74 || token() === 80; case 7: - return token() === 17 || token() === 85 || token() === 108; + return token() === 18 || token() === 86 || token() === 109; case 8: return isVariableDeclaratorListTerminator(); case 19: - return token() === 29 || token() === 19 || token() === 17 || token() === 85 || token() === 108; + return token() === 30 || token() === 20 || token() === 18 || token() === 86 || token() === 109; case 11: - return token() === 20 || token() === 25; + return token() === 21 || token() === 26; case 15: case 21: case 10: - return token() === 22; + return token() === 23; case 17: case 16: case 18: - return token() === 20 || token() === 22; + return token() === 21 || token() === 23; case 20: - return token() !== 26; + return token() !== 27; case 22: - return token() === 17 || token() === 18; + return token() === 18 || token() === 19; case 13: - return token() === 29 || token() === 41; + return token() === 30 || token() === 42; case 14: - return token() === 27 && lookAhead(nextTokenIsSlash); + return token() === 28 && lookAhead(nextTokenIsSlash); default: return false; } @@ -13893,7 +14165,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 36) { + if (token() === 37) { return true; } return false; @@ -14003,17 +14275,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 155: - case 160: - case 156: case 157: - case 152: - case 215: - return true; + case 162: + case 158: + case 159: case 154: + case 217: + return true; + case 156: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 71 && - methodDeclaration.name.originalKeywordKind === 123; + var nameIsConstructor = methodDeclaration.name.kind === 72 && + methodDeclaration.name.originalKeywordKind === 124; return !nameIsConstructor; } } @@ -14022,8 +14294,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 269: - case 270: + case 271: + case 272: return true; } } @@ -14032,65 +14304,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 237: - case 217: - case 216: - case 220: + case 239: case 219: - case 232: - case 228: - case 230: - case 227: - case 226: - case 224: - case 225: - case 223: - case 222: - case 229: case 218: - case 233: - case 231: + case 222: case 221: case 234: - case 247: - case 246: - case 253: - case 252: - case 242: - case 238: - case 239: - case 241: + case 230: + case 232: + case 229: + case 228: + case 226: + case 227: + case 225: + case 224: + case 231: + case 220: + case 235: + case 233: + case 223: + case 236: + case 249: + case 248: + case 255: + case 254: + case 244: case 240: + case 241: + case 243: + case 242: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 276; + return node.kind === 278; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 159: + case 161: + case 155: + case 162: case 153: case 160: - case 151: - case 158: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 235) { + if (node.kind !== 237) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 149) { + if (node.kind !== 151) { return false; } var parameter = node; @@ -14144,15 +14416,15 @@ var ts; var startPos = scanner.getStartPos(); list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(26)) { + if (parseOptional(27)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(26); - if (considerSemicolonAsDelimiter && token() === 25 && !scanner.hasPrecedingLineBreak()) { + parseExpected(27); + if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -14193,8 +14465,8 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); - while (parseOptional(23)) { - if (token() === 27) { + while (parseOptional(24)) { + if (token() === 28) { entity.jsdocDotPos = dotPos; break; } @@ -14204,7 +14476,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(146, entity.pos); + var node = createNode(148, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -14213,33 +14485,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(71, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(72, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(204); + var template = createNode(206); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.last(list).literal.kind === 15); + } while (ts.last(list).literal.kind === 16); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(214); + var span = createNode(216); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 18) { + if (token() === 19) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(16, ts.Diagnostics._0_expected, ts.tokenToString(18)); + literal = parseExpectedToken(17, ts.Diagnostics._0_expected, ts.tokenToString(19)); } span.literal = literal; return finishNode(span); @@ -14249,18 +14521,17 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 14, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 || fragment.kind === 16, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 || fragment.kind === 17, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind) { var node = createNode(kind); - var text = scanner.getTokenValue(); - node.text = text; + node.text = scanner.getTokenValue(); if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -14275,23 +14546,23 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(162); + var node = createNode(164); node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token() === 27) { - node.typeArguments = parseBracketedList(20, parseType, 27, 29); + if (!scanner.hasPrecedingLineBreak() && token() === 28) { + node.typeArguments = parseBracketedList(20, parseType, 28, 30); } return finishNode(node); } function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 162: + case 164: return ts.nodeIsMissing(node.typeName); - case 163: - case 164: { + case 165: + case 166: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 175: + case 177: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -14299,20 +14570,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(161, lhs.pos); + var node = createNode(163, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(176); + var node = createNode(178); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(282); + var result = createNode(284); if (postFixEquals) { - return createPostfixType(286, result); + return createPostfixType(288, result); } else { nextToken(); @@ -14320,7 +14591,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(285); + var result = createNode(287); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -14328,66 +14599,66 @@ var ts; function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 26 || - token() === 18 || - token() === 20 || - token() === 29 || - token() === 58 || - token() === 49) { - var result = createNode(283, pos); + if (token() === 27 || + token() === 19 || + token() === 21 || + token() === 30 || + token() === 59 || + token() === 50) { + var result = createNode(285, pos); return finishNode(result); } else { - var result = createNode(284, pos); + var result = createNode(286, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(287); + var result = createNodeWithJSDoc(289); nextToken(); - fillSignature(56, 4 | 32, result); + fillSignature(57, 4 | 32, result); return finishNode(result); } - var node = createNode(162); + var node = createNode(164); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(149); - if (token() === 99 || token() === 94) { + var parameter = createNode(151); + if (token() === 100 || token() === 95) { parameter.name = parseIdentifierName(); - parseExpected(56); + parseExpected(57); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var dotdotdot = parseOptionalToken(24); + var dotdotdot = parseOptionalToken(25); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(288, dotdotdot.pos); + var variadic = createNode(290, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 58) { - return createPostfixType(286, type); + if (token() === 59) { + return createPostfixType(288, type); } return type; } function parseTypeQuery() { - var node = createNode(165); - parseExpected(103); + var node = createNode(167); + parseExpected(104); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(148); + var node = createNode(150); node.name = parseIdentifier(); - if (parseOptional(85)) { + if (parseOptional(86)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -14395,44 +14666,44 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(58)) { + if (parseOptional(59)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 27) { - return parseBracketedList(19, parseTypeParameter, 27, 29); + if (token() === 28) { + return parseBracketedList(19, parseTypeParameter, 28, 30); } } function parseParameterType() { - if (parseOptional(56)) { + if (parseOptional(57)) { return parseType(); } return undefined; } function isStartOfParameter(isJSDocParameter) { - return token() === 24 || + return token() === 25 || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 || + token() === 58 || isStartOfType(!isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(149); - if (token() === 99) { + var node = createNodeWithJSDoc(151); + if (token() === 100) { node.name = createIdentifier(true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(24); + node.dotDotDotToken = parseOptionalToken(25); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(55); + node.questionToken = parseOptionalToken(56); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -14450,22 +14721,22 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 36) { + if (returnToken === 37) { parseExpected(returnToken); return true; } - else if (parseOptional(56)) { + else if (parseOptional(57)) { return true; } - else if (isType && token() === 36) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56)); + else if (isType && token() === 37) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57)); nextToken(); return true; } return false; } function parseParameterList(signature, flags) { - if (!parseExpected(19)) { + if (!parseExpected(20)) { signature.parameters = createMissingList(); return false; } @@ -14478,29 +14749,29 @@ var ts; parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - return parseExpected(20); + return parseExpected(21); } function parseTypeMemberSemicolon() { - if (parseOptional(26)) { + if (parseOptional(27)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 159) { - parseExpected(94); + if (kind === 161) { + parseExpected(95); } - fillSignature(56, 4, node); + fillSignature(57, 4, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - return token() === 21 && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 24 || token() === 22) { + if (token() === 25 || token() === 23) { return true; } if (ts.isModifierKind(token())) { @@ -14515,33 +14786,33 @@ var ts; else { nextToken(); } - if (token() === 56 || token() === 26) { + if (token() === 57 || token() === 27) { return true; } - if (token() !== 55) { + if (token() !== 56) { return false; } nextToken(); - return token() === 56 || token() === 26 || token() === 22; + return token() === 57 || token() === 27 || token() === 23; } function parseIndexSignatureDeclaration(node) { - node.kind = 160; - node.parameters = parseBracketedList(16, parseParameter, 21, 22); + node.kind = 162; + node.parameters = parseBracketedList(16, parseParameter, 22, 23); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55); - if (token() === 19 || token() === 27) { - node.kind = 153; - fillSignature(56, 4, node); + node.questionToken = parseOptionalToken(56); + if (token() === 20 || token() === 28) { + node.kind = 155; + fillSignature(57, 4, node); } else { - node.kind = 151; + node.kind = 153; node.type = parseTypeAnnotation(); - if (token() === 58) { + if (token() === 59) { node.initializer = parseInitializer(); } } @@ -14549,7 +14820,7 @@ var ts; return finishNode(node); } function isTypeMemberStart() { - if (token() === 19 || token() === 27) { + if (token() === 20 || token() === 28) { return true; } var idToken = false; @@ -14557,7 +14828,7 @@ var ts; idToken = true; nextToken(); } - if (token() === 21) { + if (token() === 22) { return true; } if (isLiteralPropertyName()) { @@ -14565,21 +14836,21 @@ var ts; nextToken(); } if (idToken) { - return token() === 19 || - token() === 27 || - token() === 55 || + return token() === 20 || + token() === 28 || token() === 56 || - token() === 26 || + token() === 57 || + token() === 27 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 19 || token() === 27) { - return parseSignatureMember(158); + if (token() === 20 || token() === 28) { + return parseSignatureMember(160); } - if (token() === 94 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(159); + if (token() === 95 && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(161); } var node = createNodeWithJSDoc(0); node.modifiers = parseModifiers(); @@ -14590,30 +14861,30 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 19 || token() === 27; + return token() === 20 || token() === 28; } function nextTokenIsDot() { - return nextToken() === 23; + return nextToken() === 24; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 19: - case 27: - case 23: + case 20: + case 28: + case 24: return true; } return false; } function parseTypeLiteral() { - var node = createNode(166); + var node = createNode(168); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(17)) { + if (parseExpected(18)) { members = parseList(4, parseTypeMember); - parseExpected(18); + parseExpected(19); } else { members = createMissingList(); @@ -14622,89 +14893,89 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 37 || token() === 38) { - return nextToken() === 132; + if (token() === 38 || token() === 39) { + return nextToken() === 133; } - if (token() === 132) { + if (token() === 133) { nextToken(); } - return token() === 21 && nextTokenIsIdentifier() && nextToken() === 92; + return token() === 22 && nextTokenIsIdentifier() && nextToken() === 93; } function parseMappedTypeParameter() { - var node = createNode(148); + var node = createNode(150); node.name = parseIdentifier(); - parseExpected(92); + parseExpected(93); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(179); - parseExpected(17); - if (token() === 132 || token() === 37 || token() === 38) { + var node = createNode(181); + parseExpected(18); + if (token() === 133 || token() === 38 || token() === 39) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 132) { - parseExpectedToken(132); + if (node.readonlyToken.kind !== 133) { + parseExpectedToken(133); } } - parseExpected(21); - node.typeParameter = parseMappedTypeParameter(); parseExpected(22); - if (token() === 55 || token() === 37 || token() === 38) { + node.typeParameter = parseMappedTypeParameter(); + parseExpected(23); + if (token() === 56 || token() === 38 || token() === 39) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 55) { - parseExpectedToken(55); + if (node.questionToken.kind !== 56) { + parseExpectedToken(56); } } node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(18); + parseExpected(19); return finishNode(node); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(24)) { - var node = createNode(170, pos); + if (parseOptional(25)) { + var node = createNode(172, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152) && type.kind === 284 && type.pos === type.type.pos) { - type.kind = 169; + if (!(contextFlags & 2097152) && type.kind === 286 && type.pos === type.type.pos) { + type.kind = 171; } return type; } function parseTupleType() { - var node = createNode(168); - node.elementTypes = parseBracketedList(21, parseTupleElementType, 21, 22); + var node = createNode(170); + node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(175); - parseExpected(19); - node.type = parseType(); + var node = createNode(177); parseExpected(20); + node.type = parseType(); + parseExpected(21); return finishNode(node); } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(94) ? 164 : 163; + var kind = parseOptional(95) ? 166 : 165; var node = createNodeWithJSDoc(kind, pos); - fillSignature(36, 4, node); + fillSignature(37, 4, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 23 ? undefined : node; + return token() === 24 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(180); + var node = createNode(182); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(200); - unaryMinusExpression.operator = 38; + unaryMinusExpression = createNode(202); + unaryMinusExpression.operator = 39; nextToken(); } - var expression = token() === 101 || token() === 86 + var expression = token() === 102 || token() === 87 ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -14717,78 +14988,81 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 91; + return token() === 92; } function parseImportType() { sourceFile.flags |= 524288; - var node = createNode(181); - if (parseOptional(103)) { + var node = createNode(183); + if (parseOptional(104)) { node.isTypeOf = true; } - parseExpected(91); - parseExpected(19); - node.argument = parseType(); + parseExpected(92); parseExpected(20); - if (parseOptional(23)) { + node.argument = parseType(); + parseExpected(21); + if (parseOptional(24)) { node.qualifier = parseEntityName(true, ts.Diagnostics.Type_expected); } node.typeArguments = tryParseTypeArguments(); return finishNode(node); } - function nextTokenIsNumericLiteral() { - return nextToken() === 8; + function nextTokenIsNumericOrBigIntLiteral() { + nextToken(); + return token() === 8 || token() === 9; } function parseNonArrayType() { switch (token()) { - case 119: - case 142: - case 137: - case 134: + case 120: + case 143: case 138: - case 122: - case 140: - case 131: case 135: + case 146: + case 139: + case 123: + case 141: + case 132: + case 136: return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 39: + case 40: return parseJSDocAllType(false); - case 61: + case 62: return parseJSDocAllType(true); - case 55: + case 56: return parseJSDocUnknownOrNullableType(); - case 89: + case 90: return parseJSDocFunctionType(); - case 51: + case 52: return parseJSDocNonNullableType(); - case 13: - case 9: + case 14: + case 10: case 8: - case 101: - case 86: + case 9: + case 102: + case 87: return parseLiteralTypeNode(); - case 38: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); - case 105: - case 95: + case 39: + return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); + case 106: + case 96: return parseTokenNode(); - case 99: { + case 100: { var thisKeyword = parseThisTypeNode(); - if (token() === 127 && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 103: + case 104: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 17: + case 18: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 21: + case 22: return parseTupleType(); - case 19: + case 20: return parseParenthesizedType(); - case 91: + case 92: return parseImportType(); default: return parseTypeReference(); @@ -14796,42 +15070,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 119: - case 142: - case 137: - case 134: - case 122: + case 120: + case 143: case 138: - case 141: - case 105: - case 140: - case 95: - case 99: - case 103: - case 131: - case 17: - case 21: - case 27: - case 49: - case 48: - case 94: - case 9: - case 8: - case 101: - case 86: case 135: - case 39: - case 55: - case 51: - case 24: - case 126: - case 91: + case 146: + case 123: + case 139: + case 142: + case 106: + case 141: + case 96: + case 100: + case 104: + case 132: + case 18: + case 22: + case 28: + case 50: + case 49: + case 95: + case 10: + case 8: + case 9: + case 102: + case 87: + case 136: + case 40: + case 56: + case 52: + case 25: + case 127: + case 92: return true; - case 89: + case 90: return !inStartOfParameter; - case 38: - return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); - case 19: + case 39: + return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); + case 20: return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -14839,34 +15115,34 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 20 || isStartOfParameter(false) || isStartOfType(); + return token() === 21 || isStartOfParameter(false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 51: - type = createPostfixType(285, type); + case 52: + type = createPostfixType(287, type); break; - case 55: + case 56: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(284, type); + type = createPostfixType(286, type); break; - case 21: - parseExpected(21); + case 22: + parseExpected(22); if (isStartOfType()) { - var node = createNode(178, type.pos); + var node = createNode(180, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(22); + parseExpected(23); type = finishNode(node); } else { - var node = createNode(167, type.pos); + var node = createNode(169, type.pos); node.elementType = type; - parseExpected(22); + parseExpected(23); type = finishNode(node); } break; @@ -14883,16 +15159,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(177); + var node = createNode(179); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(174); - parseExpected(126); - var typeParameter = createNode(148); + var node = createNode(176); + parseExpected(127); + var typeParameter = createNode(150); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -14900,10 +15176,10 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 128: - case 141: + case 129: + case 142: return parseTypeOperator(operator); - case 126: + case 127: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -14923,26 +15199,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(172, parseTypeOperatorOrHigher, 48); + return parseUnionOrIntersectionType(174, parseTypeOperatorOrHigher, 49); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(171, parseIntersectionTypeOrHigher, 49); + return parseUnionOrIntersectionType(173, parseIntersectionTypeOrHigher, 50); } function isStartOfFunctionType() { - if (token() === 27) { + if (token() === 28) { return true; } - return token() === 19 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 99) { + if (isIdentifier() || token() === 100) { nextToken(); return true; } - if (token() === 21 || token() === 17) { + if (token() === 22 || token() === 18) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -14951,17 +15227,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 20 || token() === 24) { + if (token() === 21 || token() === 25) { return true; } if (skipParameterStart()) { - if (token() === 56 || token() === 26 || - token() === 55 || token() === 58) { + if (token() === 57 || token() === 27 || + token() === 56 || token() === 59) { return true; } - if (token() === 20) { + if (token() === 21) { nextToken(); - if (token() === 36) { + if (token() === 37) { return true; } } @@ -14972,7 +15248,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(161, typePredicateVariable.pos); + var node = createNode(163, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14983,7 +15259,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 127 && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -14992,47 +15268,48 @@ var ts; return doOutsideOfContext(20480, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 94) { + if (isStartOfFunctionType() || token() === 95) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85)) { - var node = createNode(173, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(86)) { + var node = createNode(175, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); - parseExpected(55); - node.trueType = parseTypeWorker(); parseExpected(56); + node.trueType = parseTypeWorker(); + parseExpected(57); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(56) ? parseType() : undefined; + return parseOptional(57) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 99: - case 97: - case 95: - case 101: - case 86: + case 100: + case 98: + case 96: + case 102: + case 87: case 8: case 9: - case 13: + case 10: case 14: - case 19: - case 21: - case 17: - case 89: - case 75: - case 94: - case 41: - case 63: - case 71: + case 15: + case 20: + case 22: + case 18: + case 90: + case 76: + case 95: + case 42: + case 64: + case 72: return true; - case 91: + case 92: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -15043,18 +15320,18 @@ var ts; return true; } switch (token()) { - case 37: case 38: + case 39: + case 53: case 52: - case 51: - case 80: - case 103: - case 105: - case 43: + case 81: + case 104: + case 106: case 44: - case 27: - case 121: - case 116: + case 45: + case 28: + case 122: + case 117: return true; default: if (isBinaryOperator()) { @@ -15064,10 +15341,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 17 && - token() !== 89 && - token() !== 75 && - token() !== 57 && + return token() !== 18 && + token() !== 90 && + token() !== 76 && + token() !== 58 && isStartOfExpression(); } function parseExpression() { @@ -15077,7 +15354,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(26))) { + while ((operatorToken = parseOptionalToken(27))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -15086,7 +15363,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(58) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(59) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { @@ -15097,7 +15374,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 71 && token() === 36) { + if (expr.kind === 72 && token() === 37) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -15106,7 +15383,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 116) { + if (token() === 117) { if (inYieldContext()) { return true; } @@ -15119,11 +15396,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(205); + var node = createNode(207); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 39 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(39); + (token() === 40 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(40); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15132,20 +15409,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 37, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(195, asyncModifier.pos); + node = createNode(197, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(195, identifier.pos); + node = createNode(197, identifier.pos); } - var parameter = createNode(149, identifier.pos); + var parameter = createNode(151, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(36); + node.equalsGreaterThanToken = parseExpectedToken(37); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -15162,92 +15439,92 @@ var ts; } var isAsync = ts.hasModifier(arrowFunction, 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(36); - arrowFunction.body = (lastToken === 36 || lastToken === 17) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(37); + arrowFunction.body = (lastToken === 37 || lastToken === 18) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token() === 19 || token() === 27 || token() === 120) { + if (token() === 20 || token() === 28 || token() === 121) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 36) { + if (token() === 37) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 120) { + if (token() === 121) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 19 && token() !== 27) { + if (token() !== 20 && token() !== 28) { return 0; } } var first = token(); var second = nextToken(); - if (first === 19) { - if (second === 20) { + if (first === 20) { + if (second === 21) { var third = nextToken(); switch (third) { - case 36: - case 56: - case 17: + case 37: + case 57: + case 18: return 1; default: return 0; } } - if (second === 21 || second === 17) { + if (second === 22 || second === 18) { return 2; } - if (second === 24) { + if (second === 25) { return 1; } - if (ts.isModifierKind(second) && second !== 120 && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 121 && lookAhead(nextTokenIsIdentifier)) { return 1; } - if (!isIdentifier() && second !== 99) { + if (!isIdentifier() && second !== 100) { return 0; } switch (nextToken()) { - case 56: + case 57: return 1; - case 55: + case 56: nextToken(); - if (token() === 56 || token() === 26 || token() === 58 || token() === 20) { + if (token() === 57 || token() === 27 || token() === 59 || token() === 21) { return 1; } return 0; - case 26: - case 58: - case 20: + case 27: + case 59: + case 21: return 2; } return 0; } else { - ts.Debug.assert(first === 27); + ts.Debug.assert(first === 28); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 85) { + if (third === 86) { var fourth = nextToken(); switch (fourth) { - case 58: - case 29: + case 59: + case 30: return false; default: return true; } } - else if (third === 26) { + else if (third === 27) { return true; } return false; @@ -15264,7 +15541,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 120) { + if (token() === 121) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); @@ -15274,37 +15551,37 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 120) { + if (token() === 121) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 36) { + if (scanner.hasPrecedingLineBreak() || token() === 37) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 && token() === 36) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 72 && token() === 37) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(195); + var node = createNodeWithJSDoc(197); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - if (!fillSignature(56, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(57, isAsync, node) && !allowAmbiguity) { return undefined; } - if (!allowAmbiguity && token() !== 36 && token() !== 17) { + if (!allowAmbiguity && token() !== 37 && token() !== 18) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 17) { + if (token() === 18) { return parseFunctionBlock(isAsync ? 2 : 0); } - if (token() !== 25 && - token() !== 89 && - token() !== 75 && + if (token() !== 26 && + token() !== 90 && + token() !== 76 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(16 | (isAsync ? 2 : 0)); @@ -15314,18 +15591,18 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(55); + var questionToken = parseOptionalToken(56); if (!questionToken) { return leftOperand; } - var node = createNode(203, leftOperand.pos); + var node = createNode(205, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(56); + node.colonToken = parseExpectedToken(57); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(71, false, ts.Diagnostics._0_expected, ts.tokenToString(56)); + : createMissingNode(72, false, ts.Diagnostics._0_expected, ts.tokenToString(57)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -15333,22 +15610,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 || t === 145; + return t === 93 || t === 147; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = ts.getBinaryOperatorPrecedence(token()); - var consumeCurrentOperator = token() === 40 ? + var consumeCurrentOperator = token() === 41 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 92 && inDisallowInContext()) { + if (token() === 93 && inDisallowInContext()) { break; } - if (token() === 118) { + if (token() === 119) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -15364,51 +15641,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 92) { + if (inDisallowInContext() && token() === 93) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(202, left.pos); + var node = createNode(204, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(210, left.pos); + var node = createNode(212, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(200); + var node = createNode(202); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(196); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { - var node = createNode(197); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseVoidExpression() { var node = createNode(198); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseTypeOfExpression() { + var node = createNode(199); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } + function parseVoidExpression() { + var node = createNode(200); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { - if (token() === 121) { + if (token() === 122) { if (inAwaitContext()) { return true; } @@ -15417,7 +15694,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(199); + var node = createNode(201); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15425,16 +15702,16 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 40 ? + return token() === 41 ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 40) { + if (token() === 41) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 192) { + if (simpleUnaryExpression.kind === 194) { 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 { @@ -15445,20 +15722,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 37: case 38: + case 39: + case 53: case 52: - case 51: return parsePrefixUnaryExpression(); - case 80: + case 81: return parseDeleteExpression(); - case 103: + case 104: return parseTypeOfExpression(); - case 105: + case 106: return parseVoidExpression(); - case 27: + case 28: return parseTypeAssertion(); - case 121: + case 122: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -15468,16 +15745,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 37: case 38: + case 39: + case 53: case 52: - case 51: - case 80: - case 103: - case 105: - case 121: + case 81: + case 104: + case 106: + case 122: return false; - case 27: + case 28: if (sourceFile.languageVariant !== 1) { return false; } @@ -15486,20 +15763,20 @@ var ts; } } function parseUpdateExpression() { - if (token() === 43 || token() === 44) { - var node = createNode(200); + if (token() === 44 || token() === 45) { + var node = createNode(202); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 27 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 && token() === 28 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { return parseJsxElementOrSelfClosingElementOrFragment(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(201, expression.pos); + if ((token() === 44 || token() === 45) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(203, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15509,7 +15786,7 @@ var ts; } function parseLeftHandSideExpressionOrHigher() { var expression; - if (token() === 91) { + if (token() === 92) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { sourceFile.flags |= 524288; expression = parseTokenNode(); @@ -15518,8 +15795,8 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(212, fullStart); - node.keywordToken = 91; + var node = createNode(214, fullStart); + node.keywordToken = 92; node.name = parseIdentifierName(); expression = finishNode(node); sourceFile.flags |= 1048576; @@ -15529,7 +15806,7 @@ var ts; } } else { - expression = token() === 97 ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 98 ? parseSuperExpression() : parseMemberExpressionOrHigher(); } return parseCallExpressionRest(expression); } @@ -15539,20 +15816,20 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 19 || token() === 23 || token() === 21) { + if (token() === 20 || token() === 24 || token() === 22) { return expression; } - var node = createNode(187, expression.pos); + var node = createNode(189, expression.pos); node.expression = expression; - parseExpectedToken(23, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 260) { - var node = createNode(258, opening.pos); + if (opening.kind === 262) { + var node = createNode(260, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15561,26 +15838,26 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 263) { - var node = createNode(262, opening.pos); + else if (opening.kind === 265) { + var node = createNode(264, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 259); + ts.Debug.assert(opening.kind === 261); result = opening; } - if (inExpressionContext && token() === 27) { + if (inExpressionContext && token() === 28) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(202, result.pos); + var badNode = createNode(204, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26, false, undefined); + badNode.operatorToken = createMissingNode(27, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -15588,8 +15865,8 @@ var ts; return result; } function parseJsxText() { - var node = createNode(10); - node.containsOnlyWhiteSpaces = currentToken === 11; + var node = createNode(11); + node.containsOnlyWhiteSpaces = currentToken === 12; currentToken = scanner.scanJsxToken(); return finishNode(node); } @@ -15603,15 +15880,15 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 28: + case 29: case 7: return undefined; - case 10: case 11: + case 12: return parseJsxText(); - case 17: + case 18: return parseJsxExpression(false); - case 27: + case 28: return parseJsxElementOrSelfClosingElementOrFragment(false); default: return ts.Debug.assertNever(token); @@ -15632,15 +15909,15 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(266); + var jsxAttributes = createNode(268); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(27); - if (token() === 29) { - var node_1 = createNode(263, fullStart); + parseExpected(28); + if (token() === 30) { + var node_1 = createNode(265, fullStart); scanJsxText(); return finishNode(node_1); } @@ -15648,20 +15925,20 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 29) { - node = createNode(260, fullStart); + if (token() === 30) { + node = createNode(262, fullStart); scanJsxText(); } else { - parseExpected(41); + parseExpected(42); if (inExpressionContext) { - parseExpected(29); + parseExpected(30); } else { - parseExpected(29, undefined, false); + parseExpected(30, undefined, false); scanJsxText(); } - node = createNode(259, fullStart); + node = createNode(261, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -15670,10 +15947,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 99 ? + var expression = token() === 100 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(23)) { - var propertyAccess = createNode(187, expression.pos); + while (parseOptional(24)) { + var propertyAccess = createNode(189, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15681,33 +15958,33 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(268); - if (!parseExpected(17)) { + var node = createNode(270); + if (!parseExpected(18)) { return undefined; } - if (token() !== 18) { - node.dotDotDotToken = parseOptionalToken(24); + if (token() !== 19) { + node.dotDotDotToken = parseOptionalToken(25); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(18); + parseExpected(19); } else { - parseExpected(18, undefined, false); + parseExpected(19, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 17) { + if (token() === 18) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(265); + var node = createNode(267); node.name = parseIdentifierName(); - if (token() === 58) { + if (token() === 59) { switch (scanJsxAttributeValue()) { - case 9: + case 10: node.initializer = parseLiteralNode(); break; default: @@ -15718,71 +15995,71 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(267); - parseExpected(17); - parseExpected(24); - node.expression = parseExpression(); + var node = createNode(269); parseExpected(18); + parseExpected(25); + node.expression = parseExpression(); + parseExpected(19); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(261); - parseExpected(28); + var node = createNode(263); + parseExpected(29); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(29); + parseExpected(30); } else { - parseExpected(29, undefined, false); + parseExpected(30, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(264); - parseExpected(28); + var node = createNode(266); + parseExpected(29); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(29); + parseExpected(30); } else { - parseExpected(29, undefined, false); + parseExpected(30, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(192); - parseExpected(27); + var node = createNode(194); + parseExpected(28); node.type = parseType(); - parseExpected(29); + parseExpected(30); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(23); + var dotToken = parseOptionalToken(24); if (dotToken) { - var propertyAccess = createNode(187, expression.pos); + var propertyAccess = createNode(189, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 51 && !scanner.hasPrecedingLineBreak()) { + if (token() === 52 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(211, expression.pos); + var nonNullExpression = createNode(213, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(21)) { - var indexedAccess = createNode(188, expression.pos); + if (!inDecoratorContext() && parseOptional(22)) { + var indexedAccess = createNode(190, expression.pos); indexedAccess.expression = expression; - if (token() === 22) { - indexedAccess.argumentExpression = createMissingNode(71, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23) { + indexedAccess.argumentExpression = createMissingNode(72, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -15791,7 +16068,7 @@ var ts; } indexedAccess.argumentExpression = argument; } - parseExpected(22); + parseExpected(23); expression = finishNode(indexedAccess); continue; } @@ -15803,13 +16080,13 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 13 || token() === 14; + return token() === 14 || token() === 15; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(191, tag.pos); + var tagExpression = createNode(193, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; - tagExpression.template = token() === 13 + tagExpression.template = token() === 14 ? parseLiteralNode() : parseTemplateExpression(); return finishNode(tagExpression); @@ -15817,7 +16094,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 27) { + if (token() === 28) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; @@ -15826,15 +16103,15 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(189, expression.pos); + var callExpr = createNode(191, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 19) { - var callExpr = createNode(189, expression.pos); + else if (token() === 20) { + var callExpr = createNode(191, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15844,17 +16121,17 @@ var ts; } } function parseArgumentList() { - parseExpected(19); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(20); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(21); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(27)) { + if (!parseOptional(28)) { return undefined; } var typeArguments = parseDelimitedList(20, parseType); - if (!parseExpected(29)) { + if (!parseExpected(30)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -15863,29 +16140,29 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 19: - case 13: - case 14: - case 23: case 20: - case 22: + case 14: + case 15: + case 24: + case 21: + case 23: + case 57: + case 26: case 56: - case 25: - case 55: - case 32: - case 34: case 33: case 35: - case 53: + case 34: + case 36: case 54: - case 50: - case 48: + case 55: + case 51: case 49: - case 18: + case 50: + case 19: case 1: return true; - case 26: - case 17: + case 27: + case 18: default: return false; } @@ -15894,120 +16171,121 @@ var ts; switch (token()) { case 8: case 9: - case 13: + case 10: + case 14: return parseLiteralNode(); - case 99: - case 97: - case 95: - case 101: - case 86: + case 100: + case 98: + case 96: + case 102: + case 87: return parseTokenNode(); - case 19: + case 20: return parseParenthesizedExpression(); - case 21: + case 22: return parseArrayLiteralExpression(); - case 17: + case 18: return parseObjectLiteralExpression(); - case 120: + case 121: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 75: + case 76: return parseClassExpression(); - case 89: + case 90: return parseFunctionExpression(); - case 94: + case 95: return parseNewExpressionOrNewDotTarget(); - case 41: - case 63: - if (reScanSlashToken() === 12) { + case 42: + case 64: + if (reScanSlashToken() === 13) { return parseLiteralNode(); } break; - case 14: + case 15: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(193); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNodeWithJSDoc(195); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); return finishNode(node); } function parseSpreadElement() { - var node = createNode(206); - parseExpected(24); + var node = createNode(208); + parseExpected(25); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 24 ? parseSpreadElement() : - token() === 26 ? createNode(208) : + return token() === 25 ? parseSpreadElement() : + token() === 27 ? createNode(210) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(185); - parseExpected(21); + var node = createNode(187); + parseExpected(22); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(22); + parseExpected(23); return finishNode(node); } function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); - if (parseOptionalToken(24)) { - node.kind = 275; + if (parseOptionalToken(25)) { + node.kind = 277; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 156); + if (parseContextualModifier(126)) { + return parseAccessorDeclaration(node, 158); } - if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 157); + if (parseContextualModifier(137)) { + return parseAccessorDeclaration(node, 159); } - var asteriskToken = parseOptionalToken(39); + var asteriskToken = parseOptionalToken(40); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55); - node.exclamationToken = parseOptionalToken(51); - if (asteriskToken || token() === 19 || token() === 27) { + node.questionToken = parseOptionalToken(56); + node.exclamationToken = parseOptionalToken(52); + if (asteriskToken || token() === 20 || token() === 28) { return parseMethodDeclaration(node, asteriskToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57); if (isShorthandPropertyAssignment) { - node.kind = 274; - var equalsToken = parseOptionalToken(58); + node.kind = 276; + var equalsToken = parseOptionalToken(59); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 273; - parseExpected(56); + node.kind = 275; + parseExpected(57); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(186); - parseExpected(17); + var node = createNode(188); + parseExpected(18); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(18); + parseExpected(19); return finishNode(node); } function parseFunctionExpression() { @@ -16015,10 +16293,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(194); + var node = createNodeWithJSDoc(196); node.modifiers = parseModifiers(); - parseExpected(89); - node.asteriskToken = parseOptionalToken(39); + parseExpected(90); + node.asteriskToken = parseOptionalToken(40); var isGenerator = node.asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; node.name = @@ -16026,7 +16304,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(56, isGenerator | isAsync, node); + fillSignature(57, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(true); @@ -16038,10 +16316,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(94); - if (parseOptional(23)) { - var node_2 = createNode(212, fullStart); - node_2.keywordToken = 94; + parseExpected(95); + if (parseOptional(24)) { + var node_2 = createNode(214, fullStart); + node_2.keywordToken = 95; node_2.name = parseIdentifierName(); return finishNode(node_2); } @@ -16057,22 +16335,22 @@ var ts; } break; } - var node = createNode(190, fullStart); + var node = createNode(192, fullStart); node.expression = expression; node.typeArguments = typeArguments; - if (node.typeArguments || token() === 19) { + if (node.typeArguments || token() === 20) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(216); - if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(218); + if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(18); + parseExpected(19); } else { node.statements = createMissingList(); @@ -16097,48 +16375,48 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(218); - parseExpected(25); + var node = createNode(220); + parseExpected(26); return finishNode(node); } function parseIfStatement() { - var node = createNode(220); - parseExpected(90); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(222); + parseExpected(91); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(82) ? parseStatement() : undefined; + node.elseStatement = parseOptional(83) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(221); - parseExpected(81); + var node = createNode(223); + parseExpected(82); node.statement = parseStatement(); - parseExpected(106); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + parseExpected(107); parseExpected(20); - parseOptional(25); + node.expression = allowInAnd(parseExpression); + parseExpected(21); + parseOptional(26); return finishNode(node); } function parseWhileStatement() { - var node = createNode(222); - parseExpected(106); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(224); + parseExpected(107); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(88); - var awaitToken = parseOptionalToken(121); - parseExpected(19); + parseExpected(89); + var awaitToken = parseOptionalToken(122); + parseExpected(20); var initializer; - if (token() !== 25) { - if (token() === 104 || token() === 110 || token() === 76) { + if (token() !== 26) { + if (token() === 105 || token() === 111 || token() === 77) { initializer = parseVariableDeclarationList(true); } else { @@ -16146,33 +16424,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(145) : parseOptional(145)) { - var forOfStatement = createNode(225, pos); + if (awaitToken ? parseExpected(147) : parseOptional(147)) { + var forOfStatement = createNode(227, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(20); + parseExpected(21); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(92)) { - var forInStatement = createNode(224, pos); + else if (parseOptional(93)) { + var forInStatement = createNode(226, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(20); + parseExpected(21); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(223, pos); + var forStatement = createNode(225, pos); forStatement.initializer = initializer; - parseExpected(25); - if (token() !== 25 && token() !== 20) { + parseExpected(26); + if (token() !== 26 && token() !== 21) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(25); - if (token() !== 20) { + parseExpected(26); + if (token() !== 21) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(20); + parseExpected(21); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -16180,7 +16458,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 227 ? 72 : 77); + parseExpected(kind === 229 ? 73 : 78); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16188,8 +16466,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(228); - parseExpected(96); + var node = createNode(230); + parseExpected(97); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -16197,69 +16475,69 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(229); - parseExpected(107); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(231); + parseExpected(108); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); node.statement = doInsideOfContext(8388608, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(269); - parseExpected(73); + var node = createNode(271); + parseExpected(74); node.expression = allowInAnd(parseExpression); - parseExpected(56); + parseExpected(57); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(270); - parseExpected(79); - parseExpected(56); + var node = createNode(272); + parseExpected(80); + parseExpected(57); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 73 ? parseCaseClause() : parseDefaultClause(); + return token() === 74 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(230); - parseExpected(98); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(232); + parseExpected(99); parseExpected(20); - var caseBlock = createNode(244); - parseExpected(17); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(21); + var caseBlock = createNode(246); parseExpected(18); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(19); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(232); - parseExpected(100); + var node = createNode(234); + parseExpected(101); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(233); - parseExpected(102); + var node = createNode(235); + parseExpected(103); node.tryBlock = parseBlock(false); - node.catchClause = token() === 74 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 87) { - parseExpected(87); + node.catchClause = token() === 75 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 88) { + parseExpected(88); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(272); - parseExpected(74); - if (parseOptional(19)) { + var result = createNode(274); + parseExpected(75); + if (parseOptional(20)) { result.variableDeclaration = parseVariableDeclaration(); - parseExpected(20); + parseExpected(21); } else { result.variableDeclaration = undefined; @@ -16268,21 +16546,21 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(234); - parseExpected(78); + var node = createNode(236); + parseExpected(79); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); - if (expression.kind === 71 && parseOptional(56)) { - node.kind = 231; + if (expression.kind === 72 && parseOptional(57)) { + node.kind = 233; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 219; + node.kind = 221; node.expression = expression; parseSemicolon(); } @@ -16294,60 +16572,60 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 75 && !scanner.hasPrecedingLineBreak(); + return token() === 76 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 89 && !scanner.hasPrecedingLineBreak(); + return token() === 90 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9 || token() === 10) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 104: - case 110: + case 105: + case 111: + case 77: + case 90: case 76: - case 89: - case 75: - case 83: + case 84: return true; - case 109: - case 139: + case 110: + case 140: return nextTokenIsIdentifierOnSameLine(); - case 129: case 130: + case 131: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 117: - case 120: - case 124: - case 112: + case 118: + case 121: + case 125: case 113: case 114: - case 132: + case 115: + case 133: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 144: + case 145: nextToken(); - return token() === 17 || token() === 71 || token() === 84; - case 91: + return token() === 18 || token() === 72 || token() === 85; + case 92: nextToken(); - return token() === 9 || token() === 39 || - token() === 17 || ts.tokenIsIdentifierOrKeyword(token()); - case 84: + return token() === 10 || token() === 40 || + token() === 18 || ts.tokenIsIdentifierOrKeyword(token()); + case 85: nextToken(); - if (token() === 58 || token() === 39 || - token() === 17 || token() === 79 || - token() === 118) { + if (token() === 59 || token() === 40 || + token() === 18 || token() === 80 || + token() === 119) { return true; } continue; - case 115: + case 116: nextToken(); continue; default: @@ -16360,47 +16638,47 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 57: - case 25: - case 17: - case 104: - case 110: - case 89: - case 75: - case 83: + case 58: + case 26: + case 18: + case 105: + case 111: case 90: - case 81: - case 106: - case 88: - case 77: - case 72: - case 96: - case 107: - case 98: - case 100: - case 102: - case 78: - case 74: - case 87: - return true; - case 91: - return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); case 76: case 84: - return isStartOfDeclaration(); - case 120: - case 124: - case 109: - case 129: - case 130: - case 139: - case 144: + case 91: + case 82: + case 107: + case 89: + case 78: + case 73: + case 97: + case 108: + case 99: + case 101: + case 103: + case 79: + case 75: + case 88: + return true; + case 92: + return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); + case 77: + case 85: + return isStartOfDeclaration(); + case 121: + case 125: + case 110: + case 130: + case 131: + case 140: + case 145: return true; - case 114: - case 112: - case 113: case 115: - case 132: + case 113: + case 114: + case 116: + case 133: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -16408,73 +16686,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 17 || token() === 21; + return isIdentifier() || token() === 18 || token() === 22; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 25: + case 26: return parseEmptyStatement(); - case 17: + case 18: return parseBlock(false); - case 104: - return parseVariableStatement(createNodeWithJSDoc(235)); - case 110: + case 105: + return parseVariableStatement(createNodeWithJSDoc(237)); + case 111: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(235)); + return parseVariableStatement(createNodeWithJSDoc(237)); } break; - case 89: - return parseFunctionDeclaration(createNodeWithJSDoc(237)); - case 75: - return parseClassDeclaration(createNodeWithJSDoc(238)); case 90: - return parseIfStatement(); - case 81: - return parseDoStatement(); - case 106: - return parseWhileStatement(); - case 88: - return parseForOrForInOrForOfStatement(); - case 77: - return parseBreakOrContinueStatement(226); - case 72: - return parseBreakOrContinueStatement(227); - case 96: - return parseReturnStatement(); - case 107: - return parseWithStatement(); - case 98: - return parseSwitchStatement(); - case 100: - return parseThrowStatement(); - case 102: - case 74: - case 87: - return parseTryStatement(); - case 78: - return parseDebuggerStatement(); - case 57: - return parseDeclaration(); - case 120: - case 109: - case 139: - case 129: - case 130: - case 124: + return parseFunctionDeclaration(createNodeWithJSDoc(239)); case 76: - case 83: - case 84: + return parseClassDeclaration(createNodeWithJSDoc(240)); case 91: - case 112: + return parseIfStatement(); + case 82: + return parseDoStatement(); + case 107: + return parseWhileStatement(); + case 89: + return parseForOrForInOrForOfStatement(); + case 78: + return parseBreakOrContinueStatement(228); + case 73: + return parseBreakOrContinueStatement(229); + case 97: + return parseReturnStatement(); + case 108: + return parseWithStatement(); + case 99: + return parseSwitchStatement(); + case 101: + return parseThrowStatement(); + case 103: + case 75: + case 88: + return parseTryStatement(); + case 79: + return parseDebuggerStatement(); + case 58: + return parseDeclaration(); + case 121: + case 110: + case 140: + case 130: + case 131: + case 125: + case 77: + case 84: + case 85: + case 92: case 113: case 114: - case 117: case 115: - case 132: - case 144: + case 118: + case 116: + case 133: + case 145: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -16483,7 +16761,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 124; + return modifier.kind === 125; } function parseDeclaration() { var node = createNodeWithJSDoc(0); @@ -16502,40 +16780,40 @@ var ts; } function parseDeclarationWorker(node) { switch (token()) { - case 104: - case 110: - case 76: + case 105: + case 111: + case 77: return parseVariableStatement(node); - case 89: + case 90: return parseFunctionDeclaration(node); - case 75: + case 76: return parseClassDeclaration(node); - case 109: + case 110: return parseInterfaceDeclaration(node); - case 139: + case 140: return parseTypeAliasDeclaration(node); - case 83: - return parseEnumDeclaration(node); - case 144: - case 129: - case 130: - return parseModuleDeclaration(node); - case 91: - return parseImportDeclarationOrImportEqualsDeclaration(node); case 84: + return parseEnumDeclaration(node); + case 145: + case 130: + case 131: + return parseModuleDeclaration(node); + case 92: + return parseImportDeclarationOrImportEqualsDeclaration(node); + case 85: nextToken(); switch (token()) { - case 79: - case 58: + case 80: + case 59: return parseExportAssignment(node); - case 118: + case 119: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(256, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(258, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -16546,35 +16824,35 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 17 && canParseSemicolon()) { + if (token() !== 18 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(flags, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 26) { - return createNode(208); + if (token() === 27) { + return createNode(210); } - var node = createNode(184); - node.dotDotDotToken = parseOptionalToken(24); + var node = createNode(186); + node.dotDotDotToken = parseOptionalToken(25); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(184); - node.dotDotDotToken = parseOptionalToken(24); + var node = createNode(186); + node.dotDotDotToken = parseOptionalToken(25); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 56) { + if (tokenIsIdentifier && token() !== 57) { node.name = propertyName; } else { - parseExpected(56); + parseExpected(57); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -16582,27 +16860,27 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(182); - parseExpected(17); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(184); parseExpected(18); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(19); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(183); - parseExpected(21); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(185); parseExpected(22); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(23); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 17 || token() === 21 || isIdentifier(); + return token() === 18 || token() === 22 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 21) { + if (token() === 22) { return parseArrayBindingPattern(); } - if (token() === 17) { + if (token() === 18) { return parseObjectBindingPattern(); } return parseIdentifier(); @@ -16611,10 +16889,10 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(235); + var node = createNode(237); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 71 && - token() === 51 && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 72 && + token() === 52 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -16624,21 +16902,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(236); + var node = createNode(238); switch (token()) { - case 104: + case 105: break; - case 110: + case 111: node.flags |= 1; break; - case 76: + case 77: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 145 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 147 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16650,44 +16928,44 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 20; + return nextTokenIsIdentifier() && nextToken() === 21; } function parseVariableStatement(node) { - node.kind = 217; + node.kind = 219; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 237; - parseExpected(89); - node.asteriskToken = parseOptionalToken(39); + node.kind = 239; + parseExpected(90); + node.asteriskToken = parseOptionalToken(40); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - fillSignature(56, isGenerator | isAsync, node); + fillSignature(57, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 155; - parseExpected(123); - fillSignature(56, 0, node); + node.kind = 157; + parseExpected(124); + fillSignature(57, 0, node); node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 154; + node.kind = 156; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - fillSignature(56, isGenerator | isAsync, node); + fillSignature(57, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 152; - if (!node.questionToken && token() === 51 && !scanner.hasPrecedingLineBreak()) { + node.kind = 154; + if (!node.questionToken && token() === 52 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -16698,10 +16976,10 @@ var ts; return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(39); + var asteriskToken = parseOptionalToken(40); node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55); - if (asteriskToken || token() === 19 || token() === 27) { + node.questionToken = parseOptionalToken(56); + if (asteriskToken || token() === 20 || token() === 28) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -16709,13 +16987,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(56, 0, node); + fillSignature(57, 0, node); node.body = parseFunctionBlockOrSemicolon(0); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 57) { + if (token() === 58) { return true; } while (ts.isModifierKind(token())) { @@ -16725,27 +17003,27 @@ var ts; } nextToken(); } - if (token() === 39) { + if (token() === 40) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 21) { + if (token() === 22) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 136 || idToken === 125) { + if (!ts.isKeyword(idToken) || idToken === 137 || idToken === 126) { return true; } switch (token()) { - case 19: - case 27: - case 51: + case 20: + case 28: + case 52: + case 57: + case 59: case 56: - case 58: - case 55: return true; default: return canParseSemicolon(); @@ -16758,10 +17036,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(57)) { + if (!parseOptional(58)) { break; } - var decorator = createNode(150, decoratorStart); + var decorator = createNode(152, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -16774,7 +17052,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 76 && permitInvalidConstAsModifier) { + if (token() === 77 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -16791,7 +17069,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 120) { + if (token() === 121) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -16801,54 +17079,54 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 25) { - var result = createNode(215); + if (token() === 26) { + var result = createNode(217); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0); node.decorators = parseDecorators(); node.modifiers = parseModifiers(true); - if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 156); + if (parseContextualModifier(126)) { + return parseAccessorDeclaration(node, 158); } - if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 157); + if (parseContextualModifier(137)) { + return parseAccessorDeclaration(node, 159); } - if (token() === 123) { + if (token() === 124) { return parseConstructorDeclaration(node); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(node); } if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 9 || + token() === 10 || token() === 8 || - token() === 39 || - token() === 21) { + token() === 40 || + token() === 22) { return parsePropertyOrMethodDeclaration(node); } if (node.decorators || node.modifiers) { - node.name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(72, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 207); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 209); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 238); + return parseClassDeclarationOrExpression(node, 240); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(75); + parseExpected(76); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(17)) { + if (parseExpected(18)) { node.members = parseClassMembers(); - parseExpected(18); + parseExpected(19); } else { node.members = createMissingList(); @@ -16861,7 +17139,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 108 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 109 && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { if (isHeritageClause()) { @@ -16871,33 +17149,33 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 85 || tok === 108); - var node = createNode(271); + ts.Debug.assert(tok === 86 || tok === 109); + var node = createNode(273); node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(209); + var node = createNode(211); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 27 - ? parseBracketedList(20, parseType, 27, 29) + return token() === 28 + ? parseBracketedList(20, parseType, 28, 30) : undefined; } function isHeritageClause() { - return token() === 85 || token() === 108; + return token() === 86 || token() === 109; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 239; - parseExpected(109); + node.kind = 241; + parseExpected(110); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -16905,28 +17183,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 240; - parseExpected(139); + node.kind = 242; + parseExpected(140); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(58); + parseExpected(59); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(276); + var node = createNodeWithJSDoc(278); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 241; - parseExpected(83); + node.kind = 243; + parseExpected(84); node.name = parseIdentifier(); - if (parseExpected(17)) { + if (parseExpected(18)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(18); + parseExpected(19); } else { node.members = createMissingList(); @@ -16934,10 +17212,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(243); - if (parseExpected(17)) { + var node = createNode(245); + if (parseExpected(18)) { node.statements = parseList(1, parseStatement); - parseExpected(18); + parseExpected(19); } else { node.statements = createMissingList(); @@ -16945,18 +17223,18 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 242; + node.kind = 244; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(23) + node.body = parseOptional(24) ? parseModuleOrNamespaceDeclaration(createNode(0), 4 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 242; - if (token() === 144) { + node.kind = 244; + if (token() === 145) { node.name = parseIdentifier(); node.flags |= 512; } @@ -16964,7 +17242,7 @@ var ts; node.name = parseLiteralNode(); node.name.text = internIdentifier(node.name.text); } - if (token() === 17) { + if (token() === 18) { node.body = parseModuleBlock(); } else { @@ -16974,75 +17252,75 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 144) { + if (token() === 145) { return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(130)) { + else if (parseOptional(131)) { flags |= 16; } else { - parseExpected(129); - if (token() === 9) { + parseExpected(130); + if (token() === 10) { return parseAmbientExternalModuleDeclaration(node); } } return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 133 && + return token() === 134 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 19; + return nextToken() === 20; } function nextTokenIsSlash() { - return nextToken() === 41; + return nextToken() === 42; } function parseNamespaceExportDeclaration(node) { - node.kind = 245; - parseExpected(118); - parseExpected(130); + node.kind = 247; + parseExpected(119); + parseExpected(131); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(91); + parseExpected(92); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 && token() !== 143) { + if (token() !== 27 && token() !== 144) { return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 247; + node.kind = 249; if (identifier || - token() === 39 || - token() === 17) { + token() === 40 || + token() === 18) { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(143); + parseExpected(144); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 246; + node.kind = 248; node.name = identifier; - parseExpected(58); + parseExpected(59); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(248, fullStart); + var importClause = createNode(250, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(26)) { - importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(250); + parseOptional(27)) { + importClause.namedBindings = token() === 40 ? parseNamespaceImport() : parseNamedImportsOrExports(252); } return finishNode(importClause); } @@ -17052,15 +17330,15 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(257); - parseExpected(133); - parseExpected(19); - node.expression = parseModuleSpecifier(); + var node = createNode(259); + parseExpected(134); parseExpected(20); + node.expression = parseModuleSpecifier(); + parseExpected(21); return finishNode(node); } function parseModuleSpecifier() { - if (token() === 9) { + if (token() === 10) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -17070,22 +17348,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(249); - parseExpected(39); - parseExpected(118); + var namespaceImport = createNode(251); + parseExpected(40); + parseExpected(119); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(23, kind === 250 ? parseImportSpecifier : parseExportSpecifier, 17, 18); + node.elements = parseBracketedList(23, kind === 252 ? parseImportSpecifier : parseExportSpecifier, 18, 19); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(255); + return parseImportOrExportSpecifier(257); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(251); + return parseImportOrExportSpecifier(253); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17093,9 +17371,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 118) { + if (token() === 119) { node.propertyName = identifierName; - parseExpected(118); + parseExpected(119); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -17104,21 +17382,21 @@ var ts; else { node.name = identifierName; } - if (kind === 251 && checkIdentifierIsKeyword) { + if (kind === 253 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 253; - if (parseOptional(39)) { - parseExpected(143); + node.kind = 255; + if (parseOptional(40)) { + parseExpected(144); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(254); - if (token() === 143 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(143); + node.exportClause = parseNamedImportsOrExports(256); + if (token() === 144 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { + parseExpected(144); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17126,12 +17404,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 252; - if (parseOptional(58)) { + node.kind = 254; + if (parseOptional(59)) { node.isExportEquals = true; } else { - parseExpected(79); + parseExpected(80); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -17144,10 +17422,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 246 && node.moduleReference.kind === 257 - || node.kind === 247 - || node.kind === 252 - || node.kind === 253 + || node.kind === 248 && node.moduleReference.kind === 259 + || node.kind === 249 + || node.kind === 254 + || node.kind === 255 ? node : undefined; } @@ -17160,7 +17438,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 91 && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 92 && node.name.escapedText === "meta"; } var JSDocParser; (function (JSDocParser) { @@ -17176,11 +17454,11 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17); + var result = createNode(283); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpected(18); + parseExpected(19); } fixupParentReferences(result); return finishNode(result); @@ -17251,7 +17529,7 @@ var ts; } loop: while (true) { switch (token()) { - case 57: + case 58: if (state === 0 || state === 1) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -17268,7 +17546,7 @@ var ts; state = 0; indent = 0; break; - case 39: + case 40: var asterisk = scanner.getTokenText(); if (state === 1 || state === 2) { state = 2; @@ -17313,7 +17591,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(289, start); + var result = createNode(291, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17346,20 +17624,19 @@ var ts; } } var precedingLineBreak = scanner.hasPrecedingLineBreak(); - while ((precedingLineBreak && token() === 39) || token() === 5 || token() === 4) { + while ((precedingLineBreak && token() === 40) || token() === 5 || token() === 4) { if (token() === 4) { precedingLineBreak = true; } - else if (token() === 39) { + else if (token() === 40) { precedingLineBreak = false; } nextJSDocToken(); } } function parseTag(indent) { - ts.Debug.assert(token() === 57); - var atToken = createNode(57, scanner.getTokenPos()); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58); + var start = scanner.getTokenPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(undefined); skipWhitespaceOrAsterisk(); @@ -17367,40 +17644,40 @@ var ts; switch (tagName.escapedText) { case "augments": case "extends": - tag = parseAugmentsTag(atToken, tagName); + tag = parseAugmentsTag(start, tagName); break; case "class": case "constructor": - tag = parseClassTag(atToken, tagName); + tag = parseClassTag(start, tagName); break; case "this": - tag = parseThisTag(atToken, tagName); + tag = parseThisTag(start, tagName); break; case "enum": - tag = parseEnumTag(atToken, tagName); + tag = parseEnumTag(start, tagName); break; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(atToken, tagName, 2, indent); + return parseParameterOrPropertyTag(start, tagName, 2, indent); case "return": case "returns": - tag = parseReturnTag(atToken, tagName); + tag = parseReturnTag(start, tagName); break; case "template": - tag = parseTemplateTag(atToken, tagName); + tag = parseTemplateTag(start, tagName); break; case "type": - tag = parseTypeTag(atToken, tagName); + tag = parseTypeTag(start, tagName); break; case "typedef": - tag = parseTypedefTag(atToken, tagName, indent); + tag = parseTypedefTag(start, tagName, indent); break; case "callback": - tag = parseCallbackTag(atToken, tagName, indent); + tag = parseCallbackTag(start, tagName, indent); break; default: - tag = parseUnknownTag(atToken, tagName); + tag = parseUnknownTag(start, tagName); break; } if (!tag.comment) { @@ -17429,7 +17706,7 @@ var ts; } indent = 0; break; - case 57: + case 58: scanner.setTextPos(scanner.getTextPos() - 1); case 1: break loop; @@ -17445,9 +17722,9 @@ var ts; indent += whitespace.length; } break; - case 17: + case 18: state = 2; - if (lookAhead(function () { return nextJSDocToken() === 57 && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextJSDocToken() === 58 && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextJSDocToken(); pushComment(scanner.getTokenText()); @@ -17455,7 +17732,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 39: + case 40: if (state === 0) { state = 1; indent += 1; @@ -17472,9 +17749,8 @@ var ts; removeTrailingWhitespace(comments); return comments.length === 0 ? undefined : comments.join(""); } - function parseUnknownTag(atToken, tagName) { - var result = createNode(292, atToken.pos); - result.atToken = atToken; + function parseUnknownTag(start, tagName) { + var result = createNode(294, start); result.tagName = tagName; return finishNode(result); } @@ -17493,34 +17769,34 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 17 ? parseJSDocTypeExpression() : undefined; + return token() === 18 ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { - if (token() === 13) { + if (token() === 14) { return { name: createIdentifier(true), isBracketed: false }; } - var isBracketed = parseOptional(21); + var isBracketed = parseOptional(22); var name = parseJSDocEntityName(); if (isBracketed) { skipWhitespace(); - if (parseOptionalToken(58)) { + if (parseOptionalToken(59)) { parseExpression(); } - parseExpected(22); + parseExpected(23); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 135: + case 136: return true; - case 167: + case 169: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; } } - function parseParameterOrPropertyTag(atToken, tagName, target, indent) { + function parseParameterOrPropertyTag(start, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); @@ -17530,15 +17806,14 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(303, atToken.pos) : - createNode(297, atToken.pos); - var comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); + createNode(305, start) : + createNode(299, start); + var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; result.name = name; @@ -17549,20 +17824,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(281, scanner.getTokenPos()); + var typeLiteralExpression = createNode(283, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 297 || child.kind === 303) { + if (child.kind === 299 || child.kind === 305) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(290, start_2); + jsdocTypeLiteral = createNode(292, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 167) { + if (typeExpression.type.kind === 169) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -17570,81 +17845,74 @@ var ts; } } } - function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 298; })) { + function parseReturnTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 300; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(298, atToken.pos); - result.atToken = atToken; + var result = createNode(300, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } - function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300; })) { + function parseTypeTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 302; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300, atToken.pos); - result.atToken = atToken; + var result = createNode(302, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } - function parseAugmentsTag(atToken, tagName) { - var result = createNode(293, atToken.pos); - result.atToken = atToken; + function parseAugmentsTag(start, tagName) { + var result = createNode(295, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(17); - var node = createNode(209); + var usedBrace = parseOptional(18); + var node = createNode(211); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); if (usedBrace) { - parseExpected(18); + parseExpected(19); } return res; } function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); - while (parseOptional(23)) { - var prop = createNode(187, node.pos); + while (parseOptional(24)) { + var prop = createNode(189, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); } return node; } - function parseClassTag(atToken, tagName) { - var tag = createNode(294, atToken.pos); - tag.atToken = atToken; + function parseClassTag(start, tagName) { + var tag = createNode(296, start); tag.tagName = tagName; return finishNode(tag); } - function parseThisTag(atToken, tagName) { - var tag = createNode(299, atToken.pos); - tag.atToken = atToken; + function parseThisTag(start, tagName) { + var tag = createNode(301, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); return finishNode(tag); } - function parseEnumTag(atToken, tagName) { - var tag = createNode(296, atToken.pos); - tag.atToken = atToken; + function parseEnumTag(start, tagName) { + var tag = createNode(298, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); return finishNode(tag); } - function parseTypedefTag(atToken, tagName, indent) { + function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(302, atToken.pos); - typedefTag.atToken = atToken; + var typedefTag = createNode(304, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -17656,12 +17924,11 @@ var ts; var child = void 0; var jsdocTypeLiteral = void 0; var childTypeTag = void 0; - var start_3 = atToken.pos; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(290, start_3); + jsdocTypeLiteral = createNode(292, start); } - if (child.kind === 300) { + if (child.kind === 302) { if (childTypeTag) { break; } @@ -17674,7 +17941,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 167) { + if (typeExpression && typeExpression.type.kind === 169) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -17691,8 +17958,8 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(23)) { - var jsDocNamespaceNode = createNode(242, pos); + if (parseOptional(24)) { + var jsDocNamespaceNode = createNode(244, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -17705,25 +17972,23 @@ var ts; } return typeNameOrNamespaceName; } - function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(295, atToken.pos); - callbackTag.atToken = atToken; + function parseCallbackTag(start, tagName, indent) { + var callbackTag = createNode(297, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var start = scanner.getStartPos(); - var jsdocSignature = createNode(291, start); + var jsdocSignature = createNode(293, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(57)) { + if (parseOptionalJsdoc(58)) { var tag = parseTag(indent); - if (tag && tag.kind === 298) { + if (tag && tag.kind === 300) { return tag; } } @@ -17765,10 +18030,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextJSDocToken()) { - case 57: + case 58: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 297 || child.kind === 303) && + if (child && (child.kind === 299 || child.kind === 305) && target !== 4 && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -17781,13 +18046,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 39: + case 40: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 71: + case 72: canParseTag = false; break; case 1: @@ -17796,16 +18061,15 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 57); - var atToken = createNode(57); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58); + var start = scanner.getStartPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); skipWhitespace(); var t; switch (tagName.escapedText) { case "type": - return target === 1 && parseTypeTag(atToken, tagName); + return target === 1 && parseTypeTag(start, tagName); case "prop": case "property": t = 1; @@ -17821,25 +18085,24 @@ var ts; if (!(target & t)) { return false; } - return parseParameterOrPropertyTag(atToken, tagName, target, indent); + return parseParameterOrPropertyTag(start, tagName, target, indent); } - function parseTemplateTag(atToken, tagName) { + function parseTemplateTag(start, tagName) { var constraint; - if (token() === 17) { + if (token() === 18) { constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(148); + var typeParameter = createNode(150); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); - } while (parseOptionalJsdoc(26)); - var result = createNode(301, atToken.pos); - result.atToken = atToken; + } while (parseOptionalJsdoc(27)); + var result = createNode(303, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -17858,13 +18121,13 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(21)) { - parseExpected(22); + if (parseOptional(22)) { + parseExpected(23); } - while (parseOptional(23)) { + while (parseOptional(24)) { var name = parseJSDocIdentifierName(); - if (parseOptional(21)) { - parseExpected(22); + if (parseOptional(22)) { + parseExpected(23); } entity = createQualifiedName(entity, name); } @@ -17872,11 +18135,11 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(71, !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(72, !message, message || ts.Diagnostics.Identifier_expected); } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(71, pos); + var result = createNode(72, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); nextJSDocToken(); @@ -17955,9 +18218,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 9: + case 10: case 8: - case 71: + case 72: return true; } return false; @@ -18380,10 +18643,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 71) { + if (lhs.kind === 72) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 99) { + if (lhs.kind === 100) { return true; } return lhs.name.escapedText === rhs.name.escapedText && @@ -18429,7 +18692,8 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], - ["esnext.intl", "lib.esnext.intl.d.ts"] + ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.bigint", "lib.esnext.bigint.d.ts"] ]; ts.libs = libEntries.map(function (entry) { return entry[0]; }); ts.libMap = ts.createMapFromEntries(libEntries); @@ -18474,6 +18738,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, { name: "traceResolution", type: "boolean", @@ -18523,11 +18794,11 @@ var ts; description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date }, { - name: "pretty", + name: "showConfig", type: "boolean", - showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + isCommandLineOnly: true, + description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, { name: "target", @@ -19108,6 +19379,7 @@ var ts; { name: "maxNodeModuleJsDepth", type: "number", + affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, @@ -19523,6 +19795,9 @@ var ts; } var result = ts.parseJsonText(configFileName, configFileText); var cwd = host.getCurrentDirectory(); + result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd)); } ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile; @@ -19640,7 +19915,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 273) { + if (element.kind !== 275) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -19690,16 +19965,16 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 101: + case 102: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 86: + case 87: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 95: + case 96: reportInvalidOptionValue(option && option.name === "extends"); return null; - case 9: + case 10: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -19715,13 +19990,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 200: - if (valueExpression.operator !== 38 || valueExpression.operand.kind !== 8) { + case 202: + if (valueExpression.operator !== 39 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 186: + case 188: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -19731,7 +20006,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 185: + case 187: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -19770,59 +20045,105 @@ var ts; } return false; } + function convertToTSConfig(configParseResult, configFileName, host) { + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var files = ts.map(ts.filter(configParseResult.fileNames, !configParseResult.configFileSpecs ? function (_) { return false; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), f, getCanonicalFileName); }); + var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); + var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var _a; + return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), + exclude: configParseResult.configFileSpecs.validatedExcludeSpecs + } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + return config; + } + ts.convertToTSConfig = convertToTSConfig; + function filterSameAsDefaultInclude(specs) { + if (!ts.length(specs)) + return undefined; + if (ts.length(specs) !== 1) + return specs; + if (specs[0] === "**/*") + return undefined; + return specs; + } + function matchesSpecs(path, includeSpecs, excludeSpecs) { + if (!includeSpecs) + return function (_) { return false; }; + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + if (includeRe) { + if (excludeRe) { + return function (path) { return includeRe.test(path) && !excludeRe.test(path); }; + } + return function (path) { return includeRe.test(path); }; + } + if (excludeRe) { + return function (path) { return !excludeRe.test(path); }; + } + return function (_) { return false; }; + } + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options, pathOptions) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); + var _loop_3 = function (name) { + if (ts.hasProperty(options, name)) { + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + return "continue"; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap_1) { + if (pathOptions && optionDefinition.isFilePath) { + result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)); + } + else { + result.set(name, value); + } + } + else { + if (optionDefinition.type === "list") { + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); + } + else { + result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); + } + } + } + } + }; + for (var name in options) { + _loop_3(name); + } + return result; + } function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var compilerOptionsMap = serializeCompilerOptions(compilerOptions); return writeConfigurations(); - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - return ts.forEachEntry(customTypeMap, function (mapValue, key) { - if (mapValue === value) { - return key; - } - }); - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - var _loop_3 = function (name) { - if (ts.hasProperty(options, name)) { - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { - return "continue"; - } - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap_1) { - result.set(name, value); - } - else { - if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); - } - else { - result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); - } - } - } - } - }; - for (var name in options) { - _loop_3(name); - } - return result; - } function getDefaultValueForOption(option) { switch (option.type) { case "number": @@ -20168,19 +20489,23 @@ var ts; } function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) { extendedConfig = ts.normalizeSlashes(extendedConfig); - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../"))) { - errors.push(createDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return undefined; - } - var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return undefined; + if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { + var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; + } } + return extendedConfigPath; } - return extendedConfigPath; + var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, undefined, undefined, true); + if (resolved.resolvedModule) { + return resolved.resolvedModule.resolvedFileName; + } + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; } function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors) { var _a; @@ -20557,7 +20882,8 @@ var ts; Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; - Extensions[Extensions["DtsOnly"] = 3] = "DtsOnly"; + Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; })(Extensions || (Extensions = {})); function resolvedTypeScriptOnly(resolved) { if (!resolved) { @@ -20602,6 +20928,9 @@ var ts; return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state) || readPackageJsonPathField(jsonContent, "types", baseDirectory, state); } + function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) { + return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state); + } function readPackageJsonMainField(jsonContent, baseDirectory, state) { return readPackageJsonPathField(jsonContent, "main", baseDirectory, state); } @@ -20689,8 +21018,11 @@ var ts; return typeRoots; } var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { var traceEnabled = isTraceEnabled(options, host); + if (redirectedReference) { + options = redirectedReference.commandLine.options; + } var failedLookupLocations = []; var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -20711,6 +21043,9 @@ var ts; trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); } } + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var resolved = primaryLookup(); var primary = true; @@ -20720,13 +21055,12 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - if (!options.preserveSymlinks) { - resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); - } + var fileName = resolved.fileName, packageId = resolved.packageId; + var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -20734,7 +21068,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - return ts.forEach(typeRoots, function (typeRoot) { + return ts.firstDefined(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); var directoryExists = ts.directoryProbablyExists(candidateDirectory, host); @@ -20758,13 +21092,14 @@ var ts; } var result = void 0; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { - result = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined); + var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined); + result = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = toSearchResult(nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true)); + result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true); } - var resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -20809,28 +21144,54 @@ var ts; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { - return createModuleResolutionCacheWithMaps(ts.createMap(), ts.createMap(), currentDirectory, getCanonicalFileName); + return createModuleResolutionCacheWithMaps(createCacheWithRedirects(), createCacheWithRedirects(), currentDirectory, getCanonicalFileName); } ts.createModuleResolutionCache = createModuleResolutionCache; + function createCacheWithRedirects() { + var ownMap = ts.createMap(); + var redirectsMap = ts.createMap(); + return { + ownMap: ownMap, + redirectsMap: redirectsMap, + getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, + clear: clear + }; + function getOrCreateMapOfCacheRedirects(redirectedReference) { + if (!redirectedReference) { + return ownMap; + } + var path = redirectedReference.sourceFile.path; + var redirects = redirectsMap.get(path); + if (!redirects) { + redirects = ts.createMap(); + redirectsMap.set(path, redirects); + } + return redirects; + } + function clear() { + ownMap.clear(); + redirectsMap.clear(); + } + } + ts.createCacheWithRedirects = createCacheWithRedirects; function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; - function getOrCreateCacheForDirectory(directoryName) { + function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - var perFolderCache = directoryToModuleNameMap.get(path); - if (!perFolderCache) { - perFolderCache = ts.createMap(); - directoryToModuleNameMap.set(path, perFolderCache); - } - return perFolderCache; + return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap); } - function getOrCreateCacheForModuleName(nonRelativeModuleName) { + function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); - if (!perModuleNameCache) { - perModuleNameCache = createPerModuleNameCache(); - moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); } - return perModuleNameCache; + return result; } function createPerModuleNameCache() { var directoryPathMap = ts.createMap(); @@ -20886,13 +21247,19 @@ var ts; return perFolderCache && perFolderCache.get(moduleName); } ts.resolveModuleNameFromCache = resolveModuleNameFromCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); + if (redirectedReference) { + compilerOptions = redirectedReference.commandLine.options; + } if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var containingDirectory = ts.getDirectoryPath(containingFile); - var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference); var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -20914,10 +21281,10 @@ var ts; } switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); @@ -20925,7 +21292,7 @@ var ts; if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { - cache.getOrCreateCacheForModuleName(moduleName).set(containingDirectory, result); + cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result); } } } @@ -20941,6 +21308,9 @@ var ts; } ts.resolveModuleName = resolveModuleName; function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) { + var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state); + if (resolved) + return resolved.value; if (!ts.isExternalModuleNameRelative(moduleName)) { return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state); } @@ -20948,6 +21318,16 @@ var ts; return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state); } } + function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { + var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + if (baseUrl && paths && !ts.pathIsRelative(moduleName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, false, state); + } + } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { if (!state.compilerOptions.rootDirs) { return undefined; @@ -21011,22 +21391,13 @@ var ts; return undefined; } function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var baseUrl = state.compilerOptions.baseUrl; if (!baseUrl) { return undefined; } if (state.traceEnabled) { trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); } - if (paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - var resolved = tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, false, state); - if (resolved) { - return resolved.value; - } - } var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName)); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate); @@ -21046,22 +21417,22 @@ var ts; return resolvedModule && resolvedModule.resolvedFileName; } ts.tryResolveJSModule = tryResolveJSModule; + var jsOnlyExtensions = [Extensions.JavaScript]; + var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; + var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { - return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, true); + return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined); } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, false); + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { + return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, jsOnly) { + function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; - var result = jsOnly ? - tryResolve(Extensions.JavaScript) : - (tryResolve(Extensions.TypeScript) || - tryResolve(Extensions.JavaScript) || - (compilerOptions.resolveJsonModule ? tryResolve(Extensions.Json) : undefined)); + var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); @@ -21071,13 +21442,13 @@ var ts; var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); if (resolved) { - return toSearchResult({ resolved: resolved, isExternalLibraryImport: ts.stringContains(resolved.path, ts.nodeModulesPathPart) }); + return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) }); } if (!ts.isExternalModuleNameRelative(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache); + var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved_1) return undefined; var resolvedValue = resolved_1.value; @@ -21140,6 +21511,10 @@ var ts; return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson); } ts.nodeModulesPathPart = "/node_modules/"; + function pathContainsNodeModules(path) { + return ts.stringContains(path, ts.nodeModulesPathPart); + } + ts.pathContainsNodeModules = pathContainsNodeModules; function parseNodeModuleFromPath(resolved) { var path = ts.normalizePath(resolved.path); var idx = path.lastIndexOf(ts.nodeModulesPathPart); @@ -21175,9 +21550,9 @@ var ts; return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state)); } function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { - if (extensions === Extensions.Json) { + if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { var extensionLess = ts.tryRemoveExtension(candidate, ".json"); - return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, onlyRecordFailures, state); + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); } var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -21206,6 +21581,7 @@ var ts; return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts"); case Extensions.JavaScript: return tryExtension(".js") || tryExtension(".jsx"); + case Extensions.TSConfig: case Extensions.Json: return tryExtension(".json"); } @@ -21288,10 +21664,26 @@ var ts; } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { - var packageFile = jsonContent && (extensions !== Extensions.JavaScript && extensions !== Extensions.Json - ? readPackageJsonTypesFields(jsonContent, candidate, state) || - (extensions === Extensions.TypeScript ? readPackageJsonMainField(jsonContent, candidate, state) : undefined) - : readPackageJsonMainField(jsonContent, candidate, state)); + var packageFile; + if (jsonContent) { + switch (extensions) { + case Extensions.JavaScript: + case Extensions.Json: + packageFile = readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.TypeScript: + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.DtsOnly: + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state); + break; + case Extensions.TSConfig: + packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state); + break; + default: + return ts.Debug.assertNever(extensions); + } + } var loader = function (extensions, candidate, onlyRecordFailures, state) { var fromFile = tryFile(candidate, onlyRecordFailures, state); if (fromFile) { @@ -21308,7 +21700,7 @@ var ts; }; var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined; var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host); - var indexPath = ts.combinePaths(candidate, "index"); + var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index"); if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) { var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, false); if (state.traceEnabled) { @@ -21332,6 +21724,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: return extension === ".js" || extension === ".jsx"; + case Extensions.TSConfig: case Extensions.Json: return extension === ".json"; case Extensions.TypeScript: @@ -21348,14 +21741,14 @@ var ts; return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } ts.parsePackageName = parsePackageName; - function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache) { - return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache); + function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) { + return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference); } function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) { - return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined); + return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined); } - function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state); @@ -21376,7 +21769,7 @@ var ts; if (packageResult) { return packageResult; } - if (extensions !== Extensions.JavaScript && extensions !== Extensions.Json) { + if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) { var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); var nodeModulesAtTypesExists = nodeModulesFolderExists; if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { @@ -21500,7 +21893,7 @@ var ts; return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + 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 }; @@ -21513,7 +21906,7 @@ var ts; return { value: resolvedUsingSettings }; } if (!ts.isExternalModuleNameRelative(moduleName)) { - var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName); + var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); if (resolutionFromCache) { @@ -21559,21 +21952,21 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateWorker(node) { switch (node.kind) { - case 239: - case 240: - return 0; case 241: + case 242: + return 0; + case 243: if (ts.isEnumConst(node)) { return 2; } break; - case 247: - case 246: + case 249: + case 248: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 243: { + case 245: { var state_1 = 0; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -21592,9 +21985,9 @@ var ts; }); return state_1; } - case 242: + case 244: return getModuleInstanceState(node); - case 71: + case 72: if (node.isInJSDocNamespace) { return 0; } @@ -21713,7 +22106,7 @@ var ts; } } function getDeclarationName(node) { - if (node.kind === 252) { + if (node.kind === 254) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -21722,7 +22115,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 147) { + if (name.kind === 149) { var nameExpression = name.expression; if (ts.isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -21733,31 +22126,31 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 155: + case 157: return "__constructor"; - case 163: - case 158: - case 291: - return "__call"; - case 164: - case 159: - return "__new"; + case 165: case 160: + case 293: + return "__call"; + case 166: + case 161: + return "__new"; + case 162: return "__index"; - case 253: + case 255: return "__export"; - case 277: + case 279: return "export="; - case 202: + case 204: if (ts.getAssignmentDeclarationKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 287: + case 289: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); - case 149: - ts.Debug.assert(node.parent.kind === 287, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + case 151: + ts.Debug.assert(node.parent.kind === 289, "Impossible parameter parent kind", function () { return "parent is: " + (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; @@ -21810,7 +22203,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 252 && !node.isExportEquals)) { + (node.kind === 254 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; } @@ -21837,7 +22230,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 255 || (node.kind === 246 && hasExportModifier)) { + if (node.kind === 257 || (node.kind === 248 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -21867,7 +22260,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 195) { + if (node.kind !== 197) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -21895,7 +22288,7 @@ var ts; currentFlow.container = node; } } - currentReturnTarget = isIIFE || node.kind === 155 ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 157 ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -21907,13 +22300,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 277) { + if (node.kind === 279) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 155) { + if (node.kind === 157) { node.returnFlowNode = currentFlow; } } @@ -21956,8 +22349,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 237 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 237 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 239 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 239 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -21990,77 +22383,77 @@ var ts; return; } switch (node.kind) { - case 222: + case 224: bindWhileStatement(node); break; - case 221: + case 223: bindDoStatement(node); break; - case 223: + case 225: bindForStatement(node); break; - case 224: - case 225: + case 226: + case 227: bindForInOrForOfStatement(node); break; - case 220: + case 222: bindIfStatement(node); break; - case 228: - case 232: + case 230: + case 234: bindReturnOrThrow(node); break; - case 227: - case 226: + case 229: + case 228: bindBreakOrContinueStatement(node); break; - case 233: + case 235: bindTryStatement(node); break; - case 230: + case 232: bindSwitchStatement(node); break; - case 244: + case 246: bindCaseBlock(node); break; - case 269: + case 271: bindCaseClause(node); break; - case 231: + case 233: bindLabeledStatement(node); break; - case 200: + case 202: bindPrefixUnaryExpressionFlow(node); break; - case 201: + case 203: bindPostfixUnaryExpressionFlow(node); break; - case 202: + case 204: bindBinaryExpressionFlow(node); break; - case 196: + case 198: bindDeleteExpressionFlow(node); break; - case 203: + case 205: bindConditionalExpressionFlow(node); break; - case 235: + case 237: bindVariableDeclarationFlow(node); break; - case 189: + case 191: bindCallExpressionFlow(node); break; - case 302: - case 295: + case 304: + case 297: bindJSDocTypeAlias(node); break; - case 277: { + case 279: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 216: - case 243: + case 218: + case 245: bindEachFunctionsFirst(node.statements); break; default: @@ -22071,26 +22464,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 71: - case 99: - case 187: - case 188: - return isNarrowableReference(expr); + case 72: + case 100: case 189: + case 190: + return isNarrowableReference(expr); + case 191: return hasNarrowableArgument(expr); - case 193: + case 195: return isNarrowingExpression(expr.expression); - case 202: + case 204: return isNarrowingBinaryExpression(expr); - case 200: - return expr.operator === 51 && isNarrowingExpression(expr.operand); - case 197: + case 202: + return expr.operator === 52 && isNarrowingExpression(expr.operand); + case 199: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 71 || expr.kind === 99 || expr.kind === 97 || + return expr.kind === 72 || expr.kind === 100 || expr.kind === 98 || ts.isPropertyAccessExpression(expr) && isNarrowableReference(expr.expression) || ts.isElementAccessExpression(expr) && expr.argumentExpression && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && @@ -22105,7 +22498,7 @@ var ts; } } } - if (expr.expression.kind === 187 && + if (expr.expression.kind === 189 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -22119,32 +22512,32 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 58: + case 59: return isNarrowableReference(expr.left); - case 32: case 33: case 34: case 35: + case 36: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 93: + case 94: return isNarrowableOperand(expr.left); - case 92: + case 93: return isNarrowableInOperands(expr.left, expr.right); - case 26: + case 27: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 193: + case 195: return isNarrowableOperand(expr.expression); - case 202: + case 204: switch (expr.operatorToken.kind) { - case 58: + case 59: return isNarrowableOperand(expr.left); - case 26: + case 27: return isNarrowableOperand(expr.right); } } @@ -22178,8 +22571,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 101 && flags & 64 || - expression.kind === 86 && flags & 32) { + if (expression.kind === 102 && flags & 64 || + expression.kind === 87 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -22217,34 +22610,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 220: case 222: - case 221: - return parent.expression === node; + case 224: case 223: - case 203: + return parent.expression === node; + case 225: + case 205: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 193) { + if (node.kind === 195) { node = node.expression; } - else if (node.kind === 200 && node.operator === 51) { + else if (node.kind === 202 && node.operator === 52) { node = node.operand; } else { - return node.kind === 202 && (node.operatorToken.kind === 53 || - node.operatorToken.kind === 54); + return node.kind === 204 && (node.operatorToken.kind === 54 || + node.operatorToken.kind === 55); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 193 || - node.parent.kind === 200 && - node.parent.operator === 51) { + while (node.parent.kind === 195 || + node.parent.kind === 202 && + node.parent.operator === 52) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -22285,7 +22678,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 231 + var enclosingLabeledStatement = node.parent.kind === 233 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -22317,13 +22710,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 225) { + if (node.kind === 227) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 236) { + if (node.initializer.kind !== 238) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -22345,7 +22738,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 228) { + if (node.kind === 230) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -22365,7 +22758,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 227 ? breakTarget : continueTarget; + var flowLabel = node.kind === 229 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -22428,7 +22821,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 272; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -22493,13 +22886,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 221) { + if (!node.statement || node.statement.kind !== 223) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 202 && node.operatorToken.kind === 58) { + if (node.kind === 204 && node.operatorToken.kind === 59) { bindAssignmentTargetFlow(node.left); } else { @@ -22510,10 +22903,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 185) { + else if (node.kind === 187) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 206) { + if (e.kind === 208) { bindAssignmentTargetFlow(e.expression); } else { @@ -22521,16 +22914,16 @@ var ts; } } } - else if (node.kind === 186) { + else if (node.kind === 188) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 273) { + if (p.kind === 275) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 274) { + else if (p.kind === 276) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 275) { + else if (p.kind === 277) { bindAssignmentTargetFlow(p.expression); } } @@ -22538,7 +22931,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 53) { + if (node.operatorToken.kind === 54) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -22549,7 +22942,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 51) { + if (node.operator === 52) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -22559,20 +22952,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 43 || node.operator === 44) { + if (node.operator === 44 || node.operator === 45) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 43 || node.operator === 44) { + if (node.operator === 44 || node.operator === 45) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 53 || operator === 54) { + if (operator === 54 || operator === 55) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -22586,7 +22979,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 && node.left.kind === 188) { + if (operator === 59 && node.left.kind === 190) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -22597,7 +22990,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 187) { + if (node.expression.kind === 189) { bindAssignmentTargetFlow(node.expression); } } @@ -22641,10 +23034,10 @@ var ts; } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 193) { + while (expr.kind === 195) { expr = expr.expression; } - if (expr.kind === 194 || expr.kind === 195) { + if (expr.kind === 196 || expr.kind === 197) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -22652,7 +23045,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 187) { + if (node.expression.kind === 189) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -22661,53 +23054,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 207: - case 238: - case 241: - case 186: - case 166: - case 290: - case 266: - return 1; - case 239: - return 1 | 64; - case 242: + case 209: case 240: - case 179: + case 243: + case 188: + case 168: + case 292: + case 268: + return 1; + case 241: + return 1 | 64; + case 244: + case 242: + case 181: return 1 | 32; - case 277: + case 279: return 1 | 4 | 32; - case 154: + case 156: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 155: - case 237: - case 153: - case 156: case 157: + case 239: + case 155: case 158: - case 291: - case 287: - case 163: case 159: case 160: - case 164: + case 293: + case 289: + case 165: + case 161: + case 162: + case 166: return 1 | 4 | 32 | 8; - case 194: - case 195: + case 196: + case 197: return 1 | 4 | 32 | 8 | 16; - case 243: + case 245: return 4; - case 152: + case 154: return node.initializer ? 4 : 0; - case 272: - case 223: - case 224: + case 274: case 225: - case 244: + case 226: + case 227: + case 246: return 2; - case 216: + case 218: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -22720,40 +23113,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 242: + case 244: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 277: + case 279: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 207: - case 238: + case 209: + case 240: return declareClassMember(node, symbolFlags, symbolExcludes); - case 241: + case 243: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 166: - case 290: - case 186: - case 239: - case 266: + case 168: + case 292: + case 188: + case 241: + case 268: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 163: - case 164: + case 165: + case 166: + case 160: + case 161: + case 293: + case 162: + case 156: + case 155: + case 157: case 158: case 159: - case 291: - case 160: - case 154: - case 153: - case 155: - case 156: - case 157: - case 237: - case 194: - case 195: - case 287: - case 302: - case 295: - case 240: - case 179: + case 239: + case 196: + case 197: + case 289: + case 304: + case 297: + case 242: + case 181: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -22768,11 +23161,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 277 ? node : node.body; - if (body && (body.kind === 277 || body.kind === 243)) { + var body = node.kind === 279 ? node : node.body; + if (body && (body.kind === 279 || body.kind === 245)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 253 || stat.kind === 252) { + if (stat.kind === 255 || stat.kind === 254) { return true; } } @@ -22798,7 +23191,7 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 9) { + if (node.name.kind === 10) { var text = node.name.text; if (ts.hasZeroOrOneAsteriskCharacter(text)) { pattern = ts.tryParsePattern(text); @@ -22840,11 +23233,11 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 || prop.name.kind !== 71) { + if (prop.kind === 277 || prop.name.kind !== 72) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 273 || prop.kind === 274 || prop.kind === 154 + var currentKind = prop.kind === 275 || prop.kind === 276 || prop.kind === 156 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -22876,10 +23269,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 242: + case 244: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 277: + case 279: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -22909,7 +23302,7 @@ var ts; currentFlow = { flags: 2 }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 71) { + if (!typeAlias.fullName || typeAlias.fullName.kind === 72) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288, 67897832); } @@ -22925,8 +23318,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 108 && - node.originalKeywordKind <= 116 && + node.originalKeywordKind >= 109 && + node.originalKeywordKind <= 117 && !ts.isIdentifierName(node) && !(node.flags & 4194304)) { if (!file.parseDiagnostics.length) { @@ -22954,7 +23347,7 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 71) { + if (inStrictMode && node.expression.kind === 72) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } @@ -22963,7 +23356,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 71) { + if (name && name.kind === 72) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -22996,8 +23389,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 277 && - blockScopeContainer.kind !== 242 && + if (blockScopeContainer.kind !== 279 && + blockScopeContainer.kind !== 244 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -23016,7 +23409,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 43 || node.operator === 44) { + if (node.operator === 44 || node.operator === 45) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -23059,7 +23452,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 145) { + if (node.kind > 147) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -23117,7 +23510,7 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 71: + case 72: if (node.isInJSDocNamespace) { var parentNode = node.parent; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { @@ -23126,13 +23519,13 @@ var ts; bindBlockScopedDeclaration(parentNode, 524288, 67897832); break; } - case 99: - if (currentFlow && (ts.isExpression(node) || parent.kind === 274)) { + case 100: + if (currentFlow && (ts.isExpression(node) || parent.kind === 276)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 187: - case 188: + case 189: + case 190: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -23146,7 +23539,7 @@ var ts; declareSymbol(file.locals, undefined, node.expression, 1 | 134217728, 67220414); } break; - case 202: + case 204: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1: @@ -23170,132 +23563,145 @@ var ts; case 0: break; default: - ts.Debug.fail("Unknown special property assignment kind"); + ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 272: + case 274: return checkStrictModeCatchClause(node); - case 196: + case 198: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 201: + case 203: return checkStrictModePostfixUnaryExpression(node); - case 200: + case 202: return checkStrictModePrefixUnaryExpression(node); - case 229: - return checkStrictModeWithStatement(node); case 231: + return checkStrictModeWithStatement(node); + case 233: return checkStrictModeLabeledStatement(node); - case 176: + case 178: seenThisKeyword = true; return; - case 161: + case 163: break; - case 148: + case 150: return bindTypeParameter(node); - case 149: + case 151: return bindParameter(node); - case 235: + case 237: return bindVariableDeclarationOrBindingElement(node); - case 184: + case 186: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 152: - case 151: - return bindPropertyWorker(node); - case 273: - case 274: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 276: - return bindPropertyOrMethodOrAccessor(node, 8, 68008959); - case 158: - case 159: - case 160: - return declareSymbolAndAddToSymbolTable(node, 131072, 0); case 154: case 153: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67212223); - case 237: - return bindFunctionDeclaration(node); - case 155: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + return bindPropertyWorker(node); + case 275: + case 276: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 278: + return bindPropertyOrMethodOrAccessor(node, 8, 68008959); + case 160: + case 161: + case 162: + return declareSymbolAndAddToSymbolTable(node, 131072, 0); case 156: - return bindPropertyOrMethodOrAccessor(node, 32768, 67154879); + case 155: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67212223); + case 239: + return bindFunctionDeclaration(node); case 157: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 158: + return bindPropertyOrMethodOrAccessor(node, 32768, 67154879); + case 159: return bindPropertyOrMethodOrAccessor(node, 65536, 67187647); - case 163: - case 287: - case 291: - case 164: - return bindFunctionOrConstructorType(node); + case 165: + case 289: + case 293: case 166: - case 290: - case 179: + return bindFunctionOrConstructorType(node); + case 168: + case 292: + case 181: return bindAnonymousTypeWorker(node); - case 186: + case 188: return bindObjectLiteralExpression(node); - case 194: - case 195: + case 196: + case 197: return bindFunctionExpression(node); - case 189: + case 191: + var assignmentKind = ts.getAssignmentDeclarationKind(node); + switch (assignmentKind) { + case 7: + return bindObjectDefinePropertyAssignment(node); + case 8: + return bindObjectDefinePropertyExport(node); + case 9: + return bindObjectDefinePrototypeProperty(node); + case 0: + break; + default: + return ts.Debug.fail("Unknown call expression assignment declaration kind"); + } if (ts.isInJSFile(node)) { bindCallExpression(node); } break; - case 207: - case 238: + case 209: + case 240: inStrictMode = true; return bindClassLikeDeclaration(node); - case 239: - return bindBlockScopedDeclaration(node, 64, 67897736); - case 240: - return bindBlockScopedDeclaration(node, 524288, 67897832); case 241: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 64, 67897736); case 242: + return bindBlockScopedDeclaration(node, 524288, 67897832); + case 243: + return bindEnumDeclaration(node); + case 244: return bindModuleDeclaration(node); - case 266: + case 268: return bindJsxAttributes(node); - case 265: + case 267: return bindJsxAttribute(node, 4, 0); - case 246: - case 249: - case 251: - case 255: - return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 245: - return bindNamespaceExportDeclaration(node); case 248: - return bindImportClause(node); + case 251: case 253: + case 257: + return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); + case 247: + return bindNamespaceExportDeclaration(node); + case 250: + return bindImportClause(node); + case 255: return bindExportDeclaration(node); - case 252: + case 254: return bindExportAssignment(node); - case 277: + case 279: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 216: + case 218: if (!ts.isFunctionLike(node.parent)) { return; } - case 243: + case 245: return updateStrictModeStatementList(node.statements); - case 297: - if (node.parent.kind === 291) { + case 299: + if (node.parent.kind === 293) { return bindParameter(node); } - if (node.parent.kind !== 290) { + if (node.parent.kind !== 292) { break; } - case 303: + case 305: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 302: - case 295: + case 304: + case 297: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -23373,6 +23779,21 @@ var ts; } return true; } + function bindObjectDefinePropertyExport(node) { + if (!setCommonJsModuleIndicator(node)) { + return; + } + var symbol = forEachIdentifierInEntityName(node.arguments[0], undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 | 67108864); + } + return symbol; + }); + if (symbol) { + var flags = 4 | 1048576; + declareSymbol(symbol.exports, symbol, node, flags, 0); + } + } function bindExportsPropertyAssignment(node) { if (!setCommonJsModuleIndicator(node)) { return; @@ -23402,16 +23823,16 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 : 4 | 1048576 | 512; - declareSymbol(file.symbol.exports, file.symbol, node, flags, 0); + declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 237: - case 194: + case 239: + case 196: var constructorSymbol = thisContainer.symbol; - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 59) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -23422,26 +23843,26 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4, 0 & ~4); } break; - case 155: - case 152: + case 157: case 154: case 156: - case 157: + case 158: + case 159: var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); break; - case 277: + case 279: break; default: ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer)); } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 100) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -23456,6 +23877,10 @@ var ts; var lhs = node.left; bindPropertyAssignment(lhs.expression, lhs, false); } + function bindObjectDefinePrototypeProperty(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true); + } function bindPrototypePropertyAssignment(lhs, parent) { var classPrototype = lhs.expression; var constructorFunction = classPrototype.expression; @@ -23464,6 +23889,12 @@ var ts; classPrototype.parent = lhs; bindPropertyAssignment(constructorFunction, lhs, true); } + function bindObjectDefinePropertyAssignment(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); + var isToplevel = node.parent.parent.kind === 279; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false); + } function bindSpecialPropertyAssignment(node) { var lhs = node.left; var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); @@ -23483,15 +23914,11 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, false); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 - : propertyAccess.parent.parent.kind === 277; + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920))) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 110735 & ~67108864; - namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_1); return symbol; @@ -23503,22 +23930,36 @@ var ts; } }); } + return namespaceSymbol; + } + function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) { return; } var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(propertyAccess)); + var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 : 4; var excludes = isMethod ? 67212223 : 0; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | 67108864, excludes & ~67108864); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864); + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var isToplevel = ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 + : propertyAccess.parent.parent.kind === 279; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } function isExpandoSymbol(symbol) { if (symbol.flags & (16 | 32 | 1024)) { return true; } var node = symbol.valueDeclaration; + if (ts.isCallExpression(node)) { + return !!ts.getAssignedExpandoInitializer(node); + } var init = !node ? undefined : ts.isVariableDeclaration(node) ? node.initializer : ts.isBinaryExpression(node) ? node.right : @@ -23527,7 +23968,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 === 54 ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 ? init.right : init, isPrototypeAssignment); } return false; } @@ -23567,7 +24008,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 238) { + if (node.kind === 240) { bindBlockScopedDeclaration(node, 32, 68008383); } else { @@ -23614,7 +24055,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 297 && container.kind !== 291) { + if (node.kind === 299 && container.kind !== 293) { return; } if (inStrictMode && !(node.flags & 4194304)) { @@ -23687,7 +24128,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144, 67635688); } } - else if (node.parent.kind === 174) { + else if (node.parent.kind === 176) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -23712,9 +24153,9 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 218) || - node.kind === 238 || - (node.kind === 242 && shouldReportErrorOnModuleDeclaration(node)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 220) || + node.kind === 240 || + (node.kind === 244 && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -23746,12 +24187,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 239: - case 240: - return true; - case 242: - return getModuleInstanceState(s) !== 1; case 241: + case 242: + return true; + case 244: + return getModuleInstanceState(s) !== 1; + case 243: return ts.hasModifier(s, 2048); default: return false; @@ -23785,58 +24226,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 189: + case 191: return computeCallExpression(node, subtreeFlags); - case 190: + case 192: return computeNewExpression(node, subtreeFlags); - case 242: + case 244: return computeModuleDeclaration(node, subtreeFlags); - case 193: - return computeParenthesizedExpression(node, subtreeFlags); - case 202: - return computeBinaryExpression(node, subtreeFlags); - case 219: - return computeExpressionStatement(node, subtreeFlags); - case 149: - return computeParameter(node, subtreeFlags); case 195: + return computeParenthesizedExpression(node, subtreeFlags); + case 204: + return computeBinaryExpression(node, subtreeFlags); + case 221: + return computeExpressionStatement(node, subtreeFlags); + case 151: + return computeParameter(node, subtreeFlags); + case 197: return computeArrowFunction(node, subtreeFlags); - case 194: + case 196: return computeFunctionExpression(node, subtreeFlags); - case 237: + case 239: return computeFunctionDeclaration(node, subtreeFlags); - case 235: + case 237: return computeVariableDeclaration(node, subtreeFlags); - case 236: - return computeVariableDeclarationList(node, subtreeFlags); - case 217: - return computeVariableStatement(node, subtreeFlags); - case 231: - return computeLabeledStatement(node, subtreeFlags); case 238: + return computeVariableDeclarationList(node, subtreeFlags); + case 219: + return computeVariableStatement(node, subtreeFlags); + case 233: + return computeLabeledStatement(node, subtreeFlags); + case 240: return computeClassDeclaration(node, subtreeFlags); - case 207: - return computeClassExpression(node, subtreeFlags); - case 271: - return computeHeritageClause(node, subtreeFlags); - case 272: - return computeCatchClause(node, subtreeFlags); case 209: + return computeClassExpression(node, subtreeFlags); + case 273: + return computeHeritageClause(node, subtreeFlags); + case 274: + return computeCatchClause(node, subtreeFlags); + case 211: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 155: - return computeConstructor(node, subtreeFlags); - case 152: - return computePropertyDeclaration(node, subtreeFlags); - case 154: - return computeMethod(node, subtreeFlags); - case 156: case 157: + return computeConstructor(node, subtreeFlags); + case 154: + return computePropertyDeclaration(node, subtreeFlags); + case 156: + return computeMethod(node, subtreeFlags); + case 158: + case 159: return computeAccessor(node, subtreeFlags); - case 246: + case 248: return computeImportEquals(node, subtreeFlags); - case 187: + case 189: return computePropertyAccess(node, subtreeFlags); - case 188: + case 190: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -23856,7 +24297,7 @@ var ts; transformFlags |= 8192; } } - if (expression.kind === 91) { + if (expression.kind === 92) { transformFlags |= 16777216; if (subtreeFlags & 8192) { transformFlags |= 16384; @@ -23880,14 +24321,14 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 && leftKind === 186) { + if (operatorTokenKind === 59 && leftKind === 188) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 58 && leftKind === 185) { + else if (operatorTokenKind === 59 && leftKind === 187) { transformFlags |= 192 | 3072; } - else if (operatorTokenKind === 40 - || operatorTokenKind === 62) { + else if (operatorTokenKind === 41 + || operatorTokenKind === 63) { transformFlags |= 32; } node.transformFlags = transformFlags | 536870912; @@ -23921,8 +24362,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 210 - || expressionKind === 192) { + if (expressionKind === 212 + || expressionKind === 194) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -23964,10 +24405,10 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 85: + case 86: transformFlags |= 192; break; - case 108: + case 109: transformFlags |= 3; break; default: @@ -24220,54 +24661,54 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 637535553; switch (kind) { - case 120: - case 199: + case 121: + case 201: transformFlags |= 8 | 16; break; - case 192: - case 210: - case 306: + case 194: + case 212: + case 308: transformFlags |= 3; excludeFlags = 536872257; break; - case 114: - case 112: + case 115: case 113: - case 117: - case 124: - case 76: - case 241: - case 276: - case 211: - case 132: + case 114: + case 118: + case 125: + case 77: + case 243: + case 278: + case 213: + case 133: transformFlags |= 3; break; - case 258: - case 259: case 260: - case 10: case 261: case 262: + case 11: case 263: case 264: case 265: case 266: case 267: case 268: + case 269: + case 270: transformFlags |= 4; break; - case 13: case 14: case 15: case 16: - case 204: - case 191: - case 274: - case 115: - case 212: + case 17: + case 206: + case 193: + case 276: + case 116: + case 214: transformFlags |= 192; break; - case 9: + case 10: if (node.hasExtendedUnicodeEscape) { transformFlags |= 192; } @@ -24277,28 +24718,30 @@ var ts; transformFlags |= 192; } break; - case 225: + case 9: + transformFlags |= 8; + break; + case 227: if (node.awaitModifier) { transformFlags |= 8; } transformFlags |= 192; break; - case 205: + case 207: transformFlags |= 8 | 192 | 4194304; break; - case 119: - case 134: - case 131: + case 120: case 135: - case 137: - case 122: + case 146: + case 132: + case 136: case 138: - case 105: - case 148: - case 151: + case 123: + case 139: + case 106: + case 150: case 153: - case 158: - case 159: + case 155: case 160: case 161: case 162: @@ -24315,57 +24758,59 @@ var ts; case 173: case 174: case 175: - case 239: - case 240: case 176: case 177: + case 241: + case 242: case 178: case 179: case 180: - case 245: + case 181: + case 182: + case 247: transformFlags = 3; excludeFlags = -3; break; - case 147: + case 149: transformFlags |= 524288; if (subtreeFlags & 8192) { transformFlags |= 32768; } break; - case 206: + case 208: transformFlags |= 192 | 131072; break; - case 275: + case 277: transformFlags |= 8 | 262144; break; - case 97: + case 98: transformFlags |= 192 | 33554432; excludeFlags = 536872257; break; - case 99: + case 100: transformFlags |= 8192; break; - case 182: + case 184: transformFlags |= 192 | 2097152; if (subtreeFlags & 131072) { transformFlags |= 8 | 262144; } excludeFlags = 637666625; break; - case 183: + case 185: transformFlags |= 192 | 2097152; excludeFlags = 637666625; break; - case 184: + case 186: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 131072; } break; - case 150: + case 152: transformFlags |= 3 | 4096; break; - case 186: + case 188: excludeFlags = 638358849; if (subtreeFlags & 524288) { transformFlags |= 192; @@ -24377,31 +24822,31 @@ var ts; transformFlags |= 8; } break; - case 185: - case 190: + case 187: + case 192: excludeFlags = 637666625; if (subtreeFlags & 131072) { transformFlags |= 192; } break; - case 221: - case 222: case 223: case 224: + case 225: + case 226: if (subtreeFlags & 1048576) { transformFlags |= 192; } break; - case 277: + case 279: if (subtreeFlags & 16384) { transformFlags |= 192; } break; - case 228: + case 230: transformFlags |= 8388608 | 8; break; - case 226: - case 227: + case 228: + case 229: transformFlags |= 8388608; break; } @@ -24409,66 +24854,67 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 && kind <= 181) { + if (kind >= 163 && kind <= 183) { return -3; } switch (kind) { - case 189: - case 190: - case 185: + case 191: + case 192: + case 187: return 637666625; - case 242: + case 244: return 647001409; - case 149: + case 151: return 637535553; - case 195: + case 197: return 653604161; - case 194: - case 237: + case 196: + case 239: return 653620545; - case 236: - return 639894849; case 238: - case 207: + return 639894849; + case 240: + case 209: return 638121281; - case 155: - return 653616449; - case 154: - case 156: case 157: return 653616449; - case 119: - case 134: - case 131: - case 137: - case 135: - case 122: - case 138: - case 105: - case 148: - case 151: - case 153: + case 156: case 158: case 159: + return 653616449; + case 120: + case 135: + case 146: + case 132: + case 138: + case 136: + case 123: + case 139: + case 106: + case 150: + case 153: + case 155: case 160: - case 239: - case 240: + case 161: + case 162: + case 241: + case 242: return -3; - case 186: - return 638358849; - case 272: - return 637797697; - case 182: - case 183: - return 637666625; - case 192: - case 210: - case 306: - case 193: - case 97: - return 536872257; - case 187: case 188: + return 638358849; + case 274: + return 637797697; + case 184: + case 185: + return 637666625; + case 194: + case 212: + case 308: + case 195: + case 98: + return 536872257; + case 189: + case 190: return 570426689; default: return 637535553; @@ -24521,7 +24967,7 @@ var ts; var shouldBail = visitSymbol(type.symbol); if (shouldBail) return; - if (type.flags & 131072) { + if (type.flags & 524288) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4) { @@ -24537,16 +24983,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 65536) { + if (type.flags & 262144) { visitTypeParameter(type); } - if (type.flags & 786432) { + if (type.flags & 3145728) { visitUnionOrIntersectionType(type); } - if (type.flags & 1048576) { + if (type.flags & 4194304) { visitIndexType(type); } - if (type.flags & 2097152) { + if (type.flags & 8388608) { visitIndexedAccessType(type); } } @@ -24630,7 +25076,7 @@ var ts; symbol.exports.forEach(visitSymbol); } ts.forEach(symbol.declarations, function (d) { - if (d.type && d.type.kind === 165) { + if (d.type && d.type.kind === 167) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -24708,6 +25154,7 @@ var ts; var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768; var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4, "undefined"); @@ -24877,10 +25324,6 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { - var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); - return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; - }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isParameter); @@ -24911,6 +25354,7 @@ var ts; getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, + getObjectFlags: ts.getObjectFlags, isArrayLikeType: isArrayLikeType, isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, @@ -24918,7 +25362,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentExport: function (node, target) { return getSuggestionForNonexistentExport(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals); }, @@ -24992,35 +25436,41 @@ var ts; var wildcardType = createIntrinsicType(1, "any"); var errorType = createIntrinsicType(1, "error"); var unknownType = createIntrinsicType(2, "unknown"); - var undefinedType = createIntrinsicType(8192, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 | 134217728, "undefined"); - var nullType = createIntrinsicType(16384, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 | 134217728, "null"); + var undefinedType = createIntrinsicType(32768, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 | 134217728, "undefined"); + var nullType = createIntrinsicType(65536, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 | 134217728, "null"); var stringType = createIntrinsicType(4, "string"); var numberType = createIntrinsicType(8, "number"); - var falseType = createIntrinsicType(256, "false"); - var regularFalseType = createIntrinsicType(256, "false"); - var trueType = createIntrinsicType(256, "true"); - var regularTrueType = createIntrinsicType(256, "true"); - falseType.flags |= 33554432; - trueType.flags |= 33554432; + var bigintType = createIntrinsicType(64, "bigint"); + var falseType = createIntrinsicType(512, "false"); + var regularFalseType = createIntrinsicType(512, "false"); + var trueType = createIntrinsicType(512, "true"); + var regularTrueType = createIntrinsicType(512, "true"); trueType.regularType = regularTrueType; + trueType.freshType = trueType; + regularTrueType.regularType = regularTrueType; regularTrueType.freshType = trueType; falseType.regularType = regularFalseType; + falseType.freshType = falseType; + regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = createBooleanType([regularFalseType, regularTrueType]); createBooleanType([regularFalseType, trueType]); createBooleanType([falseType, regularTrueType]); createBooleanType([falseType, trueType]); - var esSymbolType = createIntrinsicType(1024, "symbol"); - var voidType = createIntrinsicType(4096, "void"); - var neverType = createIntrinsicType(32768, "never"); - var silentNeverType = createIntrinsicType(32768, "never"); - var implicitNeverType = createIntrinsicType(32768, "never"); - var nonPrimitiveType = createIntrinsicType(16777216, "object"); + var esSymbolType = createIntrinsicType(4096, "symbol"); + var voidType = createIntrinsicType(16384, "void"); + var neverType = createIntrinsicType(131072, "never"); + var silentNeverType = createIntrinsicType(131072, "never"); + var implicitNeverType = createIntrinsicType(131072, "never"); + var nonPrimitiveType = createIntrinsicType(67108864, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; + var numberOrBigIntType = getUnionType([numberType, bigintType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + emptyJsxObjectType.objectFlags |= 4096; var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -25031,16 +25481,15 @@ var ts; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var markerSuperType = createType(65536); - var markerSubType = createType(65536); + var markerSuperType = createType(262144); + var markerSubType = createType(262144); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(65536); + var markerOtherType = createType(262144); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, false, false); - var resolvingSignaturesArray = [resolvingSignature]; var enumNumberIndexInfo = createIndexInfo(stringType, true); var globals = ts.createSymbolTable(); var amalgamatedDuplicates; @@ -25078,6 +25527,9 @@ var ts; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; var deferredGlobalExtractSymbol; + var deferredGlobalExcludeSymbol; + var deferredGlobalPickSymbol; + var deferredGlobalBigIntType; var allPotentiallyUnusedIdentifiers = ts.createMap(); var flowLoopStart = 0; var flowLoopCount = 0; @@ -25085,6 +25537,7 @@ var ts; var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); + var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -25107,24 +25560,27 @@ var ts; var typeofEQFacts = ts.createMapFromTemplate({ string: 1, number: 2, - boolean: 4, - symbol: 8, - undefined: 16384, - object: 16, - function: 32 + bigint: 4, + boolean: 8, + symbol: 16, + undefined: 65536, + object: 32, + function: 64 }); var typeofNEFacts = ts.createMapFromTemplate({ - string: 128, - number: 256, - boolean: 512, - symbol: 1024, - undefined: 131072, - object: 2048, - function: 4096 + string: 256, + number: 512, + bigint: 1024, + boolean: 2048, + symbol: 4096, + undefined: 524288, + object: 8192, + function: 16384 }); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, + bigint: bigintType, boolean: booleanType, symbol: esSymbolType, undefined: undefinedType @@ -25293,7 +25749,7 @@ var ts; (source.flags | target.flags) & 67108864) { ts.Debug.assert(source !== target); if (!(target.flags & 33554432)) { - target = cloneSymbol(target); + target = cloneSymbol(resolveSymbol(target)); } if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) { target.constEnumOnlyModule = false; @@ -25385,7 +25841,8 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); + var targetSymbol = target.get(id); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -25439,7 +25896,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 277 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 279 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -25485,15 +25942,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 184) { - var errorBindingElement = ts.getAncestor(usage, 184); + if (declaration.kind === 186) { + var errorBindingElement = ts.getAncestor(usage, 186); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 237), usage); } - else if (declaration.kind === 235) { + else if (declaration.kind === 237) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -25501,10 +25958,10 @@ var ts; } return true; } - if (usage.parent.kind === 255 || (usage.parent.kind === 252 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 257 || (usage.parent.kind === 254 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 252 && usage.isExportEquals) { + if (usage.kind === 254 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -25512,9 +25969,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 217: - case 223: + case 219: case 225: + case 227: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } @@ -25532,16 +25989,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 152 && + current.parent.kind === 154 && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32)) { - if (declaration.kind === 154) { + if (declaration.kind === 156) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 152 && !ts.hasModifier(declaration, 32); + var isDeclarationInstanceProperty = declaration.kind === 154 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -25569,11 +26026,11 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 67897832 && lastLocation.kind !== 289) { + if (meaning & result.flags & 67897832 && lastLocation.kind !== 291) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 149 || - lastLocation.kind === 148 + lastLocation.kind === 151 || + lastLocation.kind === 150 : false; } if (meaning & result.flags & 3) { @@ -25584,13 +26041,13 @@ var ts; } else if (result.flags & 1) { useResult = - lastLocation.kind === 149 || + lastLocation.kind === 151 || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 173) { + else if (location.kind === 175) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -25602,13 +26059,13 @@ var ts; } } switch (location.kind) { - case 277: + case 279: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 242: + case 244: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 277 || ts.isAmbientModule(location)) { + if (location.kind === 279 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -25619,7 +26076,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 255)) { + ts.getDeclarationOfKind(moduleExport, 257)) { break; } } @@ -25632,13 +26089,13 @@ var ts; } } break; - case 241: + case 243: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 152: - case 151: + case 154: + case 153: if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -25648,9 +26105,9 @@ var ts; } } break; - case 238: - case 207: - case 239: + case 240: + case 209: + case 241: if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -25662,7 +26119,7 @@ var ts; } break loop; } - if (location.kind === 207 && meaning & 32) { + if (location.kind === 209 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -25670,8 +26127,8 @@ var ts; } } break; - case 209: - if (lastLocation === location.expression && location.parent.token === 85) { + case 211: + if (lastLocation === location.expression && location.parent.token === 86) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832))) { if (nameNotFoundMessage) { @@ -25681,28 +26138,28 @@ var ts; } } break; - case 147: + case 149: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 239) { + if (ts.isClassLike(grandparent) || grandparent.kind === 241) { if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 154: - case 153: - case 155: case 156: + case 155: case 157: - case 237: - case 195: + case 158: + case 159: + case 239: + case 197: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 194: + case 196: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -25715,16 +26172,16 @@ var ts; } } break; - case 150: - if (location.parent && location.parent.kind === 149) { + case 152: + if (location.parent && location.parent.kind === 151) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { location = location.parent; } break; - case 302: - case 295: + case 304: + case 297: location = ts.getJSDocHost(location); break; } @@ -25739,7 +26196,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 277); + ts.Debug.assert(lastLocation.kind === 279); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -25797,8 +26254,7 @@ var ts; } } if (result && isInExternalModule && (meaning & 67220415) === 67220415 && !(originalLocation.flags & 2097152)) { - var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 245) { + if (ts.some(result.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } @@ -25807,12 +26263,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 237: - case 238: case 239: - case 241: case 240: + case 241: + case 243: case 242: + case 244: return true; default: return false; @@ -25824,7 +26280,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 148) { + if (decl.kind === 150) { 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)); @@ -25872,10 +26328,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 71: - case 187: + case 72: + case 189: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 209: + case 211: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -25940,7 +26396,7 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 243) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -25971,13 +26427,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 246: - return node; case 248: + return node; + case 250: return node.parent; - case 249: - return node.parent.parent; case 251: + return node.parent.parent; + case 253: return node.parent.parent.parent; default: return undefined; @@ -25987,7 +26443,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 257) { + if (node.moduleReference.kind === 259) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -26146,20 +26602,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 246: - return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); case 248: + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); + case 250: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 249: - return getTargetOfNamespaceImport(node, dontRecursivelyResolve); case 251: + return getTargetOfNamespaceImport(node, dontRecursivelyResolve); + case 253: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 255: + case 257: return getTargetOfExportSpecifier(node, 67220415 | 67897832 | 1920, dontRecursivelyResolve); - case 252: - case 202: + case 254: + case 204: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 245: + case 247: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -26213,10 +26669,10 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 252) { + if (node.kind === 254) { checkExpressionCached(node.expression); } - else if (node.kind === 255) { + else if (node.kind === 257) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -26225,14 +26681,14 @@ var ts; } } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { - if (entityName.kind === 71 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 72 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 71 || entityName.parent.kind === 146) { + if (entityName.kind === 72 || entityName.parent.kind === 148) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 246); + ts.Debug.assert(entityName.parent.kind === 248); return resolveEntityName(entityName, 67220415 | 67897832 | 1920, false, dontResolveAlias); } } @@ -26245,7 +26701,7 @@ var ts; } var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 67220415 : 0); var symbol; - if (name.kind === 71) { + if (name.kind === 72) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name).escapedText); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true); @@ -26253,9 +26709,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 || name.kind === 187) { - var left = name.kind === 146 ? name.left : name.expression; - var right = name.kind === 146 ? name.right : name.name; + else if (name.kind === 148 || name.kind === 189) { + var left = name.kind === 148 ? name.left : name.expression; + var right = name.kind === 148 ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -26330,6 +26786,9 @@ var ts; } function getDeclarationOfJSPrototypeContainer(symbol) { var decl = symbol.parent.valueDeclaration; + if (!decl) { + return undefined; + } var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) : ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) : undefined; @@ -26441,10 +26900,15 @@ var ts; return getPackagesSet().has(ts.getTypesPackageName(packageName)); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias), moduleSymbol)) || moduleSymbol; + if (moduleSymbol) { + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias); + var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + return getMergedSymbol(exported) || moduleSymbol; + } + return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || moduleSymbol.exports.size === 1) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) { return exported; } var merged = cloneSymbol(exported); @@ -26462,7 +26926,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 277)) { + if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 279)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -26529,7 +26993,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 32764 ? undefined : getPropertyOfType(type, memberName); + return type.flags & 131068 ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : @@ -26660,7 +27124,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 155 && ts.nodeIsPresent(member.body)) { + if (member.kind === 157 && ts.nodeIsPresent(member.body)) { return member; } } @@ -26683,7 +27147,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(131072); + var type = createType(524288); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -26733,11 +27197,11 @@ var ts; } } switch (location.kind) { - case 277: + case 279: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 242: + case 244: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -26787,7 +27251,7 @@ var ts; && symbolFromSymbolTable.escapedName !== "default" && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 255))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 257))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -26816,7 +27280,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 257)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -26830,10 +27294,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 152: case 154: case 156: - case 157: + case 158: + case 159: continue; default: return false; @@ -26921,10 +27385,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 277 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 279 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -26964,13 +27428,13 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 165 || + if (entityName.parent.kind === 167 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 147) { + entityName.parent.kind === 149) { meaning = 67220415 | 1048576; } - else if (entityName.kind === 146 || entityName.kind === 187 || - entityName.parent.kind === 246) { + else if (entityName.kind === 148 || entityName.kind === 189 || + entityName.parent.kind === 248) { meaning = 1920; } else { @@ -27015,15 +27479,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144) { - sigOutput = kind === 1 ? 164 : 163; + sigOutput = kind === 1 ? 166 : 165; } else { - sigOutput = kind === 1 ? 159 : 158; + sigOutput = kind === 1 ? 161 : 160; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 | 512); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4, sig, sourceFile, writer); + printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); return writer; } } @@ -27087,7 +27551,8 @@ var ts; getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) } : undefined }, encounteredError: false, - visitedSymbols: undefined, + visitedTypes: undefined, + symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; @@ -27111,48 +27576,55 @@ var ts; } if (type.flags & 1) { context.approximateLength += 3; - return ts.createKeywordTypeNode(119); + return ts.createKeywordTypeNode(120); } if (type.flags & 2) { - return ts.createKeywordTypeNode(142); + return ts.createKeywordTypeNode(143); } if (type.flags & 4) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137); + return ts.createKeywordTypeNode(138); } if (type.flags & 8) { context.approximateLength += 6; - return ts.createKeywordTypeNode(134); + return ts.createKeywordTypeNode(135); + } + if (type.flags & 64) { + context.approximateLength += 6; + return ts.createKeywordTypeNode(146); } if (type.flags & 16) { context.approximateLength += 7; - return ts.createKeywordTypeNode(122); + return ts.createKeywordTypeNode(123); } - if (type.flags & 512 && !(type.flags & 262144)) { + if (type.flags & 1024 && !(type.flags & 1048576)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToName(parentSymbol, context, 67897832, false); - var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(enumLiteralName, undefined); + var parentName = symbolToTypeNode(parentSymbol, context, 67897832); + var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type + ? parentName + : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), undefined)); + return enumLiteralName; } - if (type.flags & 544) { - var name = symbolToName(type.symbol, context, 67897832, false); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(name, undefined); + if (type.flags & 1056) { + return symbolToTypeNode(type.symbol, context, 67897832); } - if (type.flags & 64) { + if (type.flags & 128) { context.approximateLength += (type.value.length + 2); return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216)); } - if (type.flags & 128) { + if (type.flags & 256) { context.approximateLength += (("" + type.value).length); return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 256) { + if (type.flags & 2048) { + context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; + return ts.createLiteralTypeNode((ts.createLiteral(type.value))); + } + if (type.flags & 512) { context.approximateLength += type.intrinsicName.length; return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 2048) { + if (type.flags & 8192) { if (!(context.flags & 1048576)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; @@ -27163,33 +27635,33 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(141, ts.createKeywordTypeNode(138)); - } - if (type.flags & 4096) { - context.approximateLength += 4; - return ts.createKeywordTypeNode(105); - } - if (type.flags & 8192) { - context.approximateLength += 9; - return ts.createKeywordTypeNode(140); + return ts.createTypeOperatorNode(142, ts.createKeywordTypeNode(139)); } if (type.flags & 16384) { context.approximateLength += 4; - return ts.createKeywordTypeNode(95); + return ts.createKeywordTypeNode(106); } if (type.flags & 32768) { + context.approximateLength += 9; + return ts.createKeywordTypeNode(141); + } + if (type.flags & 65536) { + context.approximateLength += 4; + return ts.createKeywordTypeNode(96); + } + if (type.flags & 131072) { context.approximateLength += 5; - return ts.createKeywordTypeNode(131); + return ts.createKeywordTypeNode(132); } - if (type.flags & 1024) { + if (type.flags & 4096) { context.approximateLength += 6; - return ts.createKeywordTypeNode(138); + return ts.createKeywordTypeNode(139); } - if (type.flags & 16777216) { + if (type.flags & 67108864) { context.approximateLength += 6; - return ts.createKeywordTypeNode(135); + return ts.createKeywordTypeNode(136); } - if (type.flags & 65536 && type.isThisType) { + if (type.flags & 262144 && type.isThisType) { if (context.flags & 4194304) { if (!context.encounteredError && !(context.flags & 32768)) { context.encounteredError = true; @@ -27203,16 +27675,16 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4) { - ts.Debug.assert(!!(type.flags & 131072)); + ts.Debug.assert(!!(type.flags & 524288)); return typeReferenceToTypeNode(type); } - if (type.flags & 65536 || objectFlags & 3) { - if (type.flags & 65536 && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 || objectFlags & 3) { + if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined)); } if (context.flags & 4 && - type.flags & 65536 && + type.flags & 262144 && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && @@ -27231,14 +27703,14 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67897832, typeArgumentNodes); } - if (type.flags & (262144 | 524288)) { - var types = type.flags & 262144 ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 | 2097152)) { + var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 ? 171 : 172, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 173 : 174, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -27249,22 +27721,22 @@ var ts; } } if (objectFlags & (16 | 32)) { - ts.Debug.assert(!!(type.flags & 131072)); + ts.Debug.assert(!!(type.flags & 524288)); return createAnonymousTypeNode(type); } - if (type.flags & 1048576) { + if (type.flags & 4194304) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 2097152) { + if (type.flags & 8388608) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 4194304) { + if (type.flags & 16777216) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -27275,12 +27747,12 @@ var ts; context.approximateLength += 15; return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 8388608) { + if (type.flags & 33554432) { return typeToTypeNodeHelper(type.typeVariable, context); } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 131072)); + ts.Debug.assert(!!(type.flags & 524288)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -27297,6 +27769,7 @@ var ts; return ts.setEmitFlags(mappedTypeNode, 1); } function createAnonymousTypeNode(type) { + var typeId = "" + type.id; var symbol = type.symbol; var id; if (symbol) { @@ -27306,28 +27779,44 @@ var ts; var isInstanceType = type === getInferredClassType(symbol) ? 67897832 : 67220415; return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 209 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67220415); } - else if (context.visitedSymbols && context.visitedSymbols.has(id)) { + else if (context.visitedTypes && context.visitedTypes.has(typeId)) { var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { return symbolToTypeNode(typeAlias, context, 67897832); } else { context.approximateLength += 3; - return ts.createKeywordTypeNode(119); + if (!(context.flags & 1)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined); + } + return ts.createKeywordTypeNode(120); } } else { - if (!context.visitedSymbols) { - context.visitedSymbols = ts.createMap(); + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); } - context.visitedSymbols.set(id, true); + if (!context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + context.approximateLength += 3; + if (!(context.flags & 1)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined); + } + return ts.createKeywordTypeNode(120); + } + context.symbolDepth.set(id, depth + 1); + context.visitedTypes.set(typeId, true); var result = createTypeNodeFromObjectType(type); - context.visitedSymbols.delete(id); + context.visitedTypes.delete(typeId); + context.symbolDepth.set(id, depth); return result; } } @@ -27340,10 +27829,10 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 277 || declaration.parent.kind === 243; + return declaration.parent.kind === 279 || declaration.parent.kind === 245; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - return (!!(context.flags & 4096) || (context.visitedSymbols && context.visitedSymbols.has(id))) && + return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) && (!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); } } @@ -27360,12 +27849,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 165, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 164, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 166, context); return signatureNode; } } @@ -27490,11 +27979,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 160, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 159, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 161, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 ? @@ -27545,12 +28034,12 @@ var ts; var propertyName = symbolToName(propertySymbol, context, 67220415, true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(55) : undefined; + var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(56) : undefined; if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length) { var signatures = getSignaturesOfType(propertyType, 0); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 155, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -27562,9 +28051,9 @@ var ts; else { var savedFlags = context.flags; context.flags |= !!(ts.getCheckFlags(propertySymbol) & 2048) ? 33554432 : 0; - var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(119); + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(120); context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(132)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(133)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -27613,14 +28102,14 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 137 : 134); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 138 : 135); var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); if (!indexInfo.type && !(context.flags & 2097152)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(132)] : undefined, [indexingParameter], typeNode); + return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(133)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -27631,7 +28120,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 157); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -27650,12 +28139,12 @@ var ts; returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256) { - if (returnTypeNode && returnTypeNode.kind === 119) { + if (returnTypeNode && returnTypeNode.kind === 120) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(119); + returnTypeNode = ts.createKeywordTypeNode(120); } context.approximateLength += 3; return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -27684,9 +28173,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 297); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -27695,16 +28184,16 @@ var ts; var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192; - var dotDotDotToken = isRest ? ts.createToken(24) : undefined; + var dotDotDotToken = isRest ? ts.createToken(25) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 71 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : - parameterDeclaration.name.kind === 146 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : + parameterDeclaration.name.kind === 72 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : + parameterDeclaration.name.kind === 148 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096; - var questionToken = isOptional ? ts.createToken(55) : undefined; + var questionToken = isOptional ? ts.createToken(56) : undefined; var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; return parameterNode; @@ -27716,7 +28205,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 184) { + if (clone.kind === 186) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); @@ -27804,7 +28293,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 277); + var file = ts.getDeclarationOfKind(symbol, 279); if (file && file.moduleName !== undefined) { return file.moduleName; } @@ -27996,10 +28485,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 24576)) { - if (t.flags & (256 | 512)) { - var baseType = t.flags & 256 ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 262144) { + if (!(t.flags & 98304)) { + if (t.flags & (512 | 1024)) { + var baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -28011,9 +28500,9 @@ var ts; result.push(t); } } - if (flags & 16384) + if (flags & 65536) result.push(nullType); - if (flags & 8192) + if (flags & 32768) result.push(undefinedType); return result || types; } @@ -28028,8 +28517,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175; }); - if (node.kind === 240) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 177; }); + if (node.kind === 242) { return getSymbolOfNode(node); } } @@ -28037,11 +28526,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 243 && + node.parent.kind === 245 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 277 || ts.isAmbientModule(location); + return location.kind === 279 || ts.isAmbientModule(location); } function getNameOfSymbolAsWritten(symbol, context) { if (context && symbol.escapedName === "default" && !(context.flags & 16384) && @@ -28054,27 +28543,30 @@ var ts; var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { + if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + return ts.symbolName(symbol); + } return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 235) { + if (declaration.parent && declaration.parent.kind === 237) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 207: - case 194: - case 195: + case 209: + case 196: + case 197: if (context && !context.encounteredError && !(context.flags & 131072)) { context.encounteredError = true; } - return declaration.kind === 207 ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 209 ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 64 && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 128 && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34) + "\""; } - if (nameType && nameType.flags & 2048) { + if (nameType && nameType.flags & 8192) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -28091,66 +28583,66 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 295: - case 302: + case 297: + case 304: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 184: + case 186: return isDeclarationVisible(node.parent.parent); - case 235: + case 237: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 242: - case 238: - case 239: + case 244: case 240: - case 237: case 241: - case 246: + case 242: + case 239: + case 243: + case 248: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 246 && parent.kind !== 277 && parent.flags & 4194304)) { + !(node.kind !== 248 && parent.kind !== 279 && parent.flags & 4194304)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 152: - case 151: - case 156: - case 157: case 154: case 153: + case 158: + case 159: + case 156: + case 155: if (ts.hasModifier(node, 8 | 16)) { return false; } - case 155: - case 159: - case 158: + case 157: + case 161: case 160: - case 149: - case 243: - case 163: - case 164: - case 166: case 162: - case 167: - case 168: - case 171: - case 172: - case 175: - return isDeclarationVisible(node.parent); - case 248: - case 249: - case 251: - return false; - case 148: - case 277: + case 151: case 245: + case 165: + case 166: + case 168: + case 164: + case 169: + case 170: + case 173: + case 174: + case 177: + return isDeclarationVisible(node.parent); + case 250: + case 251: + case 253: + return false; + case 150: + case 279: + case 247: return true; - case 252: + case 254: return false; default: return false; @@ -28159,10 +28651,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 252) { + if (node.parent && node.parent.kind === 254) { exportSymbol = resolveName(node, node.escapedText, 67220415 | 67897832 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 255) { + else if (node.parent.kind === 257) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 | 67897832 | 1920 | 2097152); } var result; @@ -28243,12 +28735,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 235: - case 236: + case 237: + case 238: + case 253: + case 252: case 251: case 250: - case 249: - case 248: return false; default: return true; @@ -28271,28 +28763,36 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 147 && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 149 && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 24576); }); - if (source.flags & 32768) { + source = filterType(source, function (t) { return !(t.flags & 98304); }); + if (source.flags & 131072) { return emptyObjectType; } - if (source.flags & 262144) { + if (source.flags & 1048576) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } - var members = ts.createSymbolTable(); - var names = ts.createUnderscoreEscapedMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; - names.set(ts.getTextOfPropertyName(name), true); + var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); + if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) { + if (omitKeyType.flags & 131072) { + return source; + } + var pickTypeAlias = getGlobalPickSymbol(); + var excludeTypeAlias = getGlobalExcludeSymbol(); + if (!pickTypeAlias || !excludeTypeAlias) { + return errorType; + } + var pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]); + return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]); } - for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { - var prop = _b[_a]; - if (!names.has(prop.escapedName) + var members = ts.createSymbolTable(); + for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576), omitKeyType) && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16)) && isSpreadableProperty(prop)) { - members.set(prop.escapedName, getNonReadonlySymbol(prop)); + members.set(prop.escapedName, getSpreadSymbol(prop)); } } var stringIndexInfo = getIndexInfoOfType(source, 0); @@ -28311,8 +28811,11 @@ var ts; if (isTypeAny(parentType)) { return parentType; } + if (strictNullChecks && declaration.flags & 4194304 && ts.isParameterDeclaration(declaration)) { + parentType = getNonNullableType(parentType); + } var type; - if (pattern.kind === 182) { + if (pattern.kind === 184) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -28329,48 +28832,9 @@ var ts; } else { var name = declaration.propertyName || declaration.name; - var isLate = isLateBindableName(name); - var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); - if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { - var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 3072)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); - } - return anyType; - } - var indexerType = isTypeAssignableToKind(exprType, 168) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); - if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { - if (getIndexTypeOfType(parentType, 1)) { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); - } - else { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(parentType)); - } - } - return indexerType || anyType; - } - var nameType = isLate ? checkComputedPropertyName(name) : undefined; - var text = isLate ? getLateBoundNameFromType(nameType) : - isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : - ts.getTextOfPropertyName(name); - if (strictNullChecks && declaration.flags & 4194304 && ts.isParameterDeclaration(declaration)) { - parentType = getNonNullableType(parentType); - } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); - } - return anyType; - } - var declaredType = getConstraintForLocation(getTypeOfPropertyOfType(parentType, text), declaration.name); - type = declaredType && getFlowTypeOfReference(declaration, declaredType) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); - if (!type) { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return errorType; - } + var exprType = getLiteralTypeFromPropertyName(name); + var declaredType = checkIndexedAccessIndexType(getIndexedAccessType(parentType, exprType, name), name); + type = getFlowTypeOfReference(declaration, getConstraintForLocation(declaredType, declaration.name)); } } else { @@ -28397,8 +28861,8 @@ var ts; } } } - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 8192)) { - type = getTypeWithFacts(type, 131072); + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768)) { + type = getTypeWithFacts(type, 524288); } return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkDeclarationInitializer(declaration)], 2) : @@ -28413,22 +28877,22 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 95 || expr.kind === 71 && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 96 || expr.kind === 72 && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 185 && expr.elements.length === 0; + return expr.kind === 187 && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (65536 | 1048576) ? getExtractStringType(indexType) : stringType; + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 226) { + var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); + return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -28442,7 +28906,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 235 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 237 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -28451,10 +28915,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 149) { + if (declaration.kind === 151) { var func = declaration.parent; - if (func.kind === 157 && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156); + if (func.kind === 159 && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 158); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -28510,7 +28974,7 @@ var ts; var types; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - var expression = ts.isBinaryExpression(declaration) ? declaration : + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { @@ -28525,9 +28989,11 @@ var ts; definedInMethod = true; } } - jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + if (!ts.isCallExpression(expression)) { + jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } if (!jsdocType) { - (types || (types = [])).push(ts.isBinaryExpression(expression) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } var type = jsdocType; @@ -28540,11 +29006,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 | 134217728)); }) ? constructorTypes : types; + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(98304 | 134217728)); }) ? constructorTypes : types; type = getUnionType(sourceTypes, 2); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~24576); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -28584,8 +29050,33 @@ var ts; return declaredType; } function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) { + if (ts.isCallExpression(expression)) { + if (resolvedSymbol) { + return getTypeOfSymbol(resolvedSymbol); + } + var objectLitType = checkExpressionCached(expression.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + return valueType; + } + var getFunc = getTypeOfPropertyOfType(objectLitType, "get"); + if (getFunc) { + var getSig = getSingleCallSignature(getFunc); + if (getSig) { + return getReturnTypeOfSignature(getSig); + } + } + var setFunc = getTypeOfPropertyOfType(objectLitType, "set"); + if (setFunc) { + var setSig = getSingleCallSignature(setFunc); + if (setSig) { + return getTypeOfFirstParameterOfSignature(setSig); + } + } + return anyType; + } var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 131072 && + if (type.flags & 524288 && kind === 2 && symbol.escapedName === "export=") { var exportedType_1 = resolveStructuredTypeMembers(type); @@ -28617,9 +29108,9 @@ var ts; } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, false); - return thisContainer.kind === 155 || - thisContainer.kind === 237 || - (thisContainer.kind === 194 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 157 || + thisContainer.kind === 239 || + (thisContainer.kind === 196 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -28687,7 +29178,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 184 && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 186 && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } @@ -28703,7 +29194,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 182 + return pattern.kind === 184 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -28715,7 +29206,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (type.flags & 2048 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -28730,7 +29221,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 149 ? root.parent : root; + var memberDeclaration = root.kind === 151 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -28766,12 +29257,12 @@ var ts; return emptyObjectType; } var type_1 = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression)); - if (type_1.flags & 131072) { + if (type_1.flags & 524288) { return getRegularTypeOfObjectLiteral(type_1); } return type_1; } - if (declaration.kind === 252) { + if (declaration.kind === 254) { return widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } if (!pushTypeResolution(symbol, 0)) { @@ -28779,7 +29270,7 @@ var ts; } var type; if (ts.isInJSFile(declaration) && - (ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { type = getWidenedTypeFromAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) @@ -28815,6 +29306,12 @@ var ts; || ts.isBindingElement(declaration)) { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); } + else if (ts.isEnumDeclaration(declaration)) { + type = getTypeOfFuncClassEnumModule(symbol); + } + else if (ts.isEnumMember(declaration)) { + type = getTypeOfEnumMember(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } @@ -28825,7 +29322,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 156) { + if (accessor.kind === 158) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -28852,8 +29349,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 156); - var setter = ts.getDeclarationOfKind(symbol, 157); + var getter = ts.getDeclarationOfKind(symbol, 158); + var setter = ts.getDeclarationOfKind(symbol, 159); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -28892,7 +29389,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 156); + var getter_1 = ts.getDeclarationOfKind(symbol, 158); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -28900,7 +29397,7 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 2162688 ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -28931,8 +29428,8 @@ var ts; if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 202 || - declaration.kind === 187 && declaration.parent.kind === 202) { + else if (declaration.kind === 204 || + declaration.kind === 189 && declaration.parent.kind === 204) { return getWidenedTypeFromAssignmentDeclaration(symbol); } else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -29036,7 +29533,7 @@ var ts; var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 524288) { + else if (type.flags & 2097152) { return ts.some(type.types, check); } return false; @@ -29056,51 +29553,51 @@ var ts; return undefined; } switch (node.kind) { - case 238: - case 207: - case 239: - case 158: - case 159: - case 153: - case 163: - case 164: - case 287: - case 237: - case 154: - case 194: - case 195: case 240: - case 301: - case 302: - case 295: - case 179: - case 173: + case 209: + case 241: + case 160: + case 161: + case 155: + case 165: + case 166: + case 289: + case 239: + case 156: + case 196: + case 197: + case 242: + case 303: + case 304: + case 297: + case 181: + case 175: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 179) { + if (node.kind === 181) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 173) { + else if (node.kind === 175) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 238 || node.kind === 207 || node.kind === 239) && + (node.kind === 240 || node.kind === 209 || node.kind === 241) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 241); return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 239 || - node.kind === 238 || - node.kind === 207 || + if (node.kind === 241 || + node.kind === 240 || + node.kind === 209 || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -29123,7 +29620,7 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { return true; } - if (type.flags & 2162688) { + if (type.flags & 8650752) { var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } @@ -29158,7 +29655,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); checkExpression(extended.expression); } - if (baseConstructorType.flags & (131072 | 524288)) { + if (baseConstructorType.flags & (524288 | 2097152)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { @@ -29166,7 +29663,18 @@ var ts; return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + if (baseConstructorType.flags & 262144) { + var constraint = getConstraintFromTypeParameter(baseConstructorType); + var ctorReturn = unknownType; + if (constraint) { + var ctorSig = getSignaturesOfType(constraint, 1); + if (ctorSig[0]) { + ctorReturn = getReturnTypeOfSignature(ctorSig[0]); + } + } + addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; @@ -29195,7 +29703,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (131072 | 524288 | 1))) { + if (!(baseConstructorType.flags & (524288 | 2097152 | 1))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -29248,14 +29756,14 @@ var ts; return true; } function isValidBaseType(type) { - return !!(type.flags & (131072 | 16777216 | 1)) && !isGenericMappedType(type) || - !!(type.flags & 524288) && ts.every(type.types, isValidBaseType); + return !!(type.flags & (524288 | 67108864 | 1)) && !isGenericMappedType(type) || + !!(type.flags & 2097152) && ts.every(type.types, isValidBaseType); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 241 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -29284,7 +29792,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239) { + if (declaration.kind === 241) { if (declaration.flags & 64) { return false; } @@ -29320,7 +29828,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536); + type.thisType = createType(262144); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -29335,7 +29843,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 240; + return ts.isJSDocTypeAlias(d) || d.kind === 242; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -29356,10 +29864,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 9) { + if (expr.kind === 10) { return true; } - else if (expr.kind === 202) { + else if (expr.kind === 204) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -29370,15 +29878,15 @@ var ts; return !(member.flags & 4194304); } switch (expr.kind) { - case 9: + case 10: case 8: return true; - case 200: - return expr.operator === 38 && - expr.operand.kind === 8; - case 71: - return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); case 202: + return expr.operator === 39 && + expr.operand.kind === 8; + case 72: + return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); + case 204: return isStringConcatExpression(expr); default: return false; @@ -29392,10 +29900,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241) { + if (declaration.kind === 243) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 9) { + if (member.initializer && member.initializer.kind === 10) { return links.enumKind = 1; } if (!isLiteralEnumMember(member)) { @@ -29407,7 +29915,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 : 1; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 512 && !(type.flags & 262144) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 && !(type.flags & 1048576) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -29419,7 +29927,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241) { + if (declaration.kind === 243) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getFreshTypeOfLiteralType(getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member))); @@ -29430,8 +29938,8 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined); - if (enumType_1.flags & 262144) { - enumType_1.flags |= 512; + if (enumType_1.flags & 1048576) { + enumType_1.flags |= 1024; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; @@ -29454,7 +29962,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(65536); + var type = createType(262144); type.symbol = symbol; links.declaredType = type; } @@ -29493,22 +30001,23 @@ var ts; } function isThislessType(node) { switch (node.kind) { - case 119: - case 142: - case 137: - case 134: - case 122: + case 120: + case 143: case 138: case 135: - case 105: - case 140: - case 95: - case 131: - case 180: + case 146: + case 123: + case 139: + case 136: + case 106: + case 141: + case 96: + case 132: + case 182: return true; - case 167: + case 169: return isThislessType(node.elementType); - case 162: + case 164: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -29524,7 +30033,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 155 || (!!returnType && isThislessType(returnType))) && + return (node.kind === 157 || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -29533,12 +30042,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 152: - case 151: - return isThislessVariableLikeDeclaration(declaration); case 154: case 153: + return isThislessVariableLikeDeclaration(declaration); + case 156: case 155: + case 157: return isThislessFunctionLikeDeclaration(declaration); } } @@ -29576,7 +30085,7 @@ var ts; return type; } function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 2240); + return !!(type.flags & 8576); } function isLateBindableName(node) { return ts.isComputedPropertyName(node) @@ -29599,10 +30108,10 @@ var ts; return ts.isDynamicName(node) && !isLateBindableName(node); } function getLateBoundNameFromType(type) { - if (type.flags & 2048) { + if (type.flags & 8192) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & (64 | 128)) { + if (type.flags & (128 | 256)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -29710,7 +30219,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 524288) { + else if (type.flags & 2097152) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -29838,7 +30347,7 @@ var ts; function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { var s = signatureList_1[_i]; - if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { + if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) { return s; } } @@ -29865,8 +30374,7 @@ var ts; } return result; } - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + function getUnionSignatures(signatureLists) { var result; for (var i = 0; i < signatureLists.length; i++) { for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { @@ -29907,8 +30415,8 @@ var ts; return createIndexInfo(getUnionType(indexTypes, 2), isAnyReadonly); } function resolveUnionTypeMembers(type) { - var callSignatures = getUnionSignatures(type.types, 0); - var constructSignatures = getUnionSignatures(type.types, 1); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 0); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1); })); var stringIndexInfo = getUnionIndexInfo(type.types, 0); var numberIndexInfo = getUnionIndexInfo(type.types, 1); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -29993,7 +30501,7 @@ var ts; if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (131072 | 524288 | 2162688)) { + if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -30022,7 +30530,7 @@ var ts; var modifiers = getMappedTypeModifiers(type.mappedType); var readonlyMask = modifiers & 1 ? false : true; var optionalMask = modifiers & 4 ? 0 : 16777216; - var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType), readonlyMask && indexInfo.isReadonly); + var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly); var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -30032,6 +30540,7 @@ var ts; inferredProp.nameType = prop.nameType; inferredProp.propertyType = getTypeOfSymbol(prop); inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -30046,11 +30555,11 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 64 : 2240; + var include = keyofStringsOnly ? 128 : 8576; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; - addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include)); + addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); } if (modifiersType.flags & 1 || getIndexInfoOfType(modifiersType, 0)) { addMemberForKeyType(stringType); @@ -30060,15 +30569,14 @@ var ts; } } else { - var keyType = constraintType.flags & 14745600 ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 1048576 ? getIndexType(getApparentType(keyType.type)) : keyType; + var iterationType = constraintType.flags & 4194304 ? getIndexType(getApparentType(constraintType.type)) : constraintType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); function addMemberForKeyType(t) { var templateMapper = combineTypeMappers(type.mapper, createTypeMapper([typeParameter], [t])); var propType = instantiateType(templateType, templateMapper); - if (t.flags & 2240) { + if (t.flags & 8576) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 || @@ -30077,7 +30585,7 @@ var ts; !(templateModifiers & 2) && modifiersProp && isReadonlySymbol(modifiersProp)); var prop = createSymbol(4 | (isOptional ? 16777216 : 0), propName, isReadonly ? 8 : 0); prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 ? getTypeWithFacts(propType, 131072) : + strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 ? getTypeWithFacts(propType, 524288) : propType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; @@ -30113,8 +30621,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 177 && - constraintDeclaration.operator === 128; + return constraintDeclaration.kind === 179 && + constraintDeclaration.operator === 129; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -30124,16 +30632,16 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 65536 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 262144 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 38 ? 2 : 1 : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 38 ? 8 : 4 : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 ? 2 : 1 : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 39 ? 8 : 4 : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -30152,7 +30660,7 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072) { + if (type.flags & 524288) { if (type.objectFlags & 4) { resolveTypeReferenceMembers(type); } @@ -30169,23 +30677,23 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 262144) { + else if (type.flags & 1048576) { resolveUnionTypeMembers(type); } - else if (type.flags & 524288) { + else if (type.flags & 2097152) { resolveIntersectionTypeMembers(type); } } return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 131072) { + if (type.flags & 524288) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 131072) { + if (type.flags & 524288) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -30207,7 +30715,7 @@ var ts; } } } - if (type.flags & 262144) { + if (type.flags & 1048576) { break; } } @@ -30217,12 +30725,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 786432 ? + return type.flags & 3145728 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { - return obj.properties.some(function (property) { + var list = obj.properties; + return list.some(function (property) { var name = property.name && ts.getTextOfPropertyName(property.name); var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && typeIsLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); @@ -30230,7 +30739,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 262144)) { + if (!(unionType.flags & 1048576)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -30248,9 +30757,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 65536 ? getConstraintOfTypeParameter(type) : - type.flags & 2097152 ? getConstraintOfIndexedAccess(type) : - type.flags & 4194304 ? getConstraintOfConditionalType(type) : + return type.flags & 262144 ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -30270,7 +30779,11 @@ var ts; function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 8388608 ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = !(rootTrueType.flags & 33554432) + ? rootTrueType + : (rootTrueType.substitute).flags & 3 + ? rootTrueType.typeVariable + : getIntersectionType([rootTrueType.substitute, rootTrueType.typeVariable]); type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -30282,7 +30795,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 32768)) { + if (!(instantiated.flags & 131072)) { return instantiated; } } @@ -30297,19 +30810,19 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 15794176) { + if (t.flags & 63176704) { var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (65536 | 1048576 | 4194304)) { + while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) { constraint = getConstraintOfType(constraint); } if (constraint) { - if (!(constraint.flags & 262144)) { + if (!(constraint.flags & 1048576)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 16809468) { + else if (t.flags & 67238908) { hasDisjointDomainType = true; } } @@ -30317,7 +30830,7 @@ var ts; if (hasDisjointDomainType) { for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 16809468) { + if (t.flags & 67238908) { constraints = ts.append(constraints, t); } } @@ -30327,11 +30840,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (14745600 | 786432)) { + if (type.flags & (58982400 | 3145728)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 1048576 ? keyofConstraintType : undefined; + return type.flags & 4194304 ? keyofConstraintType : undefined; } function getBaseConstraintOrType(type) { return getBaseConstraintOfType(type) || type; @@ -30367,13 +30880,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 65536) { + if (t.flags & 262144) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 786432) { + if (t.flags & 3145728) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -30383,24 +30896,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 262144 && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 524288 && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 1048576) { + if (t.flags & 4194304) { return keyofConstraintType; } - if (t.flags & 2097152) { + if (t.flags & 8388608) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType, undefined, errorType) : undefined; return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 4194304) { + if (t.flags & 16777216) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 8388608) { + if (t.flags & 33554432) { return getBaseConstraint(t.substitute); } return t; @@ -30454,21 +30967,22 @@ var ts; return type; } function getApparentType(type) { - var t = type.flags & 15794176 ? getBaseConstraintOfType(type) || emptyObjectType : type; + var t = type.flags & 63176704 ? getBaseConstraintOfType(type) || emptyObjectType : type; return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) : - t.flags & 524288 ? getApparentTypeOfIntersectionType(t) : - t.flags & 68 ? globalStringType : - t.flags & 168 ? globalNumberType : - t.flags & 272 ? globalBooleanType : - t.flags & 3072 ? getGlobalESSymbolType(languageVersion >= 2) : - t.flags & 16777216 ? emptyObjectType : - t.flags & 1048576 ? keyofConstraintType : - t; + t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) : + t.flags & 132 ? globalStringType : + t.flags & 296 ? globalNumberType : + t.flags & 2112 ? getGlobalBigIntType(languageVersion >= 6) : + t.flags & 528 ? globalBooleanType : + t.flags & 12288 ? getGlobalESSymbolType(languageVersion >= 2) : + t.flags & 67108864 ? emptyObjectType : + t.flags & 4194304 ? keyofConstraintType : + t; } function createUnionOrIntersectionProperty(containingType, name) { var props; var indexTypes; - var isUnion = containingType.flags & 262144; + var isUnion = containingType.flags & 1048576; var excludeModifiers = isUnion ? 24 : 0; var commonFlags = isUnion ? 0 : 16777216; var syntheticFlag = 4; @@ -30566,7 +31080,7 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 131072) { + if (type.flags & 524288) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -30584,13 +31098,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 786432) { + if (type.flags & 3145728) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 917504) { + if (type.flags & 3670016) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } @@ -30600,7 +31114,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 917504) { + if (type.flags & 3670016) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -30648,10 +31162,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJSFile(node) && (node.type && node.type.kind === 286 + return ts.isInJSFile(node) && (node.type && node.type.kind === 288 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -30684,7 +31198,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -30705,27 +31219,29 @@ var ts; } function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); - if (numTypeParameters) { - var numTypeArguments = ts.length(typeArguments); - if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { - if (!typeArguments) { - typeArguments = []; - } - for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - for (var i = numTypeArguments; i < numTypeParameters; i++) { - var mapper = createTypeMapper(typeParameters, typeArguments); - var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { - defaultType = anyType; - } - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - typeArguments.length = typeParameters.length; - } + if (!numTypeParameters) { + return []; } - return typeArguments; + var numTypeArguments = ts.length(typeArguments); + if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { + var result = typeArguments ? typeArguments.slice() : []; + var baseDefaultType_1 = getDefaultTypeArgumentType(isJavaScriptImplicitAny); + var circularityMapper = createTypeMapper(typeParameters, ts.map(typeParameters, function () { return baseDefaultType_1; })); + for (var i = numTypeArguments; i < numTypeParameters; i++) { + result[i] = instantiateType(getConstraintFromTypeParameter(typeParameters[i]) || baseDefaultType_1, circularityMapper); + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, result); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { + defaultType = anyType; + } + result[i] = defaultType ? instantiateType(defaultType, mapper) : baseDefaultType_1; + } + result.length = typeParameters.length; + return result; + } + return typeArguments && typeArguments.slice(); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); @@ -30757,7 +31273,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 180) { + if (type && type.kind === 182) { hasLiteralTypes = true; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -30769,16 +31285,16 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 156 || declaration.kind === 157) && + if ((declaration.kind === 158 || declaration.kind === 159) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 156 ? 157 : 156; + var otherKind = declaration.kind === 158 ? 159 : 158; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 155 ? + var classType = declaration.kind === 157 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -30828,13 +31344,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 71: + case 72: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 152: case 154: case 156: - case 157: - return node.name.kind === 147 + case 158: + case 159: + return node.name.kind === 149 && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -30906,7 +31422,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, func) { var parameterName = node.parameterName; var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 71) { + if (parameterName.kind === 72) { return createIdentifierTypePredicate(parameterName.escapedText, getTypePredicateParameterIndex(func.parameters, parameterName), type); } else { @@ -30916,7 +31432,7 @@ var ts; function getTypePredicateParameterIndex(parameterList, parameter) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 71 && param.name.escapedText === parameter.escapedText) { + if (param.name.kind === 72 && param.name.escapedText === parameter.escapedText) { return i; } } @@ -30956,7 +31472,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 155) { + if (declaration.kind === 157) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -30966,12 +31482,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 156 && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 158 && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 159); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -31038,7 +31554,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 155 || signature.declaration.kind === 159; + var isConstructor = signature.declaration.kind === 157 || signature.declaration.kind === 161; var type = createObjectType(16); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -31052,7 +31568,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 134 : 137; + var syntaxKind = kind === 1 ? 135 : 138; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -31079,7 +31595,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 150); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -31087,9 +31603,9 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 174) { + if (declaration.parent.kind === 176) { var grandParent = declaration.parent.parent; - if (grandParent.kind === 162) { + if (grandParent.kind === 164) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -31106,7 +31622,7 @@ var ts; } } } - else if (grandParent.kind === 149 && grandParent.dotDotDotToken) { + else if (grandParent.kind === 151 && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -31129,7 +31645,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 148); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 150); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -31246,9 +31762,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 162: + case 164: return node.typeName; - case 209: + case 211: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -31287,7 +31803,7 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 65536 ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : + res.flags & 262144 ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } if (!(symbol.flags & 67220415 && isJSDocTypeReference(node))) { @@ -31337,13 +31853,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(8388608); + var result = createType(33554432); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 168 && node.elementTypes.length === 1; + return node.kind === 170 && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -31352,9 +31868,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 289) { + while (node && !ts.isStatement(node) && node.kind !== 291) { var parent = node.parent; - if (parent.kind === 173 && node === parent.trueType) { + if (parent.kind === 175 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -31365,7 +31881,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152) && (node.kind === 162 || node.kind === 181); + return !!(node.flags & 2097152) && (node.kind === 164 || node.kind === 183); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -31423,7 +31939,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 16384) : type; + return strictNullChecks ? getNullableType(type, 65536) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -31460,9 +31976,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 238: - case 239: + case 240: case 241: + case 243: return declaration; } } @@ -31471,7 +31987,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 131072)) { + if (!(type.flags & 524288)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -31547,6 +32063,15 @@ var ts; function getGlobalExtractSymbol() { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288, ts.Diagnostics.Cannot_find_global_type_0)); } + function getGlobalExcludeSymbol() { + return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude", 524288, ts.Diagnostics.Cannot_find_global_type_0)); + } + function getGlobalPickSymbol() { + return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick", 524288, ts.Diagnostics.Cannot_find_global_type_0)); + } + function getGlobalBigIntType(reportErrors) { + return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", 0, reportErrors)) || emptyObjectType; + } function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } @@ -31585,7 +32110,7 @@ var ts; if (arity) { typeParameters = new Array(arity); for (var i = 0; i < arity; i++) { - var typeParameter = typeParameters[i] = createType(65536); + var typeParameter = typeParameters[i] = createType(262144); if (i < maxLength) { var property = createSymbol(4 | (i >= minLength ? 16777216 : 0), "" + i); property.type = typeParameter; @@ -31607,7 +32132,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536); + type.thisType = createType(262144); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -31642,8 +32167,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 170 ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 172 ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 171 && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1) || type; @@ -31681,16 +32206,17 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 27072 && combined & 27072) { + if (t.flags & 109440 && combined & 109440) { return true; } combined |= t.flags; - if (combined & 24576 && combined & (131072 | 16777216) || - combined & 16777216 && combined & (16809468 & ~16777216) || - combined & 68 && combined & (16809468 & ~68) || - combined & 168 && combined & (16809468 & ~168) || - combined & 3072 && combined & (16809468 & ~3072) || - combined & 12288 && combined & (16809468 & ~12288)) { + if (combined & 98304 && combined & (524288 | 67108864) || + combined & 67108864 && combined & (67238908 & ~67108864) || + combined & 132 && combined & (67238908 & ~132) || + combined & 296 && combined & (67238908 & ~296) || + combined & 2112 && combined & (67238908 & ~2112) || + combined & 12288 && combined & (67238908 & ~12288) || + combined & 49152 && combined & (67238908 & ~49152)) { return true; } } @@ -31698,16 +32224,14 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144) { + if (flags & 1048576) { return addTypesToUnion(typeSet, includes, type.types); } - if (!(flags & 32768 || flags & 524288 && isEmptyIntersectionType(type))) { + if (!(flags & 131072 || flags & 2097152 && isEmptyIntersectionType(type))) { includes |= flags & ~939524096; - if (flags & 3) { - if (type === wildcardType) - includes |= 268435456; - } - else if (!strictNullChecks && flags & 24576) { + if (type === wildcardType) + includes |= 268435456; + if (!strictNullChecks && flags & 98304) { if (!(flags & 134217728)) includes |= 134217728; } @@ -31741,11 +32265,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 512) { + if (first.flags & 1024) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 512) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 1024) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -31770,10 +32294,11 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 64 && includes & 4 || - t.flags & 128 && includes & 8 || - t.flags & 2048 && includes & 1024 || - t.flags & 448 && t.flags & 33554432 && containsType(types, t.regularType); + var remove = t.flags & 128 && includes & 4 || + t.flags & 256 && includes & 8 || + t.flags & 2048 && includes & 64 || + t.flags & 8192 && includes & 4096 || + isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -31789,25 +32314,27 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 3) { - return includes & 1 ? includes & 268435456 ? wildcardType : anyType : unknownType; + if (unionReduction !== 0) { + if (includes & 3) { + return includes & 1 ? includes & 268435456 ? wildcardType : anyType : unknownType; + } + switch (unionReduction) { + case 1: + if (includes & 8576 | 512) { + removeRedundantLiteralTypes(typeSet, includes); + } + break; + case 2: + removeSubtypes(typeSet); + break; + } + if (typeSet.length === 0) { + return includes & 65536 ? includes & 134217728 ? nullType : nullWideningType : + includes & 32768 ? includes & 134217728 ? undefinedType : undefinedWideningType : + neverType; + } } - switch (unionReduction) { - case 1: - if (includes & 2240 | 256) { - removeRedundantLiteralTypes(typeSet, includes); - } - break; - case 2: - removeSubtypes(typeSet); - break; - } - if (typeSet.length === 0) { - return includes & 16384 ? includes & 134217728 ? nullType : nullWideningType : - includes & 8192 ? includes & 134217728 ? undefinedType : undefinedWideningType : - neverType; - } - return getUnionTypeFromSortedList(typeSet, includes & 16748579 ? 0 : 67108864, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, !(includes & 66994211), aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -31841,7 +32368,7 @@ var ts; ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex : !ts.isIdentifierTypePredicate(b); } - function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) { + function getUnionTypeFromSortedList(types, primitiveTypesOnly, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { return neverType; } @@ -31851,10 +32378,11 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, 24576); - type = createType(262144 | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, 98304); + type = createType(1048576 | propagatedFlags); unionTypes.set(id, type); type.types = types; + type.primitiveTypesOnly = primitiveTypesOnly; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } @@ -31870,11 +32398,14 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 524288) { + if (flags & 2097152) { return addTypesToIntersection(typeSet, includes, type.types); } - if (ts.getObjectFlags(type) & 16 && isEmptyObjectType(type)) { - includes |= 536870912; + if (isEmptyAnonymousObjectType(type)) { + if (!(includes & 536870912)) { + includes |= 536870912; + typeSet.push(type); + } } else { includes |= flags & ~939524096; @@ -31882,7 +32413,7 @@ var ts; if (type === wildcardType) includes |= 268435456; } - else if ((strictNullChecks || !(flags & 24576)) && !ts.contains(typeSet, type)) { + else if ((strictNullChecks || !(flags & 98304)) && !ts.contains(typeSet, type)) { typeSet.push(type); } } @@ -31900,9 +32431,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 && includes & 64 || - t.flags & 8 && includes & 128 || - t.flags & 1024 && includes & 2048; + var remove = t.flags & 4 && includes & 128 || + t.flags & 8 && includes & 256 || + t.flags & 64 && includes & 2048 || + t.flags & 4096 && includes & 8192; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -31912,10 +32444,11 @@ 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 & 64 ? stringType : - type.flags & 128 ? numberType : - type.flags & 2048 ? esSymbolType : - undefined; + var primitive = type.flags & 128 ? stringType : + type.flags & 256 ? numberType : + type.flags & 2048 ? bigintType : + type.flags & 8192 ? esSymbolType : + undefined; if (!primitive || !containsType(u.types, primitive)) { return false; } @@ -31925,11 +32458,14 @@ var ts; } function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return (t.flags & 67108864) !== 0; }); + var index = ts.findIndex(types, function (t) { return !!(t.flags & 1048576) && t.primitiveTypesOnly; }); + if (index < 0) { + return false; + } var i = index + 1; while (i < types.length) { var t = types[i]; - if (t.flags & 67108864) { + if (t.flags & 1048576 && t.primitiveTypesOnly) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -31953,28 +32489,29 @@ var ts; } } } - types[index] = getUnionTypeFromSortedList(result, 67108864); + types[index] = getUnionTypeFromSortedList(result, true); return true; } function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 32768) { + if (includes & 131072) { return neverType; } if (includes & 1) { return includes & 268435456 ? wildcardType : anyType; } - if (!strictNullChecks && includes & 24576) { - return includes & 8192 ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304) { + return includes & 32768 ? undefinedType : nullType; } - if (includes & 4 && includes & 64 || - includes & 8 && includes & 128 || - includes & 1024 && includes & 2048) { + if (includes & 4 && includes & 128 || + includes & 8 && includes & 256 || + includes & 64 && includes & 2048 || + includes & 4096 && includes & 8192) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 536870912 && !(includes & 131072)) { - typeSet.push(emptyObjectType); + if (includes & 536870912 && includes & 524288) { + ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { return unknownType; @@ -31982,19 +32519,19 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 262144) { - if (includes & 67108864 && intersectUnionsOfPrimitiveTypes(typeSet)) { + if (includes & 1048576) { + if (intersectUnionsOfPrimitiveTypes(typeSet)) { return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 24576); - type = createType(524288 | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 98304); + type = createType(2097152 | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; @@ -32011,7 +32548,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(1048576); + var result = createType(4194304); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -32021,14 +32558,22 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false)); } - function getLiteralTypeFromPropertyName(prop, include) { + function getLiteralTypeFromPropertyName(name) { + return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : + getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); + } + function getBigIntLiteralType(node) { + return getLiteralType({ + negative: false, + base10Value: ts.parsePseudoBigInt(node.text) + }); + } + function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 147 && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : - getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { return type; @@ -32036,8 +32581,8 @@ var ts; } return neverType; } - function getLiteralTypeFromPropertyNames(type, include) { - return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromPropertyName(t, include); })); + function getLiteralTypeFromProperties(type, include) { + return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromProperty(t, include); })); } function getNonEnumNumberIndexInfo(type) { var numberIndexInfo = getIndexInfoOfType(type, 1); @@ -32045,16 +32590,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 262144 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 524288 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 14745600) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 58982400) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromPropertyNames(type, 64) : - getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 | 2048)]) : - getLiteralTypeFromPropertyNames(type, 2240); + stringsOnly ? getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromProperties(type, 128) : + getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 | 8192)]) : + getLiteralTypeFromProperties(type, 8576); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -32065,17 +32610,17 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 32768 ? stringType : indexType; + return indexType.flags & 131072 ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 128: + case 129: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 141: - links.resolvedType = node.type.kind === 138 + case 142: + links.resolvedType = node.type.kind === 139 ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; @@ -32084,7 +32629,7 @@ var ts; return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { - var type = createType(2097152); + var type = createType(8388608); type.objectType = objectType; type.indexType = indexType; return type; @@ -32096,28 +32641,31 @@ var ts; if (ts.getObjectFlags(type) & 16384) { return true; } - if (type.flags & 262144) { + if (type.flags & 1048576) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 524288) { + if (type.flags & 2097152) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 15794176) { + if (type.flags & 63176704) { return isJSLiteralType(getResolvedBaseConstraint(type)); } return false; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol, missingType) { - var accessExpression = accessNode && accessNode.kind === 188 ? accessNode : undefined; - var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - undefined; + var accessExpression = accessNode && accessNode.kind === 190 ? accessNode : undefined; + var propName = isTypeUsableAsLateBoundName(indexType) + ? getLateBoundNameFromType(indexType) + : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) + ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) + : accessNode && ts.isPropertyName(accessNode) + ? ts.getPropertyNameForPropertyNameNode(accessNode) + : undefined; if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 99); + markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 100); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); return missingType; @@ -32133,22 +32681,22 @@ var ts; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; })) { - var indexNode = accessNode.kind === 188 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; }); } } - if (!(indexType.flags & 24576) && isTypeAssignableToKind(indexType, 68 | 168 | 3072)) { - if (objectType.flags & (1 | 32768)) { + if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 132 | 296 | 12288)) { + if (objectType.flags & (1 | 131072)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 168) && getIndexInfoOfType(objectType, 1) || + var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) { - var indexNode = accessNode.kind === 188 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -32156,7 +32704,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 32768) { + if (indexType.flags & 131072) { return neverType; } if (isJSLiteralType(objectType)) { @@ -32189,8 +32737,8 @@ var ts; return anyType; } if (accessNode) { - var indexNode = accessNode.kind === 188 ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (64 | 128)) { + var indexNode = getIndexNodeForAccessExpression(accessNode); + if (indexType.flags & (128 | 256)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } else if (indexType.flags & (4 | 8)) { @@ -32205,14 +32753,31 @@ var ts; } return missingType; } + function getIndexNodeForAccessExpression(accessNode) { + return accessNode.kind === 190 + ? accessNode.argumentExpression + : accessNode.kind === 180 + ? accessNode.indexType + : accessNode.kind === 149 + ? accessNode.expression + : accessNode; + } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 14745600 | 134217728); + return maybeTypeOfKind(type, 58982400 | 134217728); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 14745600 | 1048576); + return maybeTypeOfKind(type, 58982400 | 4194304); } function getSimplifiedType(type) { - return type.flags & 2097152 ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type) : type; + } + function distributeIndexOverObjectType(objectType, indexType) { + if (objectType.flags & 1048576) { + return mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); + } + if (objectType.flags & 2097152) { + return getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + } } function getSimplifiedIndexedAccessType(type) { if (type.simplified) { @@ -32221,21 +32786,19 @@ var ts; type.simplified = circularConstraintType; var objectType = getSimplifiedType(type.objectType); var indexType = getSimplifiedType(type.indexType); - if (indexType.flags & 262144) { + if (indexType.flags & 1048576) { return type.simplified = mapType(indexType, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t)); }); } - if (!(indexType.flags & 15794176)) { - if (objectType.flags & 262144) { - return type.simplified = mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); - } - if (objectType.flags & 524288) { - return type.simplified = getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + if (!(indexType.flags & 63176704)) { + var simplified = distributeIndexOverObjectType(objectType, indexType); + if (simplified) { + return type.simplified = simplified; } } if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 65536) { + if (objectType.flags & 262144) { var constraint = getConstraintOfTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -32253,7 +32816,7 @@ var ts; if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 180) && isGenericObjectType(objectType)) { if (objectType.flags & 3) { return objectType; } @@ -32265,7 +32828,7 @@ var ts; return type; } var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 262144 && !(indexType.flags & 16)) { + if (indexType.flags & 1048576 && !(indexType.flags & 16)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { @@ -32294,7 +32857,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 2097152 && + links.resolvedType = resolved.flags & 8388608 && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -32314,7 +32877,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 8388608 ? type.typeVariable : type; + return type.flags & 33554432 ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -32322,7 +32885,7 @@ var ts; if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 63176704); var combinedMapper; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, undefined, 0); @@ -32347,7 +32910,7 @@ var ts; } } var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(4194304); + var result = createType(16777216); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -32379,7 +32942,7 @@ var ts; return true; } while (node) { - if (node.kind === 173) { + if (node.kind === 175) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -32402,7 +32965,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 65536), + isDistributive: !!(checkType.flags & 262144), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -32520,6 +33083,9 @@ var ts; function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } + function isNonGenericObjectType(type) { + return !!(type.flags & 524288) && !isGenericMappedType(type); + } function getSpreadType(left, right, symbol, typeFlags, objectFlags) { if (left.flags & 1 || right.flags & 1) { return anyType; @@ -32527,21 +33093,34 @@ var ts; if (left.flags & 2 || right.flags & 2) { return unknownType; } - if (left.flags & 32768) { + if (left.flags & 131072) { return right; } - if (right.flags & 32768) { + if (right.flags & 131072) { return left; } - if (left.flags & 262144) { + if (left.flags & 1048576) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 262144) { + if (right.flags & 1048576) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (272 | 168 | 68 | 544 | 16777216 | 1048576)) { + if (right.flags & (528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304)) { return left; } + if (isGenericObjectType(left) || isGenericObjectType(right)) { + if (isEmptyObjectType(left)) { + return right; + } + if (left.flags & 2097152) { + var types = left.types; + var lastLeft = types[types.length - 1]; + if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { + return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, typeFlags, objectFlags)])); + } + } + return getIntersectionType([left, right]); + } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); var stringIndexInfo; @@ -32560,7 +33139,7 @@ var ts; skippedPrivateMembers.set(rightProp.escapedName, true); } else if (isSpreadableProperty(rightProp)) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSpreadSymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -32575,7 +33154,7 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 | (leftProp.flags & 16777216); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -32584,26 +33163,27 @@ var ts; } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSpreadSymbol(leftProp)); } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 268435456; - spread.objectFlags |= objectFlags | (128 | 1024); + spread.flags |= 268435456 | typeFlags; + spread.objectFlags |= 128 | 1024 | objectFlags; return spread; } function isSpreadableProperty(prop) { - return prop.flags & (8192 | 32768) - ? !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }) - : !(prop.flags & 65536); + return !(prop.flags & (8192 | 32768 | 65536)) || + !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }); } - function getNonReadonlySymbol(prop) { - if (!isReadonlySymbol(prop)) { + function getSpreadSymbol(prop) { + var isReadonly = isReadonlySymbol(prop); + var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); + if (!isReadonly && !isSetonlyAccessor) { return prop; } var flags = 4 | (prop.flags & 16777216); var result = createSymbol(flags, prop.escapedName); - result.type = getTypeOfSymbol(prop); + result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = prop.nameType; result.syntheticOrigin = prop; @@ -32622,10 +33202,11 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 448 && !(type.flags & 33554432)) { + if (type.flags & 2944) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 33554432, type.value, type.symbol); + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; + freshType.freshType = freshType; type.freshType = freshType; } return type.freshType; @@ -32633,17 +33214,23 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 448 && type.flags & 33554432 ? type.regularType : - type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + return type.flags & 2944 ? type.regularType : + type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : type; } + function isFreshLiteralType(type) { + return !!(type.flags & 2944) && type.freshType === type; + } function getLiteralType(value, enumId, symbol) { - var qualifier = typeof value === "number" ? "#" : "@"; - var key = enumId ? enumId + qualifier + value : qualifier + value; + var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; + var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value); var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 128 : 64) | (enumId ? 512 : 0); + var flags = (typeof value === "number" ? 256 : + typeof value === "string" ? 128 : 2048) | + (enumId ? 1024 : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); + type.regularType = type; } return type; } @@ -32655,7 +33242,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(2048); + var type = createType(8192); type.symbol = symbol; return type; } @@ -32670,9 +33257,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 239)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 241)) { if (!ts.hasModifier(container, 32) && - (container.kind !== 155 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 157 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -32688,85 +33275,87 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 119: - case 282: - case 283: - return anyType; - case 142: - return unknownType; - case 137: - return stringType; - case 134: - return numberType; - case 122: - return booleanType; - case 138: - return esSymbolType; - case 105: - return voidType; - case 140: - return undefinedType; - case 95: - return nullType; - case 131: - return neverType; - case 135: - return node.flags & 65536 ? anyType : nonPrimitiveType; - case 176: - case 99: - return getTypeFromThisTypeNode(node); - case 180: - return getTypeFromLiteralTypeNode(node); - case 162: - return getTypeFromTypeReference(node); - case 161: - return booleanType; - case 209: - return getTypeFromTypeReference(node); - case 165: - return getTypeFromTypeQueryNode(node); - case 167: - return getTypeFromArrayTypeNode(node); - case 168: - return getTypeFromTupleTypeNode(node); - case 169: - return getTypeFromOptionalTypeNode(node); - case 171: - return getTypeFromUnionTypeNode(node); - case 172: - return getTypeFromIntersectionTypeNode(node); + case 120: case 284: - return getTypeFromJSDocNullableTypeNode(node); - case 286: - return addOptionality(getTypeFromTypeNode(node.type)); - case 175: - case 170: case 285: - case 281: - return getTypeFromTypeNode(node.type); - case 288: - return getTypeFromJSDocVariadicType(node); - case 163: - case 164: - case 166: - case 290: - case 287: - case 291: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 177: - return getTypeFromTypeOperatorNode(node); - case 178: - return getTypeFromIndexedAccessTypeNode(node); - case 179: - return getTypeFromMappedTypeNode(node); - case 173: - return getTypeFromConditionalTypeNode(node); - case 174: - return getTypeFromInferTypeNode(node); - case 181: - return getTypeFromImportTypeNode(node); - case 71: + return anyType; + case 143: + return unknownType; + case 138: + return stringType; + case 135: + return numberType; case 146: + return bigintType; + case 123: + return booleanType; + case 139: + return esSymbolType; + case 106: + return voidType; + case 141: + return undefinedType; + case 96: + return nullType; + case 132: + return neverType; + case 136: + return node.flags & 65536 ? anyType : nonPrimitiveType; + case 178: + case 100: + return getTypeFromThisTypeNode(node); + case 182: + return getTypeFromLiteralTypeNode(node); + case 164: + return getTypeFromTypeReference(node); + case 163: + return booleanType; + case 211: + return getTypeFromTypeReference(node); + case 167: + return getTypeFromTypeQueryNode(node); + case 169: + return getTypeFromArrayTypeNode(node); + case 170: + return getTypeFromTupleTypeNode(node); + case 171: + return getTypeFromOptionalTypeNode(node); + case 173: + return getTypeFromUnionTypeNode(node); + case 174: + return getTypeFromIntersectionTypeNode(node); + case 286: + return getTypeFromJSDocNullableTypeNode(node); + case 288: + return addOptionality(getTypeFromTypeNode(node.type)); + case 177: + case 172: + case 287: + case 283: + return getTypeFromTypeNode(node.type); + case 290: + return getTypeFromJSDocVariadicType(node); + case 165: + case 166: + case 168: + case 292: + case 289: + case 293: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 179: + return getTypeFromTypeOperatorNode(node); + case 180: + return getTypeFromIndexedAccessTypeNode(node); + case 181: + return getTypeFromMappedTypeNode(node); + case 175: + return getTypeFromConditionalTypeNode(node); + case 176: + return getTypeFromInferTypeNode(node); + case 183: + return getTypeFromImportTypeNode(node); + case 72: + case 148: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -32843,10 +33432,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 65536 ? wildcardType : type; + return type.flags & 262144 ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(65536); + var result = createType(262144); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -32884,7 +33473,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 131072 | 15794176)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 | 63176704)) { return symbol; } if (ts.getCheckFlags(symbol) & 1) { @@ -32950,25 +33539,25 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 146 || - node.parent.kind === 162 && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 148 || + node.parent.kind === 164 && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 216 ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 218 ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 176: + case 178: return !!tp.isThisType; - case 71: + case 72: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 165: + case 167: return true; } return !!ts.forEachChild(node, containsReference); @@ -32976,9 +33565,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 1048576) { + if (constraintType.flags & 4194304) { var typeVariable = constraintType.type; - if (typeVariable.flags & 65536) { + if (typeVariable.flags & 262144) { return typeVariable; } } @@ -32994,7 +33583,7 @@ var ts; } type.instantiating = true; var result = mapType(mappedTypeVariable, function (t) { - if (t.flags & (3 | 14745600 | 131072 | 524288) && t !== wildcardType) { + if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType) { var replacementMapper = createReplacementMapper(typeVariable, t, mapper); return isArrayType(t) ? createArrayType(instantiateMappedTypeTemplate(type, numberType, true, replacementMapper)) : isReadonlyArrayType(t) ? createReadonlyArrayType(instantiateMappedTypeTemplate(type, numberType, true, replacementMapper)) : @@ -33025,7 +33614,7 @@ var ts; var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); return strictNullChecks && modifiers & 4 && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 131072) : + strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) : propType; } function instantiateAnonymousType(type, mapper) { @@ -33063,7 +33652,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 | 32768)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -33083,10 +33672,10 @@ var ts; } function instantiateTypeWorker(type, mapper) { var flags = type.flags; - if (flags & 65536) { + if (flags & 262144) { return mapper(type); } - if (flags & 131072) { + if (flags & 524288) { var objectFlags = type.objectFlags; if (objectFlags & 16) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ? @@ -33102,65 +33691,65 @@ var ts; } return type; } - if (flags & 262144 && !(flags & 32764)) { + if (flags & 1048576 && !(flags & 131068)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 524288) { + if (flags & 2097152) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 1048576) { + if (flags & 4194304) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 2097152) { + if (flags & 8388608) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (flags & 4194304) { + if (flags & 16777216) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (flags & 8388608) { + if (flags & 33554432) { return instantiateType(type.typeVariable, mapper); } return type; } function getWildcardInstantiation(type) { - return type.flags & (32764 | 3 | 32768) ? type : + return type.flags & (131068 | 3 | 131072) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 194: - case 195: - case 154: + case 196: + case 197: + case 156: return isContextSensitiveFunctionLikeDeclaration(node); - case 186: + case 188: return ts.some(node.properties, isContextSensitive); - case 185: + case 187: return ts.some(node.elements, isContextSensitive); - case 203: + case 205: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 202: - return node.operatorToken.kind === 54 && + case 204: + return node.operatorToken.kind === 55 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 273: + case 275: return isContextSensitive(node.initializer); - case 193: + case 195: return isContextSensitive(node.expression); - case 266: - return ts.some(node.properties, isContextSensitive); - case 265: { + case 268: + return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); + case 267: { var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 268: { + case 270: { var expression = node.expression; return !!expression && isContextSensitive(expression); } @@ -33174,7 +33763,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 195) { + if (node.kind !== 197) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; @@ -33184,14 +33773,14 @@ var ts; } function hasContextSensitiveReturnExpression(node) { var body = node.body; - return body.kind === 216 ? false : isContextSensitive(body); + return body.kind === 218 ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 131072) { + if (type.flags & 524288) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { var result = createObjectType(16, type.symbol); @@ -33202,7 +33791,7 @@ var ts; return result; } } - else if (type.flags & 524288) { + else if (type.flags & 2097152) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -33216,6 +33805,9 @@ var ts; function compareTypesAssignable(source, target) { return isTypeRelatedTo(source, target, assignableRelation) ? -1 : 0; } + function compareTypesSubtypeOf(source, target) { + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 : 0; + } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); } @@ -33223,11 +33815,11 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeDerivedFrom(source, target) { - return source.flags & 262144 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 262144 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 14745600 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : - target === globalObjectType ? !!(source.flags & (131072 | 16777216)) : - target === globalFunctionType ? !!(source.flags & 131072) && isFunctionObjectType(source) : + return source.flags & 1048576 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : + target === globalObjectType ? !!(source.flags & (524288 | 67108864)) : + target === globalFunctionType ? !!(source.flags & 524288) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)); } function isTypeComparableTo(source, target) { @@ -33251,7 +33843,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 4194304 || (type.flags & 524288 && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 || (type.flags & 2097152 && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage) { if (!node || isOrHasGenericConditional(target)) @@ -33260,23 +33852,23 @@ var ts; return true; } switch (node.kind) { - case 268: - case 193: + case 270: + case 195: return elaborateError(node.expression, source, target, relation, headMessage); - case 202: + case 204: switch (node.operatorToken.kind) { - case 58: - case 26: + case 59: + case 27: return elaborateError(node.right, source, target, relation, headMessage); } break; - case 186: + case 188: return elaborateObjectLiteral(node, source, target, relation); - case 185: + case 187: return elaborateArrayLiteral(node, source, target, relation); - case 266: + case 268: return elaborateJsxAttributes(node, source, target, relation); - case 195: + case 197: return elaborateArrowFunction(node, source, target, relation); } return false; @@ -33288,7 +33880,7 @@ var ts; var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 | 32768)) && checkTypeRelatedTo(returnType, target, relation, undefined); + return !(returnType.flags & (1 | 131072)) && checkTypeRelatedTo(returnType, target, relation, undefined); })) { var resultObj = {}; checkTypeAssignableTo(source, target, node, headMessage, undefined, resultObj); @@ -33337,8 +33929,10 @@ var ts; var reportedError = false; 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 sourcePropType = getIndexedAccessType(source, nameType, undefined, errorType); var targetPropType = getIndexedAccessType(target, nameType, undefined, errorType); + if (targetPropType === errorType || targetPropType.flags & 8388608) + continue; + var sourcePropType = getIndexedAccessType(source, nameType, undefined, errorType); if (sourcePropType !== errorType && targetPropType !== errorType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined); if (elaborated) { @@ -33357,7 +33951,7 @@ var ts; var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; var issuedElaboration = false; if (!targetProp) { - var indexInfo = isTypeAssignableToKind(nameType, 168) && getIndexInfoOfType(target, 1) || + var indexInfo = isTypeAssignableToKind(nameType, 296) && getIndexInfoOfType(target, 1) || getIndexInfoOfType(target, 0) || undefined; if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) { @@ -33368,7 +33962,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) { - addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + 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) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -33459,17 +34053,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3, 7]; - type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240); - if (!type || (type.flags & 32768)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576); + if (!type || (type.flags & 131072)) { return [3, 7]; } _b = prop.kind; switch (_b) { - case 157: return [3, 2]; + case 159: return [3, 2]; + case 158: return [3, 2]; case 156: return [3, 2]; - case 154: return [3, 2]; - case 274: return [3, 2]; - case 273: return [3, 4]; + case 276: return [3, 2]; + case 275: return [3, 4]; } return [3, 6]; case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -33518,8 +34112,8 @@ var ts; return 0; } var kind = target.declaration ? target.declaration.kind : 0; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 && - kind !== 153 && kind !== 155; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 156 && + kind !== 155 && kind !== 157; var result = -1; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -33544,7 +34138,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 24576) === (getFalsyFlags(targetType) & 24576); + (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304); var related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 : 1, false, reportErrors, errorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); @@ -33630,12 +34224,15 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 131072 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 16777216 ? true : - type.flags & 262144 ? ts.some(type.types, isEmptyObjectType) : - type.flags & 524288 ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 ? true : + type.flags & 1048576 ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 ? ts.every(type.types, isEmptyObjectType) : false; } + function isEmptyAnonymousObjectType(type) { + return !!(ts.getObjectFlags(type) & 16) && isEmptyObjectType(type); + } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { if (sourceSymbol === targetSymbol) { return true; @@ -33672,71 +34269,73 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 || s & 32768 || source === wildcardType) + if (t & 3 || s & 131072 || source === wildcardType) return true; - if (t & 32768) + if (t & 131072) return false; - if (s & 68 && t & 4) + if (s & 132 && t & 4) return true; - if (s & 64 && s & 512 && - t & 64 && !(t & 512) && + if (s & 128 && s & 1024 && + t & 128 && !(t & 1024) && source.value === target.value) return true; - if (s & 168 && t & 8) + if (s & 296 && t & 8) return true; - if (s & 128 && s & 512 && - t & 128 && !(t & 512) && + if (s & 256 && s & 1024 && + t & 256 && !(t & 1024) && source.value === target.value) return true; - if (s & 272 && t & 16) + if (s & 2112 && t & 64) return true; - if (s & 3072 && t & 1024) + if (s & 528 && t & 16) + return true; + if (s & 12288 && t & 4096) return true; if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 512 && t & 512) { - if (s & 262144 && t & 262144 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 && t & 1024) { + if (s & 1048576 && t & 1048576 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 448 && t & 448 && + if (s & 2944 && t & 2944 && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 8192 && (!strictNullChecks || t & (8192 | 4096))) + if (s & 32768 && (!strictNullChecks || t & (32768 | 16384))) return true; - if (s & 16384 && (!strictNullChecks || t & 16384)) + if (s & 65536 && (!strictNullChecks || t & 65536)) return true; - if (s & 131072 && t & 16777216) + if (s & 524288 && t & 67108864) return true; - if (s & 2048 || t & 2048) + if (s & 8192 || t & 8192) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1) return true; - if (s & (8 | 128) && !(s & 512) && (t & 32 || t & 128 && t & 512)) + if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 448 && source.flags & 33554432) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 && target.flags & 33554432) { + if (isFreshLiteralType(target)) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 32768) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 131072 && target.flags & 131072) { + if (source.flags & 524288 && target.flags & 524288) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1; } } - if (source.flags & 16711680 || target.flags & 16711680) { + if (source.flags & 66846720 || target.flags & 66846720) { return checkTypeRelatedTo(source, target, relation, undefined); } return false; @@ -33746,6 +34345,7 @@ var ts; } function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; + var relatedInfo; var maybeKeys; var sourceStack; var targetStack; @@ -33753,7 +34353,7 @@ var ts; var depth = 0; var expandingFlags = 0; var overflow = false; - var isIntersectionConstituent = false; + var suppressNextError = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, !!errorNode, headMessage); if (overflow) { @@ -33778,15 +34378,27 @@ var ts; } } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (relatedInfo) { + addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + } if (errorOutputContainer) { errorOutputContainer.error = diag; } diagnostics.add(diag); } return result !== 0; - function reportError(message, arg0, arg1, arg2) { + function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); + } + function associateRelatedInfo(info) { + ts.Debug.assert(!!errorInfo); + if (!relatedInfo) { + relatedInfo = [info]; + } + else { + relatedInfo.push(info); + } } function reportRelationError(message, source, target) { var sourceType = typeToString(source); @@ -33819,13 +34431,13 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 786432)) { + if (!(type.flags & 3145728)) { return false; } var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 24576) { + if (t.flags & 98304) { continue; } if (seenNonNullable) { @@ -33835,30 +34447,30 @@ var ts; } return false; } - function isRelatedTo(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage, isApparentIntersectionConstituent) { if (reportErrors === void 0) { reportErrors = false; } - if (source.flags & 448 && source.flags & 33554432) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 && target.flags & 33554432) { + if (isFreshLiteralType(target)) { target = target.regularType; } - if (source.flags & 8388608) { + if (source.flags & 33554432) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 8388608) { + if (target.flags & 33554432) { target = target.typeVariable; } - if (source.flags & 2097152) { + if (source.flags & 8388608) { source = getSimplifiedType(source); } - if (target.flags & 2097152) { + if (target.flags & 8388608) { target = getSimplifiedType(target); } - if (target.flags & 262144 && source.flags & 131072 && - target.types.length <= 3 && maybeTypeOfKind(target, 24576)) { - var nullStrippedTarget = extractTypesOfKind(target, ~24576); - if (!(nullStrippedTarget.flags & (262144 | 32768))) { + if (target.flags & 1048576 && source.flags & 524288 && + target.types.length <= 3 && maybeTypeOfKind(target, 98304)) { + var nullStrippedTarget = extractTypesOfKind(target, ~98304); + if (!(nullStrippedTarget.flags & (1048576 | 131072))) { target = nullStrippedTarget; } } @@ -33867,11 +34479,12 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 32768) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (isObjectLiteralType(source) && source.flags & 33554432) { - var discriminantType = target.flags & 262144 ? findMatchingDiscriminantType(source, target) : undefined; + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); + if (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768) { + var discriminantType = target.flags & 1048576 ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -33882,11 +34495,11 @@ var ts; source = getRegularTypeOfObjectLiteral(source); } } - if (relation !== comparableRelation && !isIntersectionConstituent && - source.flags & (32764 | 131072 | 524288) && source !== globalObjectType && - target.flags & (131072 | 524288) && isWeakType(target) && + if (relation !== comparableRelation && !isApparentIntersectionConstituent && + source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType && + target.flags & (524288 | 2097152) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target)) { + !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0); var constructs = getSignaturesOfType(source, 1); @@ -33902,47 +34515,47 @@ var ts; } var result = 0; var saveErrorInfo = errorInfo; - var saveIsIntersectionConstituent = isIntersectionConstituent; - isIntersectionConstituent = false; - if (source.flags & 262144) { + var isIntersectionConstituent = !!isApparentIntersectionConstituent; + if (source.flags & 1048576) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)); } else { - if (target.flags & 262144) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764) && !(target.flags & 32764)); + if (target.flags & 1048576) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068)); } - else if (target.flags & 524288) { + else if (target.flags & 2097152) { isIntersectionConstituent = true; result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 524288) { + else if (source.flags & 2097152) { result = someTypeRelatedToType(source, target, false); } - if (!result && (source.flags & 16711680 || target.flags & 16711680)) { - if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { + if (!result && (source.flags & 66846720 || target.flags & 66846720)) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 524288) { - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144)); + if (!result && source.flags & 2097152) { + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576)); if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { + if (result = isRelatedTo(constraint, target, reportErrors, undefined, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 131072 && target.flags & 32764) { + var maybeSuppress = suppressNextError; + suppressNextError = false; + if (source.flags & 524288 && target.flags & 131068) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 131072 && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 && 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) & 4096 && target.flags & 524288) { + else if (isComparingJsxAttributes && target.flags & 2097152) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -33951,6 +34564,9 @@ var ts; return result; } } + if (!headMessage && maybeSuppress) { + return result; + } reportRelationError(headMessage, source, target); } return result; @@ -33958,10 +34574,10 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 131072 || flags & 2097152 || flags & 4194304 || flags & 1048576 || flags & 8388608) { - return recursiveTypeRelatedTo(source, target, false); + if (flags & 524288 || flags & 8388608 || flags & 16777216 || flags & 4194304 || flags & 33554432) { + return recursiveTypeRelatedTo(source, target, false, false); } - if (flags & (262144 | 524288)) { + if (flags & (1048576 | 2097152)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -33974,7 +34590,7 @@ var ts; if (!noImplicitAny && ts.getObjectFlags(target) & 16384) { return false; } - if (maybeTypeOfKind(target, 131072) && !(ts.getObjectFlags(target) & 512)) { + if (maybeTypeOfKind(target, 524288) && !(ts.getObjectFlags(target) & 512)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -33984,11 +34600,11 @@ var ts; return hasExcessProperties(source, discriminant, undefined, reportErrors); } var _loop_6 = function (prop) { - if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { if (!errorNode) return { value: ts.Debug.fail() }; - if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -34023,8 +34639,8 @@ var ts; } return false; } - function isPropertyFromSpread(prop, container) { - return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + function shouldCheckAsExcessProperty(prop, container) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration; } function eachTypeRelatedToSomeType(source, target) { var result = -1; @@ -34041,7 +34657,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 262144 && containsType(targetTypes, source)) { + if (target.flags & 1048576 && containsType(targetTypes, source)) { return -1; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -34062,9 +34678,9 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 262144) { + if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 131072) { + if (target.flags & 524288) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); if (overlapObjFlags & 4) { return source.target === target.target; @@ -34091,11 +34707,13 @@ var ts; } } function findMatchingDiscriminantType(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - if (sourceProperties) { - var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); - if (sourcePropertiesFiltered) { - return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + if (target.flags & 1048576) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (sourcePropertiesFiltered) { + return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + } } } return undefined; @@ -34105,7 +34723,7 @@ var ts; 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, reportErrors); + var related = isRelatedTo(source, targetType, reportErrors, undefined, true); if (!related) { return 0; } @@ -34115,7 +34733,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 262144 && containsType(sourceTypes, target)) { + if (source.flags & 1048576 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; @@ -34140,9 +34758,10 @@ var ts; } return result; } - function typeArgumentsRelatedTo(source, target, variances, reportErrors) { - var sources = source.typeArguments || ts.emptyArray; - var targets = target.typeArguments || ts.emptyArray; + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + if (sources === void 0) { sources = ts.emptyArray; } + if (targets === void 0) { targets = ts.emptyArray; } + if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { return 0; } @@ -34180,7 +34799,7 @@ var ts; } return result; } - function recursiveTypeRelatedTo(source, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0; } @@ -34220,7 +34839,7 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1; + var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -34240,21 +34859,21 @@ var ts; function getConstraintForRelation(type) { return relation === definitelyAssignableRelation ? undefined : getConstraintOfType(type); } - function structuredTypeRelatedTo(source, target, reportErrors) { + function structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { var flags = source.flags & target.flags; - if (relation === identityRelation && !(flags & 131072)) { - if (flags & 1048576) { + if (relation === identityRelation && !(flags & 524288)) { + if (flags & 4194304) { return isRelatedTo(source.type, target.type, false); } var result_2 = 0; - if (flags & 2097152) { + if (flags & 8388608) { if (result_2 = isRelatedTo(source.objectType, target.objectType, false)) { if (result_2 &= isRelatedTo(source.indexType, target.indexType, false)) { return result_2; } } } - if (flags & 4194304) { + if (flags & 16777216) { if (source.root.isDistributive === target.root.isDistributive) { if (result_2 = isRelatedTo(source.checkType, target.checkType, false)) { if (result_2 &= isRelatedTo(source.extendsType, target.extendsType, false)) { @@ -34267,7 +34886,7 @@ var ts; } } } - if (flags & 8388608) { + if (flags & 33554432) { return isRelatedTo(source.substitute, target.substitute, false); } return 0; @@ -34275,8 +34894,18 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 65536) { - if (ts.getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (source.flags & (524288 | 16777216) && source.aliasSymbol && + source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && + !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { + var variances = getAliasVariances(source.aliasSymbol); + if (result = typeArgumentsRelatedTo(source.aliasTypeArguments, target.aliasTypeArguments, variances, reportErrors)) { + return result; + } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; + } + if (target.flags & 262144) { + if (ts.getObjectFlags(source) & 32 && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { if (!(getMappedTypeModifiers(source) & 4)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); @@ -34286,8 +34915,8 @@ var ts; } } } - else if (target.flags & 1048576) { - if (source.flags & 1048576) { + else if (target.flags & 4194304) { + if (source.flags & 4194304) { if (result = isRelatedTo(target.type, source.type, false)) { return result; } @@ -34302,7 +34931,7 @@ var ts; } } } - else if (target.flags & 2097152) { + else if (target.flags & 8388608) { if (relation !== identityRelation && !(isGenericObjectType(target.objectType) && isGenericIndexType(target.indexType))) { var constraint = getBaseConstraintOfType(target); if (constraint && constraint !== target) { @@ -34316,21 +34945,23 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8)) { - if (template.flags & 2097152 && template.objectType === source && + if (template.flags & 8388608 && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1; } - if (!isGenericMappedType(source) && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + if (!isGenericMappedType(source) && isRelatedTo(getConstraintTypeFromMappedType(target), getIndexType(source))) { var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { return result; } } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; } } - if (source.flags & 2162688) { - if (source.flags & 2097152 && target.flags & 2097152) { + if (source.flags & 8650752) { + if (source.flags & 8388608 && target.flags & 8388608) { if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } @@ -34340,28 +34971,29 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 65536 && constraint.flags & 3)) { - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216))) { + if (!constraint || (source.flags & 262144 && constraint.flags & 3)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) { errorInfo = saveErrorInfo; return result; } } - else { - var instantiated = getTypeWithThisArgument(constraint, source); - if (result = isRelatedTo(instantiated, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } + else if (result = isRelatedTo(constraint, target, false, undefined, isIntersectionConstituent)) { + errorInfo = saveErrorInfo; + return result; } - } - else if (source.flags & 1048576) { - if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, isIntersectionConstituent)) { errorInfo = saveErrorInfo; return result; } } else if (source.flags & 4194304) { - if (target.flags & 4194304) { + if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (source.flags & 16777216) { + if (target.flags & 16777216) { if (isTypeIdenticalTo(source.extendsType, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { @@ -34406,14 +35038,14 @@ var ts; if (relation === definitelyAssignableRelation && isGenericMappedType(source)) { return 0; } - var sourceIsPrimitive = !!(source.flags & 32764); + var sourceIsPrimitive = !!(source.flags & 131068); if (relation !== identityRelation) { source = getApparentType(source); } if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target && !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) { var variances = getVariances(source.target); - if (result = typeArgumentsRelatedTo(source, target, variances, reportErrors)) { + if (result = typeArgumentsRelatedTo(source.typeArguments, target.typeArguments, variances, reportErrors)) { return result; } if (variances !== ts.emptyArray && !hasCovariantVoidArgument(target, variances)) { @@ -34427,7 +35059,7 @@ var ts; else if (isTupleType(source) && (isArrayType(target) || isReadonlyArrayType(target)) || isArrayType(source) && isReadonlyArrayType(target)) { return isRelatedTo(getIndexTypeOfType(source, 1) || anyType, getIndexTypeOfType(target, 1) || anyType, reportErrors); } - if (source.flags & (131072 | 524288) && target.flags & 131072) { + if (source.flags & (524288 | 2097152) && target.flags & 524288) { var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors); if (result) { @@ -34473,7 +35105,24 @@ var ts; var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties)); + if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code && + headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) { + suppressNextError = true; + } + if (props.length === 1) { + var propName = symbolToString(unmatchedProperty); + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, typeToString(source), typeToString(target)); + if (ts.length(unmatchedProperty.declarations)) { + associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); + } + } + else if (props.length > 5) { + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, typeToString(source), typeToString(target), ts.map(props.slice(0, 4), function (p) { return symbolToString(p); }).join(", "), props.length - 4); + } + else { + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); + } } return 0; } @@ -34520,8 +35169,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { - var targetProp = properties_3[_b]; + for (var _b = 0, properties_2 = properties; _b < properties_2.length; _b++) { + var targetProp = properties_2[_b]; if (!(targetProp.flags & 4194304)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { @@ -34584,7 +35233,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 131072 && target.flags & 131072)) { + if (!(source.flags & 524288 && target.flags & 524288)) { return 0; } var sourceProperties = getPropertiesOfObjectType(source); @@ -34694,7 +35343,7 @@ var ts; if (isIgnoredJsxProperty(source, prop, undefined)) { continue; } - if (prop.nameType && prop.nameType.flags & 2048) { + if (prop.nameType && prop.nameType.flags & 8192) { continue; } if (kind === 0 || isNumericLiteralName(prop.escapedName)) { @@ -34803,20 +35452,19 @@ var ts; return match || defaultValue; } function isWeakType(type) { - if (type.flags & 131072) { + if (type.flags & 524288) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); }); } - if (type.flags & 524288) { + if (type.flags & 2097152) { return ts.every(type.types, isWeakType); } return false; } - function hasCommonProperties(source, target) { - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); + function hasCommonProperties(source, target, isComparingJsxAttributes) { for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { @@ -34830,45 +35478,54 @@ var ts; result.objectFlags |= 8192; return result; } + 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; + }); + } + function getVariancesWorker(typeParameters, cache, createMarkerType) { + if (typeParameters === void 0) { typeParameters = ts.emptyArray; } + var variances = cache.variances; + if (!variances) { + cache.variances = ts.emptyArray; + variances = []; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var tp = typeParameters_1[_i]; + var typeWithSuper = createMarkerType(cache, tp, markerSuperType); + var typeWithSub = createMarkerType(cache, tp, markerSubType); + var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0); + if (variance === 3 && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) { + variance = 4; + } + variances.push(variance); + } + cache.variances = variances; + } + return variances; + } function getVariances(type) { if (!strictFunctionTypes) { return ts.emptyArray; } - var typeParameters = type.typeParameters || ts.emptyArray; - var variances = type.variances; - if (!variances) { - if (type === globalArrayType || type === globalReadonlyArrayType) { - variances = [1]; - } - else { - type.variances = ts.emptyArray; - variances = []; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - var typeWithSuper = getMarkerTypeReference(type, tp, markerSuperType); - var typeWithSub = getMarkerTypeReference(type, tp, markerSubType); - var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0); - if (variance === 3 && isTypeAssignableTo(getMarkerTypeReference(type, tp, markerOtherType), typeWithSuper)) { - variance = 4; - } - variances.push(variance); - } - } - type.variances = variances; + if (type === globalArrayType || type === globalReadonlyArrayType) { + return ts.emptyArray; } - return variances; + return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference); } function hasCovariantVoidArgument(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 && type.typeArguments[i].flags & 4096) { + if (variances[i] === 1 && type.typeArguments[i].flags & 16384) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 65536 && !getConstraintOfTypeParameter(type); + return type.flags & 262144 && !getConstraintOfTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { return !!(ts.getObjectFlags(type) & 4) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); @@ -34939,13 +35596,13 @@ var ts; !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } function isDeeplyNestedType(type, stack, depth) { - if (depth >= 5 && type.flags & 131072) { + if (depth >= 5 && type.flags & 524288) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 131072 && t.symbol === symbol) { + if (t.flags & 524288 && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -35032,7 +35689,7 @@ var ts; for (var i = 0; i < targetLen; i++) { var s = getTypeAtPosition(source, i); var t = getTypeAtPosition(target, i); - var related = compareTypes(s, t); + var related = compareTypes(t, s); if (!related) { return 0; } @@ -35073,9 +35730,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) : getUnionType(types, 2); } function getCommonSubtype(types) { @@ -35089,7 +35746,7 @@ var ts; } function isArrayLikeType(type) { return ts.getObjectFlags(type) & 4 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 24576) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -35109,35 +35766,37 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (27072 | 32768)); + return !(type.flags & (109440 | 131072)); } function isUnitType(type) { - return !!(type.flags & 27072); + return !!(type.flags & 109440); } function isLiteralType(type) { return type.flags & 16 ? true : - type.flags & 262144 ? type.flags & 512 ? true : ts.every(type.types, isUnitType) : + type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 512 ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 ? stringType : - type.flags & 128 ? numberType : - type.flags & 256 ? booleanType : - type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : - type; + return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 ? stringType : + type.flags & 256 ? numberType : + type.flags & 2048 ? bigintType : + type.flags & 512 ? booleanType : + type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type; } function getWidenedLiteralType(type) { - return type.flags & 512 && type.flags & 33554432 ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 && type.flags & 33554432 ? stringType : - type.flags & 128 && type.flags & 33554432 ? numberType : - type.flags & 256 && type.flags & 33554432 ? booleanType : - type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : - type; + return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 && isFreshLiteralType(type) ? stringType : + type.flags & 256 && isFreshLiteralType(type) ? numberType : + type.flags & 2048 && isFreshLiteralType(type) ? bigintType : + type.flags & 512 && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 2048 ? esSymbolType : - type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 8192 ? esSymbolType : + type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -35159,6 +35818,10 @@ var ts; function getLengthOfTupleType(type) { return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); } + function isZeroBigInt(_a) { + var value = _a.value; + return value.base10Value === "0"; + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -35168,15 +35831,16 @@ var ts; return result; } function getFalsyFlags(type) { - return type.flags & 262144 ? getFalsyFlagsOfTypes(type.types) : - type.flags & 64 ? type.value === "" ? 64 : 0 : - type.flags & 128 ? type.value === 0 ? 128 : 0 : - type.flags & 256 ? (type === falseType || type === regularFalseType) ? 256 : 0 : - type.flags & 29148; + return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) : + type.flags & 128 ? type.value === "" ? 128 : 0 : + type.flags & 256 ? type.value === 0 ? 256 : 0 : + type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 : + type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 : + type.flags & 117724; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 29120 ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 29120); }) : + return getFalsyFlags(type) & 117632 ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) : type; } function extractDefinitelyFalsyTypes(type) { @@ -35185,23 +35849,25 @@ var ts; function getDefinitelyFalsyPartOfType(type) { return type.flags & 4 ? emptyStringType : type.flags & 8 ? zeroType : - type === regularFalseType || - type === falseType || - type.flags & (4096 | 8192 | 16384) || - type.flags & 64 && type.value === "" || - type.flags & 128 && type.value === 0 ? type : - neverType; + type.flags & 64 ? zeroBigIntType : + type === regularFalseType || + type === falseType || + type.flags & (16384 | 32768 | 65536) || + type.flags & 128 && type.value === "" || + type.flags & 256 && type.value === 0 || + type.flags & 2048 && isZeroBigInt(type) ? type : + neverType; } function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (8192 | 16384); + var missing = (flags & ~type.flags) & (32768 | 65536); return missing === 0 ? type : - missing === 8192 ? getUnionType([type, undefinedType]) : - missing === 16384 ? getUnionType([type, nullType]) : + missing === 32768 ? getUnionType([type, undefinedType]) : + missing === 65536 ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 8192 ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -35210,7 +35876,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288); + return getTypeWithFacts(type, 2097152); } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -35244,7 +35910,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 33554432)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) { return type; } var regularType = type.regularType; @@ -35254,7 +35920,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~33554432; + regularNew.flags = resolved.flags; regularNew.objectFlags |= 128 | (ts.getObjectFlags(resolved) & 16384); type.regularType = regularNew; return regularNew; @@ -35340,15 +36006,15 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (type.flags & 402653184) { - if (type.flags & 24576) { + if (type.flags & 98304) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 262144) { + if (type.flags & 1048576) { var unionContext_1 = context || createWideningContext(undefined, undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); }); return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1); } if (isArrayType(type) || isTupleType(type)) { @@ -35360,7 +36026,7 @@ var ts; function reportWideningErrorsInType(type) { var errorReported = false; if (type.flags & 134217728) { - if (type.flags & 262144) { + if (type.flags & 1048576) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -35403,39 +36069,42 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 202: - case 152: - case 151: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 149: - diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - case 184: - diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; - break; - case 237: + case 204: case 154: case 153: + 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 151: + diagnostic = declaration.dotDotDotToken ? + 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 186: + diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; + break; + case 289: + error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + case 239: case 156: - case 157: - case 194: - case 195: + case 155: + case 158: + case 159: + case 196: + case 197: if (noImplicitAny && !declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + diagnostic = noImplicitAny ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type : ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage; break; - case 179: + case 181: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } return; default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + diagnostic = noImplicitAny ? ts.Diagnostics.Variable_0_implicitly_has_an_1_type : ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; } errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } @@ -35510,11 +36179,11 @@ var ts; } function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 15794176 || + return !!(type.flags & 63176704 || objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 2048 | 32) || objectFlags & 32 || - type.flags & 786432 && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -35523,12 +36192,12 @@ var ts; return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || !!(type.flags & 786432) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 3145728) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 64)) { + if (!(t.flags & 128)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -35543,35 +36212,35 @@ var ts; var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); } - function inferTypeForHomomorphicMappedType(source, target) { - var key = source.id + "," + target.id; + function inferTypeForHomomorphicMappedType(source, target, constraint) { + var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } reverseMappedCache.set(key, undefined); - var type = createReverseMappedType(source, target); + var type = createReverseMappedType(source, target, constraint); reverseMappedCache.set(key, type); return type; } - function createReverseMappedType(source, target) { + function createReverseMappedType(source, target, constraint) { var properties = getPropertiesOfType(source); if (properties.length === 0 && !getIndexInfoOfType(source, 0)) { return undefined; } - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var prop = properties_3[_i]; if (getTypeOfSymbol(prop).flags & 536870912) { return undefined; } } if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isReadonlyArrayType(source)) { - return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target); }); + var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.associatedNames); @@ -35579,30 +36248,46 @@ var ts; var reversed = createObjectType(2048 | 16, undefined); reversed.source = source; reversed.mappedType = target; + reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType); + return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); } - function inferReverseMappedType(sourceType, target) { - var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target)); + function inferReverseMappedType(sourceType, target, constraint) { + var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); var inference = createInferenceInfo(typeParameter); inferTypes([inference], sourceType, templateType); return getTypeFromInference(inference); } - function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 524288 ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; - if (requireOptionalProperties || !(targetProp.flags & 16777216)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (!sourceProp) { - return targetProp; - } + function getUnmatchedProperties(source, target, requireOptionalProperties) { + var properties, _i, properties_4, targetProp, sourceProp; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + properties = target.flags & 2097152 ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + _i = 0, properties_4 = properties; + _a.label = 1; + case 1: + if (!(_i < properties_4.length)) return [3, 4]; + targetProp = properties_4[_i]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216))) return [3, 3]; + sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (!!sourceProp) return [3, 3]; + return [4, targetProp]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + _i++; + return [3, 1]; + case 4: return [2]; } - } - return undefined; + }); + } + function getUnmatchedProperty(source, target, requireOptionalProperties) { + return getUnmatchedProperties(source, target, requireOptionalProperties).next().value; } function tupleTypesDefinitelyUnrelated(source, target) { return target.target.minLength > source.target.minLength || @@ -35645,8 +36330,8 @@ var ts; } return; } - if (source.flags & 262144 && target.flags & 262144 && !(source.flags & 512 && target.flags & 512) || - source.flags & 524288 && target.flags & 524288) { + if (source.flags & 1048576 && target.flags & 1048576 && !(source.flags & 1024 && target.flags & 1024) || + source.flags & 2097152 && target.flags & 2097152) { if (source === target) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -35661,7 +36346,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (128 | 64)) { + else if (t.flags & (256 | 128)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -35673,8 +36358,8 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 2162688) { - if (source.flags & 536870912 || source === silentNeverType) { + if (target.flags & 8650752) { + if (source.flags & 536870912 || source === silentNeverType || (priority & 8 && (source === autoType || source === autoArrayType))) { return; } var inference = getInferenceInfoForType(target); @@ -35694,12 +36379,27 @@ var ts; inference.candidates = ts.appendIfUnique(inference.candidates, candidate); } } - if (!(priority & 8) && target.flags & 65536 && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8) && target.flags & 262144 && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } return; } + else { + var simplified = getSimplifiedType(target); + if (simplified !== target) { + inferFromTypesOnce(source, simplified); + } + else if (target.flags & 8388608) { + var indexType = getSimplifiedType(target.indexType); + if (indexType.flags & 63176704) { + var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType), indexType); + if (simplified_1 && simplified_1 !== target) { + inferFromTypesOnce(source, simplified_1); + } + } + } + } } if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target) { var sourceTypes = source.typeArguments || ts.emptyArray; @@ -35715,12 +36415,12 @@ var ts; } } } - else if (source.flags & 1048576 && target.flags & 1048576) { + else if (source.flags & 4194304 && target.flags & 4194304) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4) && target.flags & 1048576) { + else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -35729,20 +36429,20 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 2097152 && target.flags & 2097152) { + else if (source.flags & 8388608 && target.flags & 8388608) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 4194304 && target.flags & 4194304) { + else if (source.flags & 16777216 && target.flags & 16777216) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 4194304) { + else if (target.flags & 16777216) { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } - else if (target.flags & 786432) { + else if (target.flags & 3145728) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -35763,7 +36463,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 262144) { + else if (source.flags & 1048576) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -35771,21 +36471,21 @@ var ts; } } else { - if (!(priority & 32 && source.flags & (524288 | 15794176))) { + if (!(priority & 32 && source.flags & (2097152 | 63176704))) { var apparentSource = getApparentType(source); - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (131072 | 524288))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) { allowComplexConstraintInference = false; return inferFromTypes(apparentSource, target); } source = apparentSource; } - if (source.flags & (131072 | 524288)) { + if (source.flags & (524288 | 2097152)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; } (visited || (visited = ts.createMap())).set(key, true); - var isNonConstructorObject = target.flags & 131072 && + var isNonConstructorObject = target.flags & 524288 && !(ts.getObjectFlags(target) & 16 && target.symbol && target.symbol.flags & 32); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -35801,6 +36501,13 @@ var ts; } } } + function inferFromTypesOnce(source, target) { + var key = source.id + "," + target.id; + if (!visited || !visited.get(key)) { + (visited || (visited = ts.createMap())).set(key, true); + inferFromTypes(source, target); + } + } } function inferFromContravariantTypes(source, target) { if (strictFunctionTypes || priority & 64) { @@ -35813,7 +36520,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 2162688) { + if (type.flags & 8650752) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -35823,6 +36530,38 @@ var ts; } return undefined; } + function inferFromMappedTypeConstraint(source, target, constraintType) { + if (constraintType.flags & 1048576) { + var result = false; + for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { + var type = _a[_i]; + result = inferFromMappedTypeConstraint(source, target, type) || result; + } + return result; + } + if (constraintType.flags & 4194304) { + var inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + var savePriority = priority; + priority |= 2; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + return true; + } + if (constraintType.flags & 262144) { + var savePriority = priority; + priority |= 4; + inferFromTypes(getIndexType(source), constraintType); + priority = savePriority; + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return true; + } + return false; + } function inferFromObjectTypes(source, target) { if (isGenericMappedType(source) && isGenericMappedType(target)) { inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); @@ -35830,25 +36569,7 @@ var ts; } if (ts.getObjectFlags(target) & 32) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 1048576) { - var inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - var inferredType = inferTypeForHomomorphicMappedType(source, target); - if (inferredType) { - var savePriority = priority; - priority |= 2; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - return; - } - if (constraintType.flags & 65536) { - var savePriority = priority; - priority |= 4; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; - inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + if (inferFromMappedTypeConstraint(source, target, constraintType)) { return; } } @@ -35887,8 +36608,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -35910,7 +36631,7 @@ var ts; if (!skipParameters) { var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0; - bivariant = bivariant || kind === 154 || kind === 153 || kind === 155; + bivariant = bivariant || kind === 156 || kind === 155 || kind === 157; forEachMatchingParameterType(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -35960,11 +36681,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 262144 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 1048576 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 4194304 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 32764 | 1048576); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 | 4194304); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128); @@ -36004,7 +36725,7 @@ var ts; var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined; if (inference.contraCandidates) { var inferredContravariantType = getContravariantInference(inference); - inferredType = inferredCovariantType && !(inferredCovariantType.flags & 32768) && + inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072) && isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ? inferredCovariantType : inferredContravariantType; } @@ -36054,17 +36775,17 @@ var ts; case "console": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; case "$": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig; case "describe": case "suite": case "it": case "test": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig; case "process": case "require": case "Buffer": case "module": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig; case "Map": case "Set": case "Promise": @@ -36086,23 +36807,23 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - return !!ts.findAncestor(node, function (n) { return n.kind === 165 ? true : n.kind === 71 || n.kind === 146 ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 167 ? true : n.kind === 72 || n.kind === 148 ? false : "quit"; }); } function getFlowCacheKey(node) { - if (node.kind === 71) { + if (node.kind === 72) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; } - if (node.kind === 99) { + if (node.kind === 100) { return "0"; } - if (node.kind === 187) { + if (node.kind === 189) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 184) { + if (node.kind === 186) { var container = node.parent.parent; - var key = container.kind === 184 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 186 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -36111,14 +36832,14 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 182) { + if (parent.kind === 184) { var name = element.propertyName || element.name; switch (name.kind) { - case 71: + case 72: return ts.idText(name); - case 147: + case 149: return ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined; - case 9: + case 10: case 8: return name.text; default: @@ -36131,29 +36852,29 @@ var ts; } function isMatchingReference(source, target) { switch (source.kind) { - case 71: - return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 235 || target.kind === 184) && + case 72: + return target.kind === 72 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 237 || target.kind === 186) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 99: - return target.kind === 99; - case 97: - return target.kind === 97; - case 187: - case 188: + case 100: + return target.kind === 100; + case 98: + return target.kind === 98; + case 189: + case 190: return (ts.isPropertyAccessExpression(target) || ts.isElementAccessExpression(target)) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 184: - if (target.kind !== 187) + case 186: + if (target.kind !== 189) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 184 && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 186 && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 235) { + if (source.parent.parent.kind === 237) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -36166,7 +36887,7 @@ var ts; undefined; } function containsMatchingReference(source, target) { - while (source.kind === 187) { + while (source.kind === 189) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -36175,23 +36896,23 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 187 && + return target.kind === 189 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 71) { + if (expr.kind === 72) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 187) { + if (expr.kind === 189) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantType(type) { - if (type.flags & 262144) { - if (type.flags & (16 | 512)) { + if (type.flags & 1048576) { + if (type.flags & (16 | 1024)) { return true; } var combined = 0; @@ -36199,14 +36920,14 @@ var ts; var t = _a[_i]; combined |= t.flags; } - if (combined & 27072 && !(combined & 15794176)) { + if (combined & 109440 && !(combined & 63176704)) { return true; } } return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 262144) { + if (type && type.flags & 1048576) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { @@ -36217,6 +36938,10 @@ var ts; } return false; } + function hasNarrowableDeclaredType(expr) { + var type = getDeclaredTypeOfReference(expr); + return !!(type && type.flags & 1048576); + } function findDiscriminantProperties(sourceProperties, target) { var result; for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { @@ -36243,7 +36968,7 @@ var ts; } } } - if (callExpression.expression.kind === 187 && + if (callExpression.expression.kind === 189 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -36257,7 +36982,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 262144)) { + if (!(source.flags & 1048576)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -36270,11 +36995,11 @@ var ts; } function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 32768) { + if (assignedType.flags & 131072) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 33554432 && assignedType.flags & 256) { + if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) { reducedType = mapType(reducedType, getFreshTypeOfLiteralType); } if (isTypeAssignableTo(assignedType, reducedType)) { @@ -36299,57 +37024,66 @@ var ts; function getTypeFacts(type) { var flags = type.flags; if (flags & 4) { - return strictNullChecks ? 4079361 : 4194049; - } - if (flags & 64) { - var isEmpty = type.value === ""; - return strictNullChecks ? - isEmpty ? 3030785 : 1982209 : - isEmpty ? 3145473 : 4194049; - } - if (flags & (8 | 32)) { - return strictNullChecks ? 4079234 : 4193922; + return strictNullChecks ? 16317953 : 16776705; } if (flags & 128) { + var isEmpty = type.value === ""; + return strictNullChecks ? + isEmpty ? 12123649 : 7929345 : + isEmpty ? 12582401 : 16776705; + } + if (flags & (8 | 32)) { + return strictNullChecks ? 16317698 : 16776450; + } + if (flags & 256) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 3030658 : 1982082 : - isZero ? 3145346 : 4193922; + isZero ? 12123394 : 7929090 : + isZero ? 12582146 : 16776450; + } + if (flags & 64) { + return strictNullChecks ? 16317188 : 16775940; + } + if (flags & 2048) { + var isZero = isZeroBigInt(type); + return strictNullChecks ? + isZero ? 12122884 : 7928580 : + isZero ? 12581636 : 16775940; } if (flags & 16) { - return strictNullChecks ? 4078980 : 4193668; + return strictNullChecks ? 16316168 : 16774920; } - if (flags & 272) { + if (flags & 528) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 3030404 : 1981828 : - (type === falseType || type === regularFalseType) ? 3145092 : 4193668; + (type === falseType || type === regularFalseType) ? 12121864 : 7927560 : + (type === falseType || type === regularFalseType) ? 12580616 : 16774920; } - if (flags & 131072) { + if (flags & 524288) { return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ? - strictNullChecks ? 4079615 : 4194303 : + strictNullChecks ? 16318463 : 16777215 : isFunctionObjectType(type) ? - strictNullChecks ? 1970144 : 4181984 : - strictNullChecks ? 1972176 : 4184016; + strictNullChecks ? 7880640 : 16728000 : + strictNullChecks ? 7888800 : 16736160; } - if (flags & (4096 | 8192)) { - return 2457472; + if (flags & (16384 | 32768)) { + return 9830144; } - if (flags & 16384) { - return 2340752; + if (flags & 65536) { + return 9363232; } - if (flags & 3072) { - return strictNullChecks ? 1981320 : 4193160; + if (flags & 12288) { + return strictNullChecks ? 7925520 : 16772880; } - if (flags & 16777216) { - return strictNullChecks ? 1972176 : 4184016; + if (flags & 67108864) { + return strictNullChecks ? 7888800 : 16736160; } - if (flags & 15794176) { + if (flags & 63176704) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 786432) { + if (flags & 3145728) { return getTypeFactsOfTypes(type.types); } - return 4194303; + return 16777215; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -36357,7 +37091,7 @@ var ts; function getTypeWithDefault(type, defaultExpression) { if (defaultExpression) { var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 131072), defaultType]); + return getUnionType([getTypeWithFacts(type, 524288), defaultType]); } return type; } @@ -36377,15 +37111,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 185 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 273 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 187 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 275 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 202 && parent.parent.left === parent || - parent.parent.kind === 225 && parent.parent.initializer === parent; + return parent.parent.kind === 204 && parent.parent.left === parent || + parent.parent.kind === 227 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -36402,21 +37136,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 224: + case 226: return stringType; - case 225: + case 227: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 202: + case 204: return getAssignedTypeOfBinaryExpression(parent); - case 196: + case 198: return undefinedType; - case 185: + case 187: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 206: + case 208: return getAssignedTypeOfSpreadExpression(parent); - case 273: + case 275: return getAssignedTypeOfPropertyAssignment(parent); - case 274: + case 276: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -36424,7 +37158,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 182 ? + var type = pattern.kind === 184 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -36439,39 +37173,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 224) { + if (node.parent.parent.kind === 226) { return stringType; } - if (node.parent.parent.kind === 225) { + if (node.parent.parent.kind === 227) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 235 ? + return node.kind === 237 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 235 || node.kind === 184 ? + return getConstraintForLocation(node.kind === 237 || node.kind === 186 ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 235 && node.initializer && + return node.kind === 237 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 184 && node.parent.kind === 202 && + node.kind !== 186 && node.parent.kind === 204 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 193: + case 195: return getReferenceCandidate(node.expression); - case 202: + case 204: switch (node.operatorToken.kind) { - case 58: + case 59: return getReferenceCandidate(node.left); - case 26: + case 27: return getReferenceCandidate(node.right); } } @@ -36479,13 +37213,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 193 || - parent.kind === 202 && parent.operatorToken.kind === 58 && parent.left === node || - parent.kind === 202 && parent.operatorToken.kind === 26 && parent.right === node ? + return parent.kind === 195 || + parent.kind === 204 && parent.operatorToken.kind === 59 && parent.left === node || + parent.kind === 204 && parent.operatorToken.kind === 27 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 269) { + if (clause.kind === 271) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -36505,8 +37239,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 269) { - if (clause.expression.kind === 9) { + if (clause.kind === 271) { + if (clause.expression.kind === 10) { witnesses.push(clause.expression.text); continue; } @@ -36517,13 +37251,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 262144 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 262144 && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 262144) { + if (source.flags & 1048576) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -36532,30 +37266,30 @@ var ts; } return true; } - if (source.flags & 512 && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 262144 ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 262144 ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 262144) { + if (type.flags & 1048576) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.primitiveTypesOnly); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 32768) { + if (type.flags & 131072) { return type; } - if (!(type.flags & 262144)) { + if (!(type.flags & 1048576)) { return mapper(type); } var types = type.types; @@ -36582,12 +37316,14 @@ var ts; return filterType(type, function (t) { return (t.flags & kind) !== 0; }); } function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256) || + isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : - t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 128) : - t; + return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) : + t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) : + t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : + t; }); } return typeWithPrimitives; @@ -36614,9 +37350,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 32768 ? + return elementType.flags & 131072 ? autoArrayType : - createArrayType(elementType.flags & 262144 ? + createArrayType(elementType.flags & 1048576 ? getUnionType(elementType.types, 2) : elementType); } @@ -36633,7 +37369,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - if (!(t.flags & 32768)) { + if (!(t.flags & 131072)) { if (!(ts.getObjectFlags(t) & 256)) { return false; } @@ -36650,15 +37386,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 187 && (parent.name.escapedText === "length" || - parent.parent.kind === 189 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 188 && + var isLengthPushOrUnshift = parent.kind === 189 && (parent.name.escapedText === "length" || + parent.parent.kind === 191 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 190 && parent.expression === root && - parent.parent.kind === 202 && - parent.parent.operatorToken.kind === 58 && + parent.parent.kind === 204 && + parent.parent.operatorToken.kind === 59 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -36669,7 +37405,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 97) { + if (node.expression.kind !== 98) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -36691,14 +37427,14 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) { return declaredType; } var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; - var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 211 && getTypeWithFacts(resultType, 524288).flags & 32768) { + var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent && reference.parent.kind === 213 && getTypeWithFacts(resultType, 2097152).flags & 131072) { return declaredType; } return resultType; @@ -36761,9 +37497,9 @@ var ts; else if (flags & 2) { var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 187 && - reference.kind !== 188 && - reference.kind !== 99) { + reference.kind !== 189 && + reference.kind !== 190 && + reference.kind !== 100) { flow = container.flowNode; continue; } @@ -36795,7 +37531,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 262144) { + if (declaredType.flags & 1048576) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); } return declaredType; @@ -36803,18 +37539,21 @@ var ts; if (containsMatchingReference(reference, node)) { if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 194 || init.kind === 195)) { + if (init && (init.kind === 196 || init.kind === 197)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 226 && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + } return undefined; } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 189 ? + var expr = node.kind === 191 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -36822,7 +37561,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 189) { + if (node.kind === 191) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -36830,7 +37569,7 @@ var ts; } else { var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 168)) { + if (isTypeAssignableToKind(indexType, 296)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -36844,7 +37583,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 32768) { + if (type.flags & 131072) { return flowType; } var assumeTrue = (flow.flags & 32) !== 0; @@ -36854,7 +37593,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 32768 ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 131072 ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -36870,7 +37609,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 197 && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 199 && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } return createFlowType(type, isIncomplete(flowType)); @@ -36952,8 +37691,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 262144) || - expr.kind !== 187 && expr.kind !== 188) { + if (!(computedType.flags & 1048576) || + expr.kind !== 189 && expr.kind !== 190) { return false; } var access = expr; @@ -36974,10 +37713,10 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? 1048576 : 2097152); + return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608); } if (isMatchingReferenceDiscriminant(expr, declaredType)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 1048576 : 2097152); }); + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); }); } if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; @@ -36995,7 +37734,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (262144 | 131072)) || (type.flags & 65536 && type.isThisType)) { + if ((type.flags & (1048576 | 524288)) || (type.flags & 262144 && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -37003,19 +37742,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 58: + case 59: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 32: case 33: case 34: case 35: + case 36: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 197 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 199 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 197 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 199 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -37034,15 +37773,15 @@ var ts; return declaredType; } break; - case 93: + case 94: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 92: + case 93: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); } break; - case 26: + case 27: return narrowType(type, expr.right, assumeTrue); } return type; @@ -37051,28 +37790,28 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 33 || operator === 35) { + if (operator === 34 || operator === 36) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 24576) { + if (valueType.flags & 98304) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 32 || operator === 33; + var doubleEquals = operator === 33 || operator === 34; var facts = doubleEquals ? - assumeTrue ? 65536 : 524288 : - valueType.flags & 16384 ? - assumeTrue ? 32768 : 262144 : - assumeTrue ? 16384 : 131072; + assumeTrue ? 262144 : 2097152 : + valueType.flags & 65536 ? + assumeTrue ? 131072 : 1048576 : + assumeTrue ? 65536 : 524288; return getTypeWithFacts(type, facts); } - if (type.flags & 16909315) { + if (type.flags & 67637251) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 32768 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 131072 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -37083,20 +37822,20 @@ var ts; function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { - if (containsMatchingReference(reference, target)) { + if (containsMatchingReference(reference, target) && hasNarrowableDeclaredType(target)) { return declaredType; } return type; } - if (operator === 33 || operator === 35) { + if (operator === 34 || operator === 36) { assumeTrue = !assumeTrue; } if (type.flags & 1 && literal.text === "function") { return type; } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 64 : - typeofNEFacts.get(literal.text) || 8192; + typeofEQFacts.get(literal.text) || 128 : + typeofNEFacts.get(literal.text) || 32768; return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); function narrowTypeForTypeof(type) { if (type.flags & 2 && literal.text === "object") { @@ -37110,7 +37849,7 @@ var ts; if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 15794176) { + if (type.flags & 63176704) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -37128,13 +37867,37 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 32768 ? neverType : + var caseType = discriminantType.flags & 131072 ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 32768 ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]); + } + function getImpliedTypeFromTypeofCase(type, text) { + switch (text) { + case "function": + return type.flags & 1 ? type : globalFunctionType; + case "object": + return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type; + default: + return typeofTypesByName.get(text) || type; + } + } + function narrowTypeForTypeofSwitch(candidate) { + return function (type) { + if (isTypeSubtypeOf(candidate, type)) { + return candidate; + } + if (type.flags & 63176704) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(candidate, constraint)) { + return getIntersectionType([type, candidate]); + } + } + return type; + }; } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); @@ -37156,31 +37919,19 @@ var ts; clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); } - if (!(hasDefaultClause || (type.flags & 262144))) { - var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return typeofTypesByName.get(text) || neverType; })), switchFacts); - if (impliedType.flags & 262144) { - impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOfType(type) || type); - } - if (!(impliedType.flags & 32768)) { - if (isTypeSubtypeOf(impliedType, type)) { - return impliedType; - } - if (type.flags & 15794176) { - var constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(impliedType, constraint)) { - return getIntersectionType([type, impliedType]); - } - } - } + if (hasDefaultClause) { + return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }); } - return hasDefaultClause ? - filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }) : - getTypeWithFacts(type, switchFacts); + var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts); + if (impliedType.flags & 1048576) { + impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type)); + } + return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { - if (containsMatchingReference(reference, left)) { + if (containsMatchingReference(reference, left) && hasNarrowableDeclaredType(left)) { return declaredType; } return type; @@ -37212,9 +37963,9 @@ var ts; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - if (type.flags & 262144) { + if (type.flags & 1048576) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 32768)) { + if (!(assignableType.flags & 131072)) { return assignableType; } } @@ -37248,7 +37999,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 188 || invokedExpression.kind === 187) { + if (invokedExpression.kind === 190 || invokedExpression.kind === 189) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -37263,20 +38014,20 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 71: - case 99: - case 97: - case 187: - case 188: - return narrowTypeByTruthiness(type, expr, assumeTrue); + case 72: + case 100: + case 98: case 189: + case 190: + return narrowTypeByTruthiness(type, expr, assumeTrue); + case 191: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 193: + case 195: return narrowType(type, expr.expression, assumeTrue); - case 202: + case 204: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 200: - if (expr.operator === 51) { + case 202: + if (expr.operator === 52) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -37286,7 +38037,7 @@ var ts; } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; - if (location.kind === 71) { + if (location.kind === 72) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -37302,9 +38053,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 243 || - node.kind === 277 || - node.kind === 152; + node.kind === 245 || + node.kind === 279 || + node.kind === 154; }); } function isParameterAssigned(symbol) { @@ -37322,10 +38073,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); }); } function markParameterAssignments(node) { - if (node.kind === 71) { + if (node.kind === 72) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 151) { symbol.isAssigned = true; } } @@ -37339,21 +38090,21 @@ var ts; } function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 149 && + declaration.kind === 151 && declaration.initializer && - getFalsyFlags(declaredType) & 8192 && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072) : declaredType; + getFalsyFlags(declaredType) & 32768 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 187 || - parent.kind === 189 && parent.expression === node || - parent.kind === 188 && parent.expression === node || - parent.kind === 184 && parent.name === node && !!parent.initializer; + return parent.kind === 189 || + parent.kind === 191 && parent.expression === node || + parent.kind === 190 && parent.expression === node || + parent.kind === 186 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 14745600 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576); + return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 98304); } function getConstraintForLocation(type, node) { if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { @@ -37374,7 +38125,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 195) { + if (container.kind === 197) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -37390,7 +38141,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 238 + if (declaration.kind === 240 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -37402,11 +38153,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 207) { + else if (declaration.kind === 209) { var container = ts.getThisContainer(node, false); - while (container.kind !== 277) { + while (container.kind !== 279) { if (container.parent === declaration) { - if (container.kind === 152 && ts.hasModifier(container, 32)) { + if (container.kind === 154 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 16777216; getNodeLinks(node).flags |= 33554432; } @@ -37445,28 +38196,28 @@ var ts; if (!declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 149; + var isParameter = ts.getRootDeclaration(declaration).kind === 151; 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; - while (flowContainer !== declarationContainer && (flowContainer.kind === 194 || - flowContainer.kind === 195 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 196 || + flowContainer.kind === 197 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || - isInTypeQuery(node) || node.parent.kind === 255) || - node.parent.kind === 211 || - declaration.kind === 235 && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 257) || + node.parent.kind === 213 || + declaration.kind === 237 && declaration.exclamationToken || declaration.flags & 4194304; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); - if (type === autoType || type === autoArrayType) { + if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) { if (flowType === autoType || flowType === autoArrayType) { if (noImplicitAny) { error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); @@ -37475,7 +38226,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 8192) && getFalsyFlags(flowType) & 8192) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } @@ -37490,7 +38241,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 272) { + symbol.valueDeclaration.parent.kind === 274) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -37508,7 +38259,7 @@ var ts; if (usedInFunction) { var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 236).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 238).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -37524,8 +38275,8 @@ var ts; getNodeLinks(current).flags |= 65536; } } - if (container.kind === 223 && - ts.getAncestor(symbol.valueDeclaration, 236).parent === container && + if (container.kind === 225 && + ts.getAncestor(symbol.valueDeclaration, 238).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304; } @@ -37541,16 +38292,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 193) { + while (current.parent.kind === 195) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 200 || current.parent.kind === 201)) { + else if ((current.parent.kind === 202 || current.parent.kind === 203)) { var expr = current.parent; - isAssigned = expr.operator === 43 || expr.operator === 44; + isAssigned = expr.operator === 44 || expr.operator === 45; } if (!isAssigned) { return false; @@ -37559,7 +38310,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 152 || container.kind === 155) { + if (container.kind === 154 || container.kind === 157) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -37603,32 +38354,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var capturedByArrowFunction = false; - if (container.kind === 155) { + if (container.kind === 157) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 195) { + if (container.kind === 197) { container = ts.getThisContainer(container, false); capturedByArrowFunction = true; } switch (container.kind) { - case 242: + case 244: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 241: + case 243: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 155: + case 157: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 152: - case 151: + case 154: + case 153: if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 147: + case 149: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -37637,9 +38388,15 @@ var ts; } var type = tryGetThisTypeAt(node, container); if (!type && noImplicitThis) { - error(node, capturedByArrowFunction && container.kind === 277 ? + var diag = error(node, capturedByArrowFunction && container.kind === 279 ? ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + if (!ts.isSourceFile(container)) { + var outsideThis = tryGetThisTypeAt(container); + if (outsideThis) { + addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + } + } } return type || anyType; } @@ -37659,7 +38416,7 @@ var ts; } } else if (isInJS && - (container.kind === 194 || container.kind === 237) && + (container.kind === 196 || container.kind === 239) && ts.getJSDocClassTag(container)) { var classType = getJSClassType(container.symbol); if (classType) { @@ -37684,7 +38441,7 @@ var ts; } } function getClassNameFromPrototypeMethod(container) { - if (container.kind === 194 && + if (container.kind === 196 && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3) { return container.parent @@ -37692,23 +38449,42 @@ var ts; .expression .expression; } - else if (container.kind === 154 && - container.parent.kind === 186 && + else if (container.kind === 156 && + container.parent.kind === 188 && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6) { return container.parent.parent.left.expression; } - else if (container.kind === 194 && - container.parent.kind === 273 && - container.parent.parent.kind === 186 && + else if (container.kind === 196 && + container.parent.kind === 275 && + container.parent.parent.kind === 188 && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) { return container.parent.parent.parent.left.expression; } + else if (container.kind === 196 && + 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) { + return container.parent.parent.parent.arguments[0].expression; + } + else if (ts.isMethodDeclaration(container) && + ts.isIdentifier(container.name) && + (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") && + ts.isObjectLiteralExpression(container.parent) && + ts.isCallExpression(container.parent.parent) && + container.parent.parent.arguments[2] === container.parent && + ts.getAssignmentDeclarationKind(container.parent.parent) === 9) { + return container.parent.parent.arguments[0].expression; + } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 287) { + if (jsdocType && jsdocType.kind === 289) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -37722,14 +38498,14 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 151; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 189 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 191 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 195) { + while (container && container.kind === 197) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -37737,14 +38513,14 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147; }); - if (current && current.kind === 147) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 149; }); + if (current && current.kind === 149) { 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 === 186)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 188)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -37752,7 +38528,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 155) { + if (!isCallExpression && container.kind === 157) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32) || isCallExpression) { @@ -37762,7 +38538,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 154 && ts.hasModifier(container, 256)) { + if (container.kind === 156 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -37773,7 +38549,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 186) { + if (container.parent.kind === 188) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -37792,7 +38568,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 155 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 157 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } @@ -37804,24 +38580,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 155; + return container.kind === 157; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 186) { + if (ts.isClassLike(container.parent) || container.parent.kind === 188) { if (ts.hasModifier(container, 32)) { - return container.kind === 154 || - container.kind === 153 || - container.kind === 156 || - container.kind === 157; + return container.kind === 156 || + container.kind === 155 || + container.kind === 158 || + container.kind === 159; } else { - return container.kind === 154 || + return container.kind === 156 || + container.kind === 155 || + container.kind === 158 || + container.kind === 159 || + container.kind === 154 || container.kind === 153 || - container.kind === 156 || - container.kind === 157 || - container.kind === 152 || - container.kind === 151 || - container.kind === 155; + container.kind === 157; } } } @@ -37829,10 +38605,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 154 || - func.kind === 156 || - func.kind === 157) && func.parent.kind === 186 ? func.parent : - func.kind === 194 && func.parent.kind === 273 ? func.parent.parent : + return (func.kind === 156 || + func.kind === 158 || + func.kind === 159) && func.parent.kind === 188 ? func.parent : + func.kind === 196 && func.parent.kind === 275 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -37840,11 +38616,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 524288 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 195) { + if (func.kind === 197) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -37868,7 +38644,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 273) { + if (literal.parent.kind !== 275) { break; } literal = literal.parent.parent; @@ -37877,9 +38653,9 @@ var ts; return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } var parent = func.parent; - if (parent.kind === 202 && parent.operatorToken.kind === 58) { + if (parent.kind === 204 && parent.operatorToken.kind === 59) { var target = parent.left; - if (target.kind === 187 || target.kind === 188) { + if (target.kind === 189 || target.kind === 190) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -37929,7 +38705,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 149) { + if (declaration.kind === 151) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -37941,7 +38717,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 184) { + if (parentDeclaration.kind !== 186) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -38024,10 +38800,13 @@ var ts; } function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); + if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { + return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 191) { + if (template.parent.kind === 193) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -38036,7 +38815,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 58: + case 59: if (node !== right) { return undefined; } @@ -38045,12 +38824,12 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 54: + case 55: var type = getContextualType(binaryExpression); return !type && node === right && !ts.isDefaultedExpandoInitializer(binaryExpression) ? getTypeOfExpression(left) : type; - case 53: - case 26: + case 54: + case 27: return node === right ? getContextualType(binaryExpression) : undefined; default: return undefined; @@ -38113,13 +38892,17 @@ var ts; } var thisType = checkThisExpression(thisAccess.expression); return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + case 7: + case 8: + case 9: + return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - if (t.flags & 917504) { + if (t.flags & 3670016) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -38130,8 +38913,8 @@ var ts; return restType; } } - return isNumericLiteralName(name) && getIndexTypeOfContextualType(type, 1) || - getIndexTypeOfContextualType(type, 0); + return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) || + getIndexTypeOfContextualType(t, 0); } return undefined; }, true); @@ -38164,7 +38947,6 @@ var ts; } function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || getIndexTypeOfContextualType(arrayContextualType, 1) || getIteratedTypeOrElementType(arrayContextualType, undefined, false, false, false)); } function getContextualTypeForConditionalOperand(node) { @@ -38198,33 +38980,34 @@ var ts; } function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 9: + case 10: case 8: - case 13: - case 101: - case 86: - case 95: - case 71: - case 140: + case 9: + case 14: + case 102: + case 87: + case 96: + case 72: + case 141: return true; - case 187: - case 193: + case 189: + case 195: return isPossiblyDiscriminantValue(node.expression); - case 268: + case 270: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 273 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 275 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 265 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 267 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (contextualType && contextualType.flags & 262144) { + if (contextualType && contextualType.flags & 1048576) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, contextualType); } @@ -38243,53 +39026,53 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 235: - case 149: - case 152: + case 237: case 151: - case 184: + case 154: + case 153: + case 186: return getContextualTypeForInitializerExpression(node); - case 195: - case 228: + case 197: + case 230: return getContextualTypeForReturnExpression(node); - case 205: + case 207: return getContextualTypeForYieldOperand(parent); - case 199: + case 201: return getContextualTypeForAwaitOperand(parent); - case 189: - case 190: - return getContextualTypeForArgument(parent, node); + case 191: case 192: - case 210: + return getContextualTypeForArgument(parent, node); + case 194: + case 212: return getTypeFromTypeNode(parent.type); - case 202: + case 204: return getContextualTypeForBinaryOperand(node); - case 273: - case 274: - return getContextualTypeForObjectLiteralElement(parent); case 275: + case 276: + return getContextualTypeForObjectLiteralElement(parent); + case 277: return getApparentTypeOfContextualType(parent.parent); - case 185: { + case 187: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 203: + case 205: return getContextualTypeForConditionalOperand(node); - case 214: - ts.Debug.assert(parent.parent.kind === 204); + case 216: + ts.Debug.assert(parent.parent.kind === 206); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 193: { + case 195: { var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 268: + case 270: return getContextualTypeForJsxExpression(parent); - case 265: case 267: + case 269: return getContextualTypeForJsxAttribute(parent); - case 260: - case 259: + case 262: + case 261: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -38302,58 +39085,10 @@ var ts; if (ts.isJsxOpeningElement(node) && node.parent.contextualType) { return node.parent.contextualType; } - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - var valueType = checkExpression(node.tagName); - if (isTypeAny(valueType)) { - return anyType; - } - var isJs = ts.isInJSFile(node); - return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); + return getContextualTypeForArgumentAtIndex(node, 0); } - function getJsxSignaturesParameterTypes(valueType, isJs, context) { - if (valueType.flags & 4) { - return anyType; - } - else if (valueType.flags & 64) { - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = valueType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); - if (indexSignatureType) { - return indexSignatureType; - } - } - return anyType; - } - var signatures = getSignaturesOfType(valueType, 1); - var ctor = true; - if (signatures.length === 0) { - signatures = getSignaturesOfType(valueType, 0); - ctor = false; - if (signatures.length === 0) { - return errorType; - } - } - var links = getNodeLinks(context); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(valueType); - var cachedResolved = links.resolvedSignatures.get(cacheKey); - if (cachedResolved && cachedResolved !== resolvingSignaturesArray) { - signatures = cachedResolved; - } - else if (!cachedResolved) { - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); - links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures)); - } - return getUnionType(ts.map(signatures, ctor ? function (t) { return getJsxPropsTypeFromClassType(t, isJs, context, false); } : function (t) { return getJsxPropsTypeFromCallSignature(t, context); }), 0); + function getEffectiveFirstArgumentForJsxSignature(signature, node) { + return getJsxReferenceKind(node) !== 0 ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); @@ -38368,22 +39103,40 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getStaticTypeOfReferencedJsxConstructor(context) { + if (isJsxIntrinsicIdentifier(context.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context); + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + var tagType = checkExpressionCached(context.tagName); + if (tagType.flags & 128) { + var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); + if (!result) { + return errorType; + } + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + return tagType; + } function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var ctorType = getStaticTypeOfReferencedJsxConstructor(context); if (ts.length(declaredManagedType.typeParameters) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); } } return attributesType; } - function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { + function getJsxPropsTypeFromClassType(sig, context) { var ns = getJsxNamespaceAt(context); var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined @@ -38392,7 +39145,7 @@ var ts; ? getReturnTypeOfSignature(sig) : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation); if (!attributesType) { - if (reportErrors && !!forcedLookupLocation && !!ts.length(context.attributes.properties)) { + if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) { error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation)); } return emptyObjectType; @@ -38408,7 +39161,7 @@ var ts; var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams - ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isJs)) + ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context))) : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); @@ -38441,7 +39194,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 194 || node.kind === 195; + return node.kind === 196 || node.kind === 197; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -38454,7 +39207,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -38463,7 +39216,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 262144)) { + if (!(type.flags & 1048576)) { return getContextualCallSignature(type, node); } var signatureList; @@ -38498,8 +39251,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 184 && !!node.initializer) || - (node.kind === 202 && node.operatorToken.kind === 58); + return (node.kind === 186 && !!node.initializer) || + (node.kind === 204 && node.operatorToken.kind === 59); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -38510,7 +39263,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 206) { + if (inDestructuringPattern && e.kind === 208) { var restArrayType = checkExpression(e.expression, checkMode, forceTuple); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); @@ -38523,12 +39276,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 206) { + if (index < elementCount - 1 && e.kind === 208) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 208; var minLength = elementCount - (hasRestElement ? 1 : 0); var tupleResult = void 0; if (inDestructuringPattern && minLength > 0) { @@ -38550,15 +39303,15 @@ var ts; if (contextualType && forEachType(contextualType, isTupleLikeType)) { var minLength = elementCount - (hasRestElement ? 1 : 0); var pattern = contextualType.pattern; - if (!hasRestElement && pattern && (pattern.kind === 183 || pattern.kind === 185)) { + if (!hasRestElement && pattern && (pattern.kind === 185 || pattern.kind === 187)) { var patternElements = pattern.elements; for (var i = elementCount; i < patternElements.length; i++) { var e = patternElements[i]; if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else if (i < patternElements.length - 1 || !(e.kind === 184 && e.dotDotDotToken || e.kind === 206)) { - if (e.kind !== 208) { + else if (i < patternElements.length - 1 || !(e.kind === 186 && e.dotDotDotToken || e.kind === 208)) { + if (e.kind !== 210) { error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -38576,19 +39329,19 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 147: + case 149: return isNumericComputedName(name); - case 71: + case 72: return isNumericLiteralName(name.escapedText); case 8: - case 9: + case 10: return isNumericLiteralName(name.text); default: return false; } } function isNumericComputedName(name) { - return isTypeAssignableToKind(checkComputedPropertyName(name), 168); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -38600,8 +39353,8 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (links.resolvedType.flags & 24576 || - !isTypeAssignableToKind(links.resolvedType, 68 | 168 | 3072) && + if (links.resolvedType.flags & 98304 || + !isTypeAssignableToKind(links.resolvedType, 132 | 296 | 12288) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -38627,10 +39380,10 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 33554432; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 182 || contextualType.pattern.kind === 186); + (contextualType.pattern.kind === 184 || contextualType.pattern.kind === 188); var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -38643,13 +39396,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 147 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 149 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 273 || - memberDecl.kind === 274 || + if (memberDecl.kind === 275 || + memberDecl.kind === 276 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 273 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 274 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 275 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 276 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -38662,7 +39415,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 2240 ? + var nameType = computedNameType && computedNameType.flags & 8576 ? computedNameType : undefined; var prop = nameType ? createSymbol(4 | member.flags, getLateBoundNameFromType(nameType), 1024) : @@ -38671,8 +39424,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 273 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 274 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 275 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 276 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -38695,12 +39448,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 275) { + else if (memberDecl.kind === 277) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768); propertiesArray = []; propertiesTable = ts.createSymbolTable(); hasComputedStringProperty = false; @@ -38712,15 +39465,15 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 0); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 32768); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 156 || memberDecl.kind === 157); + ts.Debug.assert(memberDecl.kind === 158 || memberDecl.kind === 159); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 2240)) { + if (computedNameType && !(computedNameType.flags & 8576)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -38752,7 +39505,7 @@ var ts; } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768); } return spread; } @@ -38761,9 +39514,8 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432; - result.flags |= 268435456 | freshObjectLiteralFlag | (typeFlags & 939524096); - result.objectFlags |= 128; + result.flags |= 268435456 | typeFlags & 939524096; + result.objectFlags |= 128 | freshObjectLiteralFlag; if (isJSObjectLiteral) { result.objectFlags |= 16384; } @@ -38773,52 +39525,51 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 24576)) { - propagatedFlags |= (result.flags & 939524096); - } + propagatedFlags |= result.flags & 939524096; return result; } } function isValidSpreadType(type) { - return !!(type.flags & (3 | 16777216) || - getFalsyFlags(type) & 29120 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 131072 && !isGenericMappedType(type) || - type.flags & 786432 && ts.every(type.types, isValidSpreadType)); + return !!(type.flags & (3 | 67108864 | 524288 | 58982400) || + getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 3145728 && ts.every(type.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { - checkJsxOpeningLikeElementOrOpeningFragment(node, 0); + checkJsxOpeningLikeElementOrOpeningFragment(node); } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxElementDeferred(node) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement); if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); } else { checkExpression(node.closingElement.tagName); } + checkJsxChildren(node); } function checkJsxElement(node, _checkMode) { checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxFragment(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment, checkMode); + function checkJsxFragment(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment); if (compilerOptions.jsx === 2 && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) { error(node, compilerOptions.jsxFactory ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma); } + checkJsxChildren(node); return getJsxElementTypeAt(node) || anyType; } function isUnhyphenatedJsxName(name) { return !ts.stringContains(name, "-"); } function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 71 && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 72 && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -38828,18 +39579,19 @@ var ts; function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createSymbolTable(); - var spread = emptyObjectType; + var spread = emptyJsxObjectType; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var propagatingFlags = 0; + var typeFlags = 0; + var objectFlags = 4096; 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); - propagatingFlags |= (exprType.flags & 939524096); + typeFlags |= exprType.flags & 939524096; var attributeSymbol = createSymbol(4 | 33554432 | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -38854,9 +39606,9 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 267); + ts.Debug.assert(attributeDecl.kind === 269); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); attributesTable = ts.createSymbolTable(); } var exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -38864,7 +39616,7 @@ var ts; hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, openingLikeElement.symbol, propagatingFlags, 4096); + spread = getSpreadType(spread, exprType, attributes.symbol, typeFlags, objectFlags); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -38873,10 +39625,10 @@ var ts; } if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); } } - var parent = openingLikeElement.parent.kind === 258 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 260 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -38891,20 +39643,21 @@ var ts; (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, false) || createArrayType(getUnionType(childrenTypes))); var childPropMap = ts.createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); - spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, propagatingFlags, 4096); + spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, typeFlags, objectFlags); } } if (hasSpreadAnyType) { return anyType; } - if (typeToIntersect && spread !== emptyObjectType) { + if (typeToIntersect && spread !== emptyJsxObjectType) { return getIntersectionType([typeToIntersect, spread]); } - return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); + return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread); function createJsxAttributesType() { + objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined); - result.flags |= (propagatingFlags |= 268435456); - result.objectFlags |= 128 | 4096; + result.flags |= 268435456 | typeFlags; + result.objectFlags |= 128 | objectFlags; return result; } } @@ -38912,7 +39665,7 @@ var ts; var childrenTypes = []; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; - if (child.kind === 10) { + if (child.kind === 11) { if (!child.containsOnlyWhiteSpaces) { childrenTypes.push(stringType); } @@ -38961,56 +39714,6 @@ var ts; } return links.resolvedSymbol; } - function instantiateJsxSignatures(node, signatures) { - var instantiatedSignatures = []; - var candidateForTypeArgumentError; - var hasTypeArgumentError = !!node.typeArguments; - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; - if (signature.typeParameters) { - var isJavascript = ts.isInJSFile(node); - var typeArgumentInstantiated = getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, false); - if (typeArgumentInstantiated) { - hasTypeArgumentError = false; - instantiatedSignatures.push(typeArgumentInstantiated); - } - else { - if (node.typeArguments && hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - candidateForTypeArgumentError = signature; - } - var inferenceContext = createInferenceContext(signature.typeParameters, signature, isJavascript ? 2 : 0); - var typeArguments = inferJsxTypeArguments(signature, node, inferenceContext); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); - } - } - else { - instantiatedSignatures.push(signature); - } - } - if (node.typeArguments && hasTypeArgumentError) { - if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true); - } - else if (node.typeArguments.length !== 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, node.typeArguments)); - } - } - return instantiatedSignatures; - } - function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { - if (reportErrors === void 0) { reportErrors = false; } - if (!node.typeArguments) { - return; - } - if (!hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - return; - } - var args = checkTypeArguments(signature, node.typeArguments, reportErrors); - if (!args) { - return; - } - return getSignatureInstantiation(signature, args, isJavascript); - } function getJsxNamespaceAt(location) { var links = location && getNodeLinks(location); if (links && links.jsxNamespace) { @@ -39060,157 +39763,54 @@ var ts; function getJsxElementChildrenPropertyName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } - function getApparentTypeOfJsxPropsType(propsType) { - if (!propsType) { - return undefined; - } - if (propsType.flags & 524288) { - var propsApparentType = []; - for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { - var t = _a[_i]; - propsApparentType.push(getApparentType(t)); - } - return getIntersectionType(propsApparentType); - } - return getApparentType(propsType); - } - function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined, false); - if (callSignature !== unknownSignature) { - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } - } - } - return undefined; - } - function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - var candidatesOutArray = []; - getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, false); - var result = void 0; - var allMatchingAttributesType = void 0; - for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { - var candidate = candidatesOutArray_1[_i]; - var callReturnType = getReturnTypeOfSignature(candidate); - var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - var shouldBeCandidate = true; - for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { - var attribute = _b[_a]; - if (ts.isJsxAttribute(attribute) && - isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { - shouldBeCandidate = false; - break; - } - } - if (shouldBeCandidate) { - result = intersectTypes(result, paramType); - } - allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); - } - } - if (!result) { - result = allMatchingAttributesType; - } - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - result = intersectTypes(intrinsicAttributes, result); - } - return result; - } - } - return undefined; - } - function getInstantiatedJsxSignatures(openingLikeElement, elementType, reportErrors) { - var links = getNodeLinks(openingLikeElement); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(elementType); - if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) === resolvingSignaturesArray) { - return; - } - else if (links.resolvedSignatures.get(cacheKey)) { - return links.resolvedSignatures.get(cacheKey); - } - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + function getUninstantiatedJsxSignaturesOfType(elementType) { var signatures = getSignaturesOfType(elementType, 1); if (signatures.length === 0) { signatures = getSignaturesOfType(elementType, 0); - if (signatures.length === 0) { - if (reportErrors) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(openingLikeElement.tagName)); - } + } + if (signatures.length === 0 && elementType.flags & 1048576) { + signatures = getUnionSignatures(ts.map(elementType.types, getUninstantiatedJsxSignaturesOfType)); + } + return signatures; + } + function getIntrinsicAttributesTypeFromStringLiteralType(type, location) { + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location); + if (intrinsicElementsType !== errorType) { + var stringLiteralTypeName = type.value; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + return indexSignatureType; + } + return undefined; + } + return anyType; + } + function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { + if (refKind === 1) { + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + if (sfcReturnConstraint) { + checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else if (refKind === 0) { + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (classConstraint) { + checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else { + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (!sfcReturnConstraint || !classConstraint) { return; } + var combined = getUnionType([sfcReturnConstraint, classConstraint]); + checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } - var results = instantiateJsxSignatures(openingLikeElement, signatures); - links.resolvedSignatures.set(cacheKey, results); - return results; - } - function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 262144) { - var types = elementType.types; - return getUnionType(types.map(function (type) { - return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); - }), 2); - } - if (isTypeAny(elementType)) { - return elementType; - } - else if (elementType.flags & 4) { - return anyType; - } - else if (elementType.flags & 64) { - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = elementType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); - if (indexSignatureType) { - return indexSignatureType; - } - error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); - } - return anyType; - } - var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, true); - if (!ts.length(instantiatedSignatures)) { - return errorType; - } - var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2); - var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? - tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : - defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); - if (statelessAttributesType) { - return statelessAttributesType; - } - if (elementClassType) { - checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - var isJs = ts.isInJSFile(openingLikeElement); - return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, true); })); } function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); @@ -39229,30 +39829,6 @@ var ts; } return links.resolvedJsxElementAttributesType; } - function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { - return resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, checkExpression(node.tagName), getJsxElementClassTypeAt(node)); - } - function getAllAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - return getCustomJsxElementAttributesType(node, true); - } - } - function getAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - return getCustomJsxElementAttributesType(node, false); - } - } - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); - var prop = getPropertyOfType(attributesType, attrib.name.escapedText); - return prop || unknownSymbol; - } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); if (type === errorType) @@ -39282,7 +39858,7 @@ var ts; } } } - function checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode) { + function checkJsxOpeningLikeElementOrOpeningFragment(node) { var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node); if (isNodeOpeningLikeElement) { checkGrammarJsxElement(node); @@ -39299,14 +39875,12 @@ var ts; } } if (isNodeOpeningLikeElement) { - checkJsxAttributesAssignableToTagNameAttributes(node, checkMode); - } - else { - checkJsxChildren(node.parent); + var sig = getResolvedSignature(node); + checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(node), getReturnTypeOfSignature(sig), node); } } function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 131072) { + if (targetType.flags & 524288) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -39315,7 +39889,7 @@ var ts; return true; } } - else if (targetType.flags & 786432) { + else if (targetType.flags & 3145728) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -39323,36 +39897,12 @@ var ts; } } } - else if (targetType.flags & 4194304) { + else if (targetType.flags & 16777216) { return isKnownProperty(targetType.root.trueType, name, isComparingJsxAttributes) || isKnownProperty(targetType.root.falseType, name, isComparingJsxAttributes); } return false; } - function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement, checkMode) { - var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? - getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : - getCustomJsxElementAttributesType(openingLikeElement, false); - var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); - var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); - if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { - for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { - var attribute = _a[_i]; - if (!ts.isJsxAttribute(attribute)) { - continue; - } - var attrName = attribute.name; - var isNotIgnoredJsxProperty = (isUnhyphenatedJsxName(ts.idText(attrName)) || !!(getPropertyOfType(targetAttributesType, attrName.escapedText))); - if (isNotIgnoredJsxProperty && !isKnownProperty(targetAttributesType, attrName.escapedText, true)) { - error(attribute, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(attrName), typeToString(targetAttributesType)); - break; - } - } - } - else if (!isSourceAttributeTypeAssignableToTarget) { - checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); - } - } function checkJsxExpression(node, checkMode) { if (node.expression) { var type = checkExpression(node.expression, checkMode); @@ -39380,7 +39930,7 @@ var ts; } function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 146 ? node.right : node.kind === 181 ? node : node.name; + var errorNode = node.kind === 148 ? node.right : node.kind === 183 ? node : node.name; if (ts.getCheckFlags(prop) & 256) { error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; @@ -39429,12 +39979,12 @@ var ts; return false; } var thisType = getTypeFromTypeNode(thisParameter.type); - enclosingClass = ((thisType.flags & 65536) ? getConstraintOfTypeParameter(thisType) : thisType); + enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType); } if (flags & 32) { return true; } - if (type.flags & 65536) { + if (type.flags & 262144) { type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); } if (!type || !hasBaseType(type, enclosingClass)) { @@ -39453,19 +40003,26 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function getNonNullableTypeIfNeeded(type) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304; + if (kind) { + return getNonNullableType(type); + } + return type; + } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (type.flags & 2) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304; if (kind) { - error(node, kind & 8192 ? kind & 16384 ? + error(node, kind & 32768 ? kind & 65536 ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (24576 | 32768) ? errorType : t; + return t.flags & (98304 | 131072) ? errorType : t; } return type; } @@ -39498,7 +40055,7 @@ var ts; return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 65536 && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 262144 && leftType.isThisType ? apparentType : leftType); } return errorType; } @@ -39509,9 +40066,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 99); + markPropertyAsReferenced(prop, node, left.kind === 100); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 97, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 98, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); @@ -39520,17 +40077,17 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - if (node.kind !== 187 || + if (node.kind !== 189 || assignmentKind === 1 || - prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 262144)) { + prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) { return propType; } var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && left.kind === 99) { + if (strictNullChecks && strictPropertyInitialization && left.kind === 100) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 155 && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 157 && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -39542,7 +40099,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 8192) && getFalsyFlags(flowType) & 8192) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) { error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); return propType; } @@ -39560,8 +40117,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 238 && - node.parent.kind !== 162 && + else if (valueDeclaration.kind === 240 && + node.parent.kind !== 164 && !(valueDeclaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -39573,9 +40130,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 152: + case 154: return true; - case 273: + case 275: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -39608,7 +40165,7 @@ var ts; function reportNonexistentProperty(propNode, containingType) { var errorInfo; var relatedInfo; - if (containingType.flags & 262144 && !(containingType.flags & 32764)) { + if (containingType.flags & 1048576 && !(containingType.flags & 131068)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -39698,16 +40255,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 187: - return isValidPropertyAccessWithType(node, node.expression.kind === 97, propertyName, getWidenedType(checkExpression(node.expression))); - case 146: + case 189: + return isValidPropertyAccessWithType(node, node.expression.kind === 98, propertyName, getWidenedType(checkExpression(node.expression))); + case 148: return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left))); - case 181: + case 183: return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind !== 181 && node.expression.kind === 97, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind !== 183 && node.expression.kind === 98, property.escapedName, type) && (!(property.flags & 8192) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -39733,17 +40290,17 @@ var ts; } var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, isSuper, type, prop) - : ts.isInJSFile(node) && (type.flags & 262144) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); + : ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 236) { + if (initializer.kind === 238) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 71) { + else if (initializer.kind === 72) { return getResolvedSymbol(initializer); } return undefined; @@ -39753,13 +40310,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 71) { + if (e.kind === 72) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 224 && + if (node.kind === 226 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -39777,7 +40334,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 190 && node.parent.expression === node) { + if (node.parent.kind === 192 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -39793,7 +40350,7 @@ var ts; if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9) { + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -39806,7 +40363,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 3072) === 0) { + if ((expressionType.flags & 12288) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -39830,16 +40387,19 @@ var ts; return true; } function callLikeExpressionMayHaveTypeArguments(node) { - return ts.isCallOrNewExpression(node); + return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); } function resolveUntypedCall(node) { if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 191) { + if (node.kind === 193) { checkExpression(node.template); } - else if (node.kind !== 150) { + else if (ts.isJsxOpeningLikeElement(node)) { + checkExpression(node.attributes); + } + else if (node.kind !== 152) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -39858,8 +40418,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var signature = signatures_4[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -39888,36 +40448,47 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 206 || arg.kind === 213 && arg.isSpread); + return !!arg && (arg.kind === 208 || arg.kind === 215 && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } + function acceptsVoid(t) { + return !!(t.flags & 16384); + } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } - if (ts.isJsxOpeningLikeElement(node)) { - return true; - } var argCount; var callIsIncomplete = false; - if (node.kind === 191) { + var effectiveParameterCount = getParameterCount(signature); + var effectiveMinimumArguments = getMinArgumentCount(signature); + if (node.kind === 193) { argCount = args.length; - if (node.template.kind === 204) { + if (node.template.kind === 206) { var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } else { var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 13); + ts.Debug.assert(templateLiteral.kind === 14); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 150) { + else if (node.kind === 152) { argCount = getDecoratorArgumentCount(node, signature); } + else if (ts.isJsxOpeningLikeElement(node)) { + callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + argCount = effectiveMinimumArguments === 0 ? args.length : 1; + effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1; + effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1); + } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 190); + ts.Debug.assert(node.kind === 192); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -39927,11 +40498,19 @@ var ts; return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } } - if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { + if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) { return false; } - var hasEnoughArguments = argCount >= getMinArgumentCount(signature); - return callIsIncomplete || hasEnoughArguments; + if (callIsIncomplete || argCount >= effectiveMinimumArguments) { + return true; + } + for (var i = argCount; i < effectiveMinimumArguments; i++) { + var type = getTypeAtPosition(signature, i); + if (filterType(type, acceptsVoid).flags & 131072) { + return false; + } + } + return true; } function hasCorrectTypeArgumentArity(signature, typeArguments) { var numTypeParameters = ts.length(signature.typeParameters); @@ -39940,7 +40519,7 @@ var ts; (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); } function getSingleCallSignature(type) { - if (type.flags & 131072) { + if (type.flags & 524288) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -39960,12 +40539,9 @@ var ts; } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); } - function inferJsxTypeArguments(signature, node, context) { - var skipContextParamType = getTypeAtPosition(signature, 0); - var checkAttrTypeSkipContextSensitive = checkExpressionWithContextualType(node.attributes, skipContextParamType, identityMapper); - inferTypes(context.inferences, checkAttrTypeSkipContextSensitive, skipContextParamType); - var paramType = getTypeAtPosition(signature, 0); - var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context); + function inferJsxTypeArguments(node, signature, excludeArgument, context) { + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] !== undefined ? identityMapper : context); inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } @@ -39976,7 +40552,10 @@ var ts; inference.inferredType = undefined; } } - if (node.kind !== 150) { + if (ts.isJsxOpeningLikeElement(node)) { + return inferJsxTypeArguments(node, signature, excludeArgument, context); + } + if (node.kind !== 152) { var contextualType = getContextualType(node); if (contextualType) { var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); @@ -39998,7 +40577,7 @@ 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 !== 208) { + if (arg.kind !== 210) { var paramType = getTypeAtPosition(signature, i); var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : context; var argType = checkExpressionWithContextualType(arg, paramType, mapper); @@ -40012,7 +40591,7 @@ var ts; return getInferredTypes(context); } function getArrayifiedType(type) { - if (forEachType(type, function (t) { return !(t.flags & (1 | 15794176) || isArrayType(t) || isTupleType(t)); })) { + if (forEachType(type, function (t) { return !(t.flags & (1 | 63176704) || isArrayType(t) || isTupleType(t)); })) { return createArrayType(getIndexTypeOfType(type, 1) || errorType); } return type; @@ -40021,13 +40600,13 @@ var ts; if (index >= argCount - 1) { var arg = args[argCount - 1]; if (isSpreadArgument(arg)) { - return arg.kind === 213 ? + return arg.kind === 215 ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context)); } } var contextualType = getIndexTypeOfType(restType, 1) || anyType; - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 | 1048576); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304); var types = []; var spreadIndex = -1; for (var i = index; i < argCount; i++) { @@ -40063,29 +40642,30 @@ var ts; } return typeArgumentTypes; } - function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { - var callIsIncomplete = node.attributes.end === node.end; - if (callIsIncomplete) { - return true; + function getJsxReferenceKind(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return 2; } - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; - var paramType = getTypeAtPosition(signature, 0); - var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined); - var argProperties = getPropertiesOfType(attributesType); - for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { - var arg = argProperties_1[_i]; - if (!getPropertyOfType(paramType, arg.escapedName) && isUnhyphenatedJsxName(arg.escapedName)) { - return false; - } + var tagType = getApparentType(checkExpression(node.tagName)); + if (ts.length(getSignaturesOfType(tagType, 1))) { + return 0; } - return checkTypeRelatedTo(attributesType, paramType, relation, undefined, headMessage); + if (ts.length(getSignaturesOfType(tagType, 0))) { + return 1; + } + return 2; + } + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors) { + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] ? identityMapper : undefined); + return checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes); } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { if (ts.isJsxOpeningLikeElement(node)) { - return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 190) { + if (thisType && thisType !== voidType && node.kind !== 192) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -40099,7 +40679,7 @@ 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 !== 208) { + if (arg.kind !== 210) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; @@ -40116,36 +40696,36 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 189) { + if (node.kind === 191) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 187 || callee.kind === 188) { + if (callee.kind === 189 || callee.kind === 190) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(213, parent.pos, parent.end); + var result = ts.createNode(215, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; return result; } function getEffectiveCallArguments(node) { - if (node.kind === 191) { + if (node.kind === 193) { var template = node.template; var args_4 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 204) { + if (template.kind === 206) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - if (node.kind === 150) { + if (node.kind === 152) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { - return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; + return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray; } var args = node.arguments || ts.emptyArray; var length = args.length; @@ -40165,23 +40745,23 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 238: - case 207: + case 240: + case 209: return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 149: + case 151: var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 155 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 157 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 152: case 154: case 156: - case 157: - var hasPropDesc = parent.kind !== 152 && languageVersion !== 0; + case 158: + case 159: + var hasPropDesc = parent.kind !== 154 && languageVersion !== 0; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -40192,16 +40772,16 @@ var ts; } function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 238: - case 207: + case 240: + case 209: return 1; - case 152: - return 2; case 154: + return 2; case 156: - case 157: + case 158: + case 159: return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3; - case 149: + case 151: return 3; default: return ts.Debug.fail(); @@ -40214,8 +40794,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -40259,8 +40839,8 @@ var ts; function getTypeArgumentArityError(node, signatures, typeArguments) { var min = Infinity; var max = -Infinity; - for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { - var sig = signatures_6[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); max = Math.max(max, ts.length(sig.typeParameters)); } @@ -40268,20 +40848,23 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp, fallbackError) { - var isTaggedTemplate = node.kind === 191; - var isDecorator = node.kind === 150; + var isTaggedTemplate = node.kind === 193; + var isDecorator = node.kind === 152; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); + var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 97) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 98) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; reorderCandidates(signatures, candidates); if (!candidates.length) { - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + if (reportErrors) { + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + } return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -40291,7 +40874,7 @@ var ts; var candidateForArgumentArityError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = isForSignatureHelp && node.kind === 189 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = isForSignatureHelp && node.kind === 191 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -40301,28 +40884,27 @@ var ts; if (result) { return result; } - if (candidateForArgumentError) { - if (isJsxOpeningOrSelfClosingElement) { - return candidateForArgumentError; + if (reportErrors) { + if (candidateForArgumentError) { + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); } - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); - } - else if (candidateForArgumentArityError) { - diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); - } - else if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError); - } - else { - var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); - if (signaturesWithCorrectTypeArgumentArity.length === 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + else if (candidateForArgumentArityError) { + diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); } - else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + else if (candidateForTypeArgumentError) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError); } - else if (fallbackError) { - diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + else { + var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); + if (signaturesWithCorrectTypeArgumentArity.length === 0) { + diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + } + else if (!isDecorator) { + diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + } + else if (fallbackError) { + diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + } } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); @@ -40499,7 +41081,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, isForSignatureHelp) { - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -40539,7 +41121,7 @@ var ts; } else { var relatedInformation = void 0; - if (node.arguments.length === 1 && isTypeAssertion(ts.first(node.arguments))) { + if (node.arguments.length === 1) { var text = ts.getSourceFileOfNode(node).text; if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) { relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); @@ -40556,8 +41138,8 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp); } function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 65536 || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 | 32768)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 262144 || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, isForSignatureHelp) { if (node.arguments && languageVersion < 1) { @@ -40614,7 +41196,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 524288) { + if (firstBase.flags & 2097152) { var types = firstBase.types; var mixinCount = ts.countWhere(types, isMixinConstructorType); var i = 0; @@ -40705,16 +41287,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 238: - case 207: + case 240: + case 209: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 149: + case 151: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 152: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 154: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 156: - case 157: + case 158: + case 159: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -40747,6 +41329,50 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp, headMessage); } + function createSignatureForJSXIntrinsic(node, result) { + var namespace = getJsxNamespaceAt(node); + var exports = namespace && getExportsOfSymbol(namespace); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 67897832); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832, node); + var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(120)); + var parameterSymbol = createSymbol(1, "props"); + parameterSymbol.type = result; + return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, false, false); + } + function resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + var fakeSignature = createSignatureForJSXIntrinsic(node, result); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined), result, node.tagName, node.attributes); + return fakeSignature; + } + var exprTypes = checkExpression(node.tagName); + var apparentType = getApparentType(exprTypes); + if (apparentType === errorType) { + return resolveErrorCall(node); + } + if (exprTypes.flags & 128) { + var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(exprTypes, node); + if (!intrinsicType) { + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, exprTypes.value, "JSX." + JsxNames.IntrinsicElements); + return resolveUntypedCall(node); + } + else { + var fakeSignature = createSignatureForJSXIntrinsic(node, intrinsicType); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined), intrinsicType, node.tagName, node.attributes); + return fakeSignature; + } + } + var signatures = getUninstantiatedJsxSignaturesOfType(apparentType); + if (exprTypes.flags & 4 || isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) { + return resolveUntypedCall(node); + } + if (signatures.length === 0) { + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return resolveErrorCall(node); + } + return resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp); + } function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { return signature.minArgumentCount === 0 && @@ -40754,38 +41380,19 @@ var ts; signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } - function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, isForSignatureHelp) { - ts.Debug.assert(!(elementType.flags & 262144)); - var callSignatures = elementType && getSignaturesOfType(elementType, 0); - if (callSignatures && callSignatures.length > 0) { - return resolveCall(openingLikeElement, callSignatures, candidatesOutArray, isForSignatureHelp); - } - return undefined; - } function resolveSignature(node, candidatesOutArray, isForSignatureHelp) { switch (node.kind) { - case 189: - return resolveCallExpression(node, candidatesOutArray, isForSignatureHelp); - case 190: - return resolveNewExpression(node, candidatesOutArray, isForSignatureHelp); case 191: + return resolveCallExpression(node, candidatesOutArray, isForSignatureHelp); + case 192: + return resolveNewExpression(node, candidatesOutArray, isForSignatureHelp); + case 193: return resolveTaggedTemplateExpression(node, candidatesOutArray, isForSignatureHelp); - case 150: + case 152: return resolveDecorator(node, candidatesOutArray, isForSignatureHelp); - case 260: - case 259: - var exprTypes = checkExpression(node.tagName); - return forEachType(exprTypes, function (exprType) { - var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray, isForSignatureHelp); - if (sfcResult && sfcResult !== unknownSignature) { - return sfcResult; - } - var sigs = getInstantiatedJsxSignatures(node, exprType); - if (candidatesOutArray && ts.length(sigs)) { - candidatesOutArray.push.apply(candidatesOutArray, sigs); - } - return ts.length(sigs) ? sigs[0] : unknownSignature; - }) || unknownSignature; + case 262: + case 261: + return resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -40817,7 +41424,7 @@ var ts; return false; } function isJSConstructorType(type) { - if (type.flags & 131072) { + if (type.flags & 524288) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); } @@ -40852,10 +41459,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 187) { + while (parent && parent.kind === 189) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 59) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -40876,18 +41483,18 @@ var ts; if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { return voidType; } - if (node.kind === 190) { + if (node.kind === 192) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 155 && - declaration.kind !== 159 && - declaration.kind !== 164 && + declaration.kind !== 157 && + declaration.kind !== 161 && + declaration.kind !== 166 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = checkExpression(node.expression).symbol; - if (!funcSymbol && node.expression.kind === 71) { + if (!funcSymbol && node.expression.kind === 72) { funcSymbol = getResolvedSymbol(node.expression); } var type = funcSymbol && getJSClassType(funcSymbol); @@ -40904,7 +41511,7 @@ var ts; return resolveExternalModuleTypeByLiteral(node.arguments[0]); } var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 3072 && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } var jsAssignmentType; @@ -40947,7 +41554,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 8192 || specifierType.flags & 16384 || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } var moduleSymbol = resolveExternalModuleName(node, specifier); @@ -40997,9 +41604,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 237 + ? 239 : resolvedRequire.flags & 3 - ? 235 + ? 237 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -41034,10 +41641,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 94) { + if (node.keywordToken === 95) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 91) { + if (node.keywordToken === 92) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -41048,7 +41655,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 === 155) { + else if (container.kind === 157) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -41216,7 +41823,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71) { + if (element.name.kind === 72) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -41230,7 +41837,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 71) { + if (decl.name.kind !== 72) { if (links.type === emptyObjectType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -41275,7 +41882,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 216) { + if (func.body.kind !== 218) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2) { type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -41364,18 +41971,18 @@ var ts; var facts = 0; if (hasDefault) { for (var i = end; i < witnesses.length; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 8192; + facts |= typeofNEFacts.get(witnesses[i]) || 32768; } for (var i = start; i < end; i++) { facts &= ~(typeofNEFacts.get(witnesses[i]) || 0); } for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 8192; + facts |= typeofNEFacts.get(witnesses[i]) || 32768; } } else { for (var i = start; i < end; i++) { - facts |= typeofEQFacts.get(witnesses[i]) || 64; + facts |= typeofEQFacts.get(witnesses[i]) || 128; } for (var i = 0; i < start; i++) { facts &= ~(typeofEQFacts.get(witnesses[i]) || 0); @@ -41387,12 +41994,12 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 197) { + if (node.expression.kind === 199) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node); var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true); var type_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 32768); + return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -41408,7 +42015,7 @@ var ts; if (!(func.flags & 128)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 232 && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -41425,7 +42032,7 @@ var ts; if (functionFlags & 2) { type = checkAwaitedType(type, 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 & 32768) { + if (type.flags & 131072) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -41445,11 +42052,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 194: - case 195: + case 196: + case 197: return true; - case 154: - return func.parent.kind === 186; + case 156: + return func.parent.kind === 188; default: return false; } @@ -41458,14 +42065,14 @@ var ts; if (!produceDiagnostics) { return; } - if (returnType && maybeTypeOfKind(returnType, 1 | 4096)) { + if (returnType && maybeTypeOfKind(returnType, 1 | 16384)) { return; } - if (func.kind === 153 || ts.nodeIsMissing(func.body) || func.body.kind !== 216 || !functionHasImplicitReturn(func)) { + if (func.kind === 155 || ts.nodeIsMissing(func.body) || func.body.kind !== 218 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; - if (returnType && returnType.flags & 32768) { + if (returnType && returnType.flags & 131072) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -41488,7 +42095,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (checkMode === 1 && isContextSensitive(node)) { if (!ts.getEffectiveReturnTypeNode(node) && hasContextSensitiveReturnExpression(node)) { @@ -41505,7 +42112,7 @@ var ts; return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 194) { + if (!hasGrammarError && node.kind === 196) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -41546,7 +42153,7 @@ var ts; getAwaitedType(type) || errorType : type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); if ((functionFlags & 1) === 0) { @@ -41556,7 +42163,7 @@ var ts; if (!ts.getEffectiveReturnTypeNode(node)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 216) { + if (node.body.kind === 218) { checkSourceElement(node.body); } else { @@ -41574,26 +42181,54 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 168)) { + if (!isTypeAssignableTo(type, numberOrBigIntType)) { error(operand, diagnostic); return false; } return true; } + function isReadonlyAssignmentDeclaration(d) { + if (!ts.isCallExpression(d)) { + return false; + } + if (!ts.isBindableObjectDefinePropertyCall(d)) { + return false; + } + var objectLitType = checkExpressionCached(d.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + var writableProp = getPropertyOfType(objectLitType, "writable"); + var writableType = writableProp && getTypeOfSymbol(writableProp); + if (!writableType || writableType === falseType || writableType === regularFalseType) { + return true; + } + if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) { + var initializer = writableProp.valueDeclaration.initializer; + var rawOriginalType = checkExpression(initializer); + if (rawOriginalType === falseType || rawOriginalType === regularFalseType) { + return true; + } + } + return false; + } + var setProp = getPropertyOfType(objectLitType, "set"); + return !setProp; + } function isReadonlySymbol(symbol) { return !!(ts.getCheckFlags(symbol) & 8 || symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 || symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || - symbol.flags & 8); + symbol.flags & 8 || + ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 187 || expr.kind === 188) && - expr.expression.kind === 99) { + (expr.kind === 189 || expr.kind === 190) && + expr.expression.kind === 100) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 155)) { + if (!(func && func.kind === 157)) { return true; } return !symbol.valueDeclaration || !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); @@ -41603,13 +42238,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 187 || expr.kind === 188) { + if (expr.kind === 189 || expr.kind === 190) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 71) { + if (node.kind === 72) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 249; + return !!declaration && declaration.kind === 251; } } } @@ -41617,7 +42252,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 71 && node.kind !== 187 && node.kind !== 188) { + if (node.kind !== 72 && node.kind !== 189 && node.kind !== 190) { error(expr, invalidReferenceMessage); return false; } @@ -41626,7 +42261,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 187 && expr.kind !== 188) { + if (expr.kind !== 189 && expr.kind !== 190) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -41662,36 +42297,51 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operand.kind === 8) { - if (node.operator === 38) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - } - else if (node.operator === 37) { - return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); - } + switch (node.operand.kind) { + case 8: + switch (node.operator) { + case 39: + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + case 38: + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } + break; + case 9: + if (node.operator === 39) { + return getFreshTypeOfLiteralType(getLiteralType({ + negative: true, + base10Value: ts.parsePseudoBigInt(node.operand.text) + })); + } } switch (node.operator) { - case 37: case 38: - case 52: + case 39: + case 53: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 3072)) { + if (maybeTypeOfKind(operandType, 12288)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - return numberType; - case 51: + if (node.operator === 38) { + if (maybeTypeOfKind(operandType, 2112)) { + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + } + return numberType; + } + return getUnaryResultType(operandType); + case 52: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (1048576 | 2097152); - return facts === 1048576 ? falseType : - facts === 2097152 ? trueType : + var facts = getTypeFacts(operandType) & (4194304 | 8388608); + return facts === 4194304 ? falseType : + facts === 8388608 ? trueType : booleanType; - case 43: case 44: - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + case 45: + 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) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } - return numberType; + return getUnaryResultType(operandType); } return errorType; } @@ -41700,17 +42350,25 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } + return getUnaryResultType(operandType); + } + function getUnaryResultType(operandType) { + if (maybeTypeOfKind(operandType, 2112)) { + return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296) + ? numberOrBigIntType + : bigintType; + } return numberType; } function maybeTypeOfKind(type, kind) { if (type.flags & kind & ~134217728 || kind & 134217728 && isGenericMappedType(type)) { return true; } - if (type.flags & 786432) { + if (type.flags & 3145728) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -41725,21 +42383,22 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 | 4096 | 8192 | 16384)) { + if (strict && source.flags & (3 | 16384 | 32768 | 65536)) { return false; } - return !!(kind & 168) && isTypeAssignableTo(source, numberType) || - !!(kind & 68) && isTypeAssignableTo(source, stringType) || - !!(kind & 272) && isTypeAssignableTo(source, booleanType) || - !!(kind & 4096) && isTypeAssignableTo(source, voidType) || - !!(kind & 32768) && isTypeAssignableTo(source, neverType) || - !!(kind & 16384) && isTypeAssignableTo(source, nullType) || - !!(kind & 8192) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 1024) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 16777216) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112) && isTypeAssignableTo(source, bigintType) || + !!(kind & 132) && isTypeAssignableTo(source, stringType) || + !!(kind & 528) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 262144 ? + return source.flags & 1048576 ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } @@ -41754,7 +42413,7 @@ var ts; return silentNeverType; } if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 32764)) { + allTypesAssignableToKind(leftType, 131068)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -41768,10 +42427,10 @@ var ts; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 | 3072))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 | 12288))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 16777216 | 14745600)) { + if (!isTypeAssignableToKind(rightType, 67108864 | 58982400)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -41781,17 +42440,17 @@ var ts; if (strictNullChecks && properties.length === 0) { return checkNonNullType(sourceType, node); } - for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { - var p = properties_7[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var p = properties_6[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) { if (rightIsThis === void 0) { rightIsThis = false; } - if (property.kind === 273 || property.kind === 274) { + if (property.kind === 275 || property.kind === 276) { var name = property.name; - if (name.kind === 147) { + if (name.kind === 149) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -41799,13 +42458,13 @@ var ts; } var type = getTypeOfObjectLiteralDestructuringProperty(objectLiteralType, name, property, rightIsThis); if (type) { - return checkDestructuringAssignment(property.kind === 274 ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 276 ? property : property.initializer, type); } else { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 275) { + else if (property.kind === 277) { if (languageVersion < 6) { checkExternalEmitHelpers(property, 4); } @@ -41854,8 +42513,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 208) { - if (element.kind !== 206) { + if (element.kind !== 210) { + if (element.kind !== 208) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType : everyType(sourceType, isTupleLikeType) ? getTupleElementType(sourceType, elementIndex) : @@ -41877,7 +42536,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 202 && restExpression.operatorToken.kind === 58) { + if (restExpression.kind === 204 && restExpression.operatorToken.kind === 59) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -41894,12 +42553,12 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 274) { + if (exprOrAssignment.kind === 276) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 8192)) { - sourceType = getTypeWithFacts(sourceType, 131072); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) { + sourceType = getTypeWithFacts(sourceType, 524288); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -41908,21 +42567,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 202 && target.operatorToken.kind === 58) { + if (target.kind === 204 && target.operatorToken.kind === 59) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 186) { + if (target.kind === 188) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 185) { + if (target.kind === 187) { 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 === 275 ? + var error = target.parent.kind === 277 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -41933,55 +42592,56 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 71: - case 9: - case 12: - case 191: - case 204: + case 72: + case 10: case 13: + case 193: + case 206: + case 14: case 8: - case 101: - case 86: - case 95: - case 140: - case 194: - case 207: - case 195: - case 185: - case 186: + case 9: + case 102: + case 87: + case 96: + case 141: + case 196: + case 209: case 197: - case 211: - case 259: - case 258: + case 187: + case 188: + case 199: + case 213: + case 261: + case 260: return true; - case 203: + case 205: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 202: + case 204: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 200: - case 201: + case 202: + case 203: switch (node.operator) { - case 51: - case 37: - case 38: case 52: + case 38: + case 39: + case 53: return true; } return false; - case 198: - case 192: - case 210: + case 200: + case 194: + case 212: default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 24576) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { @@ -41991,11 +42651,11 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 && (left.kind === 186 || left.kind === 185)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 99); + if (operator === 59 && (left.kind === 188 || left.kind === 187)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 100); } var leftType; - if (operator === 53 || operator === 54) { + if (operator === 54 || operator === 55) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -42003,61 +42663,82 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 39: case 40: - case 61: - case 62: case 41: + case 62: case 63: case 42: case 64: - case 38: - case 60: - case 45: + case 43: case 65: + case 39: + case 61: case 46: case 66: case 47: case 67: - case 49: - case 69: - case 50: - case 70: case 48: case 68: + case 50: + case 70: + case 51: + case 71: + case 49: + case 69: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; - if ((leftType.flags & 272) && - (rightType.flags & 272) && + if ((leftType.flags & 528) && + (rightType.flags & 528) && (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; } else { - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + var resultType_1; + if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) || + !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) { + resultType_1 = numberType; } + else if (isTypeAssignableToKind(leftType, 2112) && isTypeAssignableToKind(rightType, 2112)) { + switch (operator) { + case 48: + case 68: + reportOperatorError(); + } + resultType_1 = bigintType; + } + else { + reportOperatorError(); + resultType_1 = errorType; + } + if (leftOk && rightOk) { + checkAssignmentOperator(resultType_1); + } + return resultType_1; } - return numberType; - case 37: - case 59: + case 38: + case 60: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 68) && !isTypeAssignableToKind(rightType, 68)) { + if (!isTypeAssignableToKind(leftType, 132) && !isTypeAssignableToKind(rightType, 132)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 168, true) && isTypeAssignableToKind(rightType, 168, true)) { + if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) { resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 68, true) || isTypeAssignableToKind(rightType, 68, true)) { + else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) { + resultType = bigintType; + } + else if (isTypeAssignableToKind(leftType, 132, true) || isTypeAssignableToKind(rightType, 132, true)) { resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { @@ -42070,26 +42751,27 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 59) { + if (operator === 60) { checkAssignmentOperator(resultType); } return resultType; - case 27: - case 29: + case 28: case 30: case 31: + case 32: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); - if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { + if (!(isTypeComparableTo(leftType, rightType) || isTypeComparableTo(rightType, leftType) || + (isTypeAssignableTo(leftType, numberOrBigIntType) && isTypeAssignableTo(rightType, numberOrBigIntType)))) { reportOperatorError(); } } return booleanType; - case 32: case 33: case 34: case 35: + case 36: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -42100,19 +42782,19 @@ var ts; reportOperatorError(); } return booleanType; - case 93: + case 94: return checkInstanceOfExpression(left, right, leftType, rightType); - case 92: + case 93: return checkInExpression(left, right, leftType, rightType); - case 53: - return getTypeFacts(leftType) & 1048576 ? + case 54: + return getTypeFacts(leftType) & 4194304 ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 54: - return getTypeFacts(leftType) & 2097152 ? + case 55: + return getTypeFacts(leftType) & 8388608 ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) : leftType; - case 58: + case 59: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0; checkAssignmentDeclaration(declKind, right); if (isAssignmentDeclaration(declKind)) { @@ -42122,7 +42804,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 26: + case 27: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -42148,11 +42830,11 @@ var ts; } } function isEvalNode(node) { - return node.kind === 71 && node.escapedText === "eval"; + return node.kind === 72 && node.escapedText === "eval"; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072) ? left : - maybeTypeOfKind(rightType, 3072) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left : + maybeTypeOfKind(rightType, 12288) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -42162,15 +42844,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 50: + case 70: + return 55; + case 51: + case 71: + return 36; case 49: case 69: return 54; - case 50: - case 70: - return 35; - case 48: - case 68: - return 53; default: return undefined; } @@ -42210,11 +42892,11 @@ var ts; } function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { switch (operatorToken.kind) { - case 34: - case 32: - return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); case 35: case 33: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 36: + case 34: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); } return undefined; @@ -42278,14 +42960,14 @@ var ts; } function checkTemplateExpression(node) { ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288)) { error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } }); return stringType; } function getContextNode(node) { - if (node.kind === 266 && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 268 && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; } return node; @@ -42318,7 +43000,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 192 || node.kind === 210; + return node.kind === 194 || node.kind === 212; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -42327,7 +43009,7 @@ var ts; ts.isDeclarationReadonly(declaration) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 24576) { + if (widened.flags & 98304) { reportImplicitAny(declaration, anyType); return anyType; } @@ -42340,21 +43022,23 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 786432) { + if (contextualType.flags & 3145728) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 14745600) { + if (contextualType.flags & 58982400) { var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; - return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 64) || - maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 128) || - maybeTypeOfKind(constraint, 1024) && maybeTypeOfKind(candidateType, 2048) || + return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) || + maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) || + maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) || + maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) || isLiteralOfContextualType(candidateType, constraint); } - return !!(contextualType.flags & (64 | 1048576) && maybeTypeOfKind(candidateType, 64) || - contextualType.flags & 128 && maybeTypeOfKind(candidateType, 128) || + return !!(contextualType.flags & (128 | 4194304) && maybeTypeOfKind(candidateType, 128) || contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) || - contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048)); + contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) || + contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) || + contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192)); } return false; } @@ -42367,14 +43051,14 @@ var ts; getWidenedLiteralLikeTypeForContextualType(type, contextualType); } function checkPropertyAssignment(node, checkMode) { - if (node.name.kind === 147) { + if (node.name.kind === 149) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); } function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 147) { + if (node.name.kind === 149) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -42397,14 +43081,14 @@ var ts; } function getTypeOfExpression(node, cache) { var expr = ts.skipParentheses(node); - if (expr.kind === 189 && expr.expression.kind !== 97 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 191 && expr.expression.kind !== 98 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - else if (expr.kind === 192 || expr.kind === 210) { + else if (expr.kind === 194 || expr.kind === 212) { return getTypeFromTypeNode(expr.type); } return cache ? checkExpressionCached(node) : checkExpression(node); @@ -42422,7 +43106,7 @@ var ts; } function checkExpression(node, checkMode, forceTuple) { var type; - if (node.kind === 146) { + if (node.kind === 148) { type = checkQualifiedName(node); } else { @@ -42430,10 +43114,10 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 187 && node.parent.expression === node) || - (node.parent.kind === 188 && node.parent.expression === node) || - ((node.kind === 71 || node.kind === 146) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 165 && node.parent.exprName === node)); + var ok = (node.parent.kind === 189 && node.parent.expression === node) || + (node.parent.kind === 190 && node.parent.expression === node) || + ((node.kind === 72 || node.kind === 148) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 167 && node.parent.exprName === node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } @@ -42449,93 +43133,96 @@ var ts; } function checkExpressionWorker(node, checkMode, forceTuple) { switch (node.kind) { - case 71: + case 72: return checkIdentifier(node); - case 99: + case 100: return checkThisExpression(node); - case 97: + case 98: return checkSuperExpression(node); - case 95: + case 96: return nullWideningType; - case 13: - case 9: + case 14: + case 10: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101: + case 9: + checkGrammarBigIntLiteral(node); + return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); + case 102: return trueType; - case 86: + case 87: return falseType; - case 204: + case 206: return checkTemplateExpression(node); - case 12: + case 13: return globalRegExpType; - case 185: - return checkArrayLiteral(node, checkMode, forceTuple); - case 186: - return checkObjectLiteral(node, checkMode); case 187: - return checkPropertyAccessExpression(node); + return checkArrayLiteral(node, checkMode, forceTuple); case 188: - return checkIndexedAccess(node); + return checkObjectLiteral(node, checkMode); case 189: - if (node.expression.kind === 91) { + return checkPropertyAccessExpression(node); + case 190: + return checkIndexedAccess(node); + case 191: + if (node.expression.kind === 92) { return checkImportCallExpression(node); } - case 190: - return checkCallExpression(node); - case 191: - return checkTaggedTemplateExpression(node); - case 193: - return checkParenthesizedExpression(node, checkMode); - case 207: - return checkClassExpression(node); - case 194: - case 195: - return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 197: - return checkTypeOfExpression(node); case 192: - case 210: - return checkAssertion(node); - case 211: - return checkNonNullAssertion(node); - case 212: - return checkMetaProperty(node); + return checkCallExpression(node); + case 193: + return checkTaggedTemplateExpression(node); + case 195: + return checkParenthesizedExpression(node, checkMode); + case 209: + return checkClassExpression(node); case 196: - return checkDeleteExpression(node); - case 198: - return checkVoidExpression(node); + case 197: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); case 199: - return checkAwaitExpression(node); - case 200: - return checkPrefixUnaryExpression(node); - case 201: - return checkPostfixUnaryExpression(node); - case 202: - return checkBinaryExpression(node, checkMode); - case 203: - return checkConditionalExpression(node, checkMode); - case 206: - return checkSpreadExpression(node, checkMode); - case 208: - return undefinedWideningType; - case 205: - return checkYieldExpression(node); + return checkTypeOfExpression(node); + case 194: + case 212: + return checkAssertion(node); case 213: + return checkNonNullAssertion(node); + case 214: + return checkMetaProperty(node); + case 198: + return checkDeleteExpression(node); + case 200: + return checkVoidExpression(node); + case 201: + return checkAwaitExpression(node); + case 202: + return checkPrefixUnaryExpression(node); + case 203: + return checkPostfixUnaryExpression(node); + case 204: + return checkBinaryExpression(node, checkMode); + case 205: + return checkConditionalExpression(node, checkMode); + case 208: + return checkSpreadExpression(node, checkMode); + case 210: + return undefinedWideningType; + case 207: + return checkYieldExpression(node); + case 215: return node.type; - case 268: + case 270: return checkJsxExpression(node, checkMode); - case 258: - return checkJsxElement(node, checkMode); - case 259: - return checkJsxSelfClosingElement(node, checkMode); - case 262: - return checkJsxFragment(node, checkMode); - case 266: - return checkJsxAttributes(node, checkMode); case 260: + return checkJsxElement(node, checkMode); + case 261: + return checkJsxSelfClosingElement(node, checkMode); + case 264: + return checkJsxFragment(node); + case 268: + return checkJsxAttributes(node, checkMode); + case 262: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -42567,7 +43254,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92)) { - if (!(func.kind === 155 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 157 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -42578,10 +43265,10 @@ 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 === 155 || func.kind === 159 || func.kind === 164) { + if (func.kind === 157 || func.kind === 161 || func.kind === 166) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 195) { + if (func.kind === 197) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -42632,13 +43319,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 195: - case 158: - case 237: - case 194: - case 163: - case 154: - case 153: + case 197: + case 160: + case 239: + case 196: + case 165: + case 156: + case 155: var parent = node.parent; if (node === parent.type) { return parent; @@ -42652,11 +43339,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 71 && name.escapedText === predicateVariableName) { + if (name.kind === 72 && 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 === 183 || name.kind === 182) { + else if (name.kind === 185 || name.kind === 184) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -42664,12 +43351,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 160) { + if (node.kind === 162) { checkGrammarIndexSignature(node); } - else if (node.kind === 163 || node.kind === 237 || node.kind === 164 || - node.kind === 158 || node.kind === 155 || - node.kind === 159) { + else if (node.kind === 165 || node.kind === 239 || node.kind === 166 || + node.kind === 160 || node.kind === 157 || + node.kind === 161) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -42694,10 +43381,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 159: + case 161: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 158: + case 160: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -42721,7 +43408,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 160 && node.kind !== 287) { + if (node.kind !== 162 && node.kind !== 289) { registerForUnusedIdentifiersCheck(node); } } @@ -42731,7 +43418,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 155) { + if (member.kind === 157) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -42746,16 +43433,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 156: + case 158: addName(names, name, memberName, 1); break; - case 157: + case 159: addName(names, name, memberName, 2); break; - case 152: + case 154: addName(names, name, memberName, 3); break; - case 154: + case 156: addName(names, name, memberName, 4); break; } @@ -42807,15 +43494,15 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151) { + if (member.kind === 153) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 9: + case 10: case 8: memberName = name.text; break; - case 71: + case 72: memberName = ts.idText(name); break; default: @@ -42832,7 +43519,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 239) { + if (node.kind === 241) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -42847,7 +43534,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 137: + case 138: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -42855,7 +43542,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 134: + case 135: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -42877,7 +43564,7 @@ var ts; if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.hasModifier(node, 128) && node.kind === 154 && node.body) { + if (ts.hasModifier(node, 128) && node.kind === 156 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -42898,7 +43585,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 152 && + return n.kind === 154 && !ts.hasModifier(n, 32) && !!n.initializer; } @@ -42918,7 +43605,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 219 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -42942,18 +43629,18 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 156) { + if (node.kind === 158) { if (!(node.flags & 4194304) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 147) { + if (node.name.kind === 149) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { - var otherKind = node.kind === 156 ? 157 : 156; + var otherKind = node.kind === 158 ? 159 : 158; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -42969,7 +43656,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 156) { + if (node.kind === 158) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -43017,7 +43704,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 162 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 164 && 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); } var type = getTypeFromTypeReference(node); @@ -43064,7 +43751,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 170) { + if (e.kind === 172) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -43073,7 +43760,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 169) { + else if (e.kind === 171) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -43088,19 +43775,19 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 2097152)) { + if (!(type.flags & 8388608)) { return type; } var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 188 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 190 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; } - if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 168)) { + if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 296)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -43132,7 +43819,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 175 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -43147,9 +43834,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 239 && - n.parent.kind !== 238 && - n.parent.kind !== 207 && + if (n.parent.kind !== 241 && + n.parent.kind !== 240 && + n.parent.kind !== 209 && n.flags & 4194304) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; @@ -43229,7 +43916,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 154 || node.kind === 153) && + var reportError = (node.kind === 156 || node.kind === 155) && ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -43262,11 +43949,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 239 || node.parent.kind === 166 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 241 || node.parent.kind === 168 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 237 || node.kind === 154 || node.kind === 153 || node.kind === 155) { + if (node.kind === 239 || node.kind === 156 || node.kind === 155 || node.kind === 157) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -43317,8 +44004,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_7 = signatures; _a < signatures_7.length; _a++) { - var signature = signatures_7[_a]; + for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { + var signature = signatures_6[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -43379,36 +44066,36 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 239: - case 240: - case 302: - case 295: - return 2; + case 241: case 242: + case 304: + case 297: + return 2; + case 244: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 238: - case 241: + case 240: + case 243: return 2 | 1; - case 277: + case 279: return 2 | 1 | 4; - case 252: + case 254: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 246: - case 249: case 248: + case 251: + case 250: var result_4 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_4 |= getDeclarationSpaces(d); }); return result_4; - case 235: - case 184: case 237: - case 251: + case 186: + case 239: + case 253: return 1; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -43441,7 +44128,7 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152); if (isTypeAny(onfulfilledParameterType)) { return undefined; } @@ -43465,7 +44152,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 262144) { + if (type.flags & 1048576) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -43528,7 +44215,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 71 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { + if (promiseConstructorName.kind === 72 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(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 { @@ -43563,22 +44250,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 238: + case 240: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 149: + case 151: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 152: + case 154: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 154: case 156: - case 157: + case 158: + case 159: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -43595,7 +44282,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 71 ? 67897832 : 1920) | 2097152; + var meaning = (typeName.kind === 72 ? 67897832 : 1920) | 2097152; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 @@ -43613,43 +44300,48 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 172: - case 171: - var commonEntityName = void 0; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175) { - typeNode = typeNode.type; - } - if (typeNode.kind === 131) { - continue; - } - if (!strictNullChecks && (typeNode.kind === 95 || typeNode.kind === 140)) { - continue; - } - var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); - if (!individualEntityName) { - return undefined; - } - if (commonEntityName) { - if (!ts.isIdentifier(commonEntityName) || - !ts.isIdentifier(individualEntityName) || - commonEntityName.escapedText !== individualEntityName.escapedText) { - return undefined; - } - } - else { - commonEntityName = individualEntityName; - } - } - return commonEntityName; + case 174: + case 173: + return getEntityNameForDecoratorMetadataFromTypeList(node.types); case 175: + return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + case 177: return getEntityNameForDecoratorMetadata(node.type); - case 162: + case 164: return node.typeName; } } } + function getEntityNameForDecoratorMetadataFromTypeList(types) { + var commonEntityName; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 177) { + typeNode = typeNode.type; + } + if (typeNode.kind === 132) { + continue; + } + if (!strictNullChecks && (typeNode.kind === 96 || typeNode.kind === 141)) { + continue; + } + var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); + if (!individualEntityName) { + return undefined; + } + if (commonEntityName) { + if (!ts.isIdentifier(commonEntityName) || + !ts.isIdentifier(individualEntityName) || + commonEntityName.escapedText !== individualEntityName.escapedText) { + return undefined; + } + } + else { + commonEntityName = individualEntityName; + } + } + return commonEntityName; + } function getParameterTypeNodeForDecoratorCheck(node) { var typeNode = ts.getEffectiveTypeAnnotationNode(node); return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode; @@ -43666,13 +44358,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 149) { + if (node.kind === 151) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 238: + case 240: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -43681,23 +44373,23 @@ var ts; } } break; - case 156: - case 157: - var otherKind = node.kind === 156 ? 157 : 156; + case 158: + case 159: + var otherKind = node.kind === 158 ? 159 : 158; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 154: + case 156: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 152: + case 154: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 149: + case 151: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -43746,16 +44438,22 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 148 ? node.name.right : node.name)); } else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 146 ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 148 ? node.name.right : node.name)); } } } } + function checkJSDocFunctionType(node) { + if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) { + reportImplicitAny(node, anyType); + } + checkSignatureDeclaration(node); + } function checkJSDocAugmentsTag(node) { var classLike = ts.getJSDocHost(node); if (!ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { @@ -43778,9 +44476,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 71: + case 72: return node; - case 187: + case 189: return node.name; default: return undefined; @@ -43790,7 +44488,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); - if (node.name && node.name.kind === 147) { + if (node.name && node.name.kind === 149) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { @@ -43806,7 +44504,7 @@ var ts; } } } - var body = node.kind === 153 ? undefined : node.body; + var body = node.kind === 155 ? undefined : node.body; checkSourceElement(body); if ((functionFlags & 1) === 0) { var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); @@ -43842,42 +44540,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 238: - case 207: + case 240: + case 209: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 239: + case 241: checkUnusedTypeParameters(node, addDiagnostic); break; - case 277: - case 242: - case 216: + case 279: case 244: - case 223: - case 224: + case 218: + case 246: case 225: + case 226: + case 227: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 155: - case 194: - case 237: - case 195: - case 154: - case 156: case 157: + case 196: + case 239: + case 197: + case 156: + case 158: + case 159: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 153: - case 158: - case 159: - case 163: - case 164: - case 240: - case 174: + case 155: + case 160: + case 161: + case 165: + case 166: + case 242: + case 176: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -43898,11 +44596,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 154: - case 152: case 156: - case 157: - if (member.kind === 157 && member.symbol.flags & 32768) { + case 154: + case 158: + case 159: + if (member.kind === 159 && member.symbol.flags & 32768) { break; } var symbol = getSymbolOfNode(member); @@ -43910,7 +44608,7 @@ var ts; addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 155: + case 157: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { @@ -43918,8 +44616,8 @@ var ts; } } break; - case 160: - case 215: + case 162: + case 217: break; default: ts.Debug.fail(); @@ -43928,9 +44626,9 @@ var ts; } } function checkUnusedTypeParameters(node, addDiagnostic) { - if (node.flags & 4194304 || node.kind !== 174 && ts.last(getSymbolOfNode(node).declarations) !== node) + if (node.flags & 4194304 || node.kind !== 176 && ts.last(getSymbolOfNode(node).declarations) !== node) return; - if (node.kind === 174) { + if (node.kind === 176) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); @@ -43945,7 +44643,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 174 && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 176 && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) ? ts.rangeOfNode(parent) @@ -44025,7 +44723,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 249 ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 251 ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0, unuseds.length === 1 @@ -44043,7 +44741,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 && bindingPattern.parent.parent.kind === 236) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 237 && bindingPattern.parent.parent.kind === 238) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -44064,7 +44762,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0, 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 === 217 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 219 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -44076,23 +44774,23 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 71: + case 72: return ts.idText(name); - case 183: - case 182: + case 185: + case 184: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 248 || node.kind === 251 || node.kind === 249; + return node.kind === 250 || node.kind === 253 || node.kind === 251; } function importClauseFromImported(decl) { - return decl.kind === 248 ? decl : decl.kind === 249 ? decl.parent : decl.parent.parent; + return decl.kind === 250 ? decl : decl.kind === 251 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 216) { + if (node.kind === 218) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -44121,19 +44819,19 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 152 || - node.kind === 151 || - node.kind === 154 || + if (node.kind === 154 || node.kind === 153 || node.kind === 156 || - node.kind === 157) { + node.kind === 155 || + node.kind === 158 || + node.kind === 159) { return false; } if (node.flags & 4194304) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 149 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 151 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -44141,7 +44839,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 71; + var isDeclaration_1 = node.kind !== 72; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -44156,7 +44854,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8) { - var isDeclaration_2 = node.kind !== 71; + var isDeclaration_2 = node.kind !== 72; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -44179,7 +44877,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 277 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 279 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -44191,7 +44889,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 277 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 279 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -44199,7 +44897,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 235 && !node.initializer) { + if (node.kind === 237 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -44211,15 +44909,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236); - var container = varDeclList.parent.kind === 217 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 238); + var container = varDeclList.parent.kind === 219 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 216 && ts.isFunctionLike(container.parent) || - container.kind === 243 || - container.kind === 242 || - container.kind === 277); + (container.kind === 218 && ts.isFunctionLike(container.parent) || + container.kind === 245 || + container.kind === 244 || + container.kind === 279); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -44229,7 +44927,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 149) { + if (ts.getRootDeclaration(node).kind !== 151) { return; } var func = ts.getContainingFunction(node); @@ -44238,10 +44936,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 187) { + if (n.kind === 189) { return visit(n.expression); } - else if (n.kind === 71) { + else if (n.kind === 72) { var symbol = resolveName(n, n.escapedText, 67220415 | 2097152, undefined, undefined, false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -44252,8 +44950,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 149 || - symbol.valueDeclaration.kind === 184) { + if (symbol.valueDeclaration.kind === 151 || + symbol.valueDeclaration.kind === 186) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -44262,7 +44960,7 @@ var ts; return "quit"; } return ts.isFunctionLike(current.parent) || - (current.parent.kind === 152 && + (current.parent.kind === 154 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)); })) { @@ -44288,17 +44986,17 @@ var ts; if (!node.name) { return; } - if (node.name.kind === 147) { + if (node.name.kind === 149) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 184) { - if (node.parent.kind === 182 && languageVersion < 6) { + if (node.kind === 186) { + if (node.parent.kind === 184 && languageVersion < 6) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 147) { + if (node.propertyName && node.propertyName.kind === 149) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -44310,23 +45008,23 @@ var ts; var property = getPropertyOfType(parentType, nameText); markPropertyAsReferenced(property, undefined, false); if (parent.initializer && property) { - checkPropertyAccessibility(parent, parent.initializer.kind === 97, parentType, property); + checkPropertyAccessibility(parent, parent.initializer.kind === 98, parentType, property); } } } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 183 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 185 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 149 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 151 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 224) { + if (node.initializer && node.parent.parent.kind !== 226) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -44347,11 +45045,16 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 226) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined); checkParameterInitializer(node); } } + if (symbol.declarations.length > 1) { + if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); + } + } } else { var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); @@ -44364,13 +45067,12 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { - error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 152 && node.kind !== 151) { + if (node.kind !== 154 && node.kind !== 153) { checkExportsOnMergedDeclarations(node); - if (node.kind === 235 || node.kind === 184) { + if (node.kind === 237 || node.kind === 186) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -44379,14 +45081,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 152 || nextDeclaration.kind === 151 + var message = nextDeclaration.kind === 154 || nextDeclaration.kind === 153 ? 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 && right.kind === 235) || - (left.kind === 235 && right.kind === 149)) { + if ((left.kind === 151 && right.kind === 237) || + (left.kind === 237 && right.kind === 151)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -44421,7 +45123,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 218) { + if (node.thenStatement.kind === 220) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -44438,19 +45140,19 @@ var ts; } function checkTruthinessExpression(node, checkMode) { var type = checkExpression(node, checkMode); - if (type.flags & 4096) { + if (type.flags & 16384) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 236) { + if (node.initializer && node.initializer.kind === 238) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 236) { + if (node.initializer.kind === 238) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -44477,13 +45179,13 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 236) { + if (node.initializer.kind === 238) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 185 || varExpr.kind === 186) { + if (varExpr.kind === 187 || varExpr.kind === 188) { checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { @@ -44501,8 +45203,8 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 236) { + var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); + if (node.initializer.kind === 238) { 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); @@ -44512,7 +45214,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 185 || varExpr.kind === 186) { + if (varExpr.kind === 187 || varExpr.kind === 188) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -44522,7 +45224,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (rightType === neverType || !isTypeAssignableToKind(rightType, 16777216 | 14745600)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) { 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); @@ -44564,14 +45266,14 @@ var ts; var reportedError = false; var hasStringConstituent = false; if (allowStringInput) { - if (arrayType.flags & 262144) { + if (arrayType.flags & 1048576) { var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 68); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2); } } - else if (arrayType.flags & 68) { + else if (arrayType.flags & 132) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -44582,7 +45284,7 @@ var ts; reportedError = true; } } - if (arrayType.flags & 32768) { + if (arrayType.flags & 131072) { return stringType; } } @@ -44607,7 +45309,7 @@ var ts; } var arrayElementType = getIndexTypeOfType(arrayType, 1); if (hasStringConstituent && arrayElementType) { - if (arrayElementType.flags & 68) { + if (arrayElementType.flags & 132) { return stringType; } return getUnionType([arrayElementType, stringType], 2); @@ -44740,7 +45442,7 @@ var ts; var unwrappedReturnType = (ts.getFunctionFlags(func) & 3) === 2 ? getPromisedTypeOfPromise(returnType) : returnType; - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 | 3); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3); } function checkReturnStatement(node) { if (checkGrammarStatementInAmbientContext(node)) { @@ -44755,17 +45457,17 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1; - if (strictNullChecks || node.expression || returnType.flags & 32768) { + if (strictNullChecks || node.expression || returnType.flags & 131072) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { return; } - else if (func.kind === 157) { + else if (func.kind === 159) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 155) { + else if (func.kind === 157) { 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); } @@ -44783,7 +45485,7 @@ var ts; } } } - else if (func.kind !== 155 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 157 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -44808,7 +45510,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 270 && !hasDuplicateDefaultClause) { + if (clause.kind === 272 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -44820,7 +45522,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 269) { + if (produceDiagnostics && clause.kind === 271) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -44844,7 +45546,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 231 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 233 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -44939,8 +45641,8 @@ var ts; } var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 202 || - name.kind === 147 || + (propDeclaration.kind === 204 || + name.kind === 149 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -44964,6 +45666,7 @@ var ts; case "any": case "unknown": case "number": + case "bigint": case "boolean": case "string": case "symbol": @@ -45125,10 +45828,10 @@ var ts; else { checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 2162688 && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 8650752 && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 2162688)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -45213,7 +45916,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 238 || d.kind === 239; + return d.kind === 240 || d.kind === 241; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -45231,7 +45934,7 @@ var ts; if (derived === base) { var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { - if (derivedClassDecl.kind === 207) { + if (derivedClassDecl.kind === 209) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -45278,8 +45981,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { - var prop = properties_8[_a]; + for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { + var prop = properties_7[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -45310,7 +46013,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 || getFalsyFlags(type) & 8192)) { + if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) { 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)); } @@ -45320,7 +46023,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 152 && + return node.kind === 154 && !ts.hasModifier(node, 32 | 128) && !node.exclamationToken && !node.initializer; @@ -45331,7 +46034,7 @@ var ts; reference.parent = constructor; reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 8192); + return !(getFalsyFlags(flowType) & 32768); } function checkInterfaceDeclaration(node) { if (!checkGrammarDecoratorsAndModifiers(node)) @@ -45342,7 +46045,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 241); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -45438,60 +46141,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 200: + case 202: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 37: return value_2; - case 38: return -value_2; - case 52: return ~value_2; + case 38: return value_2; + case 39: return -value_2; + case 53: return ~value_2; } } break; - case 202: + case 204: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 49: return left | right; - case 48: return left & right; - case 46: return left >> right; - case 47: return left >>> right; - case 45: return left << right; - case 50: return left ^ right; - case 39: return left * right; - case 41: return left / right; - case 37: return left + right; - case 38: return left - right; - case 42: return left % right; - case 40: return Math.pow(left, right); + case 50: return left | right; + case 49: return left & right; + case 47: return left >> right; + case 48: return left >>> right; + case 46: return left << right; + case 51: return left ^ right; + case 40: return left * right; + case 42: return left / right; + case 38: return left + right; + case 39: return left - right; + case 43: return left % right; + case 41: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 37) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38) { return left + right; } break; - case 9: + case 10: return expr.text; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 193: + case 195: return evaluate(expr.expression); - case 71: + case 72: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 188: - case 187: + case 190: + case 189: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384) { var name = void 0; - if (ex.kind === 187) { + if (ex.kind === 189) { name = ex.name.escapedText; } else { @@ -45522,10 +46225,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 71 || - node.kind === 187 && isConstantMemberAccess(node.expression) || - node.kind === 188 && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 9; + return node.kind === 72 || + node.kind === 189 && isConstantMemberAccess(node.expression) || + node.kind === 190 && isConstantMemberAccess(node.expression) && + node.argumentExpression.kind === 10; } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -45553,7 +46256,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 241) { + if (declaration.kind !== 243) { return false; } var enumDeclaration = declaration; @@ -45576,8 +46279,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 238 || - (declaration.kind === 237 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 240 || + (declaration.kind === 239 && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304)) { return declaration; } @@ -45612,7 +46315,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 9) { + if (!inAmbientContext && node.name.kind === 10) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -45635,7 +46338,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 238); + var mergedClass = ts.getDeclarationOfKind(symbol, 240); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -45678,22 +46381,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 217: + case 219: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 252: - case 253: + case 254: + case 255: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 246: - case 247: + case 248: + case 249: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 184: - case 235: + case 186: + case 237: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -45702,12 +46405,12 @@ var ts; } break; } - case 238: - case 241: - case 237: - case 239: - case 242: case 240: + case 243: + case 239: + case 241: + case 244: + case 242: if (isGlobalAugmentation) { return; } @@ -45715,7 +46418,7 @@ var ts; if (symbol) { var reportError = !(symbol.flags & 33554432); if (!reportError) { - reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -45723,17 +46426,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 71: + case 72: return node; - case 146: + case 148: do { node = node.left; - } while (node.kind !== 71); + } while (node.kind !== 72); return node; - case 187: + case 189: do { node = node.expression; - } while (node.kind !== 71); + } while (node.kind !== 72); return node; } } @@ -45746,9 +46449,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 243 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 277 && !inAmbientExternalModule) { - error(moduleName, node.kind === 253 ? + var inAmbientExternalModule = node.parent.kind === 245 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 279 && !inAmbientExternalModule) { + error(moduleName, node.kind === 255 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -45769,13 +46472,13 @@ var ts; (symbol.flags & 67897832 ? 67897832 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 255 ? + var message = node.kind === 257 ? 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 - && node.kind === 255 + && node.kind === 257 && !(target.flags & 67220415) && !(node.flags & 4194304)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -45801,7 +46504,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249) { + if (importClause.namedBindings.kind === 251) { checkImportBinding(importClause.namedBindings); } else { @@ -45824,7 +46527,7 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 257) { + if (node.moduleReference.kind !== 259) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67220415) { @@ -45855,10 +46558,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 243 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 && + var inAmbientExternalModule = node.parent.kind === 245 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 && !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 277 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 279 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -45874,7 +46577,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 277 || node.parent.kind === 243 || node.parent.kind === 242; + var isInAppropriateContext = node.parent.kind === 279 || node.parent.kind === 245 || node.parent.kind === 244; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -45900,8 +46603,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 277 ? node.parent : node.parent.parent; - if (container.kind === 242 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 279 ? node.parent : node.parent.parent; + if (container.kind === 244 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -45913,7 +46616,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 71) { + if (node.expression.kind === 72) { markExportAsReferenced(node); if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, true); @@ -45980,7 +46683,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 237 && declaration.kind !== 154) || + return (declaration.kind !== 239 && declaration.kind !== 156) || !!declaration.body; } function checkSourceElement(node) { @@ -45996,157 +46699,157 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 242: - case 238: + case 244: + case 240: + case 241: case 239: - case 237: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 148: + case 150: return checkTypeParameter(node); - case 149: - return checkParameter(node); - case 152: case 151: - return checkPropertyDeclaration(node); - case 163: - case 164: - case 158: - case 159: - case 160: - return checkSignatureDeclaration(node); + return checkParameter(node); case 154: case 153: - return checkMethodDeclaration(node); - case 155: - return checkConstructorDeclaration(node); - case 156: - case 157: - return checkAccessorDeclaration(node); - case 162: - return checkTypeReferenceNode(node); - case 161: - return checkTypePredicate(node); + return checkPropertyDeclaration(node); case 165: - return checkTypeQuery(node); case 166: - return checkTypeLiteral(node); + case 160: + case 161: + case 162: + return checkSignatureDeclaration(node); + case 156: + case 155: + return checkMethodDeclaration(node); + case 157: + return checkConstructorDeclaration(node); + case 158: + case 159: + return checkAccessorDeclaration(node); + case 164: + return checkTypeReferenceNode(node); + case 163: + return checkTypePredicate(node); case 167: - return checkArrayType(node); + return checkTypeQuery(node); case 168: + return checkTypeLiteral(node); + case 169: + return checkArrayType(node); + case 170: return checkTupleType(node); + case 173: + case 174: + return checkUnionOrIntersectionType(node); + case 177: case 171: case 172: - return checkUnionOrIntersectionType(node); - case 175: - case 169: - case 170: return checkSourceElement(node.type); - case 176: + case 178: return checkThisType(node); - case 177: + case 179: return checkTypeOperator(node); - case 173: + case 175: return checkConditionalType(node); - case 174: + case 176: return checkInferType(node); - case 181: + case 183: return checkImportType(node); - case 293: - return checkJSDocAugmentsTag(node); - case 302: case 295: - return checkJSDocTypeAliasTag(node); - case 301: - return checkJSDocTemplateTag(node); - case 300: - return checkJSDocTypeTag(node); + return checkJSDocAugmentsTag(node); + case 304: case 297: + return checkJSDocTypeAliasTag(node); + case 303: + return checkJSDocTemplateTag(node); + case 302: + return checkJSDocTypeTag(node); + case 299: return checkJSDocParameterTag(node); + case 289: + checkJSDocFunctionType(node); case 287: - checkSignatureDeclaration(node); - case 285: + case 286: case 284: - case 282: - case 283: - case 290: + case 285: + case 292: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 288: + case 290: checkJSDocVariadicType(node); return; - case 281: + case 283: return checkSourceElement(node.type); - case 178: + case 180: return checkIndexedAccessType(node); - case 179: + case 181: return checkMappedType(node); - case 237: - return checkFunctionDeclaration(node); - case 216: - case 243: - return checkBlock(node); - case 217: - return checkVariableStatement(node); - case 219: - return checkExpressionStatement(node); - case 220: - return checkIfStatement(node); - case 221: - return checkDoStatement(node); - case 222: - return checkWhileStatement(node); - case 223: - return checkForStatement(node); - case 224: - return checkForInStatement(node); - case 225: - return checkForOfStatement(node); - case 226: - case 227: - return checkBreakOrContinueStatement(node); - case 228: - return checkReturnStatement(node); - case 229: - return checkWithStatement(node); - case 230: - return checkSwitchStatement(node); - case 231: - return checkLabeledStatement(node); - case 232: - return checkThrowStatement(node); - case 233: - return checkTryStatement(node); - case 235: - return checkVariableDeclaration(node); - case 184: - return checkBindingElement(node); - case 238: - return checkClassDeclaration(node); case 239: - return checkInterfaceDeclaration(node); - case 240: - return checkTypeAliasDeclaration(node); - case 241: - return checkEnumDeclaration(node); - case 242: - return checkModuleDeclaration(node); - case 247: - return checkImportDeclaration(node); - case 246: - return checkImportEqualsDeclaration(node); - case 253: - return checkExportDeclaration(node); - case 252: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); case 218: + case 245: + return checkBlock(node); + case 219: + return checkVariableStatement(node); + case 221: + return checkExpressionStatement(node); + case 222: + return checkIfStatement(node); + case 223: + return checkDoStatement(node); + case 224: + return checkWhileStatement(node); + case 225: + return checkForStatement(node); + case 226: + return checkForInStatement(node); + case 227: + return checkForOfStatement(node); + case 228: + case 229: + return checkBreakOrContinueStatement(node); + case 230: + return checkReturnStatement(node); + case 231: + return checkWithStatement(node); + case 232: + return checkSwitchStatement(node); + case 233: + return checkLabeledStatement(node); case 234: + return checkThrowStatement(node); + case 235: + return checkTryStatement(node); + case 237: + return checkVariableDeclaration(node); + case 186: + return checkBindingElement(node); + case 240: + return checkClassDeclaration(node); + case 241: + return checkInterfaceDeclaration(node); + case 242: + return checkTypeAliasDeclaration(node); + case 243: + return checkEnumDeclaration(node); + case 244: + return checkModuleDeclaration(node); + case 249: + return checkImportDeclaration(node); + case 248: + return checkImportEqualsDeclaration(node); + case 255: + return checkExportDeclaration(node); + case 254: + return checkExportAssignment(node); + case 220: + case 236: checkGrammarStatementInAmbientContext(node); return; - case 256: + case 258: return checkMissingDeclaration(node); } } @@ -46218,23 +46921,23 @@ var ts; } links.deferredNodes.forEach(function (node) { switch (node.kind) { - case 194: - case 195: - case 154: - case 153: + case 196: + case 197: + case 156: + case 155: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 156: - case 157: + case 158: + case 159: checkAccessorDeclaration(node); break; - case 207: + case 209: checkClassExpressionDeferred(node); break; - case 259: + case 261: checkJsxSelfClosingElementDeferred(node); break; - case 258: + case 260: checkJsxElementDeferred(node); break; } @@ -46269,6 +46972,7 @@ var ts; ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); ts.forEach(node.statements, checkSourceElement); + checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); if (ts.isExternalOrCommonJsModule(node)) { registerForUnusedIdentifiersCheck(node); @@ -46347,24 +47051,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 242: + case 279: + if (!ts.isExternalOrCommonJsModule(location)) + break; + case 244: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 241: + case 243: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 207: + case 209: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 238: - case 239: + case 240: + case 241: if (!isStatic) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832); } break; - case 194: + case 196: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -46396,33 +47103,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 71 && + return name.kind === 72 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 148: - case 238: - case 239: + case 150: case 240: case 241: + case 242: + case 243: return true; default: return false; } } function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 146) { + while (node.parent.kind === 148) { node = node.parent; } - return node.parent.kind === 162; + return node.parent.kind === 164; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 187) { + while (node.parent.kind === 189) { node = node.parent; } - return node.parent.kind === 209; + return node.parent.kind === 211; } function forEachEnclosingClass(node, callback) { var result; @@ -46450,13 +47157,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 146) { + while (nodeOnRightSide.parent.kind === 148) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 246) { + if (nodeOnRightSide.parent.kind === 248) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 252) { + if (nodeOnRightSide.parent.kind === 254) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -46482,7 +47189,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 181 && parent.qualifier === node) { + if (parent && parent.kind === 183 && parent.qualifier === node) { return parent; } return undefined; @@ -46492,21 +47199,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 187 && + entityName.parent.kind === 189 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 252 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 254 && ts.isEntityNameExpression(entityName)) { var success = resolveEntityName(entityName, 67220415 | 67897832 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 246); + var importEqualsDeclaration = ts.getAncestor(entityName, 248); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -46523,7 +47230,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 209) { + if (entityName.parent.kind === 211) { meaning = 67897832; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 67220415; @@ -46538,10 +47245,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 297) { + if (entityName.parent.kind === 299) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 && entityName.parent.parent.kind === 301) { + if (entityName.parent.kind === 150 && entityName.parent.parent.kind === 303) { ts.Debug.assert(!ts.isInJSFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -46550,19 +47257,19 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 71) { + if (entityName.kind === 72) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 67220415, false, true); } - else if (entityName.kind === 187 || entityName.kind === 146) { + else if (entityName.kind === 189 || entityName.kind === 148) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 187) { + if (entityName.kind === 189) { checkPropertyAccessExpression(entityName); } else { @@ -46572,19 +47279,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 162 ? 67897832 : 1920; + var meaning = entityName.parent.kind === 164 ? 67897832 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 265) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 161) { + if (entityName.parent.kind === 163) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 277) { + if (node.kind === 279) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -46598,12 +47302,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 71) { + if (node.kind === 72) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 184 && - grandParent.kind === 182 && + else if (parent.kind === 186 && + grandParent.kind === 184 && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -46613,11 +47317,11 @@ var ts; } } switch (node.kind) { - case 71: - case 187: - case 146: + case 72: + case 189: + case 148: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 99: + case 100: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -46628,24 +47332,27 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 176: + case 178: return getTypeFromThisTypeNode(node).symbol; - case 97: + case 98: return checkExpression(node).symbol; - case 123: + case 124: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 155) { + if (constructorDeclaration && constructorDeclaration.kind === 157) { return constructorDeclaration.parent.symbol; } return undefined; - case 9: - case 13: + case 10: + case 14: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 247 || node.parent.kind === 253) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 249 || node.parent.kind === 255) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); } + if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) { + return getSymbolOfNode(parent); + } case 8: var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -46653,19 +47360,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 79: - case 89: - case 36: - case 75: + case 80: + case 90: + case 37: + case 76: return getSymbolOfNode(node.parent); - case 181: + case 183: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; + case 85: + return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 274) { + if (location && location.kind === 276) { return resolveEntityName(location.name, 67220415 | 2097152); } return undefined; @@ -46721,20 +47430,20 @@ var ts; return errorType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 186 || expr.kind === 185); - if (expr.parent.kind === 225) { + ts.Debug.assert(expr.kind === 188 || expr.kind === 187); + if (expr.parent.kind === 227) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 202) { + if (expr.parent.kind === 204) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 273) { + if (expr.parent.kind === 275) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 185); + ts.Debug.assert(expr.parent.kind === 187); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, false, false) || errorType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); @@ -46758,14 +47467,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 71: + case 72: return getLiteralType(ts.idText(name)); case 8: - case 9: + case 10: return getLiteralType(name.text); - case 147: + case 149: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 3072) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType; default: ts.Debug.fail("Unsupported property name."); return errorType; @@ -46817,7 +47526,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 187 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 189 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -46859,7 +47568,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 277) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 279) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -46893,7 +47602,7 @@ var ts; else if (nodeLinks_1.flags & 262144) { var isDeclaredInLoop = nodeLinks_1.flags & 524288; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 216 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 218 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -46929,18 +47638,18 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 246: case 248: - case 249: + case 250: case 251: - case 255: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); case 253: + case 257: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 255: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 252: + case 254: return node.expression - && node.expression.kind === 71 + && node.expression.kind === 72 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -46948,7 +47657,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 277 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 279 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -46972,7 +47681,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; - if (target && ts.getModifierFlags(node) & 1 && target.flags & 67220415) { + if (target && ts.getModifierFlags(node) & 1 && + target.flags & 67220415 && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -47033,15 +47743,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 276: - case 187: - case 188: + case 278: + case 189: + case 190: return true; } return false; } function getConstantValue(node) { - if (node.kind === 276) { + if (node.kind === 278) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -47054,7 +47764,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 131072) && getSignaturesOfType(type, 0).length > 0; + return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName); @@ -47087,22 +47797,25 @@ var ts; else if (type.flags & 3) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 4096 | 24576 | 32768)) { + else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 272)) { + else if (isTypeAssignableToKind(type, 528)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 168)) { + else if (isTypeAssignableToKind(type, 296)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 68)) { + else if (isTypeAssignableToKind(type, 2112)) { + return ts.TypeReferenceSerializationKind.BigIntLikeType; + } + else if (isTypeAssignableToKind(type, 132)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 3072)) { + else if (isTypeAssignableToKind(type, 12288)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -47118,13 +47831,13 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(119); + return ts.createToken(120); } var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 2048 && + if (type.flags & 8192 && type.symbol === symbol) { flags |= 1048576; } @@ -47136,7 +47849,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(119); + return ts.createToken(120); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker); @@ -47144,7 +47857,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(119); + return ts.createToken(120); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker); @@ -47180,19 +47893,18 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 448 && type.flags & 33554432); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } - function literalTypeToNode(type, enclosing) { - var enumResult = type.flags & 512 ? nodeBuilder.symbolToExpression(type.symbol, 67220415, enclosing) + function literalTypeToNode(type, enclosing, tracker) { + var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 67220415, enclosing, undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } - function createLiteralConstValue(node) { + function createLiteralConstValue(node, tracker) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return literalTypeToNode(type, node); + return literalTypeToNode(type, node, tracker); } function createResolver() { var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives(); @@ -47260,12 +47972,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 157 ? 156 : 157; + var otherKind = accessor.kind === 159 ? 158 : 159; 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 === 157 ? accessor : otherAccessor; - var getAccessor = accessor.kind === 156 ? accessor : otherAccessor; + var setAccessor = accessor.kind === 159 ? accessor : otherAccessor; + var getAccessor = accessor.kind === 158 ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -47281,14 +47993,14 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 209 && node.parent.parent && node.parent.parent.kind === 271; + return node.parent && node.parent.kind === 211 && node.parent.parent && node.parent.parent.kind === 273; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } var meaning = 67897832 | 1920; - if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 187 && !isInHeritageClause(node))) { + if ((node.kind === 72 && isInTypeQuery(node)) || (node.kind === 189 && !isInHeritageClause(node))) { meaning = 67220415 | 1048576; } var symbol = resolveEntityName(node, meaning, true); @@ -47331,7 +48043,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 277 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 279 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -47345,12 +48057,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 242 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 244 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 277); + return ts.getDeclarationOfKind(moduleSymbol, 279); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -47509,14 +48221,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 154 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 156 && !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 === 156 || node.kind === 157) { + else if (node.kind === 158 || node.kind === 159) { 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); @@ -47533,23 +48245,23 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 132) { - if (node.kind === 151 || node.kind === 153) { + if (modifier.kind !== 133) { + if (node.kind === 153 || node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 160) { + if (node.kind === 162) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 76: - if (node.kind !== 241) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); + case 77: + if (node.kind !== 243) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(77)); } break; + case 115: case 114: case 113: - case 112: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -47563,11 +48275,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 243 || node.parent.kind === 277) { + else if (node.parent.kind === 245 || node.parent.kind === 279) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 112) { + if (modifier.kind === 113) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -47576,7 +48288,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 115: + case 116: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -47586,10 +48298,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 243 || node.parent.kind === 277) { + else if (node.parent.kind === 245 || node.parent.kind === 279) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 149) { + else if (node.kind === 151) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -47598,17 +48310,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 132: + case 133: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 152 && node.kind !== 151 && node.kind !== 160 && node.kind !== 149) { + else if (node.kind !== 154 && node.kind !== 153 && node.kind !== 162 && node.kind !== 151) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 84: + case 85: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -47621,52 +48333,52 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 240) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 149) { + else if (node.kind === 151) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 79: - var container = node.parent.kind === 277 ? node.parent : node.parent.parent; - if (container.kind === 242 && !ts.isAmbientModule(container)) { + case 80: + var container = node.parent.kind === 279 ? node.parent : node.parent.parent; + if (container.kind === 244 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; break; - case 124: + case 125: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 240) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 149) { + else if (node.kind === 151) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304) && node.parent.kind === 243) { + else if ((node.parent.flags & 4194304) && node.parent.kind === 245) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 117: + case 118: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 238) { - if (node.kind !== 154 && - node.kind !== 152 && - node.kind !== 156 && - node.kind !== 157) { + if (node.kind !== 240) { + if (node.kind !== 156 && + node.kind !== 154 && + node.kind !== 158 && + node.kind !== 159) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 238 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 240 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -47678,14 +48390,14 @@ var ts; } flags |= 128; break; - case 120: + case 121: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || node.parent.flags & 4194304) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 149) { + else if (node.kind === 151) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -47693,7 +48405,7 @@ var ts; break; } } - if (node.kind === 155) { + if (node.kind === 157) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -47708,13 +48420,13 @@ var ts; } return false; } - else if ((node.kind === 247 || node.kind === 246) && flags & 2) { + else if ((node.kind === 249 || node.kind === 248) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 149 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 151 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 149 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 151 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -47731,38 +48443,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 156: + case 158: + case 159: case 157: - case 155: - case 152: - case 151: case 154: case 153: - case 160: - case 242: - case 247: - case 246: - case 253: - case 252: - case 194: - case 195: - case 149: + case 156: + case 155: + case 162: + case 244: + case 249: + case 248: + case 255: + case 254: + case 196: + case 197: + case 151: return false; default: - if (node.parent.kind === 243 || node.parent.kind === 277) { + if (node.parent.kind === 245 || node.parent.kind === 279) { return false; } switch (node.kind) { - case 237: - return nodeHasAnyModifiersExcept(node, 120); - case 238: - return nodeHasAnyModifiersExcept(node, 117); case 239: - case 217: + return nodeHasAnyModifiersExcept(node, 121); case 240: - return true; + return nodeHasAnyModifiersExcept(node, 118); case 241: - return nodeHasAnyModifiersExcept(node, 76); + case 219: + case 242: + return true; + case 243: + return nodeHasAnyModifiersExcept(node, 77); default: ts.Debug.fail(); return false; @@ -47774,10 +48486,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 154: - case 237: - case 194: - case 195: + case 156: + case 239: + case 196: + case 197: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -47894,12 +48606,12 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 137 && parameter.type.kind !== 134) { + if (parameter.type.kind !== 138 && parameter.type.kind !== 135) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 || type.flags & 8) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(getTypeFromTypeNode(node.type))); } - if (type.flags & 262144 && allTypesAssignableToKind(type, 64, true)) { + if (type.flags & 1048576 && allTypesAssignableToKind(type, 128, true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -47929,7 +48641,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 208) { + if (arg.kind === 210) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -47959,7 +48671,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 === 85) { + if (heritageClause.token === 86) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -47972,7 +48684,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108); + ts.Debug.assert(heritageClause.token === 109); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -47987,14 +48699,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 85) { + if (heritageClause.token === 86) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108); + ts.Debug.assert(heritageClause.token === 109); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -48003,20 +48715,20 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 147) { + if (node.kind !== 149) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 202 && computedPropertyName.expression.operatorToken.kind === 26) { + if (computedPropertyName.expression.kind === 204 && computedPropertyName.expression.operatorToken.kind === 27) { 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 === 237 || - node.kind === 194 || - node.kind === 154); + ts.Debug.assert(node.kind === 239 || + node.kind === 196 || + node.kind === 156); if (node.flags & 4194304) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -48035,40 +48747,40 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275) { + if (prop.kind === 277) { continue; } var name = prop.name; - if (name.kind === 147) { + if (name.kind === 149) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 274 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 276 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 120 || prop.kind !== 154) { + if (mod.kind !== 121 || prop.kind !== 156) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; switch (prop.kind) { - case 274: + case 276: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - case 273: + case 275: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } - case 154: + case 156: currentKind = 1; break; - case 156: + case 158: currentKind = 2; break; - case 157: + case 159: currentKind = 4; break; default: @@ -48105,7 +48817,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 267) { + if (attr.kind === 269) { continue; } var name = attr.name, initializer = attr.initializer; @@ -48115,7 +48827,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 268 && !initializer.expression) { + if (initializer && initializer.kind === 270 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -48124,12 +48836,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 225 && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 227 && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384) === 0) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 236) { + if (forInOrOfStatement.initializer.kind === 238) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -48137,20 +48849,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 224 + var diagnostic = forInOrOfStatement.kind === 226 ? 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 === 224 + var diagnostic = forInOrOfStatement.kind === 226 ? 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 === 224 + var diagnostic = forInOrOfStatement.kind === 226 ? 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); @@ -48177,11 +48889,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 156 ? + return grammarErrorOnNode(accessor.name, kind === 158 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 157) { + else if (kind === 159) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -48201,23 +48913,23 @@ var ts; return false; } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 156 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 158 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 156 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 158 ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 141) { - if (node.type.kind !== 138) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(138)); + if (node.operator === 142) { + if (node.type.kind !== 139) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(139)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 235: + case 237: var decl = parent; - if (decl.name.kind !== 71) { + if (decl.name.kind !== 72) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -48227,13 +48939,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 152: + case 154: if (!ts.hasModifier(parent, 32) || !ts.hasModifier(parent, 64)) { 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 151: + case 153: if (!ts.hasModifier(parent, 64)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -48252,9 +48964,9 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 154) { - if (node.parent.kind === 186) { - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120)) { + if (node.kind === 156) { + if (node.parent.kind === 188) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 121)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -48275,14 +48987,14 @@ var ts; if (node.flags & 4194304) { 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 === 154 && !node.body) { + else if (node.kind === 156 && !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 === 239) { + else if (node.parent.kind === 241) { 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 === 166) { + else if (node.parent.kind === 168) { 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); } } @@ -48293,9 +49005,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 231: + case 233: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 226 + var isMisplacedContinueLabel = node.kind === 228 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -48303,8 +49015,8 @@ var ts; return false; } break; - case 230: - if (node.kind === 227 && !node.label) { + case 232: + if (node.kind === 229 && !node.label) { return false; } break; @@ -48317,13 +49029,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 227 + var message = node.kind === 229 ? 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 === 227 + var message = node.kind === 229 ? 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); @@ -48345,34 +49057,43 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 9 || expr.kind === 8 || - expr.kind === 200 && expr.operator === 38 && + return expr.kind === 10 || expr.kind === 8 || + expr.kind === 202 && expr.operator === 39 && expr.operand.kind === 8; } + function isBigIntLiteralExpression(expr) { + return expr.kind === 9 || + expr.kind === 202 && expr.operator === 39 && + expr.operand.kind === 9; + } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) - return !!(checkExpressionCached(expr).flags & 512); + return !!(checkExpressionCached(expr).flags & 1024); } function checkAmbientInitializer(node) { - if (node.initializer) { - var isInvalidInitializer = !(isStringOrNumberLiteralExpression(node.initializer) || isSimpleLiteralEnumReference(node.initializer) || node.initializer.kind === 101 || node.initializer.kind === 86); + var initializer = node.initializer; + if (initializer) { + var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || + isSimpleLiteralEnumReference(initializer) || + initializer.kind === 102 || initializer.kind === 87 || + isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { if (isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); + return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); } } else { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 224 && node.parent.parent.kind !== 225) { + if (node.parent.parent.kind !== 226 && node.parent.parent.kind !== 227) { if (node.flags & 4194304) { checkAmbientInitializer(node); } @@ -48385,7 +49106,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 217 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 219 || !node.type || node.initializer || node.flags & 4194304)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -48396,7 +49117,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 71) { + if (name.kind === 72) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -48413,8 +49134,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 71) { - if (name.originalKeywordKind === 110) { + if (name.kind === 72) { + if (name.originalKeywordKind === 111) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -48441,15 +49162,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 220: - case 221: case 222: - case 229: case 223: case 224: - case 225: - return false; case 231: + case 225: + case 226: + case 227: + return false; + case 233: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -48467,12 +49188,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 94: + case 95: 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 91: + case 92: 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"); } @@ -48527,7 +49248,7 @@ var ts; return true; } } - else if (node.parent.kind === 239) { + else if (node.parent.kind === 241) { 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; } @@ -48535,7 +49256,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 166) { + else if (node.parent.kind === 168) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -48552,13 +49273,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 239 || - node.kind === 240 || + if (node.kind === 241 || + node.kind === 242 || + node.kind === 249 || + node.kind === 248 || + node.kind === 255 || + node.kind === 254 || node.kind === 247 || - node.kind === 246 || - node.kind === 253 || - node.kind === 252 || - node.kind === 245 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -48567,7 +49288,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 === 217) { + if (ts.isDeclaration(decl) || decl.kind === 219) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -48587,7 +49308,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 216 || node.parent.kind === 243 || node.parent.kind === 277) { + if (node.parent.kind === 218 || node.parent.kind === 245 || node.parent.kind === 279) { var links_2 = getNodeLinks(node.parent); if (!links_2.hasReportedStatementInAmbientContext) { return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -48604,20 +49325,32 @@ var ts; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 180)) { + else if (ts.isChildOfNodeWithKind(node, 182)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 276)) { + else if (ts.isChildOfNodeWithKind(node, 278)) { 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 === 38; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } return false; } + function checkGrammarBigIntLiteral(node) { + var literalType = ts.isLiteralTypeNode(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); + if (!literalType) { + if (languageVersion < 6) { + if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ESNext)) { + return true; + } + } + } + return false; + } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -48658,8 +49391,8 @@ var ts; ts.createTypeChecker = createTypeChecker; function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 251: - case 255: + case 253: + case 257: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -48667,13 +49400,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { + case 250: case 248: - case 246: - case 249: case 251: + case 253: return true; - case 71: - return decl.parent.kind === 251; + case 72: + return decl.parent.kind === 253; default: return false; } @@ -48691,7 +49424,7 @@ var ts; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; })(JsxNames || (JsxNames = {})); function typeIsLiteralType(type) { - return !!(type.flags & 448); + return !!(type.flags & 2944); } })(ts || (ts = {})); var ts; @@ -48744,6 +49477,9 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + if (typeof value === "object" && "base10Value" in value) { + return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); + } if (typeof value === "boolean") { return value ? createTrue() : createFalse(); } @@ -48763,14 +49499,20 @@ var ts; return node; } ts.createNumericLiteral = createNumericLiteral; - function createStringLiteral(text) { + function createBigIntLiteral(value) { var node = createSynthesizedNode(9); + node.text = value; + return node; + } + ts.createBigIntLiteral = createBigIntLiteral; + function createStringLiteral(text) { + var node = createSynthesizedNode(10); node.text = text; return node; } ts.createStringLiteral = createStringLiteral; function createRegularExpressionLiteral(text) { - var node = createSynthesizedNode(12); + var node = createSynthesizedNode(13); node.text = text; return node; } @@ -48781,7 +49523,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(71); + var node = createSynthesizedNode(72); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateFlags = 0; @@ -48857,23 +49599,23 @@ var ts; } ts.createToken = createToken; function createSuper() { - return createSynthesizedNode(97); + return createSynthesizedNode(98); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(99); + return createSynthesizedNode(100); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(95); + return createSynthesizedNode(96); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(101); + return createSynthesizedNode(102); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(86); + return createSynthesizedNode(87); } ts.createFalse = createFalse; function createModifier(kind) { @@ -48883,43 +49625,43 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1) { - result.push(createModifier(84)); + result.push(createModifier(85)); } if (flags & 2) { - result.push(createModifier(124)); + result.push(createModifier(125)); } if (flags & 512) { - result.push(createModifier(79)); + result.push(createModifier(80)); } if (flags & 2048) { - result.push(createModifier(76)); + result.push(createModifier(77)); } if (flags & 4) { - result.push(createModifier(114)); - } - if (flags & 8) { - result.push(createModifier(112)); - } - if (flags & 16) { - result.push(createModifier(113)); - } - if (flags & 128) { - result.push(createModifier(117)); - } - if (flags & 32) { result.push(createModifier(115)); } + if (flags & 8) { + result.push(createModifier(113)); + } + if (flags & 16) { + result.push(createModifier(114)); + } + if (flags & 128) { + result.push(createModifier(118)); + } + if (flags & 32) { + result.push(createModifier(116)); + } if (flags & 64) { - result.push(createModifier(132)); + result.push(createModifier(133)); } if (flags & 256) { - result.push(createModifier(120)); + result.push(createModifier(121)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; function createQualifiedName(left, right) { - var node = createSynthesizedNode(146); + var node = createSynthesizedNode(148); node.left = left; node.right = asName(right); return node; @@ -48938,7 +49680,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(147); + var node = createSynthesizedNode(149); node.expression = parenthesizeForComputedName(expression); return node; } @@ -48950,7 +49692,7 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(148); + var node = createSynthesizedNode(150); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -48966,7 +49708,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(149); + var node = createSynthesizedNode(151); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -48990,7 +49732,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(150); + var node = createSynthesizedNode(152); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -49002,7 +49744,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(153); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -49022,12 +49764,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(152); + var node = createSynthesizedNode(154); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -49037,8 +49779,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -49046,7 +49788,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(153, typeParameters, parameters, type); + var node = createSignatureDeclaration(155, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -49063,7 +49805,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(154); + var node = createSynthesizedNode(156); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -49091,7 +49833,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(155); + var node = createSynthesizedNode(157); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -49111,7 +49853,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(156); + var node = createSynthesizedNode(158); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -49134,7 +49876,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(157); + var node = createSynthesizedNode(159); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -49155,7 +49897,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158, typeParameters, parameters, type); + return createSignatureDeclaration(160, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -49163,7 +49905,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(159, typeParameters, parameters, type); + return createSignatureDeclaration(161, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -49171,7 +49913,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(160); + var node = createSynthesizedNode(162); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -49209,7 +49951,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(161); + var node = createSynthesizedNode(163); node.parameterName = asName(parameterName); node.type = type; return node; @@ -49223,7 +49965,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(162); + var node = createSynthesizedNode(164); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -49237,7 +49979,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163, typeParameters, parameters, type); + return createSignatureDeclaration(165, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -49245,7 +49987,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(164, typeParameters, parameters, type); + return createSignatureDeclaration(166, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -49253,7 +49995,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(165); + var node = createSynthesizedNode(167); node.exprName = exprName; return node; } @@ -49265,7 +50007,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(166); + var node = createSynthesizedNode(168); node.members = createNodeArray(members); return node; } @@ -49277,7 +50019,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(167); + var node = createSynthesizedNode(169); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -49289,7 +50031,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(168); + var node = createSynthesizedNode(170); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -49301,7 +50043,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(169); + var node = createSynthesizedNode(171); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -49313,7 +50055,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(170); + var node = createSynthesizedNode(172); node.type = type; return node; } @@ -49325,7 +50067,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(171, types); + return createUnionOrIntersectionTypeNode(173, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -49333,7 +50075,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(172, types); + return createUnionOrIntersectionTypeNode(174, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -49352,7 +50094,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(175); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -49370,7 +50112,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(174); + var node = createSynthesizedNode(176); node.typeParameter = typeParameter; return node; } @@ -49382,7 +50124,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(183); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -49400,7 +50142,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(175); + var node = createSynthesizedNode(177); node.type = type; return node; } @@ -49412,12 +50154,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(176); + return createSynthesizedNode(178); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(177); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 128; + var node = createSynthesizedNode(179); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 129; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -49427,7 +50169,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(180); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -49441,7 +50183,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(181); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -49459,7 +50201,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(182); node.literal = literal; return node; } @@ -49471,7 +50213,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(184); node.elements = createNodeArray(elements); return node; } @@ -49483,7 +50225,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(185); node.elements = createNodeArray(elements); return node; } @@ -49495,7 +50237,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(186); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -49513,7 +50255,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(187); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -49527,7 +50269,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(188); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -49541,7 +50283,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(189); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -49556,7 +50298,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(190); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -49570,7 +50312,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(191); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -49586,7 +50328,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(192); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -49602,7 +50344,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(193); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -49625,7 +50367,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(194); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -49639,7 +50381,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(195); node.expression = expression; return node; } @@ -49651,7 +50393,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(196); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -49675,12 +50417,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(197); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -49697,7 +50439,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(198); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -49709,7 +50451,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(199); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -49721,7 +50463,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(200); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -49733,7 +50475,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(201); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -49745,7 +50487,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(202); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -49758,7 +50500,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(203); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -49771,7 +50513,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(204); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -49788,11 +50530,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(205); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(56); + node.colonToken = whenFalse ? colonToken : createToken(57); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -49808,7 +50550,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(206); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -49822,33 +50564,33 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createTemplateHead(text) { - var node = createSynthesizedNode(14); + var node = createSynthesizedNode(15); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; function createTemplateMiddle(text) { - var node = createSynthesizedNode(15); + var node = createSynthesizedNode(16); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; function createTemplateTail(text) { - var node = createSynthesizedNode(16); + var node = createSynthesizedNode(17); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(13); + var node = createSynthesizedNode(14); node.text = text; return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(205); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(207); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -49860,7 +50602,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(206); + var node = createSynthesizedNode(208); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -49872,7 +50614,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(209); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -49893,11 +50635,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(208); + return createSynthesizedNode(210); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(211); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -49911,7 +50653,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(212); node.expression = expression; node.type = type; return node; @@ -49925,7 +50667,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(211); + var node = createSynthesizedNode(213); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -49937,7 +50679,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(212); + var node = createSynthesizedNode(214); node.keywordToken = keywordToken; node.name = name; return node; @@ -49950,7 +50692,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(216); node.expression = expression; node.literal = literal; return node; @@ -49964,11 +50706,11 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(215); + return createSynthesizedNode(217); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(216); + var block = createSynthesizedNode(218); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -49982,7 +50724,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(219); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -49997,11 +50739,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(218); + return createSynthesizedNode(220); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(221); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -50015,7 +50757,7 @@ var ts; ts.createStatement = createExpressionStatement; ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(222); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -50031,7 +50773,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(223); node.statement = statement; node.expression = expression; return node; @@ -50045,7 +50787,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(224); node.expression = expression; node.statement = statement; return node; @@ -50059,7 +50801,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(225); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -50077,7 +50819,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(226); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -50093,7 +50835,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(227); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -50111,7 +50853,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(228); node.label = asName(label); return node; } @@ -50123,7 +50865,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(229); node.label = asName(label); return node; } @@ -50135,7 +50877,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(230); node.expression = expression; return node; } @@ -50147,7 +50889,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(231); node.expression = expression; node.statement = statement; return node; @@ -50161,7 +50903,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(230); + var node = createSynthesizedNode(232); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -50175,7 +50917,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(233); node.label = asName(label); node.statement = statement; return node; @@ -50189,7 +50931,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(234); node.expression = expression; return node; } @@ -50201,7 +50943,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(235); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -50217,11 +50959,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(234); + return createSynthesizedNode(236); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(237); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -50238,7 +50980,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(238); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -50251,7 +50993,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(239); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -50277,7 +51019,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(240); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -50299,7 +51041,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(241); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -50321,7 +51063,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(242); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -50341,7 +51083,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -50360,7 +51102,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(244); node.flags |= flags & (16 | 4 | 512); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -50379,7 +51121,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(245); node.statements = createNodeArray(statements); return node; } @@ -50391,7 +51133,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(246); node.clauses = createNodeArray(clauses); return node; } @@ -50403,7 +51145,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(245); + var node = createSynthesizedNode(247); node.name = asName(name); return node; } @@ -50415,7 +51157,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(248); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -50433,7 +51175,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(249); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -50451,7 +51193,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(250); node.name = name; node.namedBindings = namedBindings; return node; @@ -50465,7 +51207,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(251); node.name = name; return node; } @@ -50477,7 +51219,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(252); node.elements = createNodeArray(elements); return node; } @@ -50489,7 +51231,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(253); node.propertyName = propertyName; node.name = name; return node; @@ -50503,11 +51245,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(254); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(58, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(59, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -50520,7 +51262,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(253); + var node = createSynthesizedNode(255); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -50538,7 +51280,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(256); node.elements = createNodeArray(elements); return node; } @@ -50550,7 +51292,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(257); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -50564,7 +51306,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(259); node.expression = expression; return node; } @@ -50575,8 +51317,49 @@ var ts; : node; } ts.updateExternalModuleReference = updateExternalModuleReference; + function createJSDocTypeExpression(type) { + var node = createSynthesizedNode(283); + node.type = type; + return node; + } + ts.createJSDocTypeExpression = createJSDocTypeExpression; + function createJSDocTypeTag(typeExpression, comment) { + var tag = createJSDocTag(302, "type"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocTypeTag = createJSDocTypeTag; + function createJSDocReturnTag(typeExpression, comment) { + var tag = createJSDocTag(300, "returns"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocReturnTag = createJSDocReturnTag; + function createJSDocParamTag(name, isBracketed, typeExpression, comment) { + var tag = createJSDocTag(299, "param"); + tag.typeExpression = typeExpression; + tag.name = name; + tag.isBracketed = isBracketed; + tag.comment = comment; + return tag; + } + ts.createJSDocParamTag = createJSDocParamTag; + function createJSDocComment(comment, tags) { + var node = createSynthesizedNode(291); + node.comment = comment; + node.tags = tags; + return node; + } + ts.createJSDocComment = createJSDocComment; + function createJSDocTag(kind, tagName) { + var node = createSynthesizedNode(kind); + node.tagName = createIdentifier(tagName); + return node; + } function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(260); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -50592,7 +51375,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(259); + var node = createSynthesizedNode(261); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -50608,7 +51391,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(260); + var node = createSynthesizedNode(262); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -50624,7 +51407,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(263); node.tagName = tagName; return node; } @@ -50636,7 +51419,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(264); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -50652,7 +51435,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(267); node.name = name; node.initializer = initializer; return node; @@ -50666,7 +51449,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(266); + var node = createSynthesizedNode(268); node.properties = createNodeArray(properties); return node; } @@ -50678,7 +51461,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(267); + var node = createSynthesizedNode(269); node.expression = expression; return node; } @@ -50690,7 +51473,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(270); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -50703,7 +51486,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(271); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -50717,7 +51500,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(272); node.statements = createNodeArray(statements); return node; } @@ -50729,7 +51512,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(273); node.token = token; node.types = createNodeArray(types); return node; @@ -50742,7 +51525,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(274); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -50756,7 +51539,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(273); + var node = createSynthesizedNode(275); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -50771,7 +51554,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(274); + var node = createSynthesizedNode(276); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -50785,7 +51568,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(275); + var node = createSynthesizedNode(277); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } @@ -50797,7 +51580,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(276); + var node = createSynthesizedNode(278); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -50817,7 +51600,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(277); + var updated = createSynthesizedNode(279); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -50891,28 +51674,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(305); + var node = createSynthesizedNode(307); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(309); + var node = createSynthesizedNode(311); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(308); + var node = createSynthesizedNode(310); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(306); + var node = createSynthesizedNode(308); node.expression = expression; node.original = original; setTextRange(node, original); @@ -50928,17 +51711,17 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 307) { + if (node.kind === 309) { return node.elements; } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) { return [node.left, node.right]; } } return node; } function createCommaList(elements) { - var node = createSynthesizedNode(307); + var node = createSynthesizedNode(309); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -50951,14 +51734,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(278); + var node = ts.createNode(280); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(279); + var node = ts.createNode(281); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -50966,7 +51749,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(280); + var node = ts.createNode(282); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -50993,47 +51776,47 @@ var ts; } ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { - return createBinary(left, 26, right); + return createBinary(left, 27, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 27, right); + return createBinary(left, 28, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 58, right); + return createBinary(left, 59, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 34, right); + return createBinary(left, 35, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 37, right); + return createBinary(left, 38, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 38, right); + return createBinary(left, 39, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 43); + return createPostfix(operand, 44); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 53, right); + return createBinary(left, 54, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 54, right); + return createBinary(left, 55, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(51, operand); + return createPrefix(52, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -51075,7 +51858,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 277) { + if (node.kind === 279) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -51506,7 +52289,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 233 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -51518,19 +52301,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 71: + case 72: return cacheIdentifiers; - case 99: + case 100: case 8: case 9: + case 10: return false; - case 185: + case 187: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 186: + case 188: return target.properties.length > 0; default: return true; @@ -51545,7 +52329,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 97) { + else if (callee.kind === 98) { thisArg = ts.createThis(); target = languageVersion < 2 ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -51557,7 +52341,7 @@ var ts; } else { switch (callee.kind) { - case 187: { + case 189: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -51569,7 +52353,7 @@ var ts; } break; } - case 188: { + case 190: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -51622,14 +52406,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 156: - case 157: + case 158: + case 159: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 273: + case 275: return createExpressionForPropertyAssignment(property, receiver); - case 274: + case 276: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 154: + case 156: return createExpressionForMethodDeclaration(property, receiver); } } @@ -51637,27 +52421,27 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_9 = []; + var properties_8 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body); ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_9.push(getter); + properties_8.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body); ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_9.push(setter); + properties_8.push(setter); } - properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_9, multiLine) + ts.createObjectLiteral(properties_8, multiLine) ]), firstAccessor); return ts.aggregateTransformFlags(expression); } @@ -51834,7 +52618,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 193) { + if (skipped.kind === 195) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -51843,10 +52627,10 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(202, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(202, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(204, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(204, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 195 && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 197 && binaryOperatorPrecedence > 4) { return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); @@ -51854,7 +52638,7 @@ var ts; case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 205) { + && operand.kind === 207) { return false; } return true; @@ -51870,7 +52654,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 37) { + if (binaryOperator === 38) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -51883,17 +52667,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 39 + return binaryOperator === 40 + || binaryOperator === 50 || binaryOperator === 49 - || binaryOperator === 48 - || binaryOperator === 50; + || binaryOperator === 51; } function getLiteralKindOfBinaryPlusOperand(node) { node = ts.skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 202 && node.operatorToken.kind === 37) { + if (node.kind === 204 && node.operatorToken.kind === 38) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -51908,7 +52692,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(203, 55); + var conditionalPrecedence = ts.getOperatorPrecedence(205, 56); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -51929,8 +52713,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, false).kind) { - case 207: - case 194: + case 209: + case 196: needsParens = true; } } @@ -51940,9 +52724,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 189: + case 191: return ts.createParen(expression); - case 190: + case 192: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -51953,7 +52737,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 190 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 192 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -51991,7 +52775,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(202, 26); + var commaPrecedence = ts.getOperatorPrecedence(204, 27); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -52002,29 +52786,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 194 || kind === 195) { + if (kind === 196 || kind === 197) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind; - if (leftmostExpressionKind === 186 || leftmostExpressionKind === 194) { + if (leftmostExpressionKind === 188 || leftmostExpressionKind === 196) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 173 ? ts.createParenthesizedType(member) : member; + return member.kind === 175 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 171: - case 172: - case 163: - case 164: + case 173: + case 174: + case 165: + case 166: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -52032,9 +52816,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 165: - case 177: - case 174: + case 167: + case 179: + case 176: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -52060,27 +52844,27 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 201: + case 203: node = node.operand; continue; - case 202: + case 204: node = node.left; continue; - case 203: + case 205: node = node.condition; continue; - case 191: + case 193: node = node.tag; continue; - case 189: + case 191: if (stopAtCallExpressions) { return node; } - case 210: - case 188: - case 187: - case 211: - case 306: + case 212: + case 190: + case 189: + case 213: + case 308: node = node.expression; continue; } @@ -52088,27 +52872,27 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 186)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 188)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 202 && node.operatorToken.kind === 26 || - node.kind === 307; + return node.kind === 204 && node.operatorToken.kind === 27 || + node.kind === 309; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 193: + case 195: return (kinds & 1) !== 0; - case 192: - case 210: - case 211: + case 194: + case 212: + case 213: return (kinds & 2) !== 0; - case 306: + case 308: return (kinds & 4) !== 0; } return false; @@ -52133,7 +52917,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 211) { + while (ts.isAssertionExpression(node) || node.kind === 213) { node = node.expression; } return node; @@ -52141,15 +52925,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 193: return ts.updateParen(outerExpression, expression); - case 192: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 210: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 211: return ts.updateNonNullExpression(outerExpression, expression); - case 306: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 195: return ts.updateParen(outerExpression, expression); + case 194: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 212: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 213: return ts.updateNonNullExpression(outerExpression, expression); + case 308: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 193 + return node.kind === 195 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -52211,10 +52995,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 247 && node.importClause) { + if (node.kind === 249 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 253 && node.moduleSpecifier) { + if (node.kind === 255 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -52222,7 +53006,7 @@ var ts; ts.getLocalNameForExternalImport = getLocalNameForExternalImport; function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { + if (moduleName.kind === 10) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) || ts.getSynthesizedClone(moduleName); @@ -52277,11 +53061,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 273: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 274: - return bindingElement.name; case 275: + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); + case 276: + return bindingElement.name; + case 277: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -52297,11 +53081,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 149: - case 184: + case 151: + case 186: return bindingElement.dotDotDotToken; - case 206: - case 275: + case 208: + case 277: return bindingElement; } return undefined; @@ -52309,7 +53093,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 184: + case 186: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -52317,7 +53101,7 @@ var ts; : propertyName; } break; - case 273: + case 275: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -52325,7 +53109,7 @@ var ts; : propertyName; } break; - case 275: + case 277: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -52339,16 +53123,16 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 9 + return kind === 10 || kind === 8; } function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 182: - case 183: + case 184: case 185: + case 187: return name.elements; - case 186: + case 188: return name.properties; } } @@ -52387,11 +53171,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 183: case 185: + case 187: return convertToArrayAssignmentPattern(node); - case 182: - case 186: + case 184: + case 188: return convertToObjectAssignmentPattern(node); } } @@ -52528,261 +53312,261 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 145) || kind === 176) { + if ((kind > 0 && kind <= 147) || kind === 178) { return node; } switch (kind) { - case 71: + case 72: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 146: - return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 147: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); case 148: - return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); case 149: - return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); case 150: - return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); case 151: - return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 152: - return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); case 153: - return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 154: - return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 155: - return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); case 156: - return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 157: - return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 158: - return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 159: - return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 160: - return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 161: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 162: - return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 163: - return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); case 164: - return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); case 165: - return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 166: - return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 167: - return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); case 168: - return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); case 169: - return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 170: - return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); case 171: - return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 172: - return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 173: - return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 174: - return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 181: - return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 175: - return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 177: - return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 178: - return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 179: - return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 180: - return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); - case 182: - return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + case 176: + return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); case 183: - return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 177: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 179: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 180: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 181: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 182: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); case 184: - return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); case 185: - return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); case 186: - return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); case 187: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); case 188: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); case 189: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 190: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 191: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 192: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 193: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 194: - return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 195: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 196: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 197: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 198: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 199: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 200: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 201: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 202: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 203: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 204: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 205: - return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 206: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 207: - return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + case 208: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); case 209: - return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 210: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 211: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 212: - return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 213: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 214: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); case 216: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 218: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 217: - return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 219: - return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 220: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 221: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 222: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); case 223: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 224: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 225: - return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 226: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 227: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 228: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); case 229: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); case 230: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); case 231: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 232: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 233: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 234: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); case 235: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 236: - return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); case 237: - return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 238: - return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); case 239: - return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 240: - return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 241: - return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); case 242: - return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 243: - return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); case 244: - return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); case 245: - return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 246: - return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 247: - return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); case 248: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 249: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 250: - return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); case 251: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 252: - return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); case 253: - return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); case 254: - return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 256: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); case 257: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); - case 258: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); case 259: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 260: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 261: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); case 262: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 263: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 264: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 265: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 266: - return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); case 267: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 268: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); case 269: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 270: - return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 271: - return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); case 272: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 273: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); case 274: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 275: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 276: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); case 277: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 278: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 279: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 306: + case 308: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 307: + case 309: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -52808,48 +53592,41 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 145)) { + if ((kind > 0 && kind <= 147)) { return initial; } - if ((kind >= 161 && kind <= 180)) { + if ((kind >= 163 && kind <= 182)) { return initial; } var result = initial; switch (node.kind) { - case 215: - case 218: - case 208: - case 234: - case 305: + case 217: + case 220: + case 210: + case 236: + case 307: break; - case 146: + case 148: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 147: - result = reduceNode(node.expression, cbNode, result); - break; case 149: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 150: result = reduceNode(node.expression, cbNode, result); break; case 151: + result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; case 152: - result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 153: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; @@ -52857,73 +53634,81 @@ var ts; result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 155: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 156: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 157: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 158: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 159: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 182: - case 183: - result = reduceNodes(node.elements, cbNodes, result); - break; case 184: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; case 185: result = reduceNodes(node.elements, cbNodes, result); break; case 186: - result = reduceNodes(node.properties, cbNodes, result); + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 187: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.elements, cbNodes, result); break; case 188: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 189: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 190: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); + break; + case 191: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 191: + case 192: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 193: result = reduceNode(node.tag, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 192: + case 194: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 194: + case 196: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -52931,121 +53716,121 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; + case 197: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; case 195: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 193: - case 196: - case 197: case 198: case 199: - case 205: - case 206: - case 211: - result = reduceNode(node.expression, cbNode, result); - break; case 200: case 201: - result = reduceNode(node.operand, cbNode, result); + case 207: + case 208: + case 213: + result = reduceNode(node.expression, cbNode, result); break; case 202: + case 203: + result = reduceNode(node.operand, cbNode, result); + break; + case 204: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 203: + case 205: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 204: + case 206: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 207: + case 209: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 209: + case 211: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 210: + case 212: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 214: + case 216: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 216: + case 218: result = reduceNodes(node.statements, cbNodes, result); break; - case 217: + case 219: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 219: + case 221: result = reduceNode(node.expression, cbNode, result); break; - case 220: + case 222: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 221: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 222: - case 229: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; case 223: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 224: + case 231: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 225: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224: - case 225: + case 226: + case 227: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 228: - case 232: + case 230: + case 234: result = reduceNode(node.expression, cbNode, result); break; - case 230: + case 232: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 231: + case 233: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 233: + case 235: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 235: + case 237: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 236: + case 238: result = reduceNodes(node.declarations, cbNodes, result); break; - case 237: + case 239: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -53054,7 +53839,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 238: + case 240: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -53062,131 +53847,132 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 241: + case 243: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 242: + case 244: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 243: + case 245: result = reduceNodes(node.statements, cbNodes, result); break; - case 244: + case 246: result = reduceNodes(node.clauses, cbNodes, result); break; - case 246: + case 248: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 247: + case 249: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 248: + case 250: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 249: - result = reduceNode(node.name, cbNode, result); - break; - case 250: - case 254: - result = reduceNodes(node.elements, cbNodes, result); - break; case 251: - case 255: - result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; case 252: + case 256: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 253: + case 257: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 254: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 253: + case 255: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 257: + case 259: result = reduceNode(node.expression, cbNode, result); break; - case 258: + case 260: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 262: + case 264: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 259: - case 260: + case 261: + case 262: result = reduceNode(node.tagName, cbNode, result); + result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 266: + case 268: result = reduceNodes(node.properties, cbNodes, result); break; - case 261: + case 263: result = reduceNode(node.tagName, cbNode, result); break; - case 265: + case 267: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 267: - result = reduceNode(node.expression, cbNode, result); - break; - case 268: - result = reduceNode(node.expression, cbNode, result); - break; case 269: result = reduceNode(node.expression, cbNode, result); + break; case 270: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNode(node.expression, cbNode, result); break; case 271: + result = reduceNode(node.expression, cbNode, result); + case 272: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 273: result = reduceNodes(node.types, cbNodes, result); break; - case 272: + case 274: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 273: + case 275: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 274: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.objectAssignmentInitializer, cbNode, result); - break; - case 275: - result = reduceNode(node.expression, cbNode, result); - break; case 276: result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; case 277: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 306: result = reduceNode(node.expression, cbNode, result); break; - case 307: + case 278: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 279: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 308: + result = reduceNode(node.expression, cbNode, result); + break; + case 309: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -53239,7 +54025,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 209)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 211)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -53280,7 +54066,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 131072 ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -53316,251 +54102,580 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createSourceFileLikeCache(host) { - var cached = ts.createMap(); + function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) { + var _a = generatorOptions.extendedDiagnostics + ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap") + : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit; + var rawSources = []; + var sources = []; + var sourceToSourceIndexMap = ts.createMap(); + var sourcesContent; + var names = []; + var nameToNameIndexMap; + var mappings = ""; + var lastGeneratedLine = 0; + var lastGeneratedCharacter = 0; + var lastSourceIndex = 0; + var lastSourceLine = 0; + var lastSourceCharacter = 0; + var lastNameIndex = 0; + var hasLast = false; + var pendingGeneratedLine = 0; + var pendingGeneratedCharacter = 0; + var pendingSourceIndex = 0; + var pendingSourceLine = 0; + var pendingSourceCharacter = 0; + var pendingNameIndex = 0; + var hasPending = false; + var hasPendingSource = false; + var hasPendingName = false; return { - get: function (path) { - if (cached.has(path)) { - return cached.get(path); + getSources: function () { return rawSources; }, + addSource: addSource, + setSourceContent: setSourceContent, + addName: addName, + addMapping: addMapping, + appendSourceMap: appendSourceMap, + toJSON: toJSON, + toString: function () { return JSON.stringify(toJSON()); } + }; + function addSource(fileName) { + enter(); + var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); + var sourceIndex = sourceToSourceIndexMap.get(source); + if (sourceIndex === undefined) { + sourceIndex = sources.length; + sources.push(source); + rawSources.push(fileName); + sourceToSourceIndexMap.set(source, sourceIndex); + } + exit(); + return sourceIndex; + } + function setSourceContent(sourceIndex, content) { + enter(); + if (content !== null) { + if (!sourcesContent) + sourcesContent = []; + while (sourcesContent.length < sourceIndex) { + sourcesContent.push(null); } - if (!host.fileExists || !host.readFile || !host.fileExists(path)) - return; - var text = host.readFile(path); - var file = { - text: text, - lineMap: undefined, - getLineAndCharacterOfPosition: function (pos) { - return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + sourcesContent[sourceIndex] = content; + } + exit(); + } + function addName(name) { + enter(); + if (!nameToNameIndexMap) + nameToNameIndexMap = ts.createMap(); + var nameIndex = nameToNameIndexMap.get(name); + if (nameIndex === undefined) { + nameIndex = names.length; + names.push(name); + nameToNameIndexMap.set(name, nameIndex); + } + exit(); + return nameIndex; + } + function isNewGeneratedPosition(generatedLine, generatedCharacter) { + return !hasPending + || pendingGeneratedLine !== generatedLine + || pendingGeneratedCharacter !== generatedCharacter; + } + function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) { + return sourceIndex !== undefined + && sourceLine !== undefined + && sourceCharacter !== undefined + && pendingSourceIndex === sourceIndex + && (pendingSourceLine > sourceLine + || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter); + } + function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) { + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative"); + ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative"); + ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative"); + enter(); + if (isNewGeneratedPosition(generatedLine, generatedCharacter) || + isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) { + commitPendingMapping(); + pendingGeneratedLine = generatedLine; + pendingGeneratedCharacter = generatedCharacter; + hasPendingSource = false; + hasPendingName = false; + hasPending = true; + } + if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) { + pendingSourceIndex = sourceIndex; + pendingSourceLine = sourceLine; + pendingSourceCharacter = sourceCharacter; + hasPendingSource = true; + if (nameIndex !== undefined) { + pendingNameIndex = nameIndex; + hasPendingName = true; + } + } + exit(); + } + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + var _a; + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + enter(); + var sourceIndexToNewSourceIndexMap = []; + var nameIndexToNewNameIndexMap; + var mappingIterator = decodeMappings(map.mappings); + for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + var newSourceIndex = void 0; + var newSourceLine = void 0; + var newSourceCharacter = void 0; + var newNameIndex = void 0; + if (raw.sourceIndex !== undefined) { + newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex]; + if (newSourceIndex === undefined) { + var rawPath = map.sources[raw.sourceIndex]; + var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath); + sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath); + if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") { + setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]); + } } - }; - cached.set(path, file); - return file; + newSourceLine = raw.sourceLine; + newSourceCharacter = raw.sourceCharacter; + if (map.names && raw.nameIndex !== undefined) { + if (!nameIndexToNewNameIndexMap) + nameIndexToNewNameIndexMap = []; + newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex]; + if (newNameIndex === undefined) { + nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]); + } + } + } + var newGeneratedLine = raw.generatedLine + generatedLine; + var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); + } + exit(); + } + function shouldCommitMapping() { + return !hasLast + || lastGeneratedLine !== pendingGeneratedLine + || lastGeneratedCharacter !== pendingGeneratedCharacter + || lastSourceIndex !== pendingSourceIndex + || lastSourceLine !== pendingSourceLine + || lastSourceCharacter !== pendingSourceCharacter + || lastNameIndex !== pendingNameIndex; + } + function commitPendingMapping() { + if (!hasPending || !shouldCommitMapping()) { + return; + } + enter(); + if (lastGeneratedLine < pendingGeneratedLine) { + do { + mappings += ";"; + lastGeneratedLine++; + lastGeneratedCharacter = 0; + } while (lastGeneratedLine < pendingGeneratedLine); + } + else { + ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); + if (hasLast) { + mappings += ","; + } + } + mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + lastGeneratedCharacter = pendingGeneratedCharacter; + if (hasPendingSource) { + mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + lastSourceIndex = pendingSourceIndex; + mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + lastSourceLine = pendingSourceLine; + mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + lastSourceCharacter = pendingSourceCharacter; + if (hasPendingName) { + mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + lastNameIndex = pendingNameIndex; + } + } + hasLast = true; + exit(); + } + function toJSON() { + commitPendingMapping(); + return { + version: 3, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings, + sourcesContent: sourcesContent, + }; + } + } + ts.createSourceMapGenerator = createSourceMapGenerator; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + function tryGetSourceMappingURL(text, lineStarts) { + if (lineStarts === void 0) { lineStarts = ts.computeLineStarts(text); } + for (var index = lineStarts.length - 1; index >= 0; index--) { + var line = text.substring(lineStarts[index], lineStarts[index + 1]); + var comment = sourceMapCommentRegExp.exec(line); + if (comment) { + return comment[1]; + } + else if (!line.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + function isStringOrNull(x) { + return typeof x === "string" || x === null; + } + function isRawSourceMap(x) { + return x !== null + && typeof x === "object" + && x.version === 3 + && typeof x.file === "string" + && typeof x.mappings === "string" + && ts.isArray(x.sources) && ts.every(x.sources, ts.isString) + && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string") + && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull)) + && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); + } + ts.isRawSourceMap = isRawSourceMap; + function tryParseRawSourceMap(text) { + try { + var parsed = JSON.parse(text); + if (isRawSourceMap(parsed)) { + return parsed; + } + } + catch (_a) { + } + return undefined; + } + ts.tryParseRawSourceMap = tryParseRawSourceMap; + function decodeMappings(mappings) { + var done = false; + var pos = 0; + var generatedLine = 0; + var generatedCharacter = 0; + var sourceIndex = 0; + var sourceLine = 0; + var sourceCharacter = 0; + var nameIndex = 0; + var error; + return { + get pos() { return pos; }, + get error() { return error; }, + get state() { return captureMapping(true, true); }, + next: function () { + while (!done && pos < mappings.length) { + var ch = mappings.charCodeAt(pos); + if (ch === 59) { + generatedLine++; + generatedCharacter = 0; + pos++; + continue; + } + if (ch === 44) { + pos++; + continue; + } + var hasSource = false; + var hasName = false; + generatedCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (generatedCharacter < 0) + return setErrorAndStopIterating("Invalid generatedCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasSource = true; + sourceIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceIndex < 0) + return setErrorAndStopIterating("Invalid sourceIndex found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex"); + sourceLine += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceLine < 0) + return setErrorAndStopIterating("Invalid sourceLine found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine"); + sourceCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceCharacter < 0) + return setErrorAndStopIterating("Invalid sourceCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasName = true; + nameIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (nameIndex < 0) + return setErrorAndStopIterating("Invalid nameIndex found"); + if (!isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex"); + } + } + return { value: captureMapping(hasSource, hasName), done: done }; + } + return stopIterating(); } }; + function captureMapping(hasSource, hasName) { + return { + generatedLine: generatedLine, + generatedCharacter: generatedCharacter, + sourceIndex: hasSource ? sourceIndex : undefined, + sourceLine: hasSource ? sourceLine : undefined, + sourceCharacter: hasSource ? sourceCharacter : undefined, + nameIndex: hasName ? nameIndex : undefined + }; + } + function stopIterating() { + done = true; + return { value: undefined, done: true }; + } + function setError(message) { + if (error === undefined) { + error = message; + } + } + function setErrorAndStopIterating(message) { + setError(message); + return stopIterating(); + } + function hasReportedError() { + return error !== undefined; + } + function isSourceMappingSegmentEnd() { + return (pos === mappings.length || + mappings.charCodeAt(pos) === 44 || + mappings.charCodeAt(pos) === 59); + } + function base64VLQFormatDecode() { + var moreDigits = true; + var shiftCount = 0; + var value = 0; + for (; moreDigits; pos++) { + if (pos >= mappings.length) + return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1; + var currentByte = base64FormatDecode(mappings.charCodeAt(pos)); + if (currentByte === -1) + return setError("Invalid character in VLQ"), -1; + moreDigits = (currentByte & 32) !== 0; + value = value | ((currentByte & 31) << shiftCount); + shiftCount += 5; + } + if ((value & 1) === 0) { + value = value >> 1; + } + else { + value = value >> 1; + value = -value; + } + return value; + } } - ts.createSourceFileLikeCache = createSourceFileLikeCache; -})(ts || (ts = {})); -(function (ts) { - var sourcemaps; - (function (sourcemaps) { - sourcemaps.identitySourceMapper = { getOriginalPosition: ts.identity, getGeneratedPosition: ts.identity }; - function decode(host, mapPath, map, program, fallbackCache) { - if (fallbackCache === void 0) { fallbackCache = ts.createSourceFileLikeCache(host); } - var currentDirectory = ts.getDirectoryPath(mapPath); - var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory; - var decodedMappings; - var generatedOrderedMappings; - var sourceOrderedMappings; - return { - getOriginalPosition: getOriginalPosition, - getGeneratedPosition: getGeneratedPosition - }; - function getGeneratedPosition(loc) { - var maps = getSourceOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { sourcePath: loc.fileName, sourcePosition: loc.position }, ts.identity, compareProcessedPositionSourcePositions); - if (targetIndex < 0 && maps.length > 0) { - targetIndex = ~targetIndex; - } - if (!maps[targetIndex] || ts.comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot) !== 0) { - return loc; - } - return { fileName: ts.toPath(map.file, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].emittedPosition }; - } - function getOriginalPosition(loc) { - var maps = getGeneratedOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { emittedPosition: loc.position }, ts.identity, compareProcessedPositionEmittedPositions); - if (targetIndex < 0 && maps.length > 0) { - targetIndex = ~targetIndex; - } - return { fileName: ts.toPath(maps[targetIndex].sourcePath, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].sourcePosition }; - } - function getSourceFileLike(fileName, location) { - var path = ts.toPath(fileName, location, host.getCanonicalFileName); - var file = program && program.getSourceFile(path); - if (!file || file.resolvedPath !== path) { - return fallbackCache.get(path); - } - return file; - } - function getPositionOfLineAndCharacterUsingName(fileName, directory, line, character) { - var file = getSourceFileLike(fileName, directory); - if (!file) { - return -1; - } - return ts.getPositionOfLineAndCharacter(file, line, character); - } - function getDecodedMappings() { - return decodedMappings || (decodedMappings = calculateDecodedMappings(map, processPosition, host)); - } - function getSourceOrderedMappings() { - return sourceOrderedMappings || (sourceOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionSourcePositions)); - } - function getGeneratedOrderedMappings() { - return generatedOrderedMappings || (generatedOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionEmittedPositions)); - } - function compareProcessedPositionSourcePositions(a, b) { - return ts.comparePaths(a.sourcePath, b.sourcePath, sourceRoot) || - ts.compareValues(a.sourcePosition, b.sourcePosition); - } - function compareProcessedPositionEmittedPositions(a, b) { - return ts.compareValues(a.emittedPosition, b.emittedPosition); - } - function processPosition(position) { - var sourcePath = map.sources[position.sourceIndex]; - return { - emittedPosition: getPositionOfLineAndCharacterUsingName(map.file, currentDirectory, position.emittedLine, position.emittedColumn), - sourcePosition: getPositionOfLineAndCharacterUsingName(sourcePath, sourceRoot, position.sourceLine, position.sourceColumn), - sourcePath: sourcePath, - }; - } + ts.decodeMappings = decodeMappings; + function sameMapping(left, right) { + return left === right + || left.generatedLine === right.generatedLine + && left.generatedCharacter === right.generatedCharacter + && left.sourceIndex === right.sourceIndex + && left.sourceLine === right.sourceLine + && left.sourceCharacter === right.sourceCharacter + && left.nameIndex === right.nameIndex; + } + ts.sameMapping = sameMapping; + function isSourceMapping(mapping) { + return mapping.sourceIndex !== undefined + && mapping.sourceLine !== undefined + && mapping.sourceCharacter !== undefined; + } + ts.isSourceMapping = isSourceMapping; + function base64FormatEncode(value) { + return value >= 0 && value < 26 ? 65 + value : + value >= 26 && value < 52 ? 97 + value - 26 : + value >= 52 && value < 62 ? 48 + value - 52 : + value === 62 ? 43 : + value === 63 ? 47 : + ts.Debug.fail(value + ": not a base64 value"); + } + function base64FormatDecode(ch) { + return ch >= 65 && ch <= 90 ? ch - 65 : + ch >= 97 && ch <= 122 ? ch - 97 + 26 : + ch >= 48 && ch <= 57 ? ch - 48 + 52 : + ch === 43 ? 62 : + ch === 47 ? 63 : + -1; + } + function base64VLQFormatEncode(inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; } - sourcemaps.decode = decode; - function decodeMappings(map) { - var state = { - encodedText: map.mappings, - currentNameIndex: undefined, - sourceMapNamesLength: map.names ? map.names.length : undefined, - currentEmittedColumn: 0, - currentEmittedLine: 0, - currentSourceColumn: 0, - currentSourceLine: 0, - currentSourceIndex: 0, - decodingIndex: 0 - }; - function captureSpan() { - return { - emittedColumn: state.currentEmittedColumn, - emittedLine: state.currentEmittedLine, - sourceColumn: state.currentSourceColumn, - sourceIndex: state.currentSourceIndex, - sourceLine: state.currentSourceLine, - nameIndex: state.currentNameIndex - }; + else { + inValue = inValue << 1; + } + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + return encodedStr; + } + function isSourceMappedPosition(value) { + return value.sourceIndex !== undefined + && value.sourcePosition !== undefined; + } + function sameMappedPosition(left, right) { + return left.generatedPosition === right.generatedPosition + && left.sourceIndex === right.sourceIndex + && left.sourcePosition === right.sourcePosition; + } + function compareSourcePositions(left, right) { + return ts.compareValues(left.sourceIndex, right.sourceIndex); + } + function compareGeneratedPositions(left, right) { + return ts.compareValues(left.generatedPosition, right.generatedPosition); + } + function getSourcePositionOfMapping(value) { + return value.sourcePosition; + } + function getGeneratedPositionOfMapping(value) { + return value.generatedPosition; + } + function createDocumentPositionMapper(host, map, mapPath) { + var mapDirectory = ts.getDirectoryPath(mapPath); + var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory; + var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory); + var generatedCanonicalFilePath = host.getCanonicalFileName(generatedAbsoluteFilePath); + var generatedFile = host.getSourceFileLike(generatedCanonicalFilePath); + var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); }); + var sourceFileCanonicalPaths = sourceFileAbsolutePaths.map(function (source) { return host.getCanonicalFileName(source); }); + var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileCanonicalPaths.map(function (source, i) { return [source, i]; })); + var decodedMappings; + var generatedMappings; + var sourceMappings; + return { + getSourcePosition: getSourcePosition, + getGeneratedPosition: getGeneratedPosition + }; + function processMapping(mapping) { + var generatedPosition = generatedFile !== undefined + ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter) + : -1; + var source; + var sourcePosition; + if (isSourceMapping(mapping)) { + var sourceFilePath = sourceFileCanonicalPaths[mapping.sourceIndex]; + var sourceFile = host.getSourceFileLike(sourceFilePath); + source = map.sources[mapping.sourceIndex]; + sourcePosition = sourceFile !== undefined + ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter) + : -1; } return { - get decodingIndex() { return state.decodingIndex; }, - get error() { return state.error; }, - get lastSpan() { return captureSpan(); }, - next: function () { - if (hasCompletedDecoding(state) || state.error) - return { done: true, value: undefined }; - if (!decodeSinglePosition(state)) - return { done: true, value: undefined }; - return { done: false, value: captureSpan() }; - } + generatedPosition: generatedPosition, + source: source, + sourceIndex: mapping.sourceIndex, + sourcePosition: sourcePosition, + nameIndex: mapping.nameIndex }; } - sourcemaps.decodeMappings = decodeMappings; - function calculateDecodedMappings(map, processPosition, host) { - var decoder = decodeMappings(map); - var positions = ts.arrayFrom(decoder, processPosition); - if (decoder.error) { - if (host && host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); - } - return []; - } - return positions; - } - function hasCompletedDecoding(state) { - return state.decodingIndex === state.encodedText.length; - } - function decodeSinglePosition(state) { - while (state.decodingIndex < state.encodedText.length) { - var char = state.encodedText.charCodeAt(state.decodingIndex); - if (char === 59) { - state.currentEmittedLine++; - state.currentEmittedColumn = 0; - state.decodingIndex++; - continue; - } - if (char === 44) { - state.decodingIndex++; - continue; - } - state.currentEmittedColumn += base64VLQFormatDecode(); - if (createErrorIfCondition(state.currentEmittedColumn < 0, "Invalid emittedColumn found")) { - return false; - } - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted column")) { - return false; - } - state.currentSourceIndex += base64VLQFormatDecode(); - if (createErrorIfCondition(state.currentSourceIndex < 0, "Invalid sourceIndex found")) { - return false; - } - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after sourceIndex")) { - return false; - } - state.currentSourceLine += base64VLQFormatDecode(); - if (createErrorIfCondition(state.currentSourceLine < 0, "Invalid sourceLine found")) { - return false; - } - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted Line")) { - return false; - } - state.currentSourceColumn += base64VLQFormatDecode(); - if (createErrorIfCondition(state.currentSourceColumn < 0, "Invalid sourceLine found")) { - return false; - } - if (!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex)) { - if (state.currentNameIndex === undefined) { - state.currentNameIndex = 0; + function getDecodedMappings() { + if (decodedMappings === undefined) { + var decoder = decodeMappings(map.mappings); + var mappings = ts.arrayFrom(decoder, processMapping); + if (decoder.error !== undefined) { + if (host.log) { + host.log("Encountered error while decoding sourcemap: " + decoder.error); } - state.currentNameIndex += base64VLQFormatDecode(); - } - if (createErrorIfCondition(!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: There are more entries after " + (state.currentNameIndex === undefined ? "sourceColumn" : "nameIndex"))) { - return false; - } - return true; - } - createErrorIfCondition(true, "No encoded entry found"); - return false; - function createErrorIfCondition(condition, errormsg) { - if (state.error) { - return true; - } - if (condition) { - state.error = errormsg; - } - return condition; - } - function base64VLQFormatDecode() { - var moreDigits = true; - var shiftCount = 0; - var value = 0; - for (; moreDigits; state.decodingIndex++) { - if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return undefined; - } - var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); - moreDigits = (currentByte & 32) !== 0; - value = value | ((currentByte & 31) << shiftCount); - shiftCount += 5; - } - if ((value & 1) === 0) { - value = value >> 1; + decodedMappings = ts.emptyArray; } else { - value = value >> 1; - value = -value; + decodedMappings = mappings; } - return value; } + return decodedMappings; } - function base64FormatDecode(char) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(char); + function getSourceMappings(sourceIndex) { + if (sourceMappings === undefined) { + var lists = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + if (!isSourceMappedPosition(mapping)) + continue; + var list = lists[mapping.sourceIndex]; + if (!list) + lists[mapping.sourceIndex] = list = []; + list.push(mapping); + } + sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); }); + } + return sourceMappings[sourceIndex]; } - function isSourceMappingSegmentEnd(encodedText, pos) { - return (pos === encodedText.length || - encodedText.charCodeAt(pos) === 44 || - encodedText.charCodeAt(pos) === 59); + function getGeneratedMappings() { + if (generatedMappings === undefined) { + var list = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + list.push(mapping); + } + generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition); + } + return generatedMappings; } - })(sourcemaps = ts.sourcemaps || (ts.sourcemaps = {})); + function getGeneratedPosition(loc) { + var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName)); + if (sourceIndex === undefined) + return loc; + var sourceMappings = getSourceMappings(sourceIndex); + if (!ts.some(sourceMappings)) + return loc; + var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + targetIndex = ~targetIndex; + } + var mapping = sourceMappings[targetIndex]; + if (mapping === undefined || mapping.sourceIndex !== sourceIndex) { + return loc; + } + return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition }; + } + function getSourcePosition(loc) { + var generatedMappings = getGeneratedMappings(); + if (!ts.some(generatedMappings)) + return loc; + var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + targetIndex = ~targetIndex; + } + var mapping = generatedMappings[targetIndex]; + if (mapping === undefined || !isSourceMappedPosition(mapping)) { + return loc; + } + return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition }; + } + } + ts.createDocumentPositionMapper = createDocumentPositionMapper; + ts.identitySourceMapConsumer = { + getSourcePosition: ts.identity, + getGeneratedPosition: ts.identity + }; })(ts || (ts = {})); var ts; (function (ts) { @@ -53582,7 +54697,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 277 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 279 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -53626,16 +54741,16 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 247: + case 249: externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 246: - if (node.moduleReference.kind === 257) { + case 248: + if (node.moduleReference.kind === 259) { externalImports.push(node); } break; - case 253: + case 255: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -53662,12 +54777,12 @@ var ts; } } break; - case 252: + case 254: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 217: + case 219: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -53675,7 +54790,7 @@ var ts; } } break; - case 237: + case 239: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -53693,7 +54808,7 @@ var ts; } } break; - case 238: + case 240: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -54138,8 +55253,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(187); - context.enableSubstitution(188); + context.enableSubstitution(189); + context.enableSubstitution(190); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -54152,14 +55267,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 278) { + if (node.kind === 280) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280) { + if (prepend.kind === 282) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -54190,16 +55305,16 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 277: - case 244: - case 243: - case 216: + case 279: + case 246: + case 245: + case 218: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 238: - case 237: + case 240: + case 239: if (ts.hasModifier(node, 2)) { break; } @@ -54207,7 +55322,7 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 238 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 240 || ts.hasModifier(node, 512)); } if (ts.isClassDeclaration(node)) { currentNameScope = node; @@ -54232,10 +55347,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 247: - case 246: - case 252: - case 253: + case 249: + case 248: + case 254: + case 255: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -54250,13 +55365,13 @@ var ts; return node; } switch (node.kind) { - case 247: + case 249: return visitImportDeclaration(node); - case 246: + case 248: return visitImportEqualsDeclaration(node); - case 252: + case 254: return visitExportAssignment(node); - case 253: + case 255: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -54266,11 +55381,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 253 || - node.kind === 247 || - node.kind === 248 || - (node.kind === 246 && - node.moduleReference.kind === 257)) { + if (node.kind === 255 || + node.kind === 249 || + node.kind === 250 || + (node.kind === 248 && + node.moduleReference.kind === 259)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -54286,15 +55401,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 155: - return undefined; - case 152: - case 160: - case 156: case 157: + return undefined; case 154: + case 162: + case 158: + case 159: + case 156: return visitorWorker(node); - case 215: + case 217: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -54304,7 +55419,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270) { return undefined; } - else if (currentNamespace && node.kind === 84) { + else if (currentNamespace && node.kind === 85) { return undefined; } return node; @@ -54314,100 +55429,100 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 84: - case 79: + case 85: + case 80: return currentNamespace ? undefined : node; - case 114: - case 112: + case 115: case 113: - case 117: - case 76: - case 124: - case 132: - case 167: - case 168: + case 114: + case 118: + case 77: + case 125: + case 133: case 169: case 170: - case 166: - case 161: - case 148: - case 119: - case 142: - case 122: - case 137: - case 134: - case 131: - case 105: - case 138: - case 164: - case 163: - case 165: - case 162: case 171: case 172: + case 168: + case 163: + case 150: + case 120: + case 143: + case 123: + case 138: + case 135: + case 132: + case 106: + case 139: + case 166: + case 165: + case 167: + case 164: case 173: + case 174: case 175: - case 176: case 177: case 178: case 179: case 180: - case 160: - case 150: - case 240: - return undefined; + case 181: + case 182: + case 162: case 152: - return visitPropertyDeclaration(node); - case 245: - return undefined; - case 155: - return visitConstructor(node); - case 239: - return ts.createNotEmittedStatement(node); - case 238: - return visitClassDeclaration(node); - case 207: - return visitClassExpression(node); - case 271: - return visitHeritageClause(node); - case 209: - return visitExpressionWithTypeArguments(node); - case 154: - return visitMethodDeclaration(node); - case 156: - return visitGetAccessor(node); - case 157: - return visitSetAccessor(node); - case 237: - return visitFunctionDeclaration(node); - case 194: - return visitFunctionExpression(node); - case 195: - return visitArrowFunction(node); - case 149: - return visitParameter(node); - case 193: - return visitParenthesizedExpression(node); - case 192: - case 210: - return visitAssertionExpression(node); - case 189: - return visitCallExpression(node); - case 190: - return visitNewExpression(node); - case 191: - return visitTaggedTemplateExpression(node); - case 211: - return visitNonNullExpression(node); - case 241: - return visitEnumDeclaration(node); - case 217: - return visitVariableStatement(node); - case 235: - return visitVariableDeclaration(node); case 242: + return undefined; + case 154: + return visitPropertyDeclaration(node); + case 247: + return undefined; + case 157: + return visitConstructor(node); + case 241: + return ts.createNotEmittedStatement(node); + case 240: + return visitClassDeclaration(node); + case 209: + return visitClassExpression(node); + case 273: + return visitHeritageClause(node); + case 211: + return visitExpressionWithTypeArguments(node); + case 156: + return visitMethodDeclaration(node); + case 158: + return visitGetAccessor(node); + case 159: + return visitSetAccessor(node); + case 239: + return visitFunctionDeclaration(node); + case 196: + return visitFunctionExpression(node); + case 197: + return visitArrowFunction(node); + case 151: + return visitParameter(node); + case 195: + return visitParenthesizedExpression(node); + case 194: + case 212: + return visitAssertionExpression(node); + case 191: + return visitCallExpression(node); + case 192: + return visitNewExpression(node); + case 193: + return visitTaggedTemplateExpression(node); + case 213: + return visitNonNullExpression(node); + case 243: + return visitEnumDeclaration(node); + case 219: + return visitVariableStatement(node); + case 237: + return visitVariableDeclaration(node); + case 244: return visitModuleDeclaration(node); - case 246: + case 248: return visitImportEqualsDeclaration(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -54437,7 +55552,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96) facts |= 64; if (shouldEmitDecorateCallForClass(node)) facts |= 2; @@ -54477,7 +55592,7 @@ var ts; addClassElementDecorationStatements(statements, node, true); addConstructorDecorationStatement(statements, node); if (facts & 128) { - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 18); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19); var localName = ts.getInternalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; @@ -54551,7 +55666,7 @@ var ts; pendingExpressions = undefined; var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 86; })); var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, node); @@ -54630,7 +55745,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 219 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -54664,13 +55779,13 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 152 + return member.kind === 154 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -54680,8 +55795,8 @@ var ts; } function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); ts.startOnNewLine(expression); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -54741,12 +55856,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 156: - case 157: + case 158: + case 159: return getAllDecoratorsOfAccessors(node, member); - case 154: + case 156: return getAllDecoratorsOfMethod(member); - case 152: + case 154: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -54825,7 +55940,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 152 + ? member.kind === 154 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -54894,13 +56009,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); @@ -54909,22 +56024,22 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 154 - || kind === 156 - || kind === 157 - || kind === 152; + return kind === 156 + || kind === 158 + || kind === 159 + || kind === 154; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 154; + return node.kind === 156; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 238: - case 207: + case 240: + case 209: return ts.getFirstConstructorWithBody(node) !== undefined; - case 154: case 156: - case 157: + case 158: + case 159: return true; } return false; @@ -54936,15 +56051,15 @@ var ts; } function serializeTypeOfNode(node) { switch (node.kind) { - case 152: - case 149: - return serializeTypeNode(node.type); - case 157: - case 156: - return serializeTypeNode(getAccessorTypeNode(node)); - case 238: - case 207: case 154: + case 151: + return serializeTypeNode(node.type); + case 159: + case 158: + return serializeTypeNode(getAccessorTypeNode(node)); + case 240: + case 209: + case 156: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -54976,7 +56091,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 156) { + if (container && node.kind === 158) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -54998,75 +56113,81 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 105: - case 140: - case 95: - case 131: + case 106: + case 141: + case 96: + case 132: return ts.createVoidZero(); - case 175: + case 177: return serializeTypeNode(node.type); - case 163: - case 164: + case 165: + case 166: return ts.createIdentifier("Function"); - case 167: - case 168: + case 169: + case 170: return ts.createIdentifier("Array"); - case 161: - case 122: + case 163: + case 123: return ts.createIdentifier("Boolean"); - case 137: + case 138: return ts.createIdentifier("String"); - case 135: + case 136: return ts.createIdentifier("Object"); - case 180: + case 182: switch (node.literal.kind) { - case 9: + case 10: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 101: - case 86: + case 9: + return getGlobalBigIntNameWithFallback(); + case 102: + case 87: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 134: + case 135: return ts.createIdentifier("Number"); - case 138: + case 146: + return getGlobalBigIntNameWithFallback(); + case 139: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 162: + case 164: return serializeTypeReferenceNode(node); - case 172: - case 171: - return serializeUnionOrIntersectionType(node); - case 165: - case 177: - case 178: + case 174: + case 173: + return serializeTypeList(node.types); + case 175: + return serializeTypeList([node.trueType, node.falseType]); + case 167: case 179: - case 166: - case 119: - case 142: - case 176: + case 180: case 181: + case 168: + case 120: + case 143: + case 178: + case 183: break; default: return ts.Debug.failBadSyntaxKind(node); } return ts.createIdentifier("Object"); } - function serializeUnionOrIntersectionType(node) { + function serializeTypeList(types) { var serializedUnion; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 177) { typeNode = typeNode.type; } - if (typeNode.kind === 131) { + if (typeNode.kind === 132) { continue; } - if (!strictNullChecks && (typeNode.kind === 95 || typeNode.kind === 140)) { + if (!strictNullChecks && (typeNode.kind === 96 || typeNode.kind === 141)) { continue; } var serializedIndividual = serializeTypeNode(typeNode); @@ -55090,6 +56211,9 @@ var ts; var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: + if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { + return ts.createIdentifier("Object"); + } var serialized = serializeEntityNameAsExpressionFallback(node.typeName); var temp = ts.createTempVariable(hoistVariableDeclaration); return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object")); @@ -55097,6 +56221,8 @@ var ts; return serializeEntityNameAsExpression(node.typeName); case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.createVoidZero(); + case ts.TypeReferenceSerializationKind.BigIntLikeType: + return getGlobalBigIntNameWithFallback(); case ts.TypeReferenceSerializationKind.BooleanType: return ts.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -55123,11 +56249,11 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(left), ts.createLiteral("undefined")), right); } function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 71) { + if (node.kind === 72) { var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 71) { + if (node.left.kind === 72) { return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } var left = serializeEntityNameAsExpressionFallback(node.left); @@ -55136,13 +56262,13 @@ var ts; } function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 71: + case 72: var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); return name; - case 146: + case 148: return serializeQualifiedNameAsExpression(node); } } @@ -55152,6 +56278,11 @@ var ts; function getGlobalSymbolNameWithFallback() { return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object")); } + function getGlobalBigIntNameWithFallback() { + return languageVersion < 6 + ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object")) + : ts.createIdentifier("BigInt"); + } function isSimpleInlineableExpression(expression) { return !ts.isIdentifier(expression) && ts.isSimpleCopiableExpression(expression) || ts.isWellKnownSymbolSyntactically(expression); @@ -55198,9 +56329,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 85) { + if (node.token === 86) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(85, types), node); + return ts.setTextRange(ts.createHeritageClause(86, types), node); } return undefined; } @@ -55400,7 +56531,7 @@ var ts; var name = getExpressionForPropertyName(member, false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 9 ? + var outerAssignment = valueExpression.kind === 10 ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -55453,11 +56584,11 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, false, true)) - ], currentLexicalScope.kind === 277 ? 0 : 1)); + ], currentLexicalScope.kind === 279 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 241) { + if (node.kind === 243) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -55523,7 +56654,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 243) { + if (body.kind === 245) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -55547,13 +56678,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 243) { + if (body.kind !== 245) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 242) { + if (moduleDeclaration.body.kind === 244) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -55573,7 +56704,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 249) { + if (node.kind === 251) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -55694,29 +56825,29 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(71); + context.enableSubstitution(72); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(71); + context.enableSubstitution(72); classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(71); - context.enableSubstitution(274); - context.enableEmitNotification(242); + context.enableSubstitution(72); + context.enableSubstitution(276); + context.enableEmitNotification(244); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 242; + return ts.getOriginalNode(node).kind === 244; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 241; + return ts.getOriginalNode(node).kind === 243; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -55760,11 +56891,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71: + case 72: return substituteExpressionIdentifier(node); - case 187: + case 189: return substitutePropertyAccessExpression(node); - case 188: + case 190: return substituteElementAccessExpression(node); } return node; @@ -55794,9 +56925,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 277) { - var substitute = (applicableSubstitutions & 2 && container.kind === 242) || - (applicableSubstitutions & 8 && container.kind === 241); + if (container && container.kind !== 279) { + var substitute = (applicableSubstitutions & 2 && container.kind === 244) || + (applicableSubstitutions & 8 && container.kind === 243); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -55910,25 +57041,25 @@ var ts; return node; } switch (node.kind) { - case 120: + case 121: return undefined; - case 199: + case 201: return visitAwaitExpression(node); - case 154: + case 156: return visitMethodDeclaration(node); - case 237: + case 239: return visitFunctionDeclaration(node); - case 194: + case 196: return visitFunctionExpression(node); - case 195: + case 197: return visitArrowFunction(node); - case 187: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97) { + case 189: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188: - if (capturedSuperProperties && node.expression.kind === 97) { + case 190: + if (capturedSuperProperties && node.expression.kind === 98) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -55939,27 +57070,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 217: + case 219: return visitVariableStatementInAsyncBody(node); - case 223: - return visitForStatementInAsyncBody(node); - case 224: - return visitForInStatementInAsyncBody(node); case 225: + return visitForStatementInAsyncBody(node); + case 226: + return visitForInStatementInAsyncBody(node); + case 227: return visitForOfStatementInAsyncBody(node); - case 272: + case 274: return visitCatchClauseInAsyncBody(node); - case 216: - case 230: - case 244: - case 269: - case 270: - case 233: - case 221: + case 218: + case 232: + case 246: + case 271: + case 272: + case 235: + case 223: + case 224: case 222: - case 220: - case 229: case 231: + case 233: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -56108,7 +57239,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 195; + var isArrowFunction = node.kind === 197; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -56183,15 +57314,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(191); context.enableSubstitution(189); - context.enableSubstitution(187); - context.enableSubstitution(188); - context.enableEmitNotification(238); - context.enableEmitNotification(154); + context.enableSubstitution(190); + context.enableEmitNotification(240); context.enableEmitNotification(156); + context.enableEmitNotification(158); + context.enableEmitNotification(159); context.enableEmitNotification(157); - context.enableEmitNotification(155); - context.enableEmitNotification(217); + context.enableEmitNotification(219); } } function onEmitNode(hint, node, emitCallback) { @@ -56223,23 +57354,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187: - return substitutePropertyAccessExpression(node); - case 188: - return substituteElementAccessExpression(node); case 189: + return substitutePropertyAccessExpression(node); + case 190: + return substituteElementAccessExpression(node); + case 191: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -56258,11 +57389,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 - || kind === 155 - || kind === 154 + return kind === 240 + || kind === 157 || kind === 156 - || kind === 157; + || kind === 158 + || kind === 159; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -56304,7 +57435,7 @@ var ts; }; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(awaiterHelper); - var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(39), undefined, undefined, [], undefined, body); + var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(40), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288; return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ ts.createThis(), @@ -56357,7 +57488,7 @@ var ts; return visitorWorker(node, true); } function visitorNoAsyncModifier(node) { - if (node.kind === 120) { + if (node.kind === 121) { return undefined; } return node; @@ -56367,55 +57498,55 @@ var ts; return node; } switch (node.kind) { - case 199: + case 201: return visitAwaitExpression(node); - case 205: + case 207: return visitYieldExpression(node); - case 228: + case 230: return visitReturnStatement(node); - case 231: + case 233: return visitLabeledStatement(node); - case 186: + case 188: return visitObjectLiteralExpression(node); - case 202: + case 204: return visitBinaryExpression(node, noDestructuringValue); - case 235: - return visitVariableDeclaration(node); - case 225: - return visitForOfStatement(node, undefined); - case 223: - return visitForStatement(node); - case 198: - return visitVoidExpression(node); - case 155: - return visitConstructorDeclaration(node); - case 154: - return visitMethodDeclaration(node); - case 156: - return visitGetAccessorDeclaration(node); - case 157: - return visitSetAccessorDeclaration(node); case 237: + return visitVariableDeclaration(node); + case 227: + return visitForOfStatement(node, undefined); + case 225: + return visitForStatement(node); + case 200: + return visitVoidExpression(node); + case 157: + return visitConstructorDeclaration(node); + case 156: + return visitMethodDeclaration(node); + case 158: + return visitGetAccessorDeclaration(node); + case 159: + return visitSetAccessorDeclaration(node); + case 239: return visitFunctionDeclaration(node); - case 194: + case 196: return visitFunctionExpression(node); - case 195: + case 197: return visitArrowFunction(node); - case 149: + case 151: return visitParameter(node); - case 219: + case 221: return visitExpressionStatement(node); - case 193: + case 195: return visitParenthesizedExpression(node, noDestructuringValue); - case 272: + case 274: return visitCatchClause(node); - case 187: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97) { + case 189: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188: - if (capturedSuperProperties && node.expression.kind === 97) { + case 190: + if (capturedSuperProperties && node.expression.kind === 98) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -56450,7 +57581,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 225 && statement.awaitModifier) { + if (statement.kind === 227 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -56462,7 +57593,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 275) { + if (e.kind === 277) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -56471,7 +57602,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 273 + chunkObject = ts.append(chunkObject, e.kind === 275 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -56484,7 +57615,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 262144) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 186) { + if (objects.length && objects[0].kind !== 188) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -56507,7 +57638,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 262144) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); } - else if (node.operatorToken.kind === 26) { + else if (node.operatorToken.kind === 27) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -56693,7 +57824,7 @@ var ts; var savedHasSuperElementAccess = hasSuperElementAccess; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; - var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(39), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(40), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -56752,15 +57883,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(191); context.enableSubstitution(189); - context.enableSubstitution(187); - context.enableSubstitution(188); - context.enableEmitNotification(238); - context.enableEmitNotification(154); + context.enableSubstitution(190); + context.enableEmitNotification(240); context.enableEmitNotification(156); + context.enableEmitNotification(158); + context.enableEmitNotification(159); context.enableEmitNotification(157); - context.enableEmitNotification(155); - context.enableEmitNotification(217); + context.enableEmitNotification(219); } } function onEmitNode(hint, node, emitCallback) { @@ -56792,23 +57923,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187: - return substitutePropertyAccessExpression(node); - case 188: - return substituteElementAccessExpression(node); case 189: + return substitutePropertyAccessExpression(node); + case 190: + return substituteElementAccessExpression(node); + case 191: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -56827,11 +57958,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 - || kind === 155 - || kind === 154 + return kind === 240 + || kind === 157 || kind === 156 - || kind === 157; + || kind === 158 + || kind === 159; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -56926,13 +58057,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 258: + case 260: return visitJsxElement(node, false); - case 259: + case 261: return visitJsxSelfClosingElement(node, false); - case 262: + case 264: return visitJsxFragment(node, false); - case 268: + case 270: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -56940,15 +58071,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 10: + case 11: return visitJsxText(node); - case 268: + case 270: return visitJsxExpression(node); - case 258: + case 260: return visitJsxElement(node, true); - case 259: + case 261: return visitJsxSelfClosingElement(node, true); - case 262: + case 264: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -57007,12 +58138,12 @@ var ts; if (node === undefined) { return ts.createTrue(); } - else if (node.kind === 9) { + else if (node.kind === 10) { var literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text); literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 268) { + else if (node.kind === 270) { if (node.expression === undefined) { return ts.createTrue(); } @@ -57072,7 +58203,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 258) { + if (node.kind === 260) { return getTagName(node.openingElement); } else { @@ -57372,7 +58503,7 @@ var ts; return node; } switch (node.kind) { - case 202: + case 204: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -57380,9 +58511,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 62: + case 63: return visitExponentiationAssignmentExpression(node); - case 40: + case 41: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -57462,13 +58593,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096) !== 0 - && node.kind === 228 + && node.kind === 230 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 216))) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 218))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -57487,104 +58618,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 97) { + if (node.kind === 98) { return visitSuperKeyword(true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 115: + case 116: return undefined; - case 238: + case 240: return visitClassDeclaration(node); - case 207: + case 209: return visitClassExpression(node); - case 149: + case 151: return visitParameter(node); - case 237: + case 239: return visitFunctionDeclaration(node); - case 195: + case 197: return visitArrowFunction(node); - case 194: + case 196: return visitFunctionExpression(node); - case 235: + case 237: return visitVariableDeclaration(node); - case 71: + case 72: return visitIdentifier(node); - case 236: + case 238: return visitVariableDeclarationList(node); - case 230: + case 232: return visitSwitchStatement(node); - case 244: + case 246: return visitCaseBlock(node); - case 216: + case 218: return visitBlock(node, false); - case 227: - case 226: + case 229: + case 228: return visitBreakOrContinueStatement(node); - case 231: + case 233: return visitLabeledStatement(node); - case 221: - case 222: - return visitDoOrWhileStatement(node, undefined); case 223: - return visitForStatement(node, undefined); case 224: - return visitForInStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 225: + return visitForStatement(node, undefined); + case 226: + return visitForInStatement(node, undefined); + case 227: return visitForOfStatement(node, undefined); - case 219: + case 221: return visitExpressionStatement(node); - case 186: + case 188: return visitObjectLiteralExpression(node); - case 272: - return visitCatchClause(node); case 274: + return visitCatchClause(node); + case 276: return visitShorthandPropertyAssignment(node); - case 147: + case 149: return visitComputedPropertyName(node); - case 185: + case 187: return visitArrayLiteralExpression(node); - case 189: + case 191: return visitCallExpression(node); - case 190: + case 192: return visitNewExpression(node); - case 193: + case 195: return visitParenthesizedExpression(node, true); - case 202: + case 204: return visitBinaryExpression(node, true); - case 13: case 14: case 15: case 16: + case 17: return visitTemplateLiteral(node); - case 9: + case 10: return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 191: + case 193: return visitTaggedTemplateExpression(node); - case 204: - return visitTemplateExpression(node); - case 205: - return visitYieldExpression(node); case 206: + return visitTemplateExpression(node); + case 207: + return visitYieldExpression(node); + case 208: return visitSpreadElement(node); - case 97: + case 98: return visitSuperKeyword(false); - case 99: + case 100: return visitThisKeyword(node); - case 212: + case 214: return visitMetaProperty(node); - case 154: - return visitMethodDeclaration(node); case 156: - case 157: + return visitMethodDeclaration(node); + case 158: + case 159: return visitAccessorDeclaration(node); - case 217: + case 219: return visitVariableStatement(node); - case 228: + case 230: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -57665,14 +58796,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 227 ? 2 : 4; + var jump = node.kind === 229 ? 2 : 4; 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 === 227) { + if (node.kind === 229) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -57682,7 +58813,7 @@ var ts; } } else { - if (node.kind === 227) { + if (node.kind === 229) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } @@ -57701,10 +58832,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 26, copyExpr); + expr = ts.createBinary(expr, 27, copyExpr); } } - returnExpression = ts.createBinary(expr, 26, returnExpression); + returnExpression = ts.createBinary(expr, 27, returnExpression); } return ts.createReturn(returnExpression); } @@ -57762,7 +58893,7 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19); var localName = ts.getInternalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; @@ -57818,7 +58949,7 @@ var ts; } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; @@ -57846,17 +58977,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 228) { + if (statement.kind === 230) { return true; } - else if (statement.kind === 220) { + else if (statement.kind === 222) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 216) { + else if (statement.kind === 218) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -57885,7 +59016,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 219 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 221 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -57893,8 +59024,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (8192 | 16384))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 202 - || superCallExpression.left.kind !== 189) { + if (superCallExpression.kind !== 204 + || superCallExpression.left.kind !== 191) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -57968,7 +59099,7 @@ var ts; statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 71 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 72 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -57995,7 +59126,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 && node.kind !== 195) { + if (node.transformFlags & 16384 && node.kind !== 197) { captureThisForNode(statements, node, ts.createThis()); } } @@ -58012,19 +59143,19 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 195: + case 197: return statements; - case 154: case 156: - case 157: + case 158: + case 159: newTarget = ts.createVoidZero(); break; - case 155: + case 157: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 237: - case 194: - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 93, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + case 239: + case 196: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 94, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -58043,20 +59174,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 215: + case 217: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 154: + case 156: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 156: - case 157: + case 158: + case 159: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 155: + case 157: break; default: ts.Debug.failBadSyntaxKind(node); @@ -58181,7 +59312,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 237 || node.kind === 194)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 239 || node.kind === 196)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -58213,7 +59344,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 195); + ts.Debug.assert(node.kind === 197); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -58244,7 +59375,7 @@ var ts; ts.setEmitFlags(block, 1); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 18, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -58266,9 +59397,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 193: + case 195: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false)); - case 202: + case 204: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -58276,9 +59407,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 193: + case 195: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 202: + case 204: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -58304,7 +59435,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { - assignment = ts.createBinary(decl.name, 58, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 59, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -58409,14 +59540,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 221: - case 222: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 223: - return visitForStatement(node, outermostLabeledStatement); case 224: - return visitForInStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 225: + return visitForStatement(node, outermostLabeledStatement); + case 226: + return visitForInStatement(node, outermostLabeledStatement); + case 227: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -58540,7 +59671,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 147) { + if (property.name.kind === 149) { numInitialProperties = i; break; } @@ -58587,7 +59718,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 71) { + if (node.kind === 72) { state.hoistedLocalVariables.push(node); } else { @@ -58651,11 +59782,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 223: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 224: return convertForInStatement(node, convertedLoopBody); - case 225: return convertForOfStatement(node, convertedLoopBody); - case 221: return convertDoStatement(node, convertedLoopBody); - case 222: return convertWhileStatement(node, convertedLoopBody); + case 225: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 226: return convertForInStatement(node, convertedLoopBody); + case 227: return convertForOfStatement(node, convertedLoopBody); + case 223: return convertDoStatement(node, convertedLoopBody); + case 224: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -58679,11 +59810,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 223: - case 224: case 225: + case 226: + case 227: var initializer = node.initializer; - if (initializer && initializer.kind === 236) { + if (initializer && initializer.kind === 238) { loopInitializer = initializer; } break; @@ -58777,7 +59908,7 @@ var ts; statements.push(ts.createVariableStatement(undefined, node.initializer)); copyOutParameters(currentState.loopOutParameters, 2, 1, statements); var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(39) : undefined, undefined, undefined, undefined, undefined, ts.visitNode(ts.createBlock(statements, true), visitor, ts.isBlock)), emitFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(40) : undefined, undefined, undefined, undefined, undefined, ts.visitNode(ts.createBlock(statements, true), visitor, ts.isBlock)), emitFlags)) ]), 2097152)); var part = ts.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; @@ -58792,7 +59923,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(51, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(52, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -58813,7 +59944,7 @@ var ts; if (containsYield && (hierarchyFacts & 4) !== 0) emitFlags |= 262144; var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(39) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(40) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags)) ]), 2097152)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; @@ -58821,7 +59952,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 58, source); + return ts.createBinary(target, 59, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -58834,7 +59965,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(39), ts.setEmitFlags(call, 8388608)) + ? ts.createYield(ts.createToken(40), ts.setEmitFlags(call, 8388608)) : call; return ts.createStatement(callResult); } @@ -58845,7 +59976,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(39), ts.setEmitFlags(call, 8388608)) + ? ts.createYield(ts.createToken(40), ts.setEmitFlags(call, 8388608)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -58865,10 +59996,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 34, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 35, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -58942,20 +60073,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 156: - case 157: + case 158: + case 159: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 154: + case 156: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 273: + case 275: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 274: + case 276: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -59030,7 +60161,7 @@ var ts; var body = node.transformFlags & (16384 | 128) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 156) { + if (node.kind === 158) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -59109,10 +60240,10 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { if (node.transformFlags & 131072 || - node.expression.kind === 97 || + node.expression.kind === 98 || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { ts.setEmitFlags(thisArg, 4); } var resultingCall = void 0; @@ -59122,7 +60253,7 @@ var ts; else { resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 97) { + if (node.expression.kind === 98) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -59161,7 +60292,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 187 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -59233,7 +60364,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 13 || node.kind === 16; + var isLast = node.kind === 14 || node.kind === 17; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.setTextRange(ts.createLiteral(text), node); @@ -59275,7 +60406,7 @@ var ts; : ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 94 && node.name.escapedText === "target") { + if (node.keywordToken === 95 && node.name.escapedText === "target") { if (hierarchyFacts & 8192) { hierarchyFacts |= 32768; } @@ -59300,20 +60431,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(71); + context.enableSubstitution(72); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(99); - context.enableEmitNotification(155); - context.enableEmitNotification(154); - context.enableEmitNotification(156); + context.enableSubstitution(100); context.enableEmitNotification(157); - context.enableEmitNotification(195); - context.enableEmitNotification(194); - context.enableEmitNotification(237); + context.enableEmitNotification(156); + context.enableEmitNotification(158); + context.enableEmitNotification(159); + context.enableEmitNotification(197); + context.enableEmitNotification(196); + context.enableEmitNotification(239); } } function onSubstituteNode(hint, node) { @@ -59337,10 +60468,10 @@ var ts; } function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 184: - case 238: - case 241: - case 235: + case 186: + case 240: + case 243: + case 237: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -59348,9 +60479,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71: + case 72: return substituteExpressionIdentifier(node); - case 99: + case 100: return substituteThisKeyword(node); } return node; @@ -59401,19 +60532,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 221) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 191) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 98) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 208) { return false; } var expression = callArgument.expression; @@ -59457,24 +60588,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(260); + context.enableEmitNotification(262); + context.enableEmitNotification(263); context.enableEmitNotification(261); - context.enableEmitNotification(259); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(187); - context.enableSubstitution(273); + context.enableSubstitution(189); + context.enableSubstitution(275); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 260: + case 262: + case 263: case 261: - case 259: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -59510,7 +60641,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 72 && token <= 107) { + if (token !== undefined && token >= 73 && token <= 108) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -59591,13 +60722,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 221: + case 223: return visitDoStatement(node); - case 222: + case 224: return visitWhileStatement(node); - case 230: + case 232: return visitSwitchStatement(node); - case 231: + case 233: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -59605,24 +60736,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 237: + case 239: return visitFunctionDeclaration(node); - case 194: + case 196: return visitFunctionExpression(node); - case 156: - case 157: + case 158: + case 159: return visitAccessorDeclaration(node); - case 217: + case 219: return visitVariableStatement(node); - case 223: + case 225: return visitForStatement(node); - case 224: - return visitForInStatement(node); - case 227: - return visitBreakStatement(node); case 226: - return visitContinueStatement(node); + return visitForInStatement(node); + case 229: + return visitBreakStatement(node); case 228: + return visitContinueStatement(node); + case 230: return visitReturnStatement(node); default: if (node.transformFlags & 4194304) { @@ -59638,21 +60769,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 202: + case 204: return visitBinaryExpression(node); - case 203: - return visitConditionalExpression(node); case 205: + return visitConditionalExpression(node); + case 207: return visitYieldExpression(node); - case 185: + case 187: return visitArrayLiteralExpression(node); - case 186: - return visitObjectLiteralExpression(node); case 188: - return visitElementAccessExpression(node); - case 189: - return visitCallExpression(node); + return visitObjectLiteralExpression(node); case 190: + return visitElementAccessExpression(node); + case 191: + return visitCallExpression(node); + case 192: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -59660,9 +60791,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 237: + case 239: return visitFunctionDeclaration(node); - case 194: + case 196: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -59795,23 +60926,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 59 - && kind <= 70; + return kind >= 60 + && kind <= 71; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; case 63: return 41; case 64: return 42; - case 65: return 45; + case 65: return 43; case 66: return 46; case 67: return 47; case 68: return 48; case 69: return 49; case 70: return 50; + case 71: return 51; } } function visitRightAssociativeBinaryExpression(node) { @@ -59819,10 +60950,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 187: + case 189: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 188: + case 190: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -59844,7 +60975,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 26) { + else if (node.operatorToken.kind === 27) { return visitCommaExpression(node); } var clone_5 = ts.getMutableClone(node); @@ -59858,7 +60989,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 53) { + if (node.operatorToken.kind === 54) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -59874,7 +61005,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) { visit(node.left); visit(node.right); } @@ -60023,35 +61154,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 216: + case 218: return transformAndEmitBlock(node); - case 219: - return transformAndEmitExpressionStatement(node); - case 220: - return transformAndEmitIfStatement(node); case 221: - return transformAndEmitDoStatement(node); + return transformAndEmitExpressionStatement(node); case 222: - return transformAndEmitWhileStatement(node); + return transformAndEmitIfStatement(node); case 223: - return transformAndEmitForStatement(node); + return transformAndEmitDoStatement(node); case 224: - return transformAndEmitForInStatement(node); + return transformAndEmitWhileStatement(node); + case 225: + return transformAndEmitForStatement(node); case 226: - return transformAndEmitContinueStatement(node); - case 227: - return transformAndEmitBreakStatement(node); + return transformAndEmitForInStatement(node); case 228: - return transformAndEmitReturnStatement(node); + return transformAndEmitContinueStatement(node); case 229: - return transformAndEmitWithStatement(node); + return transformAndEmitBreakStatement(node); case 230: - return transformAndEmitSwitchStatement(node); + return transformAndEmitReturnStatement(node); case 231: - return transformAndEmitLabeledStatement(node); + return transformAndEmitWithStatement(node); case 232: - return transformAndEmitThrowStatement(node); + return transformAndEmitSwitchStatement(node); case 233: + return transformAndEmitLabeledStatement(node); + case 234: + return transformAndEmitThrowStatement(node); + case 235: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -60345,7 +61476,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 270 && defaultClauseIndex === -1) { + if (clause.kind === 272 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -60355,7 +61486,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 269) { + if (clause.kind === 271) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -60590,7 +61721,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(71); + context.enableSubstitution(72); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -61170,12 +62301,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71); + context.enableSubstitution(72); + context.enableSubstitution(204); context.enableSubstitution(202); - context.enableSubstitution(200); - context.enableSubstitution(201); - context.enableSubstitution(274); - context.enableEmitNotification(277); + context.enableSubstitution(203); + context.enableSubstitution(276); + context.enableEmitNotification(279); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -61366,23 +62497,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 247: + case 249: return visitImportDeclaration(node); - case 246: + case 248: return visitImportEqualsDeclaration(node); - case 253: + case 255: return visitExportDeclaration(node); - case 252: + case 254: return visitExportAssignment(node); - case 217: + case 219: return visitVariableStatement(node); - case 237: + case 239: return visitFunctionDeclaration(node); - case 238: + case 240: return visitClassDeclaration(node); - case 308: + case 310: return visitMergeDeclarationMarker(node); - case 309: + case 311: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -61407,24 +62538,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 273: + case 275: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 274: + case 276: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 275: + case 277: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 154: case 156: - case 157: + case 158: + case 159: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -61739,7 +62870,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -61771,10 +62902,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249: + case 251: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250: + case 252: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -61875,14 +63006,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 84: - case 79: + case 85: + case 80: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277) { + if (node.kind === 279) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -61922,12 +63053,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71: + case 72: return substituteExpressionIdentifier(node); - case 202: + case 204: return substituteBinaryExpression(node); - case 201: - case 200: + case 203: + case 202: return substituteUnaryExpression(node); } return node; @@ -61942,7 +63073,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 277) { + if (exportContainer && exportContainer.kind === 279) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -61978,15 +63109,15 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 43 || node.operator === 44) + if ((node.operator === 44 || node.operator === 45) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 ? 59 : 60), ts.createLiteral(1)), node) + var expression = node.kind === 203 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 ? 60 : 61), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; @@ -62048,12 +63179,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71); - context.enableSubstitution(274); + context.enableSubstitution(72); + context.enableSubstitution(276); + context.enableSubstitution(204); context.enableSubstitution(202); - context.enableSubstitution(200); - context.enableSubstitution(201); - context.enableEmitNotification(277); + context.enableSubstitution(203); + context.enableEmitNotification(279); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -62157,7 +63288,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 253 && externalImport.exportClause) { + if (externalImport.kind === 255 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -62180,7 +63311,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 253) { + if (externalImport.kind !== 255) { continue; } if (!externalImport.exportClause) { @@ -62231,15 +63362,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 247: + case 249: if (!entry.importClause) { break; } - case 246: + case 248: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 253: + case 255: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -62261,13 +63392,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 247: + case 249: return visitImportDeclaration(node); - case 246: + case 248: return visitImportEqualsDeclaration(node); - case 253: + case 255: return undefined; - case 252: + case 254: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -62388,7 +63519,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 277 + && (enclosingBlockScopedContainer.kind === 279 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -62410,7 +63541,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -62449,10 +63580,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249: + case 251: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250: + case 252: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -62552,43 +63683,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 217: + case 219: return visitVariableStatement(node); - case 237: + case 239: return visitFunctionDeclaration(node); - case 238: + case 240: return visitClassDeclaration(node); - case 223: - return visitForStatement(node); - case 224: - return visitForInStatement(node); case 225: + return visitForStatement(node); + case 226: + return visitForInStatement(node); + case 227: return visitForOfStatement(node); - case 221: + case 223: return visitDoStatement(node); - case 222: + case 224: return visitWhileStatement(node); - case 231: - return visitLabeledStatement(node); - case 229: - return visitWithStatement(node); - case 230: - return visitSwitchStatement(node); - case 244: - return visitCaseBlock(node); - case 269: - return visitCaseClause(node); - case 270: - return visitDefaultClause(node); case 233: - return visitTryStatement(node); + return visitLabeledStatement(node); + case 231: + return visitWithStatement(node); + case 232: + return visitSwitchStatement(node); + case 246: + return visitCaseBlock(node); + case 271: + return visitCaseClause(node); case 272: + return visitDefaultClause(node); + case 235: + return visitTryStatement(node); + case 274: return visitCatchClause(node); - case 216: + case 218: return visitBlock(node); - case 308: + case 310: return visitMergeDeclarationMarker(node); - case 309: + case 311: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -62682,7 +63813,7 @@ var ts; } function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 202) { + && node.kind === 204) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -62725,7 +63856,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 277; + return container !== undefined && container.kind === 279; } else { return false; @@ -62733,14 +63864,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 84: - case 79: + case 85: + case 80: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277) { + if (node.kind === 279) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -62774,7 +63905,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 274: + case 276: return substituteShorthandPropertyAssignment(node); } return node; @@ -62796,12 +63927,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71: + case 72: return substituteExpressionIdentifier(node); - case 202: + case 204: return substituteBinaryExpression(node); - case 200: - case 201: + case 202: + case 203: return substituteUnaryExpression(node); } return node; @@ -62846,22 +63977,22 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 43 || node.operator === 44) + if ((node.operator === 44 || node.operator === 45) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 + var expression = node.kind === 203 ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 201) { - expression = node.operator === 43 + if (node.kind === 203) { + expression = node.operator === 44 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -62877,7 +64008,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 277) { + if (exportContainer && exportContainer.kind === 279) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -62905,8 +64036,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(277); - context.enableSubstitution(71); + context.enableEmitNotification(279); + context.enableSubstitution(72); var currentSourceFile; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -62932,9 +64063,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 246: + case 248: return undefined; - case 252: + case 254: return visitExportAssignment(node); } return node; @@ -63020,7 +64151,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 240) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -63049,7 +64180,7 @@ var ts; 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 === 238) { + else if (node.parent.kind === 240) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -63096,15 +64227,15 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 235 || node.kind === 184) { + if (node.kind === 237 || node.kind === 186) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 152 || node.kind === 151 || - (node.kind === 149 && ts.hasModifier(node.parent, 8))) { + else if (node.kind === 154 || node.kind === 153 || + (node.kind === 151 && ts.hasModifier(node.parent, 8))) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -63112,7 +64243,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 || node.kind === 149) { + else if (node.parent.kind === 240 || node.kind === 151) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -63136,7 +64267,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 157) { + if (node.kind === 159) { if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -63173,23 +64304,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 159: + case 161: 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 158: + case 160: 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 160: + case 162: 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 154: - case 153: + case 156: + case 155: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -63197,7 +64328,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 240) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -63210,7 +64341,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 237: + case 239: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -63235,27 +64366,27 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 155: + case 157: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 159: - case 164: + case 161: + case 166: 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 158: + case 160: 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 160: + case 162: 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 154: - case 153: + case 156: + case 155: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -63263,7 +64394,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238) { + else if (node.parent.parent.kind === 240) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -63275,8 +64406,8 @@ 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 237: - case 163: + case 239: + case 165: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -63289,34 +64420,34 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 238: + case 240: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 239: + case 241: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 159: + case 161: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 158: + case 160: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154: - case 153: + case 156: + case 155: if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238) { + else if (node.parent.parent.kind === 240) { 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 237: + case 239: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 240: + case 242: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -63330,8 +64461,8 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 238) { - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 108 ? + if (node.parent.parent.kind === 240) { + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 109 ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -63483,10 +64614,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 277 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 279 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 278) { + if (node.kind === 280) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -63509,14 +64640,14 @@ var ts; resultHasExternalModuleIndicator = false; needsDeclare = false; var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(124)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], true, [], [], false, []); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(125)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], true, [], [], false, []); return newFile; } needsDeclare = true; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280) { + if (prepend.kind === 282) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -63625,11 +64756,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 71) { + if (name.kind === 72) { return name; } else { - if (name.kind === 183) { + if (name.kind === 185) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -63637,7 +64768,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 208) { + if (elem.kind === 210) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -63649,7 +64780,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = ts.updateParameter(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(55)) : undefined, ensureType(p, p.type, true), ensureNoInitializer(p)); + var newParam = ts.updateParameter(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56)) : undefined, ensureType(p, p.type, true), ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } @@ -63660,7 +64791,7 @@ var ts; } function ensureNoInitializer(node) { if (shouldPrintWithInitializer(node)) { - return resolver.createLiteralConstValue(ts.getParseTreeNode(node)); + return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker); } return undefined; } @@ -63671,17 +64802,17 @@ var ts; if (shouldPrintWithInitializer(node)) { return; } - var shouldUseResolverType = node.kind === 149 && + var shouldUseResolverType = node.kind === 151 && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(119); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(120); } - if (node.kind === 157) { - return ts.createKeywordTypeNode(119); + if (node.kind === 159) { + return ts.createKeywordTypeNode(120); } errorNameNode = node.name; var oldDiag; @@ -63689,12 +64820,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 235 || node.kind === 184) { + if (node.kind === 237 || node.kind === 186) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 149 - || node.kind === 152 - || node.kind === 151) { + if (node.kind === 151 + || node.kind === 154 + || node.kind === 153) { 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)); @@ -63705,25 +64836,25 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(119); + return returnValue || ts.createKeywordTypeNode(120); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 237: - case 242: case 239: - case 238: - case 240: + case 244: case 241: + case 240: + case 242: + case 243: return !resolver.isDeclarationVisible(node); - case 235: + case 237: return !getBindingNameVisible(node); - case 246: - case 247: - case 253: - case 252: + case 248: + case 249: + case 255: + case 254: return false; } return false; @@ -63776,7 +64907,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 && parent.kind !== 181); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 244 && parent.kind !== 183); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -63796,7 +64927,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 257) { + if (decl.moduleReference.kind === 259) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -63816,7 +64947,7 @@ var ts; if (!decl.importClause.namedBindings) { return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 249) { + if (decl.importClause.namedBindings.kind === 251) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; } @@ -63896,61 +65027,61 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 || input.kind === 179) && input.parent.kind !== 240); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 168 || input.kind === 181) && input.parent.kind !== 242); if (shouldEnterSuppressNewDiagnosticsContextContext) { suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 209: { + case 211: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 162: { + case 164: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 159: + case 161: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 155: { + case 157: { var isPrivate = ts.hasModifier(input, 8); - var ctor = ts.createSignatureDeclaration(155, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); + var ctor = ts.createSignatureDeclaration(157, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 154: { - var sig = ts.createSignatureDeclaration(153, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 156: { + var sig = ts.createSignatureDeclaration(155, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 156: { + case 158: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 157: { + case 159: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 152: + case 154: return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 151: + case 153: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 153: { + case 155: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 158: { + case 160: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 160: { - return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119))); + case 162: { + return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(120))); } - case 235: { + case 237: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -63958,13 +65089,13 @@ var ts; suppressNewDiagnosticContexts = true; return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 148: { + case 150: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 173: { + case 175: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -63974,13 +65105,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 163: { + case 165: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 164: { + case 166: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 181: { + case 183: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -64009,7 +65140,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 154 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 156 && ts.hasModifier(node.parent, 8); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -64018,19 +65149,19 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 253: { + case 255: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; } return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 252: { + case 254: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; } - if (input.expression.kind === 71) { + if (input.expression.kind === 72) { return input; } else { @@ -64040,7 +65171,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124)] : [], ts.createVariableDeclarationList([varDecl], 2)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125)] : [], ts.createVariableDeclarationList([varDecl], 2)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -64053,10 +65184,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 246: { + case 248: { return transformImportEqualsDeclaration(input); } - case 247: { + case 249: { return transformImportDeclaration(input); } } @@ -64076,12 +65207,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 240: + case 242: return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 239: { + case 241: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 237: { + case 239: { var clean = cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input, isPrivate), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); if (clean && resolver.isExpandoFunctionDeclaration(input)) { var declarations = ts.mapDefined(resolver.getPropertiesOfContainerFunction(input), function (p) { @@ -64099,10 +65230,10 @@ var ts; return clean; } } - case 242: { + case 244: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 243) { + if (inner && inner.kind === 245) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -64120,7 +65251,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 238: { + case 240: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -64131,7 +65262,7 @@ var ts; if (!ts.hasModifier(param, 92)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 71) { + if (param.name.kind === 72) { return preserveJsDoc(ts.createProperty(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -64156,7 +65287,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 96) { var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, @@ -64164,16 +65295,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124)] : [], ts.createVariableDeclarationList([varDecl], 2)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125)] : [], ts.createVariableDeclarationList([varDecl], 2)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 85) { + if (clause.token === 86) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 96; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; } @@ -64182,10 +65313,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 217: { + case 219: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 241: { + case 243: { return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -64202,7 +65333,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 242) { + if (input.kind === 244) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -64223,7 +65354,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 208) { + if (e.kind === 210) { return; } if (e.name) { @@ -64286,7 +65417,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 277; + var parentIsFile = node.parent.kind === 279; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1) | 2); additions = 0; @@ -64327,13 +65458,13 @@ var ts; } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 85 && t.expression.kind === 95); + return ts.isEntityNameExpression(t.expression) || (clause.token === 86 && t.expression.kind === 96); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 239) { + if (node.kind === 241) { return true; } return false; @@ -64355,7 +65486,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 156 + return accessor.kind === 158 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -64364,52 +65495,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 152: - case 151: + case 154: + case 153: return !ts.hasModifier(node, 8); - case 149: - case 235: + case 151: + case 237: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 237: - case 242: - case 246: case 239: - case 238: - case 240: + case 244: + case 248: case 241: - case 217: - case 247: - case 253: - case 252: + case 240: + case 242: + case 243: + case 219: + case 249: + case 255: + case 254: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 159: - case 155: - case 154: - case 156: + case 161: case 157: - case 152: - case 151: - case 153: + case 156: case 158: + case 159: + case 154: + case 153: + case 155: case 160: - case 235: - case 148: - case 209: case 162: - case 173: - case 163: + case 237: + case 150: + case 211: case 164: - case 181: + case 175: + case 165: + case 166: + case 183: return true; } return false; @@ -64459,8 +65590,16 @@ var ts; return transformers; } ts.getTransformers = getTransformers; + function noEmitSubstitution(_hint, node) { + return node; + } + ts.noEmitSubstitution = noEmitSubstitution; + function noEmitNotification(hint, node, callback) { + callback(hint, node); + } + ts.noEmitNotification = noEmitNotification; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(310); + var enabledSyntaxKindFeatures = new Array(312); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -64468,8 +65607,8 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; - var onSubstituteNode = function (_, node) { return node; }; - var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var onSubstituteNode = noEmitSubstitution; + var onEmitNode = noEmitNotification; var state = 0; var diagnostics = []; var context = { @@ -64660,694 +65799,10 @@ var ts; ts.transformNodes = transformNodes; })(ts || (ts = {})); var ts; -(function (ts) { - var defaultLastEncodedSourceMapSpan = { - emittedLine: 0, - emittedColumn: 0, - sourceLine: 0, - sourceColumn: 0, - sourceIndex: 0 - }; - function createSourceMapWriter(host, writer, compilerOptions) { - if (compilerOptions === void 0) { compilerOptions = host.getCompilerOptions(); } - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var currentSource; - var currentSourceText; - var sourceMapDir; - var sourceMapSourceIndex; - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan; - var lastEncodedNameIndex; - var sourceMapData; - var sourceMapDataList; - var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); - return { - initialize: initialize, - reset: reset, - setSourceFile: setSourceFile, - emitPos: emitPos, - emitNodeWithSourceMap: emitNodeWithSourceMap, - emitTokenWithSourceMap: emitTokenWithSourceMap, - getText: getText, - getSourceMappingURL: getSourceMappingURL, - }; - function skipSourceTrivia(pos) { - return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); - } - function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled || ts.fileExtensionIs(filePath, ".json")) { - return; - } - if (sourceMapData) { - reset(); - } - sourceMapDataList = outputSourceMapDataList; - currentSource = undefined; - currentSourceText = undefined; - sourceMapSourceIndex = -1; - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; - lastEncodedNameIndex = 0; - sourceMapData = { - sourceMapFilePath: sourceMapFilePath, - jsSourceMappingURL: !compilerOptions.inlineSourceMap ? ts.getBaseFileName(ts.normalizeSlashes(sourceMapFilePath)) : undefined, - sourceMapFile: ts.getBaseFileName(ts.normalizeSlashes(filePath)), - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 277) { - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle.fileName, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(filePath)); - } - } - function reset() { - if (disabled) { - return; - } - if (sourceMapDataList) { - sourceMapDataList.push(sourceMapData); - } - currentSource = undefined; - sourceMapDir = undefined; - sourceMapSourceIndex = undefined; - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = undefined; - lastEncodedNameIndex = undefined; - sourceMapData = undefined; - sourceMapDataList = undefined; - } - function captureSection() { - return { - version: 3, - file: sourceMapData.sourceMapFile, - sourceRoot: sourceMapData.sourceMapSourceRoot, - sources: sourceMapData.sourceMapSources, - names: sourceMapData.sourceMapNames, - mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent, - }; - } - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - ts.Debug.assert(lastRecordedSourceMapSpan.emittedColumn >= 0, "lastEncodedSourceMapSpan.emittedColumn was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceIndex >= 0, "lastEncodedSourceMapSpan.sourceIndex was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceLine >= 0, "lastEncodedSourceMapSpan.sourceLine was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceColumn >= 0, "lastEncodedSourceMapSpan.sourceColumn was negative"); - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 0; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - } - function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeSourcemap"); - } - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSource, pos); - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - if (extendedDiagnostics) { - ts.performance.mark("afterSourcemap"); - ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); - } - } - function isPossiblySourceMap(x) { - return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; - } - function emitNodeWithSourceMap(hint, node, emitCallback) { - var _a; - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(hint, node); - } - if (node) { - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var text = node.sourceMapText; - var parsed = void 0; - try { - parsed = JSON.parse(text); - } - catch (_b) { - } - if (!parsed || !isPossiblySourceMap(parsed)) { - return emitCallback(hint, node); - } - var offsetLine = writer.getLine(); - var firstLineColumnOffset = writer.getColumn(); - var originalMap = parsed; - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache = ts.createMap(); - var absolutePathCache = ts.createMap(); - var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); - for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { - var pathCacheKey = "" + raw.sourceIndex; - if (!resolvedPathCache.has(pathCacheKey)) { - var rawPath = originalMap.sources[raw.sourceIndex]; - var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, true); - resolvedPathCache.set(pathCacheKey, resolvedPath_1); - absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); - } - var resolvedPath = resolvedPathCache.get(pathCacheKey); - var absolutePath = absolutePathCache.get(pathCacheKey); - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); - var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); - } - return emitCallback(hint, node); - } - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var range = emitNode && emitNode.sourceMapRange; - var _d = range || node, pos = _d.pos, end = _d.end; - var source = range && range.source; - var oldSource = currentSource; - if (source === oldSource) - source = undefined; - if (source) - setSourceFile(source); - if (node.kind !== 305 - && (emitFlags & 16) === 0 - && pos >= 0) { - emitPos(skipSourceTrivia(pos)); - } - if (source) - setSourceFile(oldSource); - if (emitFlags & 64) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - if (source) - setSourceFile(source); - if (node.kind !== 305 - && (emitFlags & 32) === 0 - && end >= 0) { - emitPos(end); - } - if (source) - setSourceFile(oldSource); - } - } - function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(token, writer, tokenPos); - } - var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; - tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); - if ((emitFlags & 128) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - tokenPos = emitCallback(token, writer, tokenPos); - if (range) - tokenPos = range.end; - if ((emitFlags & 256) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - return tokenPos; - } - function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json"); - } - function setSourceFile(sourceFile) { - if (disabled) { - return; - } - currentSource = sourceFile; - currentSourceText = currentSource.text; - if (isJsonSourceMapSource(sourceFile)) { - return; - } - setupSourceEntry(sourceFile.fileName, sourceFile.text); - } - function setupSourceEntry(fileName, content, source) { - if (!source) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); - } - sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); - if (sourceMapSourceIndex === -1) { - sourceMapSourceIndex = sourceMapData.sourceMapSources.length; - sourceMapData.sourceMapSources.push(source); - sourceMapData.inputSourceFileNames.push(fileName); - if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent.push(content); - } - } - } - function getText() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; - } - encodeLastRecordedSourceMapSpan(); - return JSON.stringify(captureSection()); - } - function getSourceMappingURL() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; - } - if (compilerOptions.inlineSourceMap) { - var base64SourceMapText = ts.base64encode(ts.sys, getText()); - return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; - } - else { - return sourceMapData.jsSourceMappingURL; - } - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - function base64FormatEncode(inValue) { - if (inValue < 64) { - return base64Chars.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - function base64VLQFormatEncode(inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } -})(ts || (ts = {})); -var ts; -(function (ts) { - function createCommentWriter(printerOptions, emitPos) { - var extendedDiagnostics = printerOptions.extendedDiagnostics; - var newLine = ts.getNewLineCharacter(printerOptions); - var writer; - var containerPos = -1; - var containerEnd = -1; - var declarationListContainerEnd = -1; - var currentSourceFile; - var currentText; - var currentLineMap; - var detachedCommentsInfo; - var hasWrittenComment = false; - var disabled = !!printerOptions.removeComments; - return { - reset: reset, - setWriter: setWriter, - setSourceFile: setSourceFile, - emitNodeWithComments: emitNodeWithComments, - emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, - emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, - }; - function emitNodeWithComments(hint, node, emitCallback) { - if (disabled) { - emitCallback(hint, node); - return; - } - if (node) { - hasWrittenComment = false; - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; - if ((pos < 0 && end < 0) || (pos === end)) { - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - } - else { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithComment"); - } - var isEmittedNode = node.kind !== 305; - var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 10; - var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 10; - if (!skipLeadingComments) { - emitLeadingComments(pos, isEmittedNode); - } - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) { - containerPos = pos; - } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) { - containerEnd = end; - if (node.kind === 236) { - declarationListContainerEnd = end; - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithComment"); - } - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithComment"); - } - containerPos = savedContainerPos; - containerEnd = savedContainerEnd; - declarationListContainerEnd = savedDeclarationListContainerEnd; - if (!skipTrailingComments && isEmittedNode) { - emitTrailingComments(end); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithComment"); - } - } - } - } - function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { - var leadingComments = emitNode && emitNode.leadingComments; - if (ts.some(leadingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithSynthesizedComments"); - } - ts.forEach(leadingComments, emitLeadingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); - } - } - emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); - var trailingComments = emitNode && emitNode.trailingComments; - if (ts.some(trailingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithSynthesizedComments"); - } - ts.forEach(trailingComments, emitTrailingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); - } - } - } - function emitLeadingSynthesizedComment(comment) { - if (comment.kind === 2) { - writer.writeLine(); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function emitTrailingSynthesizedComment(comment) { - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - } - function writeSynthesizedComment(comment) { - var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined; - ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); - } - function formatSynthesizedComment(comment) { - return comment.kind === 3 - ? "/*" + comment.text + "*/" - : "//" + comment.text; - } - function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { - if (emitFlags & 2048) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - } - function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitBodyWithDetachedComments"); - } - var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; - var skipTrailingComments = disabled || end < 0 || (emitFlags & 1024) !== 0; - if (!skipLeadingComments) { - emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); - } - if (emitFlags & 2048 && !disabled) { - disabled = true; - emitCallback(node); - disabled = false; - } - else { - emitCallback(node); - } - if (extendedDiagnostics) { - ts.performance.mark("beginEmitBodyWithDetachedComments"); - } - if (!skipTrailingComments) { - emitLeadingComments(detachedRange.end, true); - if (hasWrittenComment && !writer.isAtStartOfLine()) { - writer.writeLine(); - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitBodyWithDetachedComments"); - } - } - function emitLeadingComments(pos, isEmittedNode) { - hasWrittenComment = false; - if (isEmittedNode) { - forEachLeadingCommentToEmit(pos, emitLeadingComment); - } - else if (pos === 0) { - forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); - } - } - function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); - } - } - function shouldWriteComment(text, pos) { - if (printerOptions.onlyPrintJsDocStyle) { - return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); - } - return true; - } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (!hasWrittenComment) { - ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); - hasWrittenComment = true; - } - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else if (kind === 3) { - writer.write(" "); - } - } - function emitLeadingCommentsOfPosition(pos) { - if (disabled || pos === -1) { - return; - } - emitLeadingComments(pos, true); - } - function emitTrailingComments(pos) { - forEachTrailingCommentToEmit(pos, emitTrailingComment); - } - function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - } - function emitTrailingCommentsOfPosition(pos, prefixSpace) { - if (disabled) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); - } - forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); - } - } - function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function forEachLeadingCommentToEmit(pos, cb) { - if (containerPos === -1 || pos !== containerPos) { - if (hasDetachedComments(pos)) { - forEachLeadingCommentWithoutDetachedComments(cb); - } - else { - ts.forEachLeadingCommentRange(currentText, pos, cb, pos); - } - } - } - function forEachTrailingCommentToEmit(end, cb) { - if (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd)) { - ts.forEachTrailingCommentRange(currentText, end, cb); - } - } - function reset() { - currentSourceFile = undefined; - currentText = undefined; - currentLineMap = undefined; - detachedCommentsInfo = undefined; - } - function setWriter(output) { - writer = output; - } - function setSourceFile(sourceFile) { - currentSourceFile = sourceFile; - currentText = currentSourceFile.text; - currentLineMap = ts.getLineStarts(currentSourceFile); - detachedCommentsInfo = undefined; - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; - } - function forEachLeadingCommentWithoutDetachedComments(cb) { - var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - ts.forEachLeadingCommentRange(currentText, pos, cb, pos); - } - function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentText, currentLineMap, writer, writeComment, range, newLine, disabled); - if (currentDetachedCommentInfo) { - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - } - function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); - } - } - ts.createCommentWriter = createCommentWriter; -})(ts || (ts = {})); -var ts; (function (ts) { var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); + var syntheticParent = { pos: -1, end: -1 }; function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); @@ -65374,7 +65829,7 @@ var ts; ts.forEachEmittedFile = forEachEmittedFile; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 278) { + if (sourceFile.kind === 280) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); @@ -65427,21 +65882,15 @@ var ts; var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); - var newLine = host.getNewLine(); + var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); - var sourceMap = ts.createSourceMapWriter(host, writer); - var declarationSourceMap = ts.createSourceMapWriter(host, writer, { - sourceMap: compilerOptions.declarationMap, - sourceRoot: compilerOptions.sourceRoot, - mapRoot: compilerOptions.mapRoot, - extendedDiagnostics: compilerOptions.extendedDiagnostics, - }); + var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; var bundleInfo = createDefaultBundleInfo(); var emitSkipped = false; var exportedModulesFromDeclarationEmit; - ts.performance.mark("beforePrint"); + enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); - ts.performance.measure("printTime", "beforePrint"); + exit(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -65482,17 +65931,24 @@ var ts; return; } var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], transformers, false); - var printer = createPrinter(__assign({}, compilerOptions, { noEmitHelpers: compilerOptions.noEmitHelpers }), { + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: compilerOptions.noEmitHelpers, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + inlineSources: compilerOptions.inlineSources, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }; + var printer = createPrinter(printerOptions, { hasGlobalName: resolver.hasGlobalName, onEmitNode: transform.emitNodeWithNotification, substituteNode: transform.substituteNode, - onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: sourceMap.emitPos, - onSetSourceFile: setSourceFile, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, sourceMap); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); transform.dispose(); } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath) { @@ -65512,12 +65968,19 @@ var ts; emitterDiagnostics.add(diagnostic); } } - var declarationPrinter = createPrinter(__assign({}, compilerOptions, { onlyPrintJsDocStyle: true, noEmitHelpers: true }), { + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: true, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + onlyPrintJsDocStyle: true, + }; + var declarationPrinter = createPrinter(printerOptions, { hasGlobalName: resolver.hasGlobalName, - onEmitSourceMapOfNode: declarationSourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: declarationSourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: declarationSourceMap.emitPos, - onSetSourceFile: setSourceFileForDeclarationSourceMaps, onEmitNode: declarationTransform.emitNodeWithNotification, substituteNode: declarationTransform.substituteNode, }); @@ -65525,8 +65988,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], undefined, declarationPrinter, declarationSourceMap); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 277) { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], undefined, declarationPrinter, { + sourceMap: compilerOptions.declarationMap, + sourceRoot: compilerOptions.sourceRoot, + mapRoot: compilerOptions.mapRoot, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }); + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -65535,7 +66003,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 71) { + if (node.expression.kind === 72) { resolver.collectLinkedAliases(node.expression, true); } return; @@ -65546,49 +66014,104 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 278 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 277 ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 280 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 279 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; - mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); + var sourceMapGenerator; + if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { + sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); + } if (bundle) { - printer.writeBundle(bundle, writer, bundleInfo); + printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); } else { - printer.writeFile(sourceFile, writer); + printer.writeFile(sourceFile, writer, sourceMapGenerator); } - writer.writeLine(); - var sourceMappingURL = mapRecorder.getSourceMappingURL(); - if (sourceMappingURL) { - writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + if (sourceMapGenerator) { + if (sourceMapDataList) { + sourceMapDataList.push({ + inputSourceFileNames: sourceMapGenerator.getSources(), + sourceMap: sourceMapGenerator.toJSON() + }); + } + var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile); + if (sourceMappingURL) { + if (!writer.isAtStartOfLine()) + writer.rawWrite(newLine); + writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + } + if (sourceMapFilePath) { + var sourceMap = sourceMapGenerator.toString(); + ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles); + } } - if (sourceMapFilePath) { - ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), false, sourceFiles); + else { + writer.writeLine(); } ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); if (bundleInfoPath) { bundleInfo.totalLength = writer.getTextPos(); ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), false); } - mapRecorder.reset(); writer.clear(); bundleInfo = createDefaultBundleInfo(); } - function setSourceFile(node) { - sourceMap.setSourceFile(node); + function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { + return (mapOptions.sourceMap || mapOptions.inlineSourceMap) + && (sourceFileOrBundle.kind !== 279 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); } - function setSourceFileForDeclarationSourceMaps(node) { - declarationSourceMap.setSourceFile(node); + function getSourceRoot(mapOptions) { + var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); + return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot; + } + function getSourceMapDirectory(mapOptions, filePath, sourceFile) { + if (mapOptions.sourceRoot) + return host.getCommonSourceDirectory(); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + } + return sourceMapDir; + } + return ts.getDirectoryPath(ts.normalizePath(filePath)); + } + function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) { + if (mapOptions.inlineSourceMap) { + var sourceMapText = sourceMapGenerator.toString(); + var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); + return "data:application/json;base64," + base64SourceMapText; + } + var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath))); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true); + } + else { + return ts.combinePaths(sourceMapDir, sourceMapFile); + } + } + return sourceMapFile; } } ts.emitFiles = emitFiles; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); - var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var moduleKind = ts.getEmitModuleKind(printerOptions); + var bundledHelpers = ts.createMap(); var currentSourceFile; var nodeIdToGeneratedName; var autoGeneratedIdToGeneratedName; @@ -65600,17 +66123,19 @@ var ts; var writer; var ownWriter; var write = writeBase; - var commitPendingSemicolon = ts.noop; - var writeSemicolon = writeSemicolonInternal; - var pendingSemicolon = false; - if (printerOptions.omitTrailingSemicolon) { - commitPendingSemicolon = commitPendingSemicolonInternal; - writeSemicolon = deferWriteSemicolon; - } - var syntheticParent = { pos: -1, end: -1 }; - var moduleKind = ts.getEmitModuleKind(printerOptions); - var bundledHelpers = ts.createMap(); var isOwnFileEmit; + var sourceMapsDisabled = true; + var sourceMapGenerator; + var sourceMapSource; + var sourceMapSourceIndex = -1; + var containerPos = -1; + var containerEnd = -1; + var declarationListContainerEnd = -1; + var currentLineMap; + var detachedCommentsInfo; + var hasWrittenComment = false; + var commentsDisabled = !!printerOptions.removeComments; + var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { printNode: printNode, @@ -65635,9 +66160,9 @@ var ts; break; } switch (node.kind) { - case 277: return printFile(node); - case 278: return printBundle(node); - case 279: return printUnparsedSource(node); + case 279: return printFile(node); + case 280: return printBundle(node); + case 281: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -65647,11 +66172,11 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, beginPrint()); + writeBundle(bundle, undefined, beginPrint(), undefined); return endPrint(); } function printFile(sourceFile) { - writeFile(sourceFile, beginPrint()); + writeFile(sourceFile, beginPrint(), undefined); return endPrint(); } function printUnparsedSource(unparsed) { @@ -65660,14 +66185,14 @@ var ts; } function writeNode(hint, node, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, undefined); print(hint, node, sourceFile); reset(); writer = previousWriter; } function writeList(format, nodes, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, undefined); if (sourceFile) { setSourceFile(sourceFile); } @@ -65675,18 +66200,18 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, output, bundleInfo) { + function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { isOwnFileEmit = false; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(bundle); emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { var prepend = _b[_a]; - print(4, prepend, undefined); writeLine(); + print(4, prepend, undefined); } if (bundleInfo) { bundleInfo.originalOffset = writer.getTextPos(); @@ -65700,15 +66225,15 @@ var ts; } function writeUnparsedSource(unparsed, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, undefined); print(4, unparsed, undefined); reset(); writer = previousWriter; } - function writeFile(sourceFile, output) { + function writeFile(sourceFile, output, sourceMapGenerator) { isOwnFileEmit = true; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); print(0, sourceFile, sourceFile); @@ -65727,19 +66252,24 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0, hint); + var pipelinePhase = getPipelinePhase(0, node); pipelinePhase(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; - comments.setSourceFile(sourceFile); - if (onSetSourceFile) { - onSetSourceFile(sourceFile); + currentLineMap = undefined; + detachedCommentsInfo = undefined; + if (sourceFile) { + setSourceMapSource(sourceFile); } } - function setWriter(output) { - writer = output; - comments.setWriter(output); + function setWriter(_writer, _sourceMapGenerator) { + if (_writer && printerOptions.omitTrailingSemicolon) { + _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + } + writer = _writer; + sourceMapGenerator = _sourceMapGenerator; + sourceMapsDisabled = !writer || !sourceMapGenerator; } function reset() { nodeIdToGeneratedName = []; @@ -65748,66 +66278,62 @@ var ts; tempFlagsStack = []; tempFlags = 0; reservedNamesStack = []; - comments.reset(); - setWriter(undefined); + currentSourceFile = undefined; + currentLineMap = undefined; + detachedCommentsInfo = undefined; + setWriter(undefined, undefined); + } + function getCurrentLineMap() { + return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } function emit(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0, 4); + var pipelinePhase = getPipelinePhase(0, node); pipelinePhase(4, node); } function emitIdentifierName(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0, 2); + var pipelinePhase = getPipelinePhase(0, node); pipelinePhase(2, node); } function emitExpression(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0, 1); + var pipelinePhase = getPipelinePhase(0, node); pipelinePhase(1, node); } - function getPipelinePhase(phase, hint) { + function getPipelinePhase(phase, node) { switch (phase) { case 0: - if (onEmitNode) { + if (onEmitNode !== ts.noEmitNotification) { return pipelineEmitWithNotification; } case 1: - if (emitNodeWithComments && hint !== 0) { + if (substituteNode !== ts.noEmitSubstitution) { + return pipelineEmitWithSubstitution; + } + case 2: + if (!commentsDisabled && node.kind !== 279) { return pipelineEmitWithComments; } - return pipelineEmitWithoutComments; - case 2: - if (onEmitSourceMapOfNode && hint !== 0) { + case 3: + if (!sourceMapsDisabled && node.kind !== 279 && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } - case 3: + case 4: return pipelineEmitWithHint; default: - return ts.Debug.assertNever(phase, "Unexpected value for PipelinePhase: " + phase); + return ts.Debug.assertNever(phase); } } - function getNextPipelinePhase(currentPhase, hint) { - return getPipelinePhase(currentPhase + 1, hint); + function getNextPipelinePhase(currentPhase, node) { + return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0, hint)); - } - function pipelineEmitWithComments(hint, node) { - ts.Debug.assertDefined(emitNodeWithComments); - ts.Debug.assert(hint !== 0); - emitNodeWithComments(hint, trySubstituteNode(hint, node), getNextPipelinePhase(1, hint)); - } - function pipelineEmitWithoutComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(1, hint); - pipelinePhase(hint, trySubstituteNode(hint, node)); - } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0); - ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); + var pipelinePhase = getNextPipelinePhase(0, node); + onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { if (hint === 0) @@ -65816,236 +66342,267 @@ var ts; return emitIdentifier(ts.cast(node, ts.isIdentifier)); if (hint === 3) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + if (hint === 5) { + ts.Debug.assertNode(node, ts.isEmptyStatement); + return emitEmptyStatement(true); + } if (hint === 4) { if (ts.isKeyword(node.kind)) return writeTokenNode(node, writeKeyword); switch (node.kind) { - case 14: case 15: case 16: + case 17: return emitLiteral(node); - case 279: + case 281: return emitUnparsedSource(node); - case 71: + case 72: return emitIdentifier(node); - case 146: - return emitQualifiedName(node); - case 147: - return emitComputedPropertyName(node); case 148: - return emitTypeParameter(node); + return emitQualifiedName(node); case 149: - return emitParameter(node); + return emitComputedPropertyName(node); case 150: - return emitDecorator(node); + return emitTypeParameter(node); case 151: - return emitPropertySignature(node); + return emitParameter(node); case 152: - return emitPropertyDeclaration(node); + return emitDecorator(node); case 153: - return emitMethodSignature(node); + return emitPropertySignature(node); case 154: - return emitMethodDeclaration(node); + return emitPropertyDeclaration(node); case 155: - return emitConstructor(node); + return emitMethodSignature(node); case 156: + return emitMethodDeclaration(node); case 157: - return emitAccessorDeclaration(node); + return emitConstructor(node); case 158: - return emitCallSignature(node); case 159: - return emitConstructSignature(node); + return emitAccessorDeclaration(node); case 160: - return emitIndexSignature(node); + return emitCallSignature(node); case 161: - return emitTypePredicate(node); + return emitConstructSignature(node); case 162: - return emitTypeReference(node); + return emitIndexSignature(node); case 163: - return emitFunctionType(node); - case 287: - return emitJSDocFunctionType(node); + return emitTypePredicate(node); case 164: - return emitConstructorType(node); + return emitTypeReference(node); case 165: - return emitTypeQuery(node); + return emitFunctionType(node); + case 289: + return emitJSDocFunctionType(node); case 166: - return emitTypeLiteral(node); + return emitConstructorType(node); case 167: - return emitArrayType(node); + return emitTypeQuery(node); case 168: - return emitTupleType(node); + return emitTypeLiteral(node); case 169: - return emitOptionalType(node); - case 171: - return emitUnionType(node); - case 172: - return emitIntersectionType(node); - case 173: - return emitConditionalType(node); - case 174: - return emitInferType(node); - case 175: - return emitParenthesizedType(node); - case 209: - return emitExpressionWithTypeArguments(node); - case 176: - return emitThisType(); - case 177: - return emitTypeOperator(node); - case 178: - return emitIndexedAccessType(node); - case 179: - return emitMappedType(node); - case 180: - return emitLiteralType(node); - case 181: - return emitImportTypeNode(node); - case 282: - write("*"); - return; - case 283: - write("?"); - return; - case 284: - return emitJSDocNullableType(node); - case 285: - return emitJSDocNonNullableType(node); - case 286: - return emitJSDocOptionalType(node); + return emitArrayType(node); case 170: - case 288: - return emitRestOrJSDocVariadicType(node); + return emitTupleType(node); + case 171: + return emitOptionalType(node); + case 173: + return emitUnionType(node); + case 174: + return emitIntersectionType(node); + case 175: + return emitConditionalType(node); + case 176: + return emitInferType(node); + case 177: + return emitParenthesizedType(node); + case 211: + return emitExpressionWithTypeArguments(node); + case 178: + return emitThisType(); + case 179: + return emitTypeOperator(node); + case 180: + return emitIndexedAccessType(node); + case 181: + return emitMappedType(node); case 182: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 183: - return emitArrayBindingPattern(node); - case 184: - return emitBindingElement(node); - case 214: - return emitTemplateSpan(node); - case 215: - return emitSemicolonClassElement(); - case 216: - return emitBlock(node); - case 217: - return emitVariableStatement(node); - case 218: - return emitEmptyStatement(); - case 219: - return emitExpressionStatement(node); - case 220: - return emitIfStatement(node); - case 221: - return emitDoStatement(node); - case 222: - return emitWhileStatement(node); - case 223: - return emitForStatement(node); - case 224: - return emitForInStatement(node); - case 225: - return emitForOfStatement(node); - case 226: - return emitContinueStatement(node); - case 227: - return emitBreakStatement(node); - case 228: - return emitReturnStatement(node); - case 229: - return emitWithStatement(node); - case 230: - return emitSwitchStatement(node); - case 231: - return emitLabeledStatement(node); - case 232: - return emitThrowStatement(node); - case 233: - return emitTryStatement(node); - case 234: - return emitDebuggerStatement(node); - case 235: - return emitVariableDeclaration(node); - case 236: - return emitVariableDeclarationList(node); - case 237: - return emitFunctionDeclaration(node); - case 238: - return emitClassDeclaration(node); - case 239: - return emitInterfaceDeclaration(node); - case 240: - return emitTypeAliasDeclaration(node); - case 241: - return emitEnumDeclaration(node); - case 242: - return emitModuleDeclaration(node); - case 243: - return emitModuleBlock(node); - case 244: - return emitCaseBlock(node); - case 245: - return emitNamespaceExportDeclaration(node); - case 246: - return emitImportEqualsDeclaration(node); - case 247: - return emitImportDeclaration(node); - case 248: - return emitImportClause(node); - case 249: - return emitNamespaceImport(node); - case 250: - return emitNamedImports(node); - case 251: - return emitImportSpecifier(node); - case 252: - return emitExportAssignment(node); - case 253: - return emitExportDeclaration(node); - case 254: - return emitNamedExports(node); - case 255: - return emitExportSpecifier(node); - case 256: + return emitImportTypeNode(node); + case 284: + writePunctuation("*"); return; + case 285: + writePunctuation("?"); + return; + case 286: + return emitJSDocNullableType(node); + case 287: + return emitJSDocNonNullableType(node); + case 288: + return emitJSDocOptionalType(node); + case 172: + case 290: + return emitRestOrJSDocVariadicType(node); + case 184: + return emitObjectBindingPattern(node); + case 185: + return emitArrayBindingPattern(node); + case 186: + return emitBindingElement(node); + case 216: + return emitTemplateSpan(node); + case 217: + return emitSemicolonClassElement(); + case 218: + return emitBlock(node); + case 219: + return emitVariableStatement(node); + case 220: + return emitEmptyStatement(false); + case 221: + return emitExpressionStatement(node); + case 222: + return emitIfStatement(node); + case 223: + return emitDoStatement(node); + case 224: + return emitWhileStatement(node); + case 225: + return emitForStatement(node); + case 226: + return emitForInStatement(node); + case 227: + return emitForOfStatement(node); + case 228: + return emitContinueStatement(node); + case 229: + return emitBreakStatement(node); + case 230: + return emitReturnStatement(node); + case 231: + return emitWithStatement(node); + case 232: + return emitSwitchStatement(node); + case 233: + return emitLabeledStatement(node); + case 234: + return emitThrowStatement(node); + case 235: + return emitTryStatement(node); + case 236: + return emitDebuggerStatement(node); + case 237: + return emitVariableDeclaration(node); + case 238: + return emitVariableDeclarationList(node); + case 239: + return emitFunctionDeclaration(node); + case 240: + return emitClassDeclaration(node); + case 241: + return emitInterfaceDeclaration(node); + case 242: + return emitTypeAliasDeclaration(node); + case 243: + return emitEnumDeclaration(node); + case 244: + return emitModuleDeclaration(node); + case 245: + return emitModuleBlock(node); + case 246: + return emitCaseBlock(node); + case 247: + return emitNamespaceExportDeclaration(node); + case 248: + return emitImportEqualsDeclaration(node); + case 249: + return emitImportDeclaration(node); + case 250: + return emitImportClause(node); + case 251: + return emitNamespaceImport(node); + case 252: + return emitNamedImports(node); + case 253: + return emitImportSpecifier(node); + case 254: + return emitExportAssignment(node); + case 255: + return emitExportDeclaration(node); + case 256: + return emitNamedExports(node); case 257: + return emitExportSpecifier(node); + case 258: + return; + case 259: return emitExternalModuleReference(node); - case 10: + case 11: return emitJsxText(node); - case 260: - case 263: - return emitJsxOpeningElementOrFragment(node); - case 261: - case 264: - return emitJsxClosingElementOrFragment(node); + case 262: case 265: - return emitJsxAttribute(node); + return emitJsxOpeningElementOrFragment(node); + case 263: case 266: - return emitJsxAttributes(node); + return emitJsxClosingElementOrFragment(node); case 267: - return emitJsxSpreadAttribute(node); + return emitJsxAttribute(node); case 268: - return emitJsxExpression(node); + return emitJsxAttributes(node); case 269: - return emitCaseClause(node); + return emitJsxSpreadAttribute(node); case 270: - return emitDefaultClause(node); + return emitJsxExpression(node); case 271: - return emitHeritageClause(node); + return emitCaseClause(node); case 272: - return emitCatchClause(node); + return emitDefaultClause(node); case 273: - return emitPropertyAssignment(node); + return emitHeritageClause(node); case 274: - return emitShorthandPropertyAssignment(node); + return emitCatchClause(node); case 275: - return emitSpreadAssignment(node); + return emitPropertyAssignment(node); case 276: + return emitShorthandPropertyAssignment(node); + case 277: + return emitSpreadAssignment(node); + case 278: return emitEnumMember(node); + case 299: + case 305: + return emitJSDocPropertyLikeTag(node); + case 300: + case 302: + case 301: + case 298: + return emitJSDocSimpleTypedTag(node); + case 295: + return emitJSDocAugmentsTag(node); + case 303: + return emitJSDocTemplateTag(node); + case 304: + return emitJSDocTypedefTag(node); + case 297: + return emitJSDocCallbackTag(node); + case 293: + return emitJSDocSignature(node); + case 292: + return emitJSDocTypeLiteral(node); + case 296: + case 294: + return emitJSDocSimpleTag(node); + case 291: + return emitJSDoc(node); } if (ts.isExpression(node)) { hint = 1; - node = trySubstituteNode(1, node); + if (substituteNode !== ts.noEmitSubstitution) { + node = substituteNode(hint, node); + } } else if (ts.isToken(node)) { return writeTokenNode(node, writePunctuation); @@ -66054,84 +66611,85 @@ var ts; if (hint === 1) { switch (node.kind) { case 8: - return emitNumericLiteral(node); case 9: - case 12: + return emitNumericOrBigIntLiteral(node); + case 10: case 13: + case 14: return emitLiteral(node); - case 71: + case 72: return emitIdentifier(node); - case 86: - case 95: - case 97: - case 101: - case 99: - case 91: + case 87: + case 96: + case 98: + case 102: + case 100: + case 92: writeTokenNode(node, writeKeyword); return; - case 185: - return emitArrayLiteralExpression(node); - case 186: - return emitObjectLiteralExpression(node); case 187: - return emitPropertyAccessExpression(node); + return emitArrayLiteralExpression(node); case 188: - return emitElementAccessExpression(node); + return emitObjectLiteralExpression(node); case 189: - return emitCallExpression(node); + return emitPropertyAccessExpression(node); case 190: - return emitNewExpression(node); + return emitElementAccessExpression(node); case 191: - return emitTaggedTemplateExpression(node); + return emitCallExpression(node); case 192: - return emitTypeAssertionExpression(node); + return emitNewExpression(node); case 193: - return emitParenthesizedExpression(node); + return emitTaggedTemplateExpression(node); case 194: - return emitFunctionExpression(node); + return emitTypeAssertionExpression(node); case 195: - return emitArrowFunction(node); + return emitParenthesizedExpression(node); case 196: - return emitDeleteExpression(node); + return emitFunctionExpression(node); case 197: - return emitTypeOfExpression(node); + return emitArrowFunction(node); case 198: - return emitVoidExpression(node); + return emitDeleteExpression(node); case 199: - return emitAwaitExpression(node); + return emitTypeOfExpression(node); case 200: - return emitPrefixUnaryExpression(node); + return emitVoidExpression(node); case 201: - return emitPostfixUnaryExpression(node); + return emitAwaitExpression(node); case 202: - return emitBinaryExpression(node); + return emitPrefixUnaryExpression(node); case 203: - return emitConditionalExpression(node); + return emitPostfixUnaryExpression(node); case 204: - return emitTemplateExpression(node); + return emitBinaryExpression(node); case 205: - return emitYieldExpression(node); + return emitConditionalExpression(node); case 206: - return emitSpreadExpression(node); + return emitTemplateExpression(node); case 207: - return emitClassExpression(node); + return emitYieldExpression(node); case 208: - return; + return emitSpreadExpression(node); + case 209: + return emitClassExpression(node); case 210: - return emitAsExpression(node); - case 211: - return emitNonNullExpression(node); + return; case 212: + return emitAsExpression(node); + case 213: + return emitNonNullExpression(node); + case 214: return emitMetaProperty(node); - case 258: + case 260: return emitJsxElement(node); - case 259: + case 261: return emitJsxSelfClosingElement(node); - case 262: + case 264: return emitJsxFragment(node); - case 306: + case 308: return emitPartiallyEmittedExpression(node); - case 307: + case 309: return emitCommaList(node); } } @@ -66143,12 +66701,13 @@ var ts; writeSpace(); emit(node.constraint); } - function trySubstituteNode(hint, node) { - return node && substituteNode && substituteNode(hint, node) || node; + function pipelineEmitWithSubstitution(hint, node) { + var pipelinePhase = getNextPipelinePhase(1, node); + pipelinePhase(hint, substituteNode(hint, node)); } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 278 ? node : undefined; + var bundle = node.kind === 280 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -66187,13 +66746,13 @@ var ts; } return helpersEmitted; } - function emitNumericLiteral(node) { + function emitNumericOrBigIntLiteral(node) { emitLiteral(node); } function emitLiteral(node) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -66206,7 +66765,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, false), node.symbol); - emitList(node, node.typeArguments, 26896); + emitList(node, node.typeArguments, 53776); } function emitQualifiedName(node) { emitEntityName(node.left); @@ -66214,7 +66773,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 71) { + if (node.kind === 72) { emitExpression(node); } else { @@ -66247,7 +66806,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 287 && !node.name) { + if (node.parent && node.parent.kind === 289 && !node.name) { emit(node.type); } else { @@ -66265,7 +66824,7 @@ var ts; emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitPropertyDeclaration(node) { emitDecorators(node, node.decorators); @@ -66275,7 +66834,7 @@ var ts; emit(node.exclamationToken); emitTypeAnnotation(node.type); emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node); - writeSemicolon(); + writeTrailingSemicolon(); } function emitMethodSignature(node) { pushNameGenerationScope(node); @@ -66286,7 +66845,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitMethodDeclaration(node) { @@ -66305,7 +66864,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 156 ? "get" : "set"); + writeKeyword(node.kind === 158 ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -66317,7 +66876,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitConstructSignature(node) { @@ -66329,7 +66888,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitIndexSignature(node) { @@ -66337,10 +66896,10 @@ var ts; emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitSemicolonClassElement() { - writeSemicolon(); + writeTrailingSemicolon(); } function emitTypePredicate(node) { emit(node.parameterName); @@ -66364,22 +66923,22 @@ var ts; popNameGenerationScope(node); } function emitJSDocFunctionType(node) { - write("function"); + writeKeyword("function"); emitParameters(node, node.parameters); - write(":"); + writePunctuation(":"); emit(node.type); } function emitJSDocNullableType(node) { - write("?"); + writePunctuation("?"); emit(node.type); } function emitJSDocNonNullableType(node) { - write("!"); + writePunctuation("!"); emit(node.type); } function emitJSDocOptionalType(node) { emit(node.type); - write("="); + writePunctuation("="); } function emitConstructorType(node) { pushNameGenerationScope(node); @@ -66400,8 +66959,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 ? 384 : 16449; - emitList(node, node.members, flags | 262144); + var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897; + emitList(node, node.members, flags | 524288); writePunctuation("}"); } function emitArrayType(node) { @@ -66410,23 +66969,23 @@ var ts; writePunctuation("]"); } function emitRestOrJSDocVariadicType(node) { - write("..."); + writePunctuation("..."); emit(node.type); } function emitTupleType(node) { writePunctuation("["); - emitList(node, node.elementTypes, 272); + emitList(node, node.elementTypes, 528); writePunctuation("]"); } function emitOptionalType(node) { emit(node.type); - write("?"); + writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 260); + emitList(node, node.types, 516); } function emitIntersectionType(node) { - emitList(node, node.types, 264); + emitList(node, node.types, 520); } function emitConditionalType(node) { emit(node.checkType); @@ -66479,25 +67038,25 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 132) { + if (node.readonlyToken.kind !== 133) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0, 3); + var pipelinePhase = getPipelinePhase(0, node.typeParameter); pipelinePhase(3, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 55) { + if (node.questionToken.kind !== 56) { writePunctuation("?"); } } writePunctuation(":"); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); if (emitFlags & 1) { writeSpace(); } @@ -66527,12 +67086,12 @@ var ts; } function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 262576); + emitList(node, node.elements, 525136); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 262448); + emitList(node, node.elements, 524880); writePunctuation("]"); } function emitBindingElement(node) { @@ -66547,8 +67106,8 @@ var ts; } function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 32768 : 0; - emitExpressionList(node, elements, 4466 | preferNewLine); + var preferNewLine = node.multiLine ? 65536 : 0; + emitExpressionList(node, elements, 8914 | preferNewLine); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -66556,9 +67115,9 @@ var ts; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 32 : 0; - emitList(node, node.properties, 263122 | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0; + emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } @@ -66569,20 +67128,20 @@ var ts; if (!(ts.getEmitFlags(node) & 131072)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = ts.createToken(23); + var dotToken = ts.createToken(24); dotToken.pos = dotRangeStart; dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } emitExpression(node.expression); - increaseIndentIf(indentBeforeDot); + increaseIndentIf(indentBeforeDot, false); var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(23, node.expression.end, writePunctuation, node); - increaseIndentIf(indentAfterDot); + emitTokenWithComment(24, node.expression.end, writePunctuation, node); + increaseIndentIf(indentAfterDot, false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } @@ -66591,7 +67150,7 @@ var ts; if (ts.isNumericLiteral(expression)) { var text = getLiteralTextOfNode(expression, true); return !expression.numericLiteralFlags - && !ts.stringContains(text, ts.tokenToString(23)); + && !ts.stringContains(text, ts.tokenToString(24)); } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -66602,21 +67161,21 @@ var ts; } function emitElementAccessExpression(node) { emitExpression(node.expression); - emitTokenWithComment(21, node.expression.end, writePunctuation, node); + emitTokenWithComment(22, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(22, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 1296); + emitExpressionList(node, node.arguments, 2576); } function emitNewExpression(node) { - emitTokenWithComment(94, node.pos, writeKeyword, node); + emitTokenWithComment(95, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 9488); + emitExpressionList(node, node.arguments, 18960); } function emitTaggedTemplateExpression(node) { emitExpression(node.tag); @@ -66631,9 +67190,9 @@ var ts; emitExpression(node.expression); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(19, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -66652,22 +67211,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(80, node.pos, writeKeyword, node); + emitTokenWithComment(81, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(103, node.pos, writeKeyword, node); + emitTokenWithComment(104, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(105, node.pos, writeKeyword, node); + emitTokenWithComment(106, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(121, node.pos, writeKeyword, node); + emitTokenWithComment(122, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -66680,24 +67239,24 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 200 - && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) - || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); + return operand.kind === 202 + && ((node.operator === 38 && (operand.operator === 38 || operand.operator === 44)) + || (node.operator === 39 && (operand.operator === 39 || operand.operator === 45))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator, writeOperator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 26; + var isCommaOperator = node.operatorToken.kind !== 27; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); - increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 93 ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, true); - increaseIndentIf(indentAfterOperator, " "); + increaseIndentIf(indentAfterOperator, true); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); } @@ -66707,23 +67266,23 @@ var ts; var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken); var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); - increaseIndentIf(indentBeforeQuestion, " "); + increaseIndentIf(indentBeforeQuestion, true); emit(node.questionToken); - increaseIndentIf(indentAfterQuestion, " "); + increaseIndentIf(indentAfterQuestion, true); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); - increaseIndentIf(indentBeforeColon, " "); + increaseIndentIf(indentBeforeColon, true); emit(node.colonToken); - increaseIndentIf(indentAfterColon, " "); + increaseIndentIf(indentAfterColon, true); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 131072); + emitList(node, node.templateSpans, 262144); } function emitYieldExpression(node) { - emitTokenWithComment(116, node.pos, writeKeyword, node); + emitTokenWithComment(117, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -66765,36 +67324,41 @@ var ts; emitBlockStatements(node, !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(17, node.pos, writePunctuation, node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 384 : 65; + emitTokenWithComment(18, node.pos, writePunctuation, node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129; emitList(node, node.statements, format); - emitTokenWithComment(18, node.statements.end, writePunctuation, node, !!(format & 1)); + emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); emit(node.declarationList); - writeSemicolon(); + writeTrailingSemicolon(); } - function emitEmptyStatement() { - writeSemicolon(); + function emitEmptyStatement(isEmbeddedStatement) { + if (isEmbeddedStatement) { + writePunctuation(";"); + } + else { + writeTrailingSemicolon(); + } } function emitExpressionStatement(node) { emitExpression(node.expression); if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { - writeSemicolon(); + writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(90, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(91, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19, openParenPos, writePunctuation, node); + emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20, node.expression.end, writePunctuation, node); + emitTokenWithComment(21, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(82, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 220) { + emitTokenWithComment(83, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 222) { writeSpace(); emit(node.elseStatement); } @@ -66804,14 +67368,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(106, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19, openParenPos, writePunctuation, node); + emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20, node.expression.end, writePunctuation, node); + emitTokenWithComment(21, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(81, node.pos, writeKeyword, node); + emitTokenWithComment(82, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -66827,45 +67391,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(88, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(19, openParenPos, writePunctuation, node); + var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); - pos = emitTokenWithComment(25, node.initializer ? node.initializer.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(25, node.condition ? node.condition.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(20, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(88, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19, openParenPos, writePunctuation, node); + emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(92, node.initializer.end, writeKeyword, node); + emitTokenWithComment(93, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20, node.expression.end, writePunctuation, node); + emitTokenWithComment(21, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(88, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(19, openParenPos, writePunctuation, node); + emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(145, node.initializer.end, writeKeyword, node); + emitTokenWithComment(147, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20, node.expression.end, writePunctuation, node); + emitTokenWithComment(21, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 236) { + if (node.kind === 238) { emit(node); } else { @@ -66874,14 +67438,14 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(77, node.pos, writeKeyword, node); + emitTokenWithComment(78, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(72, node.pos, writeKeyword, node); + emitTokenWithComment(73, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) { var node = ts.getParseTreeNode(contextNode); @@ -66907,40 +67471,40 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(96, node.pos, writeKeyword, node); + emitTokenWithComment(97, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(107, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(108, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19, openParenPos, writePunctuation, node); + emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20, node.expression.end, writePunctuation, node); + emitTokenWithComment(21, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(98, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19, openParenPos, writePunctuation, node); + emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20, node.expression.end, writePunctuation, node); + emitTokenWithComment(21, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(56, node.label.end, writePunctuation, node); + emitTokenWithComment(57, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(100, node.pos, writeKeyword, node); + emitTokenWithComment(101, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(102, node.pos, writeKeyword, node); + emitTokenWithComment(103, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -66949,14 +67513,14 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(87, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(88, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(78, node.pos, writeKeyword); - writeSemicolon(); + writeToken(79, node.pos, writeKeyword); + writeTrailingSemicolon(); } function emitVariableDeclaration(node) { emit(node.name); @@ -66966,7 +67530,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 272); + emitList(node, node.declarations, 528); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -67014,7 +67578,7 @@ var ts; } else { emitSignatureHead(node); - writeSemicolon(); + writeTrailingSemicolon(); } } function emitSignatureHead(node) { @@ -67060,7 +67624,7 @@ var ts; emitBlockFunctionBody(body); } decreaseIndent(); - writeToken(18, body.statements.end, writePunctuation, body); + writeToken(19, body.statements.end, writePunctuation, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -67071,7 +67635,7 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 384); + emitList(body, body.statements, 768); increaseIndent(); } else { @@ -67098,7 +67662,7 @@ var ts; emitList(node, node.heritageClauses, 0); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65); + emitList(node, node.members, 129); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -67111,10 +67675,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 256); + emitList(node, node.heritageClauses, 512); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65); + emitList(node, node.members, 129); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -67128,7 +67692,7 @@ var ts; writePunctuation("="); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitEnumDeclaration(node) { emitModifiers(node, node.modifiers); @@ -67137,7 +67701,7 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 81); + emitList(node, node.members, 145); writePunctuation("}"); } function emitModuleDeclaration(node) { @@ -67149,8 +67713,8 @@ var ts; emit(node.name); var body = node.body; if (!body) - return writeSemicolon(); - while (body.kind === 242) { + return writeTrailingSemicolon(); + while (body.kind === 244) { writePunctuation("."); emit(body.name); body = body.body; @@ -67165,23 +67729,23 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(17, node.pos, writePunctuation, node); - emitList(node, node.clauses, 65); - emitTokenWithComment(18, node.clauses.end, writePunctuation, node, true); + emitTokenWithComment(18, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129); + emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(58, node.name.end, writePunctuation, node); + emitTokenWithComment(59, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); - writeSemicolon(); + writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 71) { + if (node.kind === 72) { emitExpression(node); } else { @@ -67190,29 +67754,29 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(143, node.importClause.end, writeKeyword, node); + emitTokenWithComment(144, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); - writeSemicolon(); + writeTrailingSemicolon(); } function emitImportClause(node) { emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(26, node.name.end, writePunctuation, node); + emitTokenWithComment(27, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(39, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(40, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(118, asPos, writeKeyword, node); + emitTokenWithComment(119, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -67223,45 +67787,45 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(84, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(58, nextPos, writeOperator, node); + emitTokenWithComment(59, nextPos, writeOperator, node); } else { - emitTokenWithComment(79, nextPos, writeKeyword, node); + emitTokenWithComment(80, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(84, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(39, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(40, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(143, fromPos, writeKeyword, node); + emitTokenWithComment(144, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(84, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(118, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(119, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(130, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(131, nextPos, writeKeyword, node); writeSpace(); emit(node.name); - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamedExports(node) { emitNamedImportsOrExports(node); @@ -67271,14 +67835,14 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 262576); + emitList(node, node.elements, 525136); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(118, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(119, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -67291,7 +67855,7 @@ var ts; } function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 131072); + emitList(node, node.children, 262144); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -67303,7 +67867,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 131072); + emitList(node, node.children, 262144); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -67318,7 +67882,6 @@ var ts; writePunctuation(">"); } function emitJsxText(node) { - commitPendingSemicolon(); writer.writeLiteral(getTextOfNode(node, true)); } function emitJsxClosingElementOrFragment(node) { @@ -67329,7 +67892,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 131328); + emitList(node, node.properties, 262656); } function emitJsxAttribute(node) { emit(node.name); @@ -67349,7 +67912,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 71) { + if (node.kind === 72) { emitExpression(node); } else { @@ -67357,13 +67920,13 @@ var ts; } } function emitCaseClause(node) { - emitTokenWithComment(73, node.pos, writeKeyword, node); + emitTokenWithComment(74, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(79, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(80, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -67371,14 +67934,14 @@ var ts; (ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 81985; + var format = 163969; if (emitAsSingleStatement) { - writeToken(56, colonPos, writePunctuation, parentNode); + writeToken(57, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 | 64); + format &= ~(1 | 128); } else { - emitTokenWithComment(56, colonPos, writePunctuation, parentNode); + emitTokenWithComment(57, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -67386,15 +67949,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 272); + emitList(node, node.types, 528); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(74, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(75, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(19, openParenPos, writePunctuation, node); + emitTokenWithComment(20, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(20, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -67429,6 +67992,139 @@ var ts; emit(node.name); emitInitializer(node.initializer, node.name.end, node); } + function emitJSDoc(node) { + write("/**"); + if (node.comment) { + var lines = node.comment.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } + } + if (node.tags) { + if (node.tags.length === 1 && node.tags[0].kind === 302 && !node.comment) { + writeSpace(); + emit(node.tags[0]); + } + else { + emitList(node, node.tags, 33); + } + } + writeSpace(); + write("*/"); + } + function emitJSDocSimpleTypedTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.typeExpression); + emitJSDocComment(tag.comment); + } + function emitJSDocAugmentsTag(tag) { + emitJSDocTagName(tag.tagName); + writeSpace(); + writePunctuation("{"); + emit(tag.class); + writePunctuation("}"); + emitJSDocComment(tag.comment); + } + function emitJSDocTemplateTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.constraint); + writeSpace(); + emitList(tag, tag.typeParameters, 528); + emitJSDocComment(tag.comment); + } + function emitJSDocTypedefTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.typeExpression) { + if (tag.typeExpression.kind === 283) { + emitJSDocTypeExpression(tag.typeExpression); + } + else { + writeSpace(); + writePunctuation("{"); + write("Object"); + if (tag.typeExpression.isArrayType) { + writePunctuation("["); + writePunctuation("]"); + } + writePunctuation("}"); + } + } + if (tag.fullName) { + writeSpace(); + emit(tag.fullName); + } + emitJSDocComment(tag.comment); + if (tag.typeExpression && tag.typeExpression.kind === 292) { + emitJSDocTypeLiteral(tag.typeExpression); + } + } + function emitJSDocCallbackTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.name) { + writeSpace(); + emit(tag.name); + } + emitJSDocComment(tag.comment); + emitJSDocSignature(tag.typeExpression); + } + function emitJSDocSimpleTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocComment(tag.comment); + } + function emitJSDocTypeLiteral(lit) { + emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33); + } + function emitJSDocSignature(sig) { + if (sig.typeParameters) { + emitList(sig, ts.createNodeArray(sig.typeParameters), 33); + } + if (sig.parameters) { + emitList(sig, ts.createNodeArray(sig.parameters), 33); + } + if (sig.type) { + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + emit(sig.type); + } + } + function emitJSDocPropertyLikeTag(param) { + emitJSDocTagName(param.tagName); + emitJSDocTypeExpression(param.typeExpression); + writeSpace(); + if (param.isBracketed) { + writePunctuation("["); + } + emit(param.name); + if (param.isBracketed) { + writePunctuation("]"); + } + emitJSDocComment(param.comment); + } + function emitJSDocTagName(tagName) { + writePunctuation("@"); + emit(tagName); + } + function emitJSDocComment(comment) { + if (comment) { + writeSpace(); + write(comment); + } + } + function emitJSDocTypeExpression(typeExpression) { + if (typeExpression) { + writeSpace(); + writePunctuation("{"); + emit(typeExpression.type); + writePunctuation("}"); + } + } function emitSourceFile(node) { writeLine(); var statements = node.statements; @@ -67452,38 +68148,38 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - write("/// "); + writeComment("/// "); } else { - write("/// "); + writeComment("/// "); } writeLine(); } } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; - write("/// "); + writeComment("/// "); writeLine(); } - for (var _d = 0, types_16 = types; _d < types_16.length; _d++) { - var directive = types_16[_d]; - write("/// "); + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; + writeComment("/// "); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; - write("/// "); + writeComment("/// "); writeLine(); } } @@ -67501,7 +68197,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 272); + emitExpressionList(node, node.elements, 528); } function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { for (var i = 0; i < statements.length; i++) { @@ -67536,13 +68232,14 @@ var ts; setSourceFile(sourceFile); emitPrologueDirectives(sourceFile.statements, true, seenPrologueDirectives); } + setSourceFile(undefined); } } function emitShebangIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { - write(shebang); + writeComment(shebang); writeLine(); return true; } @@ -67566,7 +68263,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 131328); + emitList(node, modifiers, 262656); writeSpace(); } } @@ -67580,7 +68277,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(58, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(59, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -67617,24 +68314,30 @@ var ts; else { writeLine(); increaseIndent(); - emit(node); + if (ts.isEmptyStatement(node)) { + var pipelinePhase = getPipelinePhase(0, node); + pipelinePhase(5, node); + } + else { + emit(node); + } decreaseIndent(); } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 24577); + emitList(parentNode, decorators, 49153); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 26896); + emitList(parentNode, typeArguments, 53776); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 26896); + emitList(parentNode, typeParameters, 53776); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 1296); + emitList(parentNode, parameters, 2576); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -67655,14 +68358,14 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 1296 & ~1024); + emitList(parentNode, parameters, 2576 & ~2048); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 4432); + emitList(parentNode, parameters, 8848); } function emitList(parentNode, children, format, start, count) { emitNodeList(emit, parentNode, children, format, start, count); @@ -67671,7 +68374,7 @@ var ts; emitNodeList(emitExpression, parentNode, children, format, start, count); } function writeDelimiter(format) { - switch (format & 28) { + switch (format & 60) { case 0: break; case 16: @@ -67681,6 +68384,11 @@ var ts; writeSpace(); writePunctuation("|"); break; + case 32: + writeSpace(); + writePunctuation("*"); + writeSpace(); + break; case 8: writeSpace(); writePunctuation("&"); @@ -67691,11 +68399,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 & 8192) { + if (isUndefined && format & 16384) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 16384) { + if (isEmpty && format & 32768) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -67704,7 +68412,7 @@ var ts; } return; } - if (format & 7680) { + if (format & 15360) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { emitTrailingCommentsOfPosition(children.pos, true); @@ -67717,41 +68425,45 @@ var ts; if (format & 1) { writeLine(); } - else if (format & 128 && !(format & 262144)) { + else if (format & 256 && !(format & 524288)) { writeSpace(); } } else { - var mayEmitInterveningComments = (format & 131072) === 0; + var mayEmitInterveningComments = (format & 262144) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { writeLine(); shouldEmitInterveningComments = false; } - else if (format & 128) { + else if (format & 256) { writeSpace(); } - if (format & 64) { + if (format & 128) { increaseIndent(); } var previousSibling = void 0; var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; - if (previousSibling) { - if (format & 28 && previousSibling.end !== parentNode.end) { + if (format & 32) { + writeLine(); + writeDelimiter(format); + } + else if (previousSibling) { + if (format & 60 && previousSibling.end !== parentNode.end) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { - if ((format & (3 | 64)) === 0) { + if ((format & (3 | 128)) === 0) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 256) { + else if (previousSibling && format & 512) { writeSpace(); } } @@ -67771,100 +68483,81 @@ var ts; } previousSibling = child; } - var hasTrailingComma = (format & 32) && children.hasTrailingComma; + var hasTrailingComma = (format & 64) && children.hasTrailingComma; if (format & 16 && hasTrailingComma) { writePunctuation(","); } - if (previousSibling && format & 28 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) { + if (previousSibling && format & 60 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) { emitLeadingCommentsOfPosition(previousSibling.end); } - if (format & 64) { + if (format & 128) { decreaseIndent(); } if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); } - else if (format & 128) { + else if (format & 256) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 7680) { + if (format & 15360) { if (isEmpty && !isUndefined) { emitLeadingCommentsOfPosition(children.end); } writePunctuation(getClosingBracket(format)); } } - function commitPendingSemicolonInternal() { - if (pendingSemicolon) { - writeSemicolonInternal(); - pendingSemicolon = false; - } - } function writeLiteral(s) { - commitPendingSemicolon(); writer.writeLiteral(s); } function writeStringLiteral(s) { - commitPendingSemicolon(); writer.writeStringLiteral(s); } function writeBase(s) { - commitPendingSemicolon(); writer.write(s); } function writeSymbol(s, sym) { - commitPendingSemicolon(); writer.writeSymbol(s, sym); } function writePunctuation(s) { - commitPendingSemicolon(); writer.writePunctuation(s); } - function deferWriteSemicolon() { - pendingSemicolon = true; - } - function writeSemicolonInternal() { - writer.writePunctuation(";"); + function writeTrailingSemicolon() { + writer.writeTrailingSemicolon(";"); } function writeKeyword(s) { - commitPendingSemicolon(); writer.writeKeyword(s); } function writeOperator(s) { - commitPendingSemicolon(); writer.writeOperator(s); } function writeParameter(s) { - commitPendingSemicolon(); writer.writeParameter(s); } + function writeComment(s) { + writer.writeComment(s); + } function writeSpace() { - commitPendingSemicolon(); writer.writeSpace(" "); } function writeProperty(s) { - commitPendingSemicolon(); writer.writeProperty(s); } function writeLine() { - commitPendingSemicolon(); writer.writeLine(); } function increaseIndent() { - commitPendingSemicolon(); writer.increaseIndent(); } function decreaseIndent() { - commitPendingSemicolon(); writer.decreaseIndent(); } function writeToken(token, pos, writer, contextNode) { - return onEmitSourceMapOfToken - ? onEmitSourceMapOfToken(contextNode, token, writer, pos, writeTokenText) + return !sourceMapsDisabled + ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText) : writeTokenText(token, writer, pos); } function writeTokenNode(node, writer) { @@ -67892,23 +68585,23 @@ var ts; function writeLines(text) { var lines = text.split(/\r\n?|\n/g); var indentation = ts.guessIndentation(lines); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var lineText = lines_2[_a]; + for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) { + var lineText = lines_3[_a]; var line = indentation ? lineText.slice(indentation) : lineText; if (line.length) { writeLine(); write(line); - writeLine(); + writer.rawWrite(newLine); } } } - function increaseIndentIf(value, valueToWriteWhenNotIndenting) { + function increaseIndentIf(value, writeSpaceIfNotIndenting) { if (value) { increaseIndent(); writeLine(); } - else if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); + else if (writeSpaceIfNotIndenting) { + writeSpace(); } } function decreaseIndentIf(value1, value2) { @@ -67924,7 +68617,7 @@ var ts; return true; } if (format & 2) { - if (format & 32768) { + if (format & 65536) { return true; } var firstChild = children[0]; @@ -67963,10 +68656,10 @@ var ts; } function shouldWriteClosingLineTerminator(parentNode, children, format) { if (format & 1) { - return (format & 65536) === 0; + return (format & 131072) === 0; } else if (format & 2) { - if (format & 32768) { + if (format & 65536) { return true; } var lastChild = ts.lastOrUndefined(children); @@ -67988,11 +68681,11 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 32768) !== 0; + return (format & 65536) !== 0; } return startsOnNewLine; } - return (format & 32768) !== 0; + return (format & 65536) !== 0; } function needsIndentation(parent, node1, node2) { parent = skipSynthesizedParentheses(parent); @@ -68011,7 +68704,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 193 && ts.nodeIsSynthesized(node)) { + while (node.kind === 195 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -68023,7 +68716,7 @@ var ts; else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { return ts.idText(node); } - else if (node.kind === 9 && node.textSourceNode) { + else if (node.kind === 10 && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { @@ -68032,7 +68725,7 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape) { - if (node.kind === 9 && node.textSourceNode) { + if (node.kind === 10 && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode)) { return neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? @@ -68070,81 +68763,81 @@ var ts; if (!node) return; switch (node.kind) { - case 216: - ts.forEach(node.statements, generateNames); - break; - case 231: - case 229: - case 221: - case 222: - generateNames(node.statement); - break; - case 220: - generateNames(node.thenStatement); - generateNames(node.elseStatement); - break; - case 223: - case 225: - case 224: - generateNames(node.initializer); - generateNames(node.statement); - break; - case 230: - generateNames(node.caseBlock); - break; - case 244: - ts.forEach(node.clauses, generateNames); - break; - case 269: - case 270: + case 218: ts.forEach(node.statements, generateNames); break; case 233: + case 231: + case 223: + case 224: + generateNames(node.statement); + break; + case 222: + generateNames(node.thenStatement); + generateNames(node.elseStatement); + break; + case 225: + case 227: + case 226: + generateNames(node.initializer); + generateNames(node.statement); + break; + case 232: + generateNames(node.caseBlock); + break; + case 246: + ts.forEach(node.clauses, generateNames); + break; + case 271: + case 272: + ts.forEach(node.statements, generateNames); + break; + case 235: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 272: + case 274: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 217: + case 219: generateNames(node.declarationList); break; - case 236: + case 238: ts.forEach(node.declarations, generateNames); break; - case 235: - case 149: - case 184: - case 238: + case 237: + case 151: + case 186: + case 240: generateNameIfNeeded(node.name); break; - case 237: + case 239: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 182: - case 183: + case 184: + case 185: ts.forEach(node.elements, generateNames); break; - case 247: + case 249: generateNames(node.importClause); break; - case 248: + case 250: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 249: + case 251: generateNameIfNeeded(node.name); break; - case 250: + case 252: ts.forEach(node.elements, generateNames); break; - case 251: + case 253: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -68153,12 +68846,12 @@ var ts; if (!node) return; switch (node.kind) { - case 273: - case 274: - case 152: + case 275: + case 276: case 154: case 156: - case 157: + case 158: + case 159: generateNameIfNeeded(node.name); break; } @@ -68290,23 +68983,23 @@ var ts; } function generateNameForNode(node, flags) { switch (node.kind) { - case 71: + case 72: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); - case 242: - case 241: + case 244: + case 243: return generateNameForModuleOrEnum(node); - case 247: - case 253: + case 249: + case 255: return generateNameForImportOrExportDeclaration(node); - case 237: - case 238: - case 252: + case 239: + case 240: + case 254: return generateNameForExportDefault(); - case 207: + case 209: return generateNameForClassExpression(); - case 154: case 156: - case 157: + case 158: + case 159: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); @@ -68338,21 +69031,343 @@ var ts; } return node; } + function pipelineEmitWithComments(hint, node) { + enterComment(); + hasWrittenComment = false; + var emitFlags = ts.getEmitFlags(node); + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var isEmittedNode = node.kind !== 307; + var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11; + var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11; + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + if ((pos > 0 || end > 0) && pos !== end) { + if (!skipLeadingComments) { + emitLeadingComments(pos, isEmittedNode); + } + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) { + containerPos = pos; + } + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) { + containerEnd = end; + if (node.kind === 238) { + declarationListContainerEnd = end; + } + } + } + ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); + exitComment(); + var pipelinePhase = getNextPipelinePhase(2, node); + if (emitFlags & 2048) { + commentsDisabled = true; + pipelinePhase(hint, node); + commentsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + enterComment(); + ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); + if ((pos > 0 || end > 0) && pos !== end) { + containerPos = savedContainerPos; + containerEnd = savedContainerEnd; + declarationListContainerEnd = savedDeclarationListContainerEnd; + if (!skipTrailingComments && isEmittedNode) { + emitTrailingComments(end); + } + } + exitComment(); + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { + enterComment(); + var pos = detachedRange.pos, end = detachedRange.end; + var emitFlags = ts.getEmitFlags(node); + var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0; + if (!skipLeadingComments) { + emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); + } + exitComment(); + if (emitFlags & 2048 && !commentsDisabled) { + commentsDisabled = true; + emitCallback(node); + commentsDisabled = false; + } + else { + emitCallback(node); + } + enterComment(); + if (!skipTrailingComments) { + emitLeadingComments(detachedRange.end, true); + if (hasWrittenComment && !writer.isAtStartOfLine()) { + writer.writeLine(); + } + } + exitComment(); + } + function emitLeadingComments(pos, isEmittedNode) { + hasWrittenComment = false; + if (isEmittedNode) { + forEachLeadingCommentToEmit(pos, emitLeadingComment); + } + else if (pos === 0) { + forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); + } + } + function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (isTripleSlashComment(commentPos, commentEnd)) { + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + } + } + function shouldWriteComment(text, pos) { + if (printerOptions.onlyPrintJsDocStyle) { + return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); + } + return true; + } + function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + if (!hasWrittenComment) { + ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); + hasWrittenComment = true; + } + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + else if (kind === 3) { + writer.writeSpace(" "); + } + } + function emitLeadingCommentsOfPosition(pos) { + if (commentsDisabled || pos === -1) { + return; + } + emitLeadingComments(pos, true); + } + function emitTrailingComments(pos) { + forEachTrailingCommentToEmit(pos, emitTrailingComment); + } + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + } + function emitTrailingCommentsOfPosition(pos, prefixSpace) { + if (commentsDisabled) { + return; + } + enterComment(); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); + exitComment(); + } + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function forEachLeadingCommentToEmit(pos, cb) { + if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) { + if (hasDetachedComments(pos)) { + forEachLeadingCommentWithoutDetachedComments(cb); + } + else { + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos); + } + } + } + function forEachTrailingCommentToEmit(end, cb) { + if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) { + ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; + } + function forEachLeadingCommentWithoutDetachedComments(cb) { + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos); + } + function emitDetachedCommentsAndUpdateCommentsInfo(range) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + emitPos(commentPos); + ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + } + function isTripleSlashComment(commentPos, commentEnd) { + return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + } + function pipelineEmitWithSourceMap(hint, node) { + var pipelinePhase = getNextPipelinePhase(3, node); + if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { + var parsed = ts.tryParseRawSourceMap(node.sourceMapText); + if (parsed) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + } + pipelinePhase(hint, node); + } + else { + var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; + var emitFlags = ts.getEmitFlags(node); + if (node.kind !== 307 + && (emitFlags & 16) === 0 + && pos >= 0) { + emitSourcePos(source, skipSourceTrivia(source, pos)); + } + if (emitFlags & 64) { + sourceMapsDisabled = true; + pipelinePhase(hint, node); + sourceMapsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + if (node.kind !== 307 + && (emitFlags & 32) === 0 + && end >= 0) { + emitSourcePos(source, end); + } + } + } + function skipSourceTrivia(source, pos) { + return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(sourceMapSource.text, pos); + } + function emitPos(pos) { + if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) { + return; + } + var _a = ts.getLineAndCharacterOfPosition(currentSourceFile, pos), sourceLine = _a.line, sourceCharacter = _a.character; + sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined); + } + function emitSourcePos(source, pos) { + if (source !== sourceMapSource) { + var savedSourceMapSource = sourceMapSource; + setSourceMapSource(source); + emitPos(pos); + setSourceMapSource(savedSourceMapSource); + } + else { + emitPos(pos); + } + } + function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { + if (sourceMapsDisabled || node && ts.isInJsonFile(node)) { + return emitCallback(token, writer, tokenPos); + } + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags || 0; + var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; + var source = range && range.source || sourceMapSource; + tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); + if ((emitFlags & 128) === 0 && tokenPos >= 0) { + emitSourcePos(source, tokenPos); + } + tokenPos = emitCallback(token, writer, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 256) === 0 && tokenPos >= 0) { + emitSourcePos(source, tokenPos); + } + return tokenPos; + } + function setSourceMapSource(source) { + if (sourceMapsDisabled) { + return; + } + sourceMapSource = source; + if (isJsonSourceMapSource(source)) { + return; + } + sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName); + if (printerOptions.inlineSources) { + sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text); + } + } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json"); + } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; + brackets[1024] = ["{", "}"]; + brackets[2048] = ["(", ")"]; + brackets[4096] = ["<", ">"]; + brackets[8192] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 7680][0]; + return brackets[format & 15360][0]; } function getClosingBracket(format) { - return brackets[format & 7680][1]; + return brackets[format & 15360][1]; } })(ts || (ts = {})); var ts; @@ -68984,7 +69999,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function loadWithLocalCache(names, containingFile, loader) { + function loadWithLocalCache(names, containingFile, redirectedReference, loader) { if (names.length === 0) { return []; } @@ -68997,7 +70012,7 @@ var ts; result = cache.get(name); } else { - cache.set(name, result = loader(name, containingFile)); + cache.set(name, result = loader(name, containingFile, redirectedReference)); } resolutions.push(result); } @@ -69010,6 +70025,7 @@ var ts; if (program.getRootFileNames().length !== rootFileNames.length) { return false; } + var seenResolvedRefs; if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { return false; } @@ -69029,7 +70045,7 @@ var ts; return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || - hasInvalidatedResolution(sourceFile.resolvedPath); + hasInvalidatedResolution(sourceFile.path); } function sourceFileVersionUptoDate(sourceFile) { return sourceFile.version === getSourceVersion(sourceFile.resolvedPath); @@ -69038,9 +70054,20 @@ var ts; if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { return false; } - var oldResolvedRef = program.getResolvedProjectReferences()[index]; + return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + } + function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - return sourceFileVersionUptoDate(oldResolvedRef.sourceFile); + if (ts.contains(seenResolvedRefs, oldResolvedRef)) { + return true; + } + if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + return false; + } + (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); + return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) { + return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]); + }); } return !fileExists(resolveProjectReferencePath(oldRef)); } @@ -69080,7 +70107,7 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; - var modifiedFilePaths; + var ambientModuleNameToUnmodifiedFileName = ts.createMap(); var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -69101,12 +70128,11 @@ var ts; var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); var hasEmitBlockingDiagnostics = ts.createMap(); var _compilerOptionsObjectLiteralSyntax; - var _referencesArrayLiteralSyntax; var moduleResolutionCache; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { if (!resolved || resolved.extension !== undefined) { return resolved; } @@ -69117,16 +70143,16 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; - resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; + var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; + resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; + resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } var packageIdToSourceFile = ts.createMap(); var sourceFileToPackageName = ts.createMap(); @@ -69134,7 +70160,7 @@ var ts; var filesByName = ts.createMap(); var missingFilePaths; var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; - var resolvedProjectReferences = projectReferences ? [] : undefined; + var resolvedProjectReferences; var projectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -69142,22 +70168,24 @@ var ts; processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { - for (var _i = 0, projectReferences_1 = projectReferences; _i < projectReferences_1.length; _i++) { - var ref = projectReferences_1[_i]; - var parsedRef = parseProjectReferenceConfigFile(ref); - resolvedProjectReferences.push(parsedRef); - if (parsedRef) { - var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - var dtsOutfile = ts.changeExtension(out, ".d.ts"); - processSourceFile(dtsOutfile, false, false, undefined); + if (!resolvedProjectReferences) { + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + } + if (rootNames.length) { + for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { + var parsedRef = resolvedProjectReferences_1[_i]; + if (parsedRef) { + var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; + if (out) { + var dtsOutfile = ts.changeExtension(out, ".d.ts"); + processSourceFile(dtsOutfile, false, false, undefined); + } } - addProjectReferenceRedirects(parsedRef.commandLine); } } } ts.forEach(rootNames, function (name) { return processRootFile(name, false, false); }); - var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); @@ -69166,7 +70194,7 @@ var ts; processTypeReferenceDirective(typeReferences[i], resolutions[i]); } } - if (!skipDefaultLib) { + if (rootNames.length && !skipDefaultLib) { var defaultLibraryFileName = getDefaultLibraryFileName(); if (!options.lib && defaultLibraryFileName) { processRootFile(defaultLibraryFileName, true, false); @@ -69187,10 +70215,17 @@ var ts; var oldSourceFiles = oldProgram.getSourceFiles(); for (var _a = 0, oldSourceFiles_1 = oldSourceFiles; _a < oldSourceFiles_1.length; _a++) { var oldSourceFile = oldSourceFiles_1[_a]; - if (!getSourceFile(oldSourceFile.path) || shouldCreateNewSourceFile) { - host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions()); + var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); + if (shouldCreateNewSourceFile || !newFile || + (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { + host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false); + } + }); } oldProgram = undefined; program = { @@ -69230,7 +70265,10 @@ var ts; getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, getProjectReferences: getProjectReferences, getResolvedProjectReferences: getResolvedProjectReferences, - getProjectReferenceRedirect: getProjectReferenceRedirect + getProjectReferenceRedirect: getProjectReferenceRedirect, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, + forEachResolvedProjectReference: forEachResolvedProjectReference }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -69287,11 +70325,11 @@ var ts; } return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) { if (structuralIsReused === 0 && !file.ambientModuleNames.length) { - return resolveModuleNamesWorker(moduleNames, containingFile); + return resolveModuleNamesWorker(moduleNames, containingFile, undefined, getResolvedProjectReferenceToRedirect(file.originalFileName)); } - var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile); + var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); if (oldSourceFile !== file && file.resolvedModules) { var result_5 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { @@ -69326,7 +70364,7 @@ var ts; } } else { - resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName); } if (resolvesToAmbientModuleInNonModifiedFile) { (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; @@ -69336,7 +70374,7 @@ var ts; } } var resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames) + ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName)) : ts.emptyArray; if (!result) { ts.Debug.assert(resolutions.length === moduleNames.length); @@ -69356,25 +70394,37 @@ var ts; } ts.Debug.assert(j === resolutions.length); return result; - function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - if (!oldProgramState.program) { - return false; - } - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); - var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) { + var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName); + var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { return false; } - var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); }); - if (!firstUnmodifiedFile) { + var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName); + if (!unmodifiedFile) { return false; } if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile); } return true; } } + function canReuseProjectReferences() { + return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) { + var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var newResolvedRef = parseProjectReferenceConfigFile(newRef); + if (oldResolvedRef) { + return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + } + else { + return newResolvedRef !== undefined; + } + }, function (oldProjectReferences, parent) { + var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences; + return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo); + }); + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return 0; @@ -69391,33 +70441,13 @@ var ts; if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { return oldProgram.structureIsReused = 0; } - var oldProjectReferences = oldProgram.getProjectReferences(); - if (!ts.arrayIsEqualTo(oldProjectReferences, projectReferences, ts.projectReferenceIsEqualTo)) { + if (!canReuseProjectReferences()) { return oldProgram.structureIsReused = 0; } - var oldRefs = oldProgram.getResolvedProjectReferences(); if (projectReferences) { - ts.Debug.assert(!!oldRefs); - for (var i = 0; i < projectReferences.length; i++) { - var oldRef = oldRefs[i]; - var newRef = parseProjectReferenceConfigFile(projectReferences[i]); - if (oldRef) { - if (!newRef || newRef.sourceFile !== oldRef.sourceFile) { - return oldProgram.structureIsReused = 0; - } - } - else { - if (newRef !== undefined) { - return oldProgram.structureIsReused = 0; - } - } - } - } - else { - ts.Debug.assert(!oldRefs); + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } var newSourceFiles = []; - var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2; if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { @@ -69455,7 +70485,6 @@ var ts; newSourceFile.originalFileName = oldSourceFile.originalFileName; newSourceFile.resolvedPath = oldSourceFile.resolvedPath; newSourceFile.fileName = oldSourceFile.fileName; - filePaths.push(newSourceFile.path); var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path); if (packageName !== undefined) { var prevKind = seenPackageNames.get(packageName); @@ -69499,14 +70528,22 @@ var ts; if (oldProgram.structureIsReused !== 2) { return oldProgram.structureIsReused; } - modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); - for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { - var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; + var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); + for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) { + var oldFile = oldSourceFiles_3[_a]; + if (!ts.contains(modifiedFiles, oldFile)) { + for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) { + var moduleName = _c[_b]; + ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); + } + } + } + for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { + var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = getModuleNames(newSourceFile); - var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { oldProgram.structureIsReused = 1; @@ -69518,7 +70555,7 @@ var ts; } if (resolveTypeReferenceDirectiveNamesWorker) { var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); if (resolutionsChanged) { oldProgram.structureIsReused = 1; @@ -69536,27 +70573,21 @@ var ts; return oldProgram.structureIsReused = 1; } missingFilePaths = oldProgram.getMissingFilePaths(); - for (var i = 0; i < newSourceFiles.length; i++) { - filesByName.set(filePaths[i], newSourceFiles[i]); - if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) { - sourceFilesFoundSearchingNodeModules.set(filePaths[i], true); + for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { + var newSourceFile = newSourceFiles_1[_f]; + var filePath = newSourceFile.path; + addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePath))) { + sourceFilesFoundSearchingNodeModules.set(filePath, true); } } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) { - var modifiedFile = modifiedSourceFiles_2[_c]; + for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) { + var modifiedFile = modifiedSourceFiles_2[_g]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - resolvedProjectReferences = oldProgram.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - resolvedProjectReferences.forEach(function (ref) { - if (ref) { - addProjectReferenceRedirects(ref.commandLine); - } - }); - } sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; return oldProgram.structureIsReused = 2; @@ -69782,62 +70813,62 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 149: - case 152: + case 151: + case 154: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 154: - case 153: - case 155: case 156: + case 155: case 157: - case 194: + case 158: + case 159: + case 196: + case 239: + case 197: case 237: - case 195: - case 235: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 246: + case 248: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 252: + case 254: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 271: + case 273: var heritageClause = node; - if (heritageClause.token === 108) { + if (heritageClause.token === 109) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 239: + case 241: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 242: + case 244: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 240: + case 242: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 241: + case 243: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 211: + case 213: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 210: + case 212: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 192: + case 194: ts.Debug.fail(); } var prevParent = parent; @@ -69850,46 +70881,46 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 238: - case 154: - case 153: - case 155: + case 240: case 156: + case 155: case 157: - case 194: - case 237: - case 195: + case 158: + case 159: + case 196: + case 239: + case 197: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 217: + case 219: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 217); + return checkModifiers(nodes, parent.kind === 219); } break; - case 152: + case 154: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 115) { + if (modifier.kind !== 116) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 149: + case 151: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 189: - case 190: - case 209: - case 259: - case 260: + case 191: + case 192: + case 211: + case 261: + case 262: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -69905,21 +70936,21 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 76: + case 77: if (isConstValid) { continue; } - case 114: - case 112: + case 115: case 113: - case 132: - case 124: - case 117: + case 114: + case 133: + case 125: + case 118: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; - case 115: - case 84: - case 79: + case 116: + case 85: + case 80: } } } @@ -69964,10 +70995,22 @@ var ts; return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } function getOptionsDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), options.configFile ? programDiagnostics.getDiagnostics(options.configFile.fileName) : []))); + return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile()))); + } + function getOptionsDiagnosticsOfConfigFile() { + if (!options.configFile) { + return ts.emptyArray; + } + var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); + } + }); + return diagnostics; } function getGlobalDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); + return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray; } function getConfigFileParsingDiagnostics() { return configFileParsingDiagnostics || ts.emptyArray; @@ -69979,9 +71022,9 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 71 - ? b.kind === 71 && a.escapedText === b.escapedText - : b.kind === 9 && a.text === b.text; + return a.kind === 72 + ? b.kind === 72 && a.escapedText === b.escapedText + : b.kind === 10 && a.text === b.text; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -70005,12 +71048,9 @@ var ts; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; collectModuleReferences(node, false); - if ((file.flags & 524288) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(node); - } } if ((file.flags & 524288) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(file.endOfFileToken); + collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; file.moduleAugmentations = moduleAugmentations || ts.emptyArray; @@ -70044,23 +71084,35 @@ var ts; } } } - function collectDynamicImportOrRequireCalls(node) { - if (ts.isRequireCall(node, true)) { - imports = ts.append(imports, node.arguments[0]); - } - else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { - imports = ts.append(imports, node.arguments[0]); - } - else if (ts.isLiteralImportTypeNode(node)) { - imports = ts.append(imports, node.argument.literal); - } - collectDynamicImportOrRequireCallsForEachChild(node); - if (ts.hasJSDocNodes(node)) { - ts.forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild); + function collectDynamicImportOrRequireCalls(file) { + var r = /import|require/g; + while (r.exec(file.text) !== null) { + var node = getNodeAtPosition(file, r.lastIndex); + if (ts.isRequireCall(node, true)) { + imports = ts.append(imports, node.arguments[0]); + } + else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { + imports = ts.append(imports, node.arguments[0]); + } + else if (ts.isLiteralImportTypeNode(node)) { + imports = ts.append(imports, node.argument.literal); + } } } - function collectDynamicImportOrRequireCallsForEachChild(node) { - ts.forEachChild(node, collectDynamicImportOrRequireCalls); + function getNodeAtPosition(sourceFile, position) { + var current = sourceFile; + var getContainingChild = function (child) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) { + return child; + } + }; + while (true) { + var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild); + if (!child) { + return current; + } + current = child; + } } } function getLibFileFromReference(ref) { @@ -70205,7 +71257,7 @@ var ts; if (fileFromPackageId) { var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); redirectTargetsMap.add(fileFromPackageId.path, fileName); - filesByName.set(path, dupFile); + addFileToFilesByName(dupFile, path, redirectedPath); sourceFileToPackageName.set(path, packageId.name); processingOtherFiles.push(dupFile); return dupFile; @@ -70215,10 +71267,7 @@ var ts; sourceFileToPackageName.set(path, packageId.name); } } - filesByName.set(path, file); - if (redirectedPath) { - filesByName.set(redirectedPath, file); - } + addFileToFilesByName(file, path, redirectedPath); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; @@ -70250,20 +71299,73 @@ var ts; } return file; } + function addFileToFilesByName(file, path, redirectedPath) { + filesByName.set(path, file); + if (redirectedPath) { + filesByName.set(redirectedPath, file); + } + } function getProjectReferenceRedirect(fileName) { - if (!projectReferenceRedirects || ts.fileExtensionIs(fileName, ".d.ts") || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { return undefined; } - return ts.forEach(projectReferenceRedirects, function (referencedProject) { - if (!ts.contains(referencedProject.fileNames, fileName, isSameFile)) { + var referencedProject = getResolvedProjectReferenceToRedirect(fileName); + if (!referencedProject) { + return undefined; + } + var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out; + return out ? + ts.changeExtension(out, ".d.ts") : + ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine); + } + function getResolvedProjectReferenceToRedirect(fileName) { + return forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) { + if (!referencedProject || + toPath(options.configFilePath) === referenceProjectPath || + !ts.contains(referencedProject.commandLine.fileNames, fileName, isSameFile)) { return undefined; } - var out = referencedProject.options.outFile || referencedProject.options.out; - return out ? - ts.changeExtension(out, ".d.ts") : - ts.getOutputDeclarationFileName(fileName, referencedProject); + return referencedProject; }); } + function forEachResolvedProjectReference(cb) { + return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var resolvedRefPath = toPath(resolveProjectReferencePath(ref)); + return cb(resolvedRef, resolvedRefPath); + }); + } + function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { + var seenResolvedRefs; + return worker(projectReferences, resolvedProjectReferences, undefined, cbResolvedRef, cbRef); + function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) { + if (cbRef) { + var result = cbRef(projectReferences, parent); + if (result) { + return result; + } + } + return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { + if (ts.contains(seenResolvedRefs, resolvedRef)) { + return undefined; + } + var result = cbResolvedRef(resolvedRef, index, parent); + if (result) { + return result; + } + if (!resolvedRef) + return undefined; + (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef); + return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef); + }); + } + } + function getResolvedProjectReferenceByPath(projectReferencePath) { + if (!projectReferenceRedirects) { + return undefined; + } + return projectReferenceRedirects.get(projectReferencePath) || undefined; + } function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); @@ -70275,7 +71377,7 @@ var ts; if (!typeDirectives) { return; } - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName)); for (var i = 0; i < typeDirectives.length; i++) { var ref = file.typeReferenceDirectives[i]; var resolvedTypeReferenceDirective = resolutions[i]; @@ -70291,6 +71393,8 @@ var ts; } var saveResolution = true; if (resolvedTypeReferenceDirective) { + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } @@ -70308,6 +71412,8 @@ var ts; processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth--; } else { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); @@ -70350,8 +71456,7 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { var moduleNames = getModuleNames(file); - var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file); ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; @@ -70411,18 +71516,32 @@ var ts; return allFilesBelongToPath; } function parseProjectReferenceConfigFile(ref) { + if (!projectReferenceRedirects) { + projectReferenceRedirects = ts.createMap(); + } var refPath = resolveProjectReferencePath(ref); + var sourceFilePath = toPath(refPath); + var fromCache = projectReferenceRedirects.get(sourceFilePath); + if (fromCache !== undefined) { + return fromCache || undefined; + } var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100); + addFileToFilesByName(sourceFile, sourceFilePath, undefined); if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); return undefined; } - sourceFile.path = toPath(refPath); + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; var commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath); - return { commandLine: commandLine, sourceFile: sourceFile }; - } - function addProjectReferenceRedirects(referencedProject) { - (projectReferenceRedirects || (projectReferenceRedirects = [])).push(referencedProject); + var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile }; + projectReferenceRedirects.set(sourceFilePath, resolvedRef); + if (commandLine.projectReferences) { + resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile); + } + return resolvedRef; } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { @@ -70458,30 +71577,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } } - if (projectReferences) { - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i] && resolvedProjectReferences[i].commandLine.options; - if (resolvedRefOpts === undefined) { - createDiagnosticForReference(i, ts.Diagnostics.File_0_does_not_exist, ref.path); - continue; - } - if (!resolvedRefOpts.composite) { - createDiagnosticForReference(i, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); - } - if (ref.prepend) { - var out = resolvedRefOpts.outFile || resolvedRefOpts.out; - if (out) { - if (!host.fileExists(out)) { - createDiagnosticForReference(i, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); - } - } - else { - createDiagnosticForReference(i, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); - } - } - } - } + verifyProjectReferences(); if (options.composite) { var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); if (rootNames.length < sourceFiles.length) { @@ -70558,12 +71654,12 @@ var ts; } var languageVersion = options.target || 0; var outFile = options.outFile || options.out; - var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { if (options.module === ts.ModuleKind.None && languageVersion < 2) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } - var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); @@ -70594,7 +71690,7 @@ var ts; options.sourceRoot || options.mapRoot) { var dir = getCommonSourceDirectory(); - if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { + if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) { createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } @@ -70658,6 +71754,34 @@ var ts; } } } + function verifyProjectReferences() { + forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var parentFile = parent && parent.sourceFile; + if (!resolvedRef) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path); + return; + } + var options = resolvedRef.commandLine.options; + if (!options.composite) { + var inputs = parent ? parent.commandLine.fileNames : rootNames; + if (inputs.length) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); + } + } + if (ref.prepend) { + var out = options.outFile || options.out; + if (out) { + if (!host.fileExists(out)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); + } + } + else { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); + } + } + }); + } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { var needCompilerDiagnostic = true; var pathsSyntax = getOptionPathsSyntax(); @@ -70708,10 +71832,10 @@ var ts; function createOptionValueDiagnostic(option1, message, arg0) { createDiagnosticForOption(false, option1, undefined, message, arg0); } - function createDiagnosticForReference(index, message, arg0, arg1) { - var referencesSyntax = getProjectReferencesSyntax(); + function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) { + var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; }); if (referencesSyntax && referencesSyntax.elements.length > index) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); } else { programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1)); @@ -70725,22 +71849,6 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2)); } } - function getProjectReferencesSyntax() { - if (_referencesArrayLiteralSyntax === undefined) { - _referencesArrayLiteralSyntax = null; - if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); - for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { - var prop = _a[_i]; - if (ts.isArrayLiteralExpression(prop.initializer)) { - _referencesArrayLiteralSyntax = prop.initializer; - break; - } - } - } - } - return _referencesArrayLiteralSyntax; - } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { _compilerOptionsObjectLiteralSyntax = null; @@ -70809,7 +71917,8 @@ var ts; readFile: function (f) { return host.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: function () { return undefined; } + onUnRecoverableConfigFileDiagnostic: function () { return undefined; }, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost; @@ -70852,7 +71961,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 === 9) { + if (aug.kind === 10) { res.push(aug.text); } } @@ -71029,6 +72138,10 @@ var ts; var latestSignature; if (sourceFile.isDeclarationFile) { latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + var references = state.referencedMap ? state.referencedMap.get(sourceFile.path) : undefined; + exportedModulesMapCache.set(sourceFile.path, references || false); + } } else { var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken); @@ -71082,7 +72195,7 @@ var ts; if (compilerOptions.outFile || compilerOptions.out) { return getAllFileNames(state, programOfThisState); } - if (!state.referencedMap || (!ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile))) { + if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) { return getAllFileNames(state, programOfThisState); } var seenMap = ts.createMap(); @@ -71128,6 +72241,13 @@ var ts; } return true; } + function containsGlobalScopeAugmentation(sourceFile) { + return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); }); + } + function isFileAffectingGlobalScope(sourceFile) { + return containsGlobalScopeAugmentation(sourceFile) || + !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + } function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) { if (state.allFilesExcludingDefaultLibraryFile) { return state.allFilesExcludingDefaultLibraryFile; @@ -71156,7 +72276,7 @@ var ts; return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { - if (!ts.isExternalModule(sourceFileWithUpdatedShape) && !containsOnlyAmbientModules(sourceFileWithUpdatedShape)) { + if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } var compilerOptions = programOfThisState.getCompilerOptions(); @@ -71194,8 +72314,9 @@ var ts; } state.changedFilesSet = ts.createMap(); var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); + var oldCompilerOptions = useOldState ? oldState.program.getCompilerOptions() : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && - !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldState.program.getCompilerOptions()); + !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions); if (useOldState) { if (!oldState.currentChangedFilePath) { ts.Debug.assert(!oldState.affectedFiles && (!oldState.currentAffectedFilesSignatures || !oldState.currentAffectedFilesSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated"); @@ -71207,6 +72328,8 @@ var ts; } var referencedMap = state.referencedMap; var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; + var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck; + var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -71218,6 +72341,13 @@ var ts; state.changedFilesSet.set(sourceFilePath, true); } else if (canCopySemanticDiagnostics) { + var sourceFile = state.program.getSourceFileByPath(sourceFilePath); + if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { + return; + } + if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { + return; + } var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath); if (diagnostics) { state.semanticDiagnosticsPerFile.set(sourceFilePath, diagnostics); @@ -71279,31 +72409,64 @@ var ts; if (removeSemanticDiagnosticsOf(state, affectedFile.path)) { return; } + if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles && !state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var options_2 = state.program.getCompilerOptions(); + if (ts.forEach(state.program.getSourceFiles(), function (f) { + return state.program.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2) && + removeSemanticDiagnosticsOf(state, f.path); + })) { + return; + } + } if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { return; } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); + var seenFileAndExportsOfFile = ts.createMap(); if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { return exportedModules && exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); })) { return; } ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); }); } - function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath) { + function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile) { return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) { - return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOf(state, filePath); + return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile); + }); + } + function removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile) { + if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) { + return false; + } + if (removeSemanticDiagnosticsOf(state, filePath)) { + return true; + } + ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); + if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { + return exportedModules && + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); + })) { + return true; + } + return !!ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { + return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); }); } function removeSemanticDiagnosticsOf(state, path) { if (!state.semanticDiagnosticsFromOldState) { - return false; + return true; } state.semanticDiagnosticsFromOldState.delete(path); state.semanticDiagnosticsPerFile.delete(path); @@ -71513,6 +72676,10 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function isPathInNodeModulesStartingWithDot(path) { + return ts.stringContains(path, "/node_modules/."); + } + ts.isPathInNodeModulesStartingWithDot = isPathInNodeModulesStartingWithDot; ts.maxNumberOfFilesToIterateForInvalidation = 256; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; @@ -71523,11 +72690,11 @@ var ts; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); var resolvedModuleNames = ts.createMap(); - var perDirectoryResolvedModuleNames = ts.createMap(); - var nonRelaticeModuleNameCache = ts.createMap(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelaticeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); + var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); + var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); var resolvedTypeReferenceDirectives = ts.createMap(); - var perDirectoryResolvedTypeReferenceDirectives = ts.createMap(); + var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"]; var customFailedLookupPaths = ts.createMap(); var directoryWatchesOfFailedLookups = ts.createMap(); @@ -71542,6 +72709,7 @@ var ts; resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives: resolveTypeReferenceDirectives, + removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects, removeResolutionsOfFile: removeResolutionsOfFile, invalidateResolutionOfFile: invalidateResolutionOfFile, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, @@ -71599,7 +72767,7 @@ var ts; } function clearPerDirectoryResolutions() { perDirectoryResolvedModuleNames.clear(); - nonRelaticeModuleNameCache.clear(); + nonRelativeModuleNameCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); @@ -71615,8 +72783,8 @@ var ts; } }); } - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache); + function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference); if (!resolutionHost.getGlobalCache) { return primaryResult; } @@ -71629,10 +72797,11 @@ var ts; } return primaryResult; } - function resolveNamesWithLocalCache(names, containingFile, cache, perDirectoryCache, loader, getResolutionWithResolvedFileName, reusedNames, logChanges) { + function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) { var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); + var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); var perDirectoryResolution = perDirectoryCache.get(dirPath); if (!perDirectoryResolution) { perDirectoryResolution = ts.createMap(); @@ -71641,20 +72810,25 @@ var ts; var resolvedModules = []; var compilerOptions = resolutionHost.getCompilationSettings(); var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path); + var program = resolutionHost.getCurrentProgram(); + var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile); + var unmatchedRedirects = oldRedirect ? + !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : + !!redirectedReference; var seenNamesInFile = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { var name = names_2[_i]; var resolution = resolutionsInFile.get(name); if (!seenNamesInFile.has(name) && - allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated || - (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && !getResolutionWithResolvedFileName(resolution))) { + allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || + (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; } else { - resolution = loader(name, containingFile, compilerOptions, resolutionHost); + resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -71696,11 +72870,11 @@ var ts; return oldResult.resolvedFileName === newResult.resolvedFileName; } } - function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile) { - return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, undefined, false); + function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) { + return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, undefined, false); } - function resolveModuleNames(moduleNames, containingFile, reusedNames) { - return resolveNamesWithLocalCache(moduleNames, containingFile, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, reusedNames, logChangesWhenResolvingModule); + function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { + return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule); } function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); @@ -71733,12 +72907,6 @@ var ts; } return true; } - function filterFSRootDirectoriesToWatch(watchPath, dirPath) { - if (!canWatchDirectory(dirPath)) { - watchPath.ignore = true; - } - return watchPath; - } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); @@ -71754,12 +72922,12 @@ var ts; return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath)); } function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) { - while (ts.stringContains(dirPath, ts.nodeModulesPathPart)) { + while (ts.pathContainsNodeModules(dirPath)) { dir = ts.getDirectoryPath(dir); dirPath = ts.getDirectoryPath(dirPath); } if (isNodeModulesDirectory(dirPath)) { - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); + return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; var subDirectoryPath, subDirectory; @@ -71776,7 +72944,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive }, dirPath); + return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -71804,8 +72972,9 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, nonRecursive = _a.nonRecursive, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive; if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0; customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1); @@ -71855,8 +73024,9 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dirPath = toWatch.dirPath; var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { if (refCount === 1) { @@ -71901,6 +73071,20 @@ var ts; cache.delete(filePath); } } + function removeResolutionsFromProjectReferenceRedirects(filePath) { + if (!ts.fileExtensionIs(filePath, ".json")) { + return; + } + var program = resolutionHost.getCurrentProgram(); + if (!program) { + return; + } + var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath); + if (!resolvedProjectReference) { + return; + } + resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); + } function removeResolutionsOfFile(filePath) { removeResolutionsOfFileFromCache(resolvedModuleNames, filePath); removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath); @@ -71955,6 +73139,8 @@ var ts; isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); }; } else { + if (isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return false; var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || isNodeModulesDirectory(dirOfFileOrDirectory)) { @@ -71988,8 +73174,8 @@ var ts; if (isInDirectoryPath(rootPath, typeRootPath)) { return rootPath; } - var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; + var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath); + return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) { @@ -72440,6 +73626,23 @@ var ts; return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; + function getErrorCountForSummary(diagnostics) { + return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + ts.getErrorCountForSummary = getErrorCountForSummary; + function getWatchErrorSummaryDiagnosticMessage(errorCount) { + return errorCount === 1 ? + ts.Diagnostics.Found_1_error_Watching_for_file_changes : + ts.Diagnostics.Found_0_errors_Watching_for_file_changes; + } + ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage; + function getErrorSummaryText(errorCount, newLine) { + if (errorCount === 0) + return ""; + var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount); + return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine; + } + ts.getErrorSummaryText = getErrorSummaryText; function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile) { var diagnostics = program.getConfigFileParsingDiagnostics().slice(); var configFileParsingDiagnosticsLength = diagnostics.length; @@ -72471,7 +73674,7 @@ var ts; } } if (reportSummary) { - reportSummary(diagnostics.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length); + reportSummary(getErrorCountForSummary(diagnostics)); } if (emitSkipped && diagnostics.length > 0) { return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; @@ -72544,15 +73747,7 @@ var ts; function emitFilesAndReportErrorUsingBuilder(builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - var reportSummary = function (errorCount) { - if (errorCount === 1) { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_1_error_Watching_for_file_changes, errorCount), newLine, compilerOptions); - } - else { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_0_errors_Watching_for_file_changes, errorCount, errorCount), newLine, compilerOptions); - } - }; - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, reportSummary); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); } } function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) { @@ -72619,7 +73814,8 @@ var ts; fileExists: function (path) { return host.fileExists(path); }, readFile: readFile, getCurrentDirectory: getCurrentDirectory, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; var newLine = updateNewLine(); if (configFileName && host.configFileParsingResult) { @@ -72681,11 +73877,11 @@ var ts; ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory, false); compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }) : - (function (moduleNames, containingFile, reusedNames) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); }); + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }) : - (function (typeDirectiveNames, containingFile) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }); + (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; synchronizeProgram(); watchConfigFileWildCardDirectories(); @@ -72843,8 +74039,8 @@ var ts; var hostSourceFile = sourceFilesCache.get(path); return !hostSourceFile || isFileMissingOnHost(hostSourceFile) ? undefined : hostSourceFile.version.toString(); } - function onReleaseOldSourceFile(oldSourceFile, _oldOptions) { - var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.path); + function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { + var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); if (hostSourceFileInfo) { if (isFileMissingOnHost(hostSourceFileInfo)) { (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path); @@ -72853,8 +74049,10 @@ var ts; if (hostSourceFileInfo.fileWatcher) { hostSourceFileInfo.fileWatcher.close(); } - sourceFilesCache.delete(oldSourceFile.path); - resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + sourceFilesCache.delete(oldSourceFile.resolvedPath); + if (!hasSourceFileByPath) { + resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + } } } } @@ -72928,6 +74126,7 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.get(path)) { resolutionCache.invalidateResolutionOfFile(path); } + resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); scheduleProgramUpdate(); } @@ -72964,6 +74163,8 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } nextSourceFileVersion(fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) { writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); return; @@ -73140,7 +74341,7 @@ var ts; }; } ts.createBuilderStatusReporter = createBuilderStatusReporter; - function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus) { + function createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) { if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker({}, undefined, system); host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; @@ -73150,10 +74351,15 @@ var ts; host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; } + function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { + if (system === void 0) { system = ts.sys; } + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); + host.reportErrorSummary = reportErrorSummary; + return host; + } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { - if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); host.onWatchStatusChange = watchHost.onWatchStatusChange; host.watchFile = watchHost.watchFile; @@ -73494,9 +74700,7 @@ var ts; globalDependencyGraph = undefined; } projectStatus.removeKey(resolved); - if (options.watch) { - diagnostics.removeKey(resolved); - } + diagnostics.removeKey(resolved); addProjToQueue(resolved, reloadLevel); } function addProjToQueue(proj, reloadLevel) { @@ -73555,15 +74759,20 @@ var ts; } } function reportErrorSummary() { - if (options.watch) { + if (options.watch || host.reportErrorSummary) { getGlobalDependencyGraph().buildQueue.forEach(function (project) { if (!projectErrorsReported.hasKey(project)) { reportErrors(diagnostics.getValue(project) || ts.emptyArray); } }); var totalErrors_1 = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += singleProjectErrors.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length; }); - reportWatchStatus(totalErrors_1 === 1 ? ts.Diagnostics.Found_1_error_Watching_for_file_changes : ts.Diagnostics.Found_0_errors_Watching_for_file_changes, totalErrors_1); + diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += ts.getErrorCountForSummary(singleProjectErrors); }); + if (options.watch) { + reportWatchStatus(ts.getWatchErrorSummaryDiagnosticMessage(totalErrors_1), totalErrors_1); + } + else { + host.reportErrorSummary(totalErrors_1); + } } } function buildSingleInvalidatedProject(resolved, reloadLevel) { @@ -73713,9 +74922,7 @@ var ts; type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime }; - if (options.watch) { - diagnostics.removeKey(proj); - } + diagnostics.removeKey(proj); projectStatus.setValue(proj, status); return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { @@ -73834,10 +75041,8 @@ var ts; } function reportAndStoreErrors(proj, errors) { reportErrors(errors); - if (options.watch) { - projectErrorsReported.setValue(proj, true); - diagnostics.setValue(proj, errors); - } + projectErrorsReported.setValue(proj, true); + diagnostics.setValue(proj, errors); } function reportErrors(errors) { errors.forEach(function (err) { return host.reportDiagnostic(err); }); @@ -73942,10 +75147,12 @@ var ts; if (builtin !== undefined) return builtin; var entries = getEntriesOfObject(value); - return { kind: 3, name: name, members: ts.flatMap(entries, function (_a) { - var key = _a.key, value = _a.value; - return getValueInfo(key, value, recurser); - }) }; + var hasNontrivialPrototype = Object.getPrototypeOf(value) !== Object.prototype; + var members = ts.flatMap(entries, function (_a) { + var key = _a.key, value = _a.value; + return getValueInfo(key, value, recurser); + }); + return { kind: 3, name: name, hasNontrivialPrototype: hasNontrivialPrototype, members: members }; } return { kind: 0, name: name, typeName: isNullOrUndefined(value) ? "any" : typeof value }; }, function (isCircularReference, keyStack) { return anyValue(name, " " + (isCircularReference ? "Circular reference" : "Too-deep object hierarchy") + " from " + keyStack.join(".")); }); @@ -74145,6 +75352,11 @@ var ts; var commandLineOptions = commandLine.options; if (configFileName) { var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, ts.sys, reportDiagnostic); // TODO: GH#18217 + if (commandLineOptions.showConfig) { + // tslint:disable-next-line:no-null-keyword + ts.sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, ts.sys), null, 4) + ts.sys.newLine); + return ts.sys.exit(ts.ExitStatus.Success); + } updateReportDiagnostic(configParseResult.options); if (ts.isWatchSet(configParseResult.options)) { reportWatchModeWithoutSysSupport(); @@ -74155,6 +75367,11 @@ var ts; } } else { + if (commandLineOptions.showConfig) { + // tslint:disable-next-line:no-null-keyword + ts.sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(ts.sys.getCurrentDirectory(), "tsconfig.json"), ts.sys), null, 4) + ts.sys.newLine); + return ts.sys.exit(ts.ExitStatus.Success); + } updateReportDiagnostic(commandLineOptions); if (ts.isWatchSet(commandLineOptions)) { reportWatchModeWithoutSysSupport(); @@ -74198,7 +75415,9 @@ var ts; reportWatchModeWithoutSysSupport(); } // TODO: change this to host if watch => watchHost otherwiue without wathc - var builder = ts.createSolutionBuilder(ts.createSolutionBuilderWithWatchHost(ts.sys, reportDiagnostic, ts.createBuilderStatusReporter(ts.sys, shouldBePretty()), createWatchStatusReporter()), projects, buildOptions); + var builder = ts.createSolutionBuilder(buildOptions.watch ? + ts.createSolutionBuilderWithWatchHost(ts.sys, reportDiagnostic, ts.createBuilderStatusReporter(ts.sys, shouldBePretty()), createWatchStatusReporter()) : + ts.createSolutionBuilderHost(ts.sys, reportDiagnostic, ts.createBuilderStatusReporter(ts.sys, shouldBePretty()), createReportErrorSummary(buildOptions)), projects, buildOptions); if (buildOptions.clean) { return ts.sys.exit(builder.cleanAllProjects()); } @@ -74208,6 +75427,11 @@ var ts; } return ts.sys.exit(builder.buildAllProjects()); } + function createReportErrorSummary(options) { + return shouldBePretty(options) ? + function (errorCount) { return ts.sys.write(ts.getErrorSummaryText(errorCount, ts.sys.newLine)); } : + undefined; + } function performCompilation(rootNames, projectReferences, options, configFileParsingDiagnostics) { var host = ts.createCompilerHost(options); enableStatistics(options); @@ -74219,7 +75443,7 @@ var ts; configFileParsingDiagnostics: configFileParsingDiagnostics }; var program = ts.createProgram(programOptions); - var exitStatus = ts.emitFilesAndReportErrors(program, reportDiagnostic, function (s) { return ts.sys.write(s + ts.sys.newLine); }); + var exitStatus = ts.emitFilesAndReportErrors(program, reportDiagnostic, function (s) { return ts.sys.write(s + ts.sys.newLine); }, createReportErrorSummary(options)); reportStatistics(program); return ts.sys.exit(exitStatus); } diff --git a/lib/tsserver.js b/lib/tsserver.js index ac46ae0c134..2e2de2b5623 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -21,7 +21,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -491,10 +491,33 @@ var ts; return result; } ts.flatten = flatten; + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ function flatMap(array, mapfn) { var result; if (array) { - result = []; + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || ts.emptyArray; + } + ts.flatMap = flatMap; + function flatMapToMutable(array, mapfn) { + var result = []; + if (array) { for (var i = 0; i < array.length; i++) { var v = mapfn(array[i], i); if (v) { @@ -509,7 +532,7 @@ var ts; } return result; } - ts.flatMap = flatMap; + ts.flatMapToMutable = flatMapToMutable; function flatMapIterator(iter, mapfn) { var first = iter.next(); if (first.done) { @@ -748,7 +771,7 @@ var ts; */ function deduplicateSorted(array, comparer) { if (array.length === 0) - return []; + return ts.emptyArray; var last = array[0]; var deduplicated = [last]; for (var i = 1; i < array.length; i++) { @@ -779,7 +802,7 @@ var ts; } ts.insertSorted = insertSorted; function sortAndDeduplicate(array, comparer, equalityComparer) { - return deduplicateSorted(sort(array, comparer), equalityComparer || comparer); + return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive); } ts.sortAndDeduplicate = sortAndDeduplicate; function arrayIsEqualTo(array1, array2, equalityComparer) { @@ -932,7 +955,7 @@ var ts; * Returns a new sorted array. */ function sort(array, comparer) { - return array.slice().sort(comparer); + return (array.length === 0 ? array : array.slice().sort(comparer)); } ts.sort = sort; function arrayIterator(array) { @@ -1038,12 +1061,25 @@ var ts; * @param offset An offset into `array` at which to start the search. */ function binarySearch(array, value, keySelector, keyComparer, offset) { - if (!array || array.length === 0) { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); + } + ts.binarySearch = binarySearch; + /** + * Performs a binary search, finding the index at which an object with `key` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `key`. + * @param array A sorted array whose first element must be no larger than number + * @param key The key to be searched for in the array. + * @param keySelector A callback used to select the search key from each element of `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + */ + function binarySearchKey(array, key, keySelector, keyComparer, offset) { + if (!some(array)) { return -1; } var low = offset || 0; var high = array.length - 1; - var key = keySelector(value); while (low <= high) { var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle]); @@ -1060,7 +1096,7 @@ var ts; } return ~low; } - ts.binarySearch = binarySearch; + ts.binarySearchKey = binarySearchKey; function reduceLeft(array, f, initial, start, count) { if (array && array.length > 0) { var size = array.length; @@ -1984,6 +2020,33 @@ var ts; var counts; var marks; var measures; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; /** * Marks a performance event. * @@ -2438,368 +2501,370 @@ var ts; SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["BigIntLiteral"] = 9] = "BigIntLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 11] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 12] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 13] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 14] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 15] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 16] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 17] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 18] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 19] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 20] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 21] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 22] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 23] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 24] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 59] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 60] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 61] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 62] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 63] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 64] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 65] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 66] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 69] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 70] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 71] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 72] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 73] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 74] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 75] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 76] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 77] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 78] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 79] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 80] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 81] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 82] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 83] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 84] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 85] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 86] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 87] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 88] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 89] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 90] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 91] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 92] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 93] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 94] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 95] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 96] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 97] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 98] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 99] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 100] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 101] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 102] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 103] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 104] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 105] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 106] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 107] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 108] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 109] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 110] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 111] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 112] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 113] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 114] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 115] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 116] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 117] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 126] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 127] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 128] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 129] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 130] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 131] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 132] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 133] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 134] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 135] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 136] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 137] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 138] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 118] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 119] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 120] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 121] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 122] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 123] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 124] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 125] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 126] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 127] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 128] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 129] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 130] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 131] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 132] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 133] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 134] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 135] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 136] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 137] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 138] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 139] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 140] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 141] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 142] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 143] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 144] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 145] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 146] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 147] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 148] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 149] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 150] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 151] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 152] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 153] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 154] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 155] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 156] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 157] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 158] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 159] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 160] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 161] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 162] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 163] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 164] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 165] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 166] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 167] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 168] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 169] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 170] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 171] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 172] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 173] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 174] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 175] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 176] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 177] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 178] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 179] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 180] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 181] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 182] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 183] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 184] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 185] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 186] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 187] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 188] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 189] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 190] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 191] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 192] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 193] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 194] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 195] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 196] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 197] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 198] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 199] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 200] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 201] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 202] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 203] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 204] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 205] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 206] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 207] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 208] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 209] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 210] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 211] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 212] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 213] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 214] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 215] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 216] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 217] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 218] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 219] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 220] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 221] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 222] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 223] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 224] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 225] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 226] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 227] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 228] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 229] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 230] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 231] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 232] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 233] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 234] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 235] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 236] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 237] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 238] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 239] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 240] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 241] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 242] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 243] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 244] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 245] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 246] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 247] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 248] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 249] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 250] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 251] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 252] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 253] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 254] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 255] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 256] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 257] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 258] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 259] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 260] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 261] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 262] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 263] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 264] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 265] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 266] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 267] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 268] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 269] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 270] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 271] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 272] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 273] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 274] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 275] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 276] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 296] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 297] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 298] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 299] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 300] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 301] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 302] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 303] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 304] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 305] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 306] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 307] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 308] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 309] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 310] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 60] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 71] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 73] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 108] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 73] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 147] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 109] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 117] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 163] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 183] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 71] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 147] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 303] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 303] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3089,14 +3154,15 @@ var ts; // of a type, such as the global `Promise` type in lib.d.ts). TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; // with call signatures. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; (function (SymbolFlags) { @@ -3251,29 +3317,27 @@ var ts; TypeFlags[TypeFlags["Number"] = 8] = "Number"; TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 4096] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 16384] = "Null"; - TypeFlags[TypeFlags["Never"] = 32768] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 131072] = "Object"; - TypeFlags[TypeFlags["Union"] = 262144] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; - TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; - /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; - /* @internal */ - TypeFlags[TypeFlags["UnionOfPrimitiveTypes"] = 67108864] = "UnionOfPrimitiveTypes"; + TypeFlags[TypeFlags["BigInt"] = 64] = "BigInt"; + TypeFlags[TypeFlags["StringLiteral"] = 128] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 256] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 512] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 1024] = "EnumLiteral"; + TypeFlags[TypeFlags["BigIntLiteral"] = 2048] = "BigIntLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 4096] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 8192] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 16384] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32768] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 65536] = "Null"; + TypeFlags[TypeFlags["Never"] = 131072] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 262144] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 524288] = "Object"; + TypeFlags[TypeFlags["Union"] = 1048576] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 2097152] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 4194304] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 8388608] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; /* @internal */ TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ @@ -3283,40 +3347,41 @@ var ts; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 98304] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 2944] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 117724] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 67359327] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 131068] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 132] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 296] = "NumberLike"; + TypeFlags[TypeFlags["BigIntLike"] = 2112] = "BigIntLike"; + TypeFlags[TypeFlags["BooleanLike"] = 528] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 1056] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 16748579] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ @@ -3351,6 +3416,7 @@ var ts; ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ @@ -3362,6 +3428,13 @@ var ts; Variance[Variance["Bivariant"] = 3] = "Bivariant"; Variance[Variance["Independent"] = 4] = "Independent"; })(Variance = ts.Variance || (ts.Variance = {})); + /* @internal */ + var JsxReferenceKind; + (function (JsxReferenceKind) { + JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; + JsxReferenceKind[JsxReferenceKind["Function"] = 1] = "Function"; + JsxReferenceKind[JsxReferenceKind["Mixed"] = 2] = "Mixed"; + })(JsxReferenceKind = ts.JsxReferenceKind || (ts.JsxReferenceKind = {})); var SignatureKind; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; @@ -3422,6 +3495,15 @@ var ts; AssignmentDeclarationKind[AssignmentDeclarationKind["Property"] = 5] = "Property"; // F.prototype = { ... } AssignmentDeclarationKind[AssignmentDeclarationKind["Prototype"] = 6] = "Prototype"; + // Object.defineProperty(x, 'name', { value: any, writable?: boolean (false by default) }); + // Object.defineProperty(x, 'name', { get: Function, set: Function }); + // Object.defineProperty(x, 'name', { get: Function }); + // Object.defineProperty(x, 'name', { set: Function }); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyValue"] = 7] = "ObjectDefinePropertyValue"; + // Object.defineProperty(exports || module.exports, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyExports"] = 8] = "ObjectDefinePropertyExports"; + // Object.defineProperty(Foo.prototype, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePrototypeProperty"] = 9] = "ObjectDefinePrototypeProperty"; })(AssignmentDeclarationKind = ts.AssignmentDeclarationKind || (ts.AssignmentDeclarationKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -3789,6 +3871,7 @@ var ts; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; + EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); var ListFormat; (function (ListFormat) { @@ -3803,64 +3886,66 @@ var ts; ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["AsteriskDelimited"] = 32] = "AsteriskDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 60] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 64] = "AllowTrailingComma"; // Whitespace - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Indented"] = 128] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 256] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 512] = "SpaceBetweenSiblings"; // Brackets/Braces - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["Braces"] = 1024] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 2048] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 4096] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 8192] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 15360] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 16384] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 32768] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 49152] = "Optional"; // Other - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; - ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; + ListFormat[ListFormat["PreferNewLine"] = 65536] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 131072] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 262144] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 524288] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 1048576] = "SingleElement"; // Precomputed Formats - ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 384] = "SingleLineTypeLiteralMembers"; - ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 16449] = "MultiLineTypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 272] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 262576] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 262448] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["Modifiers"] = 262656] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 512] = "HeritageClauses"; + ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 768] = "SingleLineTypeLiteralMembers"; + ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 32897] = "MultiLineTypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 528] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 516] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 520] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 525136] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 524880] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 526226] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 8914] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CommaListElements"] = 528] = "CommaListElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 2576] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 18960] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 262144] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 768] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 129] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 528] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 768] = "SingleLineFunctionBodyStatements"; ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; ListFormat[ListFormat["ClassHeritageClauses"] = 0] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 262576] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 131072] = "JsxElementOrFragmentChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26896] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26896] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1296] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + ListFormat[ListFormat["ClassMembers"] = 129] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 129] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 145] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 129] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 525136] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 262144] = "JsxElementOrFragmentChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 262656] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 163969] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 528] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 131073] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 49153] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 53776] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 53776] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 2576] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 8848] = "IndexSignatureParameters"; + ListFormat[ListFormat["JSDocComment"] = 33] = "JSDocComment"; })(ListFormat = ts.ListFormat || (ts.ListFormat = {})); /* @internal */ var PragmaKindFlags; @@ -5164,6 +5249,7 @@ var ts; use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), 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."), @@ -5220,14 +5306,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number' or an enum type."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), @@ -5434,9 +5520,9 @@ var ts; No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), @@ -5534,6 +5620,13 @@ var ts; Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), It_is_highly_likely_that_you_are_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "It_is_highly_likely_that_you_are_missing_a_semicolon_2734", "It is highly likely that you are missing a semicolon."), + Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), + Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), + BigInt_literals_are_not_available_when_targeting_lower_than_ESNext: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ESNext_2737", "BigInt literals are not available when targeting lower than ESNext."), + An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, ts.DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."), + Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."), 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}'."), @@ -5850,6 +5943,9 @@ var ts; Did_you_mean_to_call_this_expression: diag(6212, ts.DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"), Did_you_mean_to_use_new_with_this_expression: diag(6213, ts.DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"), Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, ts.DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."), + Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."), + Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."), + Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5890,6 +5986,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."), Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."), Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."), + Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, ts.DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."), Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."), Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."), Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."), @@ -5917,6 +6014,14 @@ var ts; If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any_7041", "The containing arrow function captures the global value of 'this' which implicitly has type 'any'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), + Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, ts.DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, ts.DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."), + Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, ts.DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."), + _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."), 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_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -6078,6 +6183,8 @@ var ts; Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), Generate_types_for_0: diag(95067, ts.DiagnosticCategory.Message, "Generate_types_for_0_95067", "Generate types for '{0}'"), Generate_types_for_all_packages_without_types: diag(95068, ts.DiagnosticCategory.Message, "Generate_types_for_all_packages_without_types_95068", "Generate types for all packages without types"), + Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), + Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), }; })(ts || (ts = {})); var ts; @@ -6085,93 +6192,94 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 71 /* Identifier */; + return token >= 72 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 117 /* AbstractKeyword */, - any: 119 /* AnyKeyword */, - as: 118 /* AsKeyword */, - boolean: 122 /* BooleanKeyword */, - break: 72 /* BreakKeyword */, - case: 73 /* CaseKeyword */, - catch: 74 /* CatchKeyword */, - class: 75 /* ClassKeyword */, - continue: 77 /* ContinueKeyword */, - const: 76 /* ConstKeyword */ + abstract: 118 /* AbstractKeyword */, + any: 120 /* AnyKeyword */, + as: 119 /* AsKeyword */, + bigint: 146 /* BigIntKeyword */, + boolean: 123 /* BooleanKeyword */, + break: 73 /* BreakKeyword */, + case: 74 /* CaseKeyword */, + catch: 75 /* CatchKeyword */, + class: 76 /* ClassKeyword */, + continue: 78 /* ContinueKeyword */, + const: 77 /* ConstKeyword */ }, - _a["" + "constructor"] = 123 /* ConstructorKeyword */, - _a.debugger = 78 /* DebuggerKeyword */, - _a.declare = 124 /* DeclareKeyword */, - _a.default = 79 /* DefaultKeyword */, - _a.delete = 80 /* DeleteKeyword */, - _a.do = 81 /* DoKeyword */, - _a.else = 82 /* ElseKeyword */, - _a.enum = 83 /* EnumKeyword */, - _a.export = 84 /* ExportKeyword */, - _a.extends = 85 /* ExtendsKeyword */, - _a.false = 86 /* FalseKeyword */, - _a.finally = 87 /* FinallyKeyword */, - _a.for = 88 /* ForKeyword */, - _a.from = 143 /* FromKeyword */, - _a.function = 89 /* FunctionKeyword */, - _a.get = 125 /* GetKeyword */, - _a.if = 90 /* IfKeyword */, - _a.implements = 108 /* ImplementsKeyword */, - _a.import = 91 /* ImportKeyword */, - _a.in = 92 /* InKeyword */, - _a.infer = 126 /* InferKeyword */, - _a.instanceof = 93 /* InstanceOfKeyword */, - _a.interface = 109 /* InterfaceKeyword */, - _a.is = 127 /* IsKeyword */, - _a.keyof = 128 /* KeyOfKeyword */, - _a.let = 110 /* LetKeyword */, - _a.module = 129 /* ModuleKeyword */, - _a.namespace = 130 /* NamespaceKeyword */, - _a.never = 131 /* NeverKeyword */, - _a.new = 94 /* NewKeyword */, - _a.null = 95 /* NullKeyword */, - _a.number = 134 /* NumberKeyword */, - _a.object = 135 /* ObjectKeyword */, - _a.package = 111 /* PackageKeyword */, - _a.private = 112 /* PrivateKeyword */, - _a.protected = 113 /* ProtectedKeyword */, - _a.public = 114 /* PublicKeyword */, - _a.readonly = 132 /* ReadonlyKeyword */, - _a.require = 133 /* RequireKeyword */, - _a.global = 144 /* GlobalKeyword */, - _a.return = 96 /* ReturnKeyword */, - _a.set = 136 /* SetKeyword */, - _a.static = 115 /* StaticKeyword */, - _a.string = 137 /* StringKeyword */, - _a.super = 97 /* SuperKeyword */, - _a.switch = 98 /* SwitchKeyword */, - _a.symbol = 138 /* SymbolKeyword */, - _a.this = 99 /* ThisKeyword */, - _a.throw = 100 /* ThrowKeyword */, - _a.true = 101 /* TrueKeyword */, - _a.try = 102 /* TryKeyword */, - _a.type = 139 /* TypeKeyword */, - _a.typeof = 103 /* TypeOfKeyword */, - _a.undefined = 140 /* UndefinedKeyword */, - _a.unique = 141 /* UniqueKeyword */, - _a.unknown = 142 /* UnknownKeyword */, - _a.var = 104 /* VarKeyword */, - _a.void = 105 /* VoidKeyword */, - _a.while = 106 /* WhileKeyword */, - _a.with = 107 /* WithKeyword */, - _a.yield = 116 /* YieldKeyword */, - _a.async = 120 /* AsyncKeyword */, - _a.await = 121 /* AwaitKeyword */, - _a.of = 145 /* OfKeyword */, + _a["" + "constructor"] = 124 /* ConstructorKeyword */, + _a.debugger = 79 /* DebuggerKeyword */, + _a.declare = 125 /* DeclareKeyword */, + _a.default = 80 /* DefaultKeyword */, + _a.delete = 81 /* DeleteKeyword */, + _a.do = 82 /* DoKeyword */, + _a.else = 83 /* ElseKeyword */, + _a.enum = 84 /* EnumKeyword */, + _a.export = 85 /* ExportKeyword */, + _a.extends = 86 /* ExtendsKeyword */, + _a.false = 87 /* FalseKeyword */, + _a.finally = 88 /* FinallyKeyword */, + _a.for = 89 /* ForKeyword */, + _a.from = 144 /* FromKeyword */, + _a.function = 90 /* FunctionKeyword */, + _a.get = 126 /* GetKeyword */, + _a.if = 91 /* IfKeyword */, + _a.implements = 109 /* ImplementsKeyword */, + _a.import = 92 /* ImportKeyword */, + _a.in = 93 /* InKeyword */, + _a.infer = 127 /* InferKeyword */, + _a.instanceof = 94 /* InstanceOfKeyword */, + _a.interface = 110 /* InterfaceKeyword */, + _a.is = 128 /* IsKeyword */, + _a.keyof = 129 /* KeyOfKeyword */, + _a.let = 111 /* LetKeyword */, + _a.module = 130 /* ModuleKeyword */, + _a.namespace = 131 /* NamespaceKeyword */, + _a.never = 132 /* NeverKeyword */, + _a.new = 95 /* NewKeyword */, + _a.null = 96 /* NullKeyword */, + _a.number = 135 /* NumberKeyword */, + _a.object = 136 /* ObjectKeyword */, + _a.package = 112 /* PackageKeyword */, + _a.private = 113 /* PrivateKeyword */, + _a.protected = 114 /* ProtectedKeyword */, + _a.public = 115 /* PublicKeyword */, + _a.readonly = 133 /* ReadonlyKeyword */, + _a.require = 134 /* RequireKeyword */, + _a.global = 145 /* GlobalKeyword */, + _a.return = 97 /* ReturnKeyword */, + _a.set = 137 /* SetKeyword */, + _a.static = 116 /* StaticKeyword */, + _a.string = 138 /* StringKeyword */, + _a.super = 98 /* SuperKeyword */, + _a.switch = 99 /* SwitchKeyword */, + _a.symbol = 139 /* SymbolKeyword */, + _a.this = 100 /* ThisKeyword */, + _a.throw = 101 /* ThrowKeyword */, + _a.true = 102 /* TrueKeyword */, + _a.try = 103 /* TryKeyword */, + _a.type = 140 /* TypeKeyword */, + _a.typeof = 104 /* TypeOfKeyword */, + _a.undefined = 141 /* UndefinedKeyword */, + _a.unique = 142 /* UniqueKeyword */, + _a.unknown = 143 /* UnknownKeyword */, + _a.var = 105 /* VarKeyword */, + _a.void = 106 /* VoidKeyword */, + _a.while = 107 /* WhileKeyword */, + _a.with = 108 /* WithKeyword */, + _a.yield = 117 /* YieldKeyword */, + _a.async = 121 /* AsyncKeyword */, + _a.await = 122 /* AwaitKeyword */, + _a.of = 147 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 59 /* EqualsToken */, "+=": 60 /* PlusEqualsToken */, "-=": 61 /* MinusEqualsToken */, "*=": 62 /* AsteriskEqualsToken */, "**=": 63 /* AsteriskAsteriskEqualsToken */, "/=": 64 /* SlashEqualsToken */, "%=": 65 /* PercentEqualsToken */, "<<=": 66 /* LessThanLessThanEqualsToken */, ">>=": 67 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 69 /* AmpersandEqualsToken */, "|=": 70 /* BarEqualsToken */, "^=": 71 /* CaretEqualsToken */, "@": 58 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6760,8 +6868,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; }, + isIdentifier: function () { return token === 72 /* Identifier */ || token > 108 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -6855,18 +6963,29 @@ var ts; end = pos; } } + var result; if (tokenFlags & 512 /* ContainsSeparator */) { - var result = mainFragment; + result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; } if (scientificFragment) { result += scientificFragment; } - return "" + +result; } else { - return "" + +(text.substring(start, end)); // No need to use all the fragments; no _ removal needed + result = text.substring(start, end); // No need to use all the fragments; no _ removal needed + } + if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { + return { + type: 8 /* NumericLiteral */, + value: "" + +result // if value is not an integer, it can be safely coerced to a number + }; + } + else { + tokenValue = result; + var type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint + return { type: type, value: tokenValue }; } } function scanOctalDigits() { @@ -6881,21 +7000,21 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count, canHaveSeparators) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + var valueString = scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + return valueString ? parseInt(valueString, 16) : -1; } /** * Scans as many hexadecimal digits as are available in the text, - * returning -1 if the given number of digits was unavailable. + * returning "" if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count, canHaveSeparators) { return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true, canHaveSeparators); } function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) { - var digits = 0; - var value = 0; + var valueChars = []; var allowSeparator = false; var isPreviousTokenSeparator = false; - while (digits < minCount || scanAsManyAsPossible) { + while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); if (canHaveSeparators && ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; @@ -6913,29 +7032,24 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; + if (ch >= 65 /* A */ && ch <= 70 /* F */) { + ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { + else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || + (ch >= 97 /* a */ && ch <= 102 /* f */))) { break; } + valueChars.push(ch); pos++; - digits++; isPreviousTokenSeparator = false; } - if (digits < minCount) { - value = -1; + if (valueChars.length < minCount) { + valueChars = []; } if (text.charCodeAt(pos - 1) === 95 /* _ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } - return value; + return String.fromCharCode.apply(String, valueChars); } function scanString(jsxAttributeString) { if (jsxAttributeString === void 0) { jsxAttributeString = false; } @@ -6987,7 +7101,7 @@ var ts; contents += text.substring(start, pos); tokenFlags |= 4 /* Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -6995,14 +7109,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; break; } // Escape character @@ -7095,7 +7209,8 @@ var ts; } } function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; var isInvalidExtendedEscape = false; // Validate the value of the digit if (escapedValue < 0) { @@ -7183,14 +7298,12 @@ var ts; } } } - return token = 71 /* Identifier */; + return token = 72 /* Identifier */; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; + var value = ""; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. - var numberOfDigits = 0; var separatorAllowed = false; var isPreviousTokenSeparator = false; while (true) { @@ -7212,27 +7325,42 @@ var ts; continue; } separatorAllowed = true; - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { + if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { break; } - value = value * base + valueOfCh; + value += text[pos]; pos++; - numberOfDigits++; isPreviousTokenSeparator = false; } - // Invalid binaryIntegerLiteral or octalIntegerLiteral - if (numberOfDigits === 0) { - return -1; - } if (text.charCodeAt(pos - 1) === 95 /* _ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); - return value; } return value; } + function checkBigIntSuffix() { + if (text.charCodeAt(pos) === 110 /* n */) { + tokenValue += "n"; + // Use base 10 instead of base 2 or base 8 for shorter literals + if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; + } + pos++; + return 9 /* 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 */ + ? parseInt(tokenValue.slice(2), 2) // skip "0b" + : tokenFlags & 256 /* OctalSpecifier */ + ? parseInt(tokenValue.slice(2), 8) // skip "0o" + : +tokenValue; + tokenValue = "" + numericValue; + return 8 /* NumericLiteral */; + } + } function scan() { + var _a; startPos = pos; tokenFlags = 0; var asteriskSeen = false; @@ -7305,48 +7433,48 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 33 /* ExclamationEqualsToken */; + return pos += 2, token = 34 /* ExclamationEqualsToken */; } pos++; - return token = 51 /* ExclamationToken */; + return token = 52 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PercentEqualsToken */; + return pos += 2, token = 65 /* PercentEqualsToken */; } pos++; - return token = 42 /* PercentToken */; + return token = 43 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 53 /* AmpersandAmpersandToken */; + return pos += 2, token = 54 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* AmpersandEqualsToken */; + return pos += 2, token = 69 /* AmpersandEqualsToken */; } pos++; - return token = 48 /* AmpersandToken */; + return token = 49 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 19 /* OpenParenToken */; + return token = 20 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 20 /* CloseParenToken */; + return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* AsteriskEqualsToken */; + return pos += 2, token = 62 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 63 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 40 /* AsteriskAsteriskToken */; + return pos += 2, token = 41 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7354,38 +7482,38 @@ var ts; asteriskSeen = true; continue; } - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 43 /* PlusPlusToken */; + return pos += 2, token = 44 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PlusEqualsToken */; + return pos += 2, token = 60 /* PlusEqualsToken */; } pos++; - return token = 37 /* PlusToken */; + return token = 38 /* PlusToken */; case 44 /* comma */: pos++; - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 44 /* MinusMinusToken */; + return pos += 2, token = 45 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* MinusEqualsToken */; + return pos += 2, token = 61 /* MinusEqualsToken */; } pos++; - return token = 38 /* MinusToken */; + return token = 39 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); + tokenValue = scanNumber().value; return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 24 /* DotDotDotToken */; + return pos += 3, token = 25 /* DotDotDotToken */; } pos++; - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -7436,43 +7564,43 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* SlashEqualsToken */; + return pos += 2, token = 64 /* SlashEqualsToken */; } pos++; - return token = 41 /* SlashToken */; + return token = 42 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; - var value = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); - if (value < 0) { + tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); + if (!tokenValue) { error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0x" + tokenValue; tokenFlags |= 64 /* HexSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 2); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 2); + if (!tokenValue) { error(ts.Diagnostics.Binary_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0b" + tokenValue; tokenFlags |= 128 /* BinarySpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 8); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 8); + if (!tokenValue) { error(ts.Diagnostics.Octal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0o" + tokenValue; tokenFlags |= 256 /* OctalSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -7493,14 +7621,14 @@ var ts; case 55 /* _7 */: case 56 /* _8 */: case 57 /* _9 */: - tokenValue = scanNumber(); - return token = 8 /* NumericLiteral */; + (_a = scanNumber(), token = _a.type, tokenValue = _a.value); + return token; case 58 /* colon */: pos++; - return token = 56 /* ColonToken */; + return token = 57 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 25 /* SemicolonToken */; + return token = 26 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7513,20 +7641,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 66 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 45 /* LessThanLessThanToken */; + return pos += 2, token = 46 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 30 /* LessThanEqualsToken */; + return pos += 2, token = 31 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 28 /* LessThanSlashToken */; + return pos += 2, token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7539,15 +7667,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 34 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 32 /* EqualsEqualsToken */; + return pos += 2, token = 33 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 36 /* EqualsGreaterThanToken */; + return pos += 2, token = 37 /* EqualsGreaterThanToken */; } pos++; - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7559,25 +7687,25 @@ var ts; } } pos++; - return token = 29 /* GreaterThanToken */; + return token = 30 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 55 /* QuestionToken */; + return token = 56 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* CaretEqualsToken */; + return pos += 2, token = 71 /* CaretEqualsToken */; } pos++; - return token = 50 /* CaretToken */; + return token = 51 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 124 /* bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7589,22 +7717,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 54 /* BarBarToken */; + return pos += 2, token = 55 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* BarEqualsToken */; + return pos += 2, token = 70 /* BarEqualsToken */; } pos++; - return token = 49 /* BarToken */; + return token = 50 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 52 /* TildeToken */; + return token = 53 /* TildeToken */; case 64 /* at */: pos++; - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -7642,29 +7770,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* 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 = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 67 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 46 /* GreaterThanGreaterThanToken */; + return token = 47 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 31 /* GreaterThanEqualsToken */; + return token = 32 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) { + if (token === 42 /* SlashToken */ || token === 64 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -7709,7 +7837,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 12 /* RegularExpressionLiteral */; + token = 13 /* RegularExpressionLiteral */; } return token; } @@ -7717,7 +7845,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -7734,14 +7862,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 28 /* LessThanSlashToken */; + return token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -7773,7 +7901,7 @@ var ts; } pos++; } - return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -7799,7 +7927,7 @@ var ts; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -7823,36 +7951,36 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 123 /* openBrace */: - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 91 /* openBracket */: - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 44 /* comma */: - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 46 /* dot */: - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 96 /* backtick */: while (pos < end && text.charCodeAt(pos) !== 96 /* backtick */) { pos++; } tokenValue = text.substring(tokenPos + 1, pos); pos++; - return token = 13 /* NoSubstitutionTemplateLiteral */; + return token = 14 /* NoSubstitutionTemplateLiteral */; } if (isIdentifierStart(ch, 6 /* Latest */)) { while (isIdentifierPart(text.charCodeAt(pos), 6 /* Latest */) && pos < end) { @@ -8005,7 +8133,6 @@ var ts; getText: function () { return str; }, write: writeText, rawWrite: writeText, - writeTextOfNode: writeText, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -8014,7 +8141,9 @@ var ts; writeLiteral: writeText, writeParameter: writeText, writeProperty: writeText, - writeSymbol: writeText, + writeSymbol: function (s, _) { return writeText(s); }, + writeTrailingSemicolon: writeText, + writeComment: writeText, getTextPos: function () { return str.length; }, getLine: function () { return 0; }, getColumn: function () { return 0; }, @@ -8213,7 +8342,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { + while (node && node.kind !== 279 /* SourceFile */) { node = node.parent; } return node; @@ -8221,11 +8350,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return true; } return false; @@ -8359,7 +8488,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 === 304 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8378,7 +8507,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 281 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8420,32 +8549,34 @@ var ts; function getLiteralText(node, sourceFile, neverAsciiEscape) { // 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 (!nodeIsSynthesized(node) && node.parent && !(ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */)) { + if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) || + ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // 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 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.singleQuote) { return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; } else { return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return "`" + escapeText(node.text, 96 /* backtick */) + "`"; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: // tslint:disable-next-line no-invalid-template-strings return "`" + escapeText(node.text, 96 /* backtick */) + "${"; - case 15 /* TemplateMiddle */: + case 16 /* TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings return "}" + escapeText(node.text, 96 /* backtick */) + "${"; - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: + case 9 /* BigIntLiteral */: + case 13 /* RegularExpressionLiteral */: return node.text; } return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -8468,15 +8599,15 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; + return node.kind === 237 /* VariableDeclaration */ && node.parent.kind === 274 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 9 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -8500,11 +8631,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 277 /* SourceFile */ || - node.kind === 242 /* ModuleDeclaration */ || + return node.kind === 279 /* SourceFile */ || + node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8521,9 +8652,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 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node.parent); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8539,22 +8670,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 272 /* CatchClause */: - case 242 /* ModuleDeclaration */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 274 /* CatchClause */: + case 244 /* ModuleDeclaration */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 216 /* Block */: + case 218 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8564,9 +8695,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 291 /* JSDocSignature */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 293 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8576,25 +8707,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -8604,8 +8735,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8614,15 +8745,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 217 /* VariableStatement */: - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 219 /* VariableStatement */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -8652,12 +8783,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isStringOrNumericLiteralLike(name.expression) ? ts.escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: return ts.Debug.assertNever(name); @@ -8666,11 +8798,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8715,7 +8847,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 216 /* Block */) { + if (node.body && node.body.kind === 218 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8729,7 +8861,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* 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 @@ -8738,25 +8870,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: errorNode = node.name; break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8805,11 +8937,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 98 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 92 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { @@ -8817,20 +8949,20 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 219 /* ExpressionStatement */ - && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 221 /* ExpressionStatement */ + && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 149 /* Parameter */ || - node.kind === 148 /* TypeParameter */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 195 /* ArrowFunction */ || - node.kind === 193 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 151 /* Parameter */ || + node.kind === 150 /* TypeParameter */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 197 /* ArrowFunction */ || + node.kind === 195 /* ParenthesizedExpression */) ? 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 '/**/' @@ -8846,47 +8978,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= node.kind && node.kind <= 183 /* LastTypeNode */) { return true; } switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 134 /* NumberKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: return true; - case 105 /* VoidKeyword */: - return node.parent.kind !== 198 /* VoidExpression */; - case 209 /* ExpressionWithTypeArguments */: + case 106 /* VoidKeyword */: + return node.parent.kind !== 200 /* VoidExpression */; + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 148 /* TypeParameter */: - return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; + case 150 /* TypeParameter */: + return node.parent.kind === 181 /* MappedType */ || node.parent.kind === 176 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 71 /* Identifier */: + case 72 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 189 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */ || node.kind === 189 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 146 /* QualifiedName */: - case 187 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: { + case 148 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 100 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 165 /* TypeQuery */) { + if (parent.kind === 167 /* TypeQuery */) { return false; } - if (parent.kind === 181 /* ImportType */) { + if (parent.kind === 183 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8895,40 +9028,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 (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= parent.kind && parent.kind <= 183 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return node === parent.constraint; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return node === parent.constraint; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return node === parent.type; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node === parent.type; - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return node === parent.type; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return node === parent.type; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8953,23 +9086,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitor(node); - case 244 /* CaseBlock */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 246 /* CaseBlock */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8979,26 +9112,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* 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); @@ -9021,10 +9154,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 167 /* ArrayType */) { + if (node && node.kind === 169 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 162 /* TypeReference */) { + else if (node && node.kind === 164 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9034,12 +9167,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 166 /* TypeLiteral */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 168 /* TypeLiteral */: return node.members; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return node.properties; } } @@ -9047,14 +9180,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 184 /* BindingElement */: - case 276 /* EnumMember */: - case 149 /* Parameter */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 274 /* ShorthandPropertyAssignment */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 278 /* EnumMember */: + case 151 /* Parameter */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 276 /* ShorthandPropertyAssignment */: + case 237 /* VariableDeclaration */: return true; } } @@ -9066,8 +9199,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 236 /* VariableDeclarationList */ - && node.parent.parent.kind === 217 /* VariableStatement */; + return node.parent.kind === 238 /* VariableDeclarationList */ + && node.parent.parent.kind === 219 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9078,13 +9211,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return true; } return false; @@ -9095,7 +9228,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 231 /* LabeledStatement */) { + if (node.statement.kind !== 233 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9103,17 +9236,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 218 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; + return node && node.kind === 156 /* MethodDeclaration */ && node.parent.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 186 /* ObjectLiteralExpression */ || - node.parent.kind === 207 /* ClassExpression */); + return node.kind === 156 /* MethodDeclaration */ && + (node.parent.kind === 188 /* ObjectLiteralExpression */ || + node.parent.kind === 209 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9126,7 +9259,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 273 /* PropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9163,14 +9296,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 277 /* SourceFile */); + ts.Debug.assert(node.kind !== 279 /* 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 147 /* ComputedPropertyName */: + case 149 /* 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 @@ -9185,9 +9318,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9198,26 +9331,26 @@ var ts; node = node.parent; } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 242 /* ModuleDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 241 /* EnumDeclaration */: - case 277 /* SourceFile */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 244 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 243 /* EnumDeclaration */: + case 279 /* SourceFile */: return node; } } @@ -9227,9 +9360,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return container; } } @@ -9251,27 +9384,27 @@ var ts; return node; } switch (node.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: node = node.parent; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9287,14 +9420,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { + if (func.kind === 196 /* FunctionExpression */ || func.kind === 197 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 193 /* ParenthesizedExpression */) { + while (parent.kind === 195 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 191 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9305,8 +9438,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 97 /* SuperKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 98 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9314,20 +9447,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 99 /* ThisKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 100 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: return node; } return undefined; @@ -9335,10 +9468,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return node.tag; - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9347,25 +9480,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // classes are valid targets return true; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 238 /* ClassDeclaration */; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + return parent.kind === 240 /* ClassDeclaration */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* 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 === 238 /* ClassDeclaration */; - case 149 /* Parameter */: + && parent.kind === 240 /* ClassDeclaration */; + case 151 /* 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 === 155 /* Constructor */ - || parent.kind === 154 /* MethodDeclaration */ - || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 238 /* ClassDeclaration */; + && (parent.kind === 157 /* Constructor */ + || parent.kind === 156 /* MethodDeclaration */ + || parent.kind === 159 /* SetAccessor */) + && grandparent.kind === 240 /* ClassDeclaration */; } return false; } @@ -9381,10 +9514,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 154 /* MethodDeclaration */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 159 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -9393,9 +9526,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 260 /* JsxOpeningElement */ || - parent.kind === 259 /* JsxSelfClosingElement */ || - parent.kind === 261 /* JsxClosingElement */) { + if (parent.kind === 262 /* JsxOpeningElement */ || + parent.kind === 261 /* JsxSelfClosingElement */ || + parent.kind === 263 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9403,56 +9536,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 12 /* RegularExpressionLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 210 /* AsExpression */: - case 192 /* TypeAssertionExpression */: - case 211 /* NonNullExpression */: - case 193 /* ParenthesizedExpression */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 206 /* SpreadElement */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 208 /* OmittedExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 205 /* YieldExpression */: - case 199 /* AwaitExpression */: - case 212 /* MetaProperty */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 13 /* RegularExpressionLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 212 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 213 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 208 /* SpreadElement */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 210 /* OmittedExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 207 /* YieldExpression */: + case 201 /* AwaitExpression */: + case 214 /* MetaProperty */: return true; - case 146 /* QualifiedName */: - while (node.parent.kind === 146 /* QualifiedName */) { + case 148 /* QualifiedName */: + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); - case 71 /* Identifier */: - if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node); + case 72 /* Identifier */: + if (node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -9462,49 +9596,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 186 /* BindingElement */: return parent.initializer === node; - case 219 /* ExpressionStatement */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 228 /* ReturnStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 232 /* ThrowStatement */: + case 221 /* ExpressionStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 230 /* ReturnStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 234 /* ThrowStatement */: return parent.expression === node; - case 223 /* ForStatement */: + case 225 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forInStatement.expression === node; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return node === parent.expression; - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return node === parent.expression; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return node === parent.expression; - case 150 /* Decorator */: - case 268 /* JsxExpression */: - case 267 /* JsxSpreadAttribute */: - case 275 /* SpreadAssignment */: + case 152 /* Decorator */: + case 270 /* JsxExpression */: + case 269 /* JsxSpreadAttribute */: + case 277 /* SpreadAssignment */: return true; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -9512,7 +9646,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9521,7 +9655,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 259 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -9549,15 +9683,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 137 /* StringKeyword */ || node.typeArguments[0].kind === 134 /* NumberKeyword */); + (node.typeArguments[0].kind === 138 /* StringKeyword */ || node.typeArguments[0].kind === 135 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 189 /* CallExpression */) { + if (callExpression.kind !== 191 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 71 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 72 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -9588,16 +9722,16 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.right === node) { name = node.parent.left; decl = name; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { name = node.parent.parent.name; decl = node.parent.parent; } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.parent.right === node.parent) { name = node.parent.parent.left; decl = name; } @@ -9612,13 +9746,13 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl); + return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -9631,16 +9765,25 @@ var ts; return init && getExpandoInitializer(init, isPrototypeAccess(node.name)); } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; + function hasExpandoValueProperty(node, isPrototypeAssignment) { + return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); } + if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) { + var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype"); + if (result) { + return result; + } + } } ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer; /** @@ -9656,11 +9799,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 196 /* FunctionExpression */ || e.kind === 197 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 194 /* FunctionExpression */ || - initializer.kind === 207 /* ClassExpression */ || - initializer.kind === 195 /* ArrowFunction */) { + if (initializer.kind === 196 /* FunctionExpression */ || + initializer.kind === 209 /* ClassExpression */ || + initializer.kind === 197 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9677,14 +9820,14 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 54 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -9692,8 +9835,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 === 54 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 58 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 59 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -9716,7 +9859,7 @@ var ts; return name.escapedText === initializer.escapedText; } if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 99 /* ThisKeyword */ || + return (initializer.expression.kind === 100 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -9750,8 +9893,31 @@ var ts; return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; + function isBindableObjectDefinePropertyCall(expr) { + return ts.length(expr.arguments) === 3 && + ts.isPropertyAccessExpression(expr.expression) && + ts.isIdentifier(expr.expression.expression) && + ts.idText(expr.expression.expression) === "Object" && + ts.idText(expr.expression.name) === "defineProperty" && + isStringOrNumericLiteralLike(expr.arguments[1]) && + isEntityNameExpression(expr.arguments[0]); + } + ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; function getAssignmentDeclarationKindWorker(expr) { - if (expr.operatorToken.kind !== 58 /* EqualsToken */ || + if (ts.isCallExpression(expr)) { + if (!isBindableObjectDefinePropertyCall(expr)) { + return 0 /* None */; + } + var entityName = expr.arguments[0]; + if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + return 8 /* ObjectDefinePropertyExports */; + } + if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + return 9 /* ObjectDefinePrototypeProperty */; + } + return 7 /* ObjectDefinePropertyValue */; + } + if (expr.operatorToken.kind !== 59 /* EqualsToken */ || !ts.isPropertyAccessExpression(expr.left)) { return 0 /* None */; } @@ -9763,10 +9929,10 @@ var ts; return getAssignmentDeclarationPropertyAccessKind(lhs); } function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 99 /* ThisKeyword */) { + if (lhs.expression.kind === 100 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (ts.isIdentifier(lhs.expression) && lhs.expression.escapedText === "module" && lhs.name.escapedText === "exports") { + else if (isModuleExportsPropertyAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } @@ -9805,7 +9971,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 221 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9814,7 +9980,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 237 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 239 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -9823,14 +9989,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.parent; - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return node.parent.parent; - case 189 /* CallExpression */: - return node.parent; - case 180 /* LiteralType */: + case 191 /* CallExpression */: + return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; + case 182 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9840,12 +10006,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.moduleSpecifier; - case 246 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 181 /* ImportType */: + case 248 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 259 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 183 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9854,11 +10020,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9866,19 +10032,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 249 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 149 /* Parameter */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 274 /* ShorthandPropertyAssignment */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 151 /* Parameter */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 276 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -9886,14 +10052,13 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 287 /* JSDocFunctionType */ && - node.parameters.length > 0 && - node.parameters[0].name && - node.parameters[0].name.escapedText === "new"; + var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined; + var name = ts.tryCast(param && param.name, ts.isIdentifier); + return !!name && name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 302 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9903,7 +10068,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ + node.expression.operatorToken.kind === 59 /* EqualsToken */ ? node.expression.right : undefined; } @@ -9912,18 +10077,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + node.expression.right.operatorToken.kind === 55 /* BarBarToken */ ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return node.initializer; } } @@ -9933,7 +10098,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 242 /* ModuleDeclaration */ + node.body.kind === 244 /* ModuleDeclaration */ ? node.body : undefined; } @@ -9948,11 +10113,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 148 /* TypeParameter */) { + if (node.kind === 150 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -9963,11 +10128,11 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 273 /* PropertyAssignment */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + if (parent.kind === 275 /* PropertyAssignment */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 221 /* ExpressionStatement */ && node.kind === 189 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 59 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -9978,7 +10143,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10001,7 +10166,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 71 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 72 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10036,7 +10201,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 === 288 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10049,31 +10214,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 59 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 193 /* ParenthesizedExpression */: - case 185 /* ArrayLiteralExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 187 /* ArrayLiteralExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: node = parent; break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10100,22 +10265,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 216 /* Block */: - case 217 /* VariableStatement */: - case 229 /* WithStatement */: - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 218 /* Block */: + case 219 /* VariableStatement */: + case 231 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return true; } return false; @@ -10132,33 +10297,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 175 /* ParenthesizedType */); + return walkUp(node, 177 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 193 /* ParenthesizedExpression */); + return walkUp(node, 195 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 196 /* DeleteExpression */; + return node && node.kind === 198 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10179,12 +10344,12 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10207,8 +10372,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 147 /* ComputedPropertyName */ && + return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + node.parent.kind === 149 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10216,32 +10381,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 187 /* PropertyAccessExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 189 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 146 /* QualifiedName */) { + while (parent.kind === 148 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; + return parent.kind === 167 /* TypeQuery */ || parent.kind === 164 /* TypeReference */; } return false; - case 184 /* BindingElement */: - case 251 /* ImportSpecifier */: + case 186 /* BindingElement */: + case 253 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 255 /* ExportSpecifier */: - case 265 /* JsxAttribute */: + case 257 /* ExportSpecifier */: + case 267 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10256,15 +10421,16 @@ var ts; // export { x as } from ... // export = // export default + // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 245 /* NamespaceExportDeclaration */ || - node.kind === 248 /* ImportClause */ && !!node.name || - node.kind === 249 /* NamespaceImport */ || - node.kind === 251 /* ImportSpecifier */ || - node.kind === 255 /* ExportSpecifier */ || - node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */; + return node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 247 /* NamespaceExportDeclaration */ || + node.kind === 250 /* ImportClause */ && !!node.name || + node.kind === 251 /* NamespaceImport */ || + node.kind === 253 /* ImportSpecifier */ || + node.kind === 257 /* ExportSpecifier */ || + node.kind === 254 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -10284,12 +10450,12 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 109 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; @@ -10301,7 +10467,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -10335,11 +10501,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; + return 73 /* FirstKeyword */ <= token && token <= 147 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; + return 118 /* FirstContextualKeyword */ <= token && token <= 147 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10351,6 +10517,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isIdentifierANonContextualKeyword(_a) { + var originalKeywordKind = _a.originalKeywordKind; + return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); + } + ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } @@ -10369,14 +10540,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10390,10 +10561,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10418,7 +10589,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 147 /* ComputedPropertyName */ && + return name.kind === 149 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10434,12 +10605,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10455,9 +10626,9 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: return true; default: @@ -10466,11 +10637,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 72 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 72 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -10485,7 +10656,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 72 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -10494,11 +10665,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 149 /* Parameter */; + return root.kind === 151 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 184 /* BindingElement */) { + while (node.kind === 186 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10506,15 +10677,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 194 /* FunctionExpression */ - || kind === 237 /* FunctionDeclaration */ - || kind === 195 /* ArrowFunction */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 242 /* ModuleDeclaration */ - || kind === 277 /* SourceFile */; + return kind === 157 /* Constructor */ + || kind === 196 /* FunctionExpression */ + || kind === 239 /* FunctionDeclaration */ + || kind === 197 /* ArrowFunction */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 244 /* ModuleDeclaration */ + || kind === 279 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10533,38 +10704,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: return 1 /* Right */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operator) { - case 40 /* AsteriskAsteriskToken */: - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 41 /* AsteriskAsteriskToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 1 /* Right */; } } @@ -10573,15 +10744,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 202 /* BinaryExpression */) { + if (expression.kind === 204 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { + else if (expression.kind === 202 /* PrefixUnaryExpression */ || expression.kind === 203 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10591,116 +10762,116 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return 0; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return 1; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return 2; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return 4; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operatorKind) { - case 26 /* CommaToken */: + case 27 /* CommaToken */: return 0; - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: return 16; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return 17; - case 189 /* CallExpression */: + case 191 /* CallExpression */: return 18; - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 19 : 18; - case 191 /* TaggedTemplateExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 193 /* TaggedTemplateExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 19; - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 71 /* Identifier */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 72 /* Identifier */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 193 /* ParenthesizedExpression */: - case 208 /* OmittedExpression */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 195 /* ParenthesizedExpression */: + case 210 /* OmittedExpression */: return 20; default: return -1; } } ts.getOperatorPrecedence = getOperatorPrecedence; - /* @internal */ function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: return 5; - case 53 /* AmpersandAmpersandToken */: + case 54 /* AmpersandAmpersandToken */: return 6; - case 49 /* BarToken */: + case 50 /* BarToken */: return 7; - case 50 /* CaretToken */: + case 51 /* CaretToken */: return 8; - case 48 /* AmpersandToken */: + case 49 /* AmpersandToken */: return 9; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return 10; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: return 11; - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 37 /* PlusToken */: - case 38 /* MinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: return 13; - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: return 14; - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -10768,7 +10939,7 @@ var ts; if (fileName) { return fileDiagnostics.get(fileName) || []; } - var fileDiags = ts.flatMap(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); + var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); if (!nonFileDiagnostics.length) { return fileDiags; } @@ -10826,7 +10997,7 @@ var ts; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || name.indexOf("-") > -1; + return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { @@ -10909,16 +11080,10 @@ var ts; lineStart = true; } } - function writeTextOfNode(text, node) { - var s = getTextOfNodeFromSourceText(text, node); - write(s); - updateLineCountAndPosFor(s); - } reset(); return { write: write, rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, writeLiteral: writeLiteral, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -10941,10 +11106,77 @@ var ts; writePunctuation: write, writeSpace: write, writeStringLiteral: write, - writeSymbol: write + writeSymbol: function (s, _) { return write(s); }, + writeTrailingSemicolon: write, + writeComment: write }; } ts.createTextWriter = createTextWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var pendingTrailingSemicolon = false; + function commitPendingTrailingSemicolon() { + if (pendingTrailingSemicolon) { + writer.writeTrailingSemicolon(";"); + pendingTrailingSemicolon = false; + } + } + return __assign({}, writer, { writeTrailingSemicolon: function () { + pendingTrailingSemicolon = true; + }, + writeLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeLiteral(s); + }, + writeStringLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeStringLiteral(s); + }, + writeSymbol: function (s, sym) { + commitPendingTrailingSemicolon(); + writer.writeSymbol(s, sym); + }, + writePunctuation: function (s) { + commitPendingTrailingSemicolon(); + writer.writePunctuation(s); + }, + writeKeyword: function (s) { + commitPendingTrailingSemicolon(); + writer.writeKeyword(s); + }, + writeOperator: function (s) { + commitPendingTrailingSemicolon(); + writer.writeOperator(s); + }, + writeParameter: function (s) { + commitPendingTrailingSemicolon(); + writer.writeParameter(s); + }, + writeSpace: function (s) { + commitPendingTrailingSemicolon(); + writer.writeSpace(s); + }, + writeProperty: function (s) { + commitPendingTrailingSemicolon(); + writer.writeProperty(s); + }, + writeComment: function (s) { + commitPendingTrailingSemicolon(); + writer.writeComment(s); + }, + writeLine: function () { + commitPendingTrailingSemicolon(); + writer.writeLine(); + }, + increaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.increaseIndent(); + }, + decreaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.decreaseIndent(); + } }); + } + ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11080,11 +11312,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 72 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 99 /* ThisKeyword */; + return id.originalKeywordKind === 100 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11095,10 +11327,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 157 /* SetAccessor */) { + else if (accessor.kind === 159 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11118,10 +11350,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 156 /* GetAccessor */ && !getAccessor) { + if (member.kind === 158 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 157 /* SetAccessor */ && !setAccessor) { + if (member.kind === 159 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11167,7 +11399,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 === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -11201,13 +11433,13 @@ var ts; function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { if (comments && comments.length > 0) { if (leadingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } var emitInterveningSeparator = false; for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var comment = comments_1[_i]; if (emitInterveningSeparator) { - writer.write(" "); + writer.writeSpace(" "); emitInterveningSeparator = false; } writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); @@ -11219,7 +11451,7 @@ var ts; } } if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } } } @@ -11337,7 +11569,7 @@ var ts; } else { // Single line comment of style //.... - writer.write(text.substring(commentPos, commentEnd)); + writer.writeComment(text.substring(commentPos, commentEnd)); } } ts.writeCommentRange = writeCommentRange; @@ -11346,14 +11578,14 @@ var ts; var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text - writer.write(currentLineText); + writer.writeComment(currentLineText); if (end !== commentEnd) { writer.writeLine(); } } else { // Empty string - make sure we write empty line - writer.writeLiteral(newLine); + writer.rawWrite(newLine); } } function calculateIndent(text, pos, end) { @@ -11407,7 +11639,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 72 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -11415,29 +11647,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 115 /* StaticKeyword */: return 32 /* Static */; - case 114 /* PublicKeyword */: return 4 /* Public */; - case 113 /* ProtectedKeyword */: return 16 /* Protected */; - case 112 /* PrivateKeyword */: return 8 /* Private */; - case 117 /* AbstractKeyword */: return 128 /* Abstract */; - case 84 /* ExportKeyword */: return 1 /* Export */; - case 124 /* DeclareKeyword */: return 2 /* Ambient */; - case 76 /* ConstKeyword */: return 2048 /* Const */; - case 79 /* DefaultKeyword */: return 512 /* Default */; - case 120 /* AsyncKeyword */: return 256 /* Async */; - case 132 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 116 /* StaticKeyword */: return 32 /* Static */; + case 115 /* PublicKeyword */: return 4 /* Public */; + case 114 /* ProtectedKeyword */: return 16 /* Protected */; + case 113 /* PrivateKeyword */: return 8 /* Private */; + case 118 /* AbstractKeyword */: return 128 /* Abstract */; + case 85 /* ExportKeyword */: return 1 /* Export */; + case 125 /* DeclareKeyword */: return 2 /* Ambient */; + case 77 /* ConstKeyword */: return 2048 /* Const */; + case 80 /* DefaultKeyword */: return 512 /* Default */; + case 121 /* AsyncKeyword */: return 256 /* Async */; + case 133 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 54 /* BarBarToken */ - || token === 53 /* AmpersandAmpersandToken */ - || token === 51 /* ExclamationToken */; + return token === 55 /* BarBarToken */ + || token === 54 /* AmpersandAmpersandToken */ + || token === 52 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */; + return token >= 59 /* FirstAssignment */ && token <= 71 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -11450,14 +11682,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 108 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 109 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 58 /* EqualsToken */ + ? node.operatorToken.kind === 59 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -11465,8 +11697,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 186 /* ObjectLiteralExpression */ - || kind === 185 /* ArrayLiteralExpression */; + return kind === 188 /* ObjectLiteralExpression */ + || kind === 187 /* ArrayLiteralExpression */; } return false; } @@ -11476,7 +11708,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 71 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 72 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function isPropertyAccessEntityNameExpression(node) { @@ -11488,17 +11720,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 186 /* ObjectLiteralExpression */ && + return expression.kind === 188 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 185 /* ArrayLiteralExpression */ && + return expression.kind === 187 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11863,8 +12095,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11941,35 +12173,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return accessKind(parent); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 202 /* BinaryExpression */: + return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 204 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 58 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 59 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 273 /* PropertyAssignment */: { + case 275 /* 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 274 /* ShorthandPropertyAssignment */: + case 276 /* 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 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 221 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12072,7 +12304,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 131072 /* Object */ ? type.objectFlags : 0; + return type.flags & 524288 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12343,9 +12575,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 148 /* TypeParameter */) { + if (d && d.kind === 150 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 241 /* InterfaceDeclaration */) { return current; } } @@ -12353,7 +12585,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 157 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12383,14 +12615,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 235 /* VariableDeclaration */) { + if (node.kind === 237 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 236 /* VariableDeclarationList */) { + if (node && node.kind === 238 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 217 /* VariableStatement */) { + if (node && node.kind === 219 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12536,27 +12768,27 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return expr.name; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 193 /* ParenthesizedExpression */: { + case 195 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 231 /* LabeledStatement */: { + case 233 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12580,17 +12812,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return declaration; - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: { + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 146 /* QualifiedName */) { + if (name.kind === 148 /* QualifiedName */) { return name.right; } break; } - case 202 /* BinaryExpression */: { + case 191 /* CallExpression */: + case 204 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -12598,13 +12831,17 @@ var ts; case 5 /* Property */: case 3 /* PrototypeProperty */: return expr.left.name; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return expr.arguments[1]; default: return undefined; } } - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 252 /* ExportAssignment */: { + case 254 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -12806,7 +13043,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12840,684 +13077,688 @@ var ts; return node.kind === 8 /* NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; + function isBigIntLiteral(node) { + return node.kind === 9 /* BigIntLiteral */; + } + ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 9 /* StringLiteral */; + return node.kind === 10 /* StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 12 /* RegularExpressionLiteral */; + return node.kind === 13 /* RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 14 /* TemplateHead */; + return node.kind === 15 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 15 /* TemplateMiddle */; + return node.kind === 16 /* TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 16 /* TemplateTail */; + return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 71 /* Identifier */; + return node.kind === 72 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 146 /* QualifiedName */; + return node.kind === 148 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 147 /* ComputedPropertyName */; + return node.kind === 149 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 148 /* TypeParameter */; + return node.kind === 150 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 149 /* Parameter */; + return node.kind === 151 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 151 /* PropertySignature */; + return node.kind === 153 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 152 /* PropertyDeclaration */; + return node.kind === 154 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 153 /* MethodSignature */; + return node.kind === 155 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 155 /* Constructor */; + return node.kind === 157 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 158 /* CallSignature */; + return node.kind === 160 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 159 /* ConstructSignature */; + return node.kind === 161 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 160 /* IndexSignature */; + return node.kind === 162 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; + return node.kind === 159 /* SetAccessor */ || node.kind === 158 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 161 /* TypePredicate */; + return node.kind === 163 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 162 /* TypeReference */; + return node.kind === 164 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 163 /* FunctionType */; + return node.kind === 165 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 164 /* ConstructorType */; + return node.kind === 166 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 165 /* TypeQuery */; + return node.kind === 167 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 166 /* TypeLiteral */; + return node.kind === 168 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 167 /* ArrayType */; + return node.kind === 169 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 168 /* TupleType */; + return node.kind === 170 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 171 /* UnionType */; + return node.kind === 173 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 172 /* IntersectionType */; + return node.kind === 174 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 173 /* ConditionalType */; + return node.kind === 175 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 174 /* InferType */; + return node.kind === 176 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 175 /* ParenthesizedType */; + return node.kind === 177 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 176 /* ThisType */; + return node.kind === 178 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 177 /* TypeOperator */; + return node.kind === 179 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 178 /* IndexedAccessType */; + return node.kind === 180 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 179 /* MappedType */; + return node.kind === 181 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 180 /* LiteralType */; + return node.kind === 182 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 181 /* ImportType */; + return node.kind === 183 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 182 /* ObjectBindingPattern */; + return node.kind === 184 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 183 /* ArrayBindingPattern */; + return node.kind === 185 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 184 /* BindingElement */; + return node.kind === 186 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 185 /* ArrayLiteralExpression */; + return node.kind === 187 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 186 /* ObjectLiteralExpression */; + return node.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 187 /* PropertyAccessExpression */; + return node.kind === 189 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 188 /* ElementAccessExpression */; + return node.kind === 190 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 189 /* CallExpression */; + return node.kind === 191 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 190 /* NewExpression */; + return node.kind === 192 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 191 /* TaggedTemplateExpression */; + return node.kind === 193 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 192 /* TypeAssertionExpression */; + return node.kind === 194 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 193 /* ParenthesizedExpression */; + return node.kind === 195 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 306 /* PartiallyEmittedExpression */) { + while (node.kind === 308 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 194 /* FunctionExpression */; + return node.kind === 196 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 195 /* ArrowFunction */; + return node.kind === 197 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 196 /* DeleteExpression */; + return node.kind === 198 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 197 /* TypeOfExpression */; + return node.kind === 199 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 198 /* VoidExpression */; + return node.kind === 200 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 199 /* AwaitExpression */; + return node.kind === 201 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 200 /* PrefixUnaryExpression */; + return node.kind === 202 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 201 /* PostfixUnaryExpression */; + return node.kind === 203 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 202 /* BinaryExpression */; + return node.kind === 204 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 203 /* ConditionalExpression */; + return node.kind === 205 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 204 /* TemplateExpression */; + return node.kind === 206 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 205 /* YieldExpression */; + return node.kind === 207 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 206 /* SpreadElement */; + return node.kind === 208 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 207 /* ClassExpression */; + return node.kind === 209 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 208 /* OmittedExpression */; + return node.kind === 210 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 210 /* AsExpression */; + return node.kind === 212 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 211 /* NonNullExpression */; + return node.kind === 213 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 212 /* MetaProperty */; + return node.kind === 214 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 214 /* TemplateSpan */; + return node.kind === 216 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 215 /* SemicolonClassElement */; + return node.kind === 217 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 216 /* Block */; + return node.kind === 218 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 217 /* VariableStatement */; + return node.kind === 219 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 218 /* EmptyStatement */; + return node.kind === 220 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 219 /* ExpressionStatement */; + return node.kind === 221 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 220 /* IfStatement */; + return node.kind === 222 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 221 /* DoStatement */; + return node.kind === 223 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 222 /* WhileStatement */; + return node.kind === 224 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 223 /* ForStatement */; + return node.kind === 225 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 224 /* ForInStatement */; + return node.kind === 226 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 225 /* ForOfStatement */; + return node.kind === 227 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 226 /* ContinueStatement */; + return node.kind === 228 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 227 /* BreakStatement */; + return node.kind === 229 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; + return node.kind === 229 /* BreakStatement */ || node.kind === 228 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 228 /* ReturnStatement */; + return node.kind === 230 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 229 /* WithStatement */; + return node.kind === 231 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 230 /* SwitchStatement */; + return node.kind === 232 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 231 /* LabeledStatement */; + return node.kind === 233 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 232 /* ThrowStatement */; + return node.kind === 234 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 233 /* TryStatement */; + return node.kind === 235 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 234 /* DebuggerStatement */; + return node.kind === 236 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 235 /* VariableDeclaration */; + return node.kind === 237 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 236 /* VariableDeclarationList */; + return node.kind === 238 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 237 /* FunctionDeclaration */; + return node.kind === 239 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 238 /* ClassDeclaration */; + return node.kind === 240 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 239 /* InterfaceDeclaration */; + return node.kind === 241 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 240 /* TypeAliasDeclaration */; + return node.kind === 242 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 241 /* EnumDeclaration */; + return node.kind === 243 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */; + return node.kind === 244 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 243 /* ModuleBlock */; + return node.kind === 245 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 244 /* CaseBlock */; + return node.kind === 246 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 245 /* NamespaceExportDeclaration */; + return node.kind === 247 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */; + return node.kind === 248 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 247 /* ImportDeclaration */; + return node.kind === 249 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 248 /* ImportClause */; + return node.kind === 250 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 249 /* NamespaceImport */; + return node.kind === 251 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 250 /* NamedImports */; + return node.kind === 252 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 251 /* ImportSpecifier */; + return node.kind === 253 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 252 /* ExportAssignment */; + return node.kind === 254 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 253 /* ExportDeclaration */; + return node.kind === 255 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 254 /* NamedExports */; + return node.kind === 256 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 255 /* ExportSpecifier */; + return node.kind === 257 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 256 /* MissingDeclaration */; + return node.kind === 258 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 257 /* ExternalModuleReference */; + return node.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 258 /* JsxElement */; + return node.kind === 260 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 259 /* JsxSelfClosingElement */; + return node.kind === 261 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 260 /* JsxOpeningElement */; + return node.kind === 262 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 261 /* JsxClosingElement */; + return node.kind === 263 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 262 /* JsxFragment */; + return node.kind === 264 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 263 /* JsxOpeningFragment */; + return node.kind === 265 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 264 /* JsxClosingFragment */; + return node.kind === 266 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 265 /* JsxAttribute */; + return node.kind === 267 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 266 /* JsxAttributes */; + return node.kind === 268 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 267 /* JsxSpreadAttribute */; + return node.kind === 269 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 268 /* JsxExpression */; + return node.kind === 270 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 269 /* CaseClause */; + return node.kind === 271 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 270 /* DefaultClause */; + return node.kind === 272 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 271 /* HeritageClause */; + return node.kind === 273 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 272 /* CatchClause */; + return node.kind === 274 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 273 /* PropertyAssignment */; + return node.kind === 275 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 274 /* ShorthandPropertyAssignment */; + return node.kind === 276 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 275 /* SpreadAssignment */; + return node.kind === 277 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 277 /* SourceFile */; + return node.kind === 279 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 278 /* Bundle */; + return node.kind === 280 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 279 /* UnparsedSource */; + return node.kind === 281 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 281 /* JSDocTypeExpression */; + return node.kind === 283 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 282 /* JSDocAllType */; + return node.kind === 284 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 283 /* JSDocUnknownType */; + return node.kind === 285 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 284 /* JSDocNullableType */; + return node.kind === 286 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 285 /* JSDocNonNullableType */; + return node.kind === 287 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 286 /* JSDocOptionalType */; + return node.kind === 288 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 287 /* JSDocFunctionType */; + return node.kind === 289 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 288 /* JSDocVariadicType */; + return node.kind === 290 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 289 /* JSDocComment */; + return node.kind === 291 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 293 /* JSDocAugmentsTag */; + return node.kind === 295 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 294 /* JSDocClassTag */; + return node.kind === 296 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 296 /* JSDocEnumTag */; + return node.kind === 298 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 299 /* JSDocThisTag */; + return node.kind === 301 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 297 /* JSDocParameterTag */; + return node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 298 /* JSDocReturnTag */; + return node.kind === 300 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 300 /* JSDocTypeTag */; + return node.kind === 302 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 301 /* JSDocTemplateTag */; + return node.kind === 303 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 302 /* JSDocTypedefTag */; + return node.kind === 304 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 303 /* JSDocPropertyTag */; + return node.kind === 305 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 303 /* JSDocPropertyTag */ || node.kind === 297 /* JSDocParameterTag */; + return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 290 /* JSDocTypeLiteral */; + return node.kind === 292 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 291 /* JSDocSignature */; + return node.kind === 293 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13528,7 +13769,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 304 /* SyntaxList */; + return n.kind === 306 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13538,7 +13779,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 146 /* FirstNode */; + return kind >= 148 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13547,7 +13788,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 147 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13559,7 +13800,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13569,7 +13810,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; + return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13578,12 +13819,12 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 15 /* TemplateMiddle */ - || kind === 16 /* TemplateTail */; + return kind === 16 /* TemplateMiddle */ + || kind === 17 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isStringTextContainingNode(node) { - return node.kind === 9 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers @@ -13596,17 +13837,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 79 /* DefaultKeyword */: - case 84 /* ExportKeyword */: - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 115 /* StaticKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 80 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 116 /* StaticKeyword */: return true; } return false; @@ -13619,7 +13860,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 115 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 116 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13628,23 +13869,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 9 /* StringLiteral */ + return kind === 72 /* Identifier */ + || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 147 /* ComputedPropertyName */; + || kind === 149 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 182 /* ObjectBindingPattern */ - || kind === 183 /* ArrayBindingPattern */; + return kind === 72 /* Identifier */ + || kind === 184 /* ObjectBindingPattern */ + || kind === 185 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13659,13 +13900,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -13674,14 +13915,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 164 /* ConstructorType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 166 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13696,29 +13937,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 152 /* PropertyDeclaration */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 160 /* IndexSignature */ - || kind === 215 /* SemicolonClassElement */; + return kind === 157 /* Constructor */ + || kind === 154 /* PropertyDeclaration */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 162 /* IndexSignature */ + || kind === 217 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); + return node && (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); + return node && (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; default: return false; @@ -13728,11 +13969,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 159 /* ConstructSignature */ - || kind === 158 /* CallSignature */ - || kind === 151 /* PropertySignature */ - || kind === 153 /* MethodSignature */ - || kind === 160 /* IndexSignature */; + return kind === 161 /* ConstructSignature */ + || kind === 160 /* CallSignature */ + || kind === 153 /* PropertySignature */ + || kind === 155 /* MethodSignature */ + || kind === 162 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13741,37 +13982,38 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 273 /* PropertyAssignment */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 275 /* SpreadAssignment */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 275 /* PropertyAssignment */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 277 /* SpreadAssignment */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) - || kind === 119 /* AnyKeyword */ - || kind === 142 /* UnknownKeyword */ - || kind === 134 /* NumberKeyword */ - || kind === 135 /* ObjectKeyword */ - || kind === 122 /* BooleanKeyword */ - || kind === 137 /* StringKeyword */ - || kind === 138 /* SymbolKeyword */ - || kind === 99 /* ThisKeyword */ - || kind === 105 /* VoidKeyword */ - || kind === 140 /* UndefinedKeyword */ - || kind === 95 /* NullKeyword */ - || kind === 131 /* NeverKeyword */ - || kind === 209 /* ExpressionWithTypeArguments */ - || kind === 282 /* JSDocAllType */ - || kind === 283 /* JSDocUnknownType */ - || kind === 284 /* JSDocNullableType */ - || kind === 285 /* JSDocNonNullableType */ - || kind === 286 /* JSDocOptionalType */ - || kind === 287 /* JSDocFunctionType */ - || kind === 288 /* JSDocVariadicType */; + return (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) + || kind === 120 /* AnyKeyword */ + || kind === 143 /* UnknownKeyword */ + || kind === 135 /* NumberKeyword */ + || kind === 146 /* BigIntKeyword */ + || kind === 136 /* ObjectKeyword */ + || kind === 123 /* BooleanKeyword */ + || kind === 138 /* StringKeyword */ + || kind === 139 /* SymbolKeyword */ + || kind === 100 /* ThisKeyword */ + || kind === 106 /* VoidKeyword */ + || kind === 141 /* UndefinedKeyword */ + || kind === 96 /* NullKeyword */ + || kind === 132 /* NeverKeyword */ + || kind === 211 /* ExpressionWithTypeArguments */ + || kind === 284 /* JSDocAllType */ + || kind === 285 /* JSDocUnknownType */ + || kind === 286 /* JSDocNullableType */ + || kind === 287 /* JSDocNonNullableType */ + || kind === 288 /* JSDocOptionalType */ + || kind === 289 /* JSDocFunctionType */ + || kind === 290 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13784,8 +14026,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return true; } return false; @@ -13796,8 +14038,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 183 /* ArrayBindingPattern */ - || kind === 182 /* ObjectBindingPattern */; + return kind === 185 /* ArrayBindingPattern */ + || kind === 184 /* ObjectBindingPattern */; } return false; } @@ -13805,15 +14047,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 185 /* ArrayLiteralExpression */ - || kind === 186 /* ObjectLiteralExpression */; + return kind === 187 /* ArrayLiteralExpression */ + || kind === 188 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 184 /* BindingElement */ - || kind === 208 /* OmittedExpression */; + return kind === 186 /* BindingElement */ + || kind === 210 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13822,9 +14064,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: return true; } return false; @@ -13845,8 +14087,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return true; } return false; @@ -13858,8 +14100,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return true; } return false; @@ -13868,26 +14110,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */ - || kind === 181 /* ImportType */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */ + || kind === 183 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 150 /* Decorator */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 152 /* Decorator */: return true; default: return false; @@ -13895,13 +14137,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; + return node.kind === 191 /* CallExpression */ || node.kind === 192 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 204 /* TemplateExpression */ - || kind === 13 /* NoSubstitutionTemplateLiteral */; + return kind === 206 /* TemplateExpression */ + || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13911,33 +14153,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 190 /* NewExpression */: - case 189 /* CallExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 191 /* TaggedTemplateExpression */: - case 185 /* ArrayLiteralExpression */: - case 193 /* ParenthesizedExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 71 /* Identifier */: - case 12 /* RegularExpressionLiteral */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 192 /* NewExpression */: + case 191 /* CallExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 193 /* TaggedTemplateExpression */: + case 187 /* ArrayLiteralExpression */: + case 195 /* ParenthesizedExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 72 /* Identifier */: + case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 101 /* TrueKeyword */: - case 97 /* SuperKeyword */: - case 211 /* NonNullExpression */: - case 212 /* MetaProperty */: - case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 102 /* TrueKeyword */: + case 98 /* SuperKeyword */: + case 213 /* NonNullExpression */: + case 214 /* MetaProperty */: + case 92 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13950,13 +14193,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 192 /* TypeAssertionExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 194 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13965,11 +14208,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 43 /* PlusPlusToken */ || - expr.operator === 44 /* MinusMinusToken */; + case 202 /* PrefixUnaryExpression */: + return expr.operator === 44 /* PlusPlusToken */ || + expr.operator === 45 /* MinusMinusToken */; default: return false; } @@ -13986,15 +14229,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: - case 195 /* ArrowFunction */: - case 202 /* BinaryExpression */: - case 206 /* SpreadElement */: - case 210 /* AsExpression */: - case 208 /* OmittedExpression */: - case 307 /* CommaListExpression */: - case 306 /* PartiallyEmittedExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: + case 197 /* ArrowFunction */: + case 204 /* BinaryExpression */: + case 208 /* SpreadElement */: + case 212 /* AsExpression */: + case 210 /* OmittedExpression */: + case 309 /* CommaListExpression */: + case 308 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14002,18 +14245,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 192 /* TypeAssertionExpression */ - || kind === 210 /* AsExpression */; + return kind === 194 /* TypeAssertionExpression */ + || kind === 212 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 306 /* PartiallyEmittedExpression */; + return node.kind === 308 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 305 /* NotEmittedStatement */; + return node.kind === 307 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14024,13 +14267,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return true; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14038,7 +14281,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; + return node.kind === 226 /* ForInStatement */ || node.kind === 227 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14062,113 +14305,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */ - || kind === 71 /* Identifier */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */ + || kind === 72 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 242 /* ModuleDeclaration */; + return kind === 72 /* Identifier */ + || kind === 244 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 250 /* NamedImports */ - || kind === 249 /* NamespaceImport */; + return kind === 252 /* NamedImports */ + || kind === 251 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; + return node.kind === 244 /* ModuleDeclaration */ || node.kind === 243 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 195 /* ArrowFunction */ - || kind === 184 /* BindingElement */ - || kind === 238 /* ClassDeclaration */ - || kind === 207 /* ClassExpression */ - || kind === 155 /* Constructor */ - || kind === 241 /* EnumDeclaration */ - || kind === 276 /* EnumMember */ - || kind === 255 /* ExportSpecifier */ - || kind === 237 /* FunctionDeclaration */ - || kind === 194 /* FunctionExpression */ - || kind === 156 /* GetAccessor */ - || kind === 248 /* ImportClause */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 251 /* ImportSpecifier */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 265 /* JsxAttribute */ - || kind === 154 /* MethodDeclaration */ - || kind === 153 /* MethodSignature */ - || kind === 242 /* ModuleDeclaration */ - || kind === 245 /* NamespaceExportDeclaration */ - || kind === 249 /* NamespaceImport */ - || kind === 149 /* Parameter */ - || kind === 273 /* PropertyAssignment */ - || kind === 152 /* PropertyDeclaration */ - || kind === 151 /* PropertySignature */ - || kind === 157 /* SetAccessor */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 148 /* TypeParameter */ - || kind === 235 /* VariableDeclaration */ - || kind === 302 /* JSDocTypedefTag */ - || kind === 295 /* JSDocCallbackTag */ - || kind === 303 /* JSDocPropertyTag */; + return kind === 197 /* ArrowFunction */ + || kind === 186 /* BindingElement */ + || kind === 240 /* ClassDeclaration */ + || kind === 209 /* ClassExpression */ + || kind === 157 /* Constructor */ + || kind === 243 /* EnumDeclaration */ + || kind === 278 /* EnumMember */ + || kind === 257 /* ExportSpecifier */ + || kind === 239 /* FunctionDeclaration */ + || kind === 196 /* FunctionExpression */ + || kind === 158 /* GetAccessor */ + || kind === 250 /* ImportClause */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 253 /* ImportSpecifier */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 267 /* JsxAttribute */ + || kind === 156 /* MethodDeclaration */ + || kind === 155 /* MethodSignature */ + || kind === 244 /* ModuleDeclaration */ + || kind === 247 /* NamespaceExportDeclaration */ + || kind === 251 /* NamespaceImport */ + || kind === 151 /* Parameter */ + || kind === 275 /* PropertyAssignment */ + || kind === 154 /* PropertyDeclaration */ + || kind === 153 /* PropertySignature */ + || kind === 159 /* SetAccessor */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 150 /* TypeParameter */ + || kind === 237 /* VariableDeclaration */ + || kind === 304 /* JSDocTypedefTag */ + || kind === 297 /* JSDocCallbackTag */ + || kind === 305 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 237 /* FunctionDeclaration */ - || kind === 256 /* MissingDeclaration */ - || kind === 238 /* ClassDeclaration */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 241 /* EnumDeclaration */ - || kind === 242 /* ModuleDeclaration */ - || kind === 247 /* ImportDeclaration */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 253 /* ExportDeclaration */ - || kind === 252 /* ExportAssignment */ - || kind === 245 /* NamespaceExportDeclaration */; + return kind === 239 /* FunctionDeclaration */ + || kind === 258 /* MissingDeclaration */ + || kind === 240 /* ClassDeclaration */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 243 /* EnumDeclaration */ + || kind === 244 /* ModuleDeclaration */ + || kind === 249 /* ImportDeclaration */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 255 /* ExportDeclaration */ + || kind === 254 /* ExportAssignment */ + || kind === 247 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 227 /* BreakStatement */ - || kind === 226 /* ContinueStatement */ - || kind === 234 /* DebuggerStatement */ - || kind === 221 /* DoStatement */ - || kind === 219 /* ExpressionStatement */ - || kind === 218 /* EmptyStatement */ - || kind === 224 /* ForInStatement */ - || kind === 225 /* ForOfStatement */ - || kind === 223 /* ForStatement */ - || kind === 220 /* IfStatement */ - || kind === 231 /* LabeledStatement */ - || kind === 228 /* ReturnStatement */ - || kind === 230 /* SwitchStatement */ - || kind === 232 /* ThrowStatement */ - || kind === 233 /* TryStatement */ - || kind === 217 /* VariableStatement */ - || kind === 222 /* WhileStatement */ - || kind === 229 /* WithStatement */ - || kind === 305 /* NotEmittedStatement */ - || kind === 309 /* EndOfDeclarationMarker */ - || kind === 308 /* MergeDeclarationMarker */; + return kind === 229 /* BreakStatement */ + || kind === 228 /* ContinueStatement */ + || kind === 236 /* DebuggerStatement */ + || kind === 223 /* DoStatement */ + || kind === 221 /* ExpressionStatement */ + || kind === 220 /* EmptyStatement */ + || kind === 226 /* ForInStatement */ + || kind === 227 /* ForOfStatement */ + || kind === 225 /* ForStatement */ + || kind === 222 /* IfStatement */ + || kind === 233 /* LabeledStatement */ + || kind === 230 /* ReturnStatement */ + || kind === 232 /* SwitchStatement */ + || kind === 234 /* ThrowStatement */ + || kind === 235 /* TryStatement */ + || kind === 219 /* VariableStatement */ + || kind === 224 /* WhileStatement */ + || kind === 231 /* WithStatement */ + || kind === 307 /* NotEmittedStatement */ + || kind === 311 /* EndOfDeclarationMarker */ + || kind === 310 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 301 /* JSDocTemplateTag */ || ts.isInJSFile(node); + if (node.kind === 150 /* TypeParameter */) { + return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14195,10 +14438,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 216 /* Block */) + if (node.kind !== 218 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { + if (node.parent.kind === 235 /* TryStatement */ || node.parent.kind === 274 /* CatchClause */) { return false; } } @@ -14208,81 +14451,81 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 257 /* ExternalModuleReference */ - || kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 259 /* ExternalModuleReference */ + || kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 99 /* ThisKeyword */ - || kind === 71 /* Identifier */ - || kind === 187 /* PropertyAccessExpression */; + return kind === 100 /* ThisKeyword */ + || kind === 72 /* Identifier */ + || kind === 189 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 258 /* JsxElement */ - || kind === 268 /* JsxExpression */ - || kind === 259 /* JsxSelfClosingElement */ - || kind === 10 /* JsxText */ - || kind === 262 /* JsxFragment */; + return kind === 260 /* JsxElement */ + || kind === 270 /* JsxExpression */ + || kind === 261 /* JsxSelfClosingElement */ + || kind === 11 /* JsxText */ + || kind === 264 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 265 /* JsxAttribute */ - || kind === 267 /* JsxSpreadAttribute */; + return kind === 267 /* JsxAttribute */ + || kind === 269 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ - || kind === 268 /* JsxExpression */; + return kind === 10 /* StringLiteral */ + || kind === 270 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 260 /* JsxOpeningElement */ - || kind === 259 /* JsxSelfClosingElement */; + return kind === 262 /* JsxOpeningElement */ + || kind === 261 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 269 /* CaseClause */ - || kind === 270 /* DefaultClause */; + return kind === 271 /* CaseClause */ + || kind === 272 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 303 /* LastJSDocNode */; + return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 303 /* LastJSDocTagNode */; + return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14312,12 +14555,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 265 /* JsxAttribute */ || node.kind === 267 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 267 /* JsxAttribute */ || node.kind === 269 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 164 /* TypeReference */ || node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14346,15 +14589,14 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 9 /* StringLiteral */ || node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; })(ts || (ts = {})); /* @internal */ (function (ts) { - /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; + return node.kind === 252 /* NamedImports */ || node.kind === 256 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -14399,10 +14641,9 @@ var ts; getSignatureConstructor: function () { return Signature; }, getSourceMapSourceConstructor: function () { return SourceMapSource; }, }; - /* @internal */ function formatStringFromArgs(text, args, baseIndex) { if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return ts.Debug.assertDefined(args[+index + baseIndex]); }); + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; function getLocaleSpecificMessage(message) { @@ -14431,7 +14672,6 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; - /* @internal */ function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -14456,7 +14696,6 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; - /* @internal */ function createCompilerDiagnosticFromMessageChain(chain) { return { file: undefined, @@ -14493,14 +14732,12 @@ var ts; function getDiagnosticFilePath(diagnostic) { return diagnostic.file ? diagnostic.file.path : undefined; } - /* @internal */ function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; - /* @internal */ function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || @@ -14804,7 +15041,6 @@ var ts; return rootLength > 0 && rootLength === path.length; } ts.isDiskPathRoot = isDiskPathRoot; - /* @internal */ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { return !isRootedDiskPath(absoluteOrRelativePath) ? absoluteOrRelativePath @@ -15769,6 +16005,82 @@ var ts; } } ts.getOrUpdate = getOrUpdate; + /** + * Converts a bigint literal string, e.g. `0x1234n`, + * to its decimal string representation, e.g. `4660`. + */ + function parsePseudoBigInt(stringValue) { + var log2Base; + switch (stringValue.charCodeAt(1)) { // "x" in "0x123" + case 98 /* b */: + case 66 /* B */: // 0b or 0B + log2Base = 1; + break; + case 111 /* o */: + case 79 /* O */: // 0o or 0O + log2Base = 3; + break; + case 120 /* x */: + case 88 /* 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 */) { + nonZeroStart++; + } + return stringValue.slice(nonZeroStart, nIndex) || "0"; + } + // Omit leading "0b", "0o", or "0x", and trailing "n" + var startIndex = 2, endIndex = stringValue.length - 1; + var bitsNeeded = (endIndex - startIndex) * log2Base; + // Stores the value specified by the string as a LE array of 16-bit integers + // using Uint16 instead of Uint32 so combining steps can use bitwise operators + var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0)); + // Add the digits, one at a time + for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) { + 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 */ + : 10 + digitChar - + (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + var shiftedDigit = digit << (bitOffset & 15); + segments[segment] |= shiftedDigit; + var residual = shiftedDigit >>> 16; + if (residual) + segments[segment + 1] |= residual; // overflows segment + } + // Repeatedly divide segments by 10 and add remainder to base10Value + var base10Value = ""; + var firstNonzeroSegment = segments.length - 1; + var segmentsRemaining = true; + while (segmentsRemaining) { + var mod10 = 0; + segmentsRemaining = false; + for (var segment = firstNonzeroSegment; segment >= 0; segment--) { + var newSegment = mod10 << 16 | segments[segment]; + var segmentValue = (newSegment / 10) | 0; + segments[segment] = segmentValue; + mod10 = newSegment - segmentValue * 10; + if (segmentValue && !segmentsRemaining) { + firstNonzeroSegment = segment; + segmentsRemaining = true; + } + } + base10Value = mod10 + base10Value; + } + return base10Value; + } + ts.parsePseudoBigInt = parsePseudoBigInt; + function pseudoBigIntToString(_a) { + var negative = _a.negative, base10Value = _a.base10Value; + return (negative && base10Value !== "0" ? "-" : "") + base10Value; + } + ts.pseudoBigIntToString = pseudoBigIntToString; })(ts || (ts = {})); var ts; (function (ts) { @@ -15788,10 +16100,10 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 277 /* SourceFile */) { + if (kind === 279 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 71 /* Identifier */) { + else if (kind === 72 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -15840,19 +16152,19 @@ 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 <= 145 /* LastToken */) { + if (!node || node.kind <= 147 /* LastToken */) { return; } switch (node.kind) { - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15860,9 +16172,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15870,7 +16182,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15878,51 +16190,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertySignature */: + case 153 /* 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 273 /* PropertyAssignment */: + case 275 /* 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 235 /* VariableDeclaration */: + case 237 /* 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 184 /* BindingElement */: + case 186 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15934,302 +16246,302 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 168 /* TupleType */: + case 170 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 174 /* InferType */: + case 176 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 181 /* ImportType */: + case 183 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 175 /* ParenthesizedType */: - case 177 /* TypeOperator */: + case 177 /* ParenthesizedType */: + case 179 /* TypeOperator */: return visitNode(cbNode, node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 179 /* MappedType */: + case 181 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return visitNode(cbNode, node.literal); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitNode(cbNode, node.name); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return visitNode(cbNode, node.label); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 150 /* Decorator */: + case 152 /* Decorator */: return visitNode(cbNode, node.expression); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 239 /* InterfaceDeclaration */: + case 241 /* 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 240 /* TypeAliasDeclaration */: + case 242 /* 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 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 169 /* OptionalType */: - case 170 /* RestType */: - case 281 /* JSDocTypeExpression */: - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 286 /* JSDocOptionalType */: - case 288 /* JSDocVariadicType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 283 /* JSDocTypeExpression */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 288 /* JSDocOptionalType */: + case 290 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 289 /* JSDocComment */: + case 291 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -16238,17 +16550,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 281 /* JSDocTypeExpression */) { + node.typeExpression.kind === 283 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -16256,20 +16568,20 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 295 /* JSDocCallbackTag */: + case 297 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocThisTag */: + case 301 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocEnumTag */: + case 298 /* JSDocEnumTag */: return visitNode(cbNode, node.typeExpression); - case 291 /* JSDocSignature */: + case 293 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 290 /* JSDocTypeLiteral */: + case 292 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -16277,7 +16589,7 @@ var ts; } } return; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -16495,18 +16807,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(219 /* ExpressionStatement */); + var statement = createNode(221 /* ExpressionStatement */); switch (token()) { - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 38 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 56 /* ColonToken */; })) { + case 39 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -16514,8 +16826,8 @@ var ts; } break; case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 56 /* ColonToken */; })) { + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -16651,7 +16963,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16856,20 +17168,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 71 /* Identifier */) { + if (token() === 72 /* 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() === 116 /* YieldKeyword */ && inYieldContext()) { + if (token() === 117 /* 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() === 121 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 122 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 107 /* LastReservedWord */; + return token() > 108 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -16912,29 +17224,29 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(25 /* SemicolonToken */); + return parseExpected(26 /* SemicolonToken */); } } function createNode(kind, pos) { nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 72 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -16976,7 +17288,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 71 /* Identifier */) { + if (kind === 72 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -16997,9 +17309,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(71 /* Identifier */); + var node = createNode(72 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 71 /* Identifier */) { + if (token() !== 72 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -17008,7 +17320,7 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17018,16 +17330,16 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -17039,13 +17351,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(147 /* ComputedPropertyName */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(149 /* ComputedPropertyName */); + parseExpected(22 /* 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. node.expression = allowInAnd(parseExpression); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -17060,20 +17372,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 83 /* EnumKeyword */; - case 84 /* ExportKeyword */: + return nextToken() === 84 /* EnumKeyword */; + case 85 /* ExportKeyword */: nextToken(); - if (token() === 79 /* DefaultKeyword */) { + if (token() === 80 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier(); - case 79 /* DefaultKeyword */: + return token() !== 40 /* AsteriskToken */ && token() !== 119 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 80 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 115 /* StaticKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -17084,18 +17396,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 21 /* OpenBracketToken */ - || token() === 17 /* OpenBraceToken */ - || token() === 39 /* AsteriskToken */ - || token() === 24 /* DotDotDotToken */ + return token() === 22 /* OpenBracketToken */ + || token() === 18 /* OpenBraceToken */ + || token() === 40 /* AsteriskToken */ + || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ || - token() === 109 /* InterfaceKeyword */ || - (token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 76 /* ClassKeyword */ || token() === 90 /* FunctionKeyword */ || + token() === 110 /* InterfaceKeyword */ || + (token() === 118 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 121 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -17113,9 +17425,9 @@ var ts; // 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() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -17123,17 +17435,17 @@ var ts; // 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() === 25 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: switch (token()) { - case 21 /* OpenBracketToken */: - case 39 /* AsteriskToken */: - case 24 /* DotDotDotToken */: - case 23 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* OpenBracketToken */: + case 40 /* 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`) return true; default: return isLiteralPropertyName(); @@ -17141,11 +17453,11 @@ var ts; case 18 /* RestProperties */: return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* 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() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -17160,37 +17472,39 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern(); case 19 /* TypeParameters */: return isIdentifier(); case 15 /* ArrayLiteralMembers */: - if (token() === 26 /* CommaToken */) { - return true; + 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`) + return true; } // falls through case 11 /* ArgumentExpressions */: - return token() === 24 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); case 17 /* JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); case 20 /* TypeArguments */: case 21 /* TupleElementTypes */: - return token() === 26 /* CommaToken */ || isStartOfType(); + return token() === 27 /* CommaToken */ || isStartOfType(); case 22 /* HeritageClauses */: return isHeritageClause(); case 23 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 17 /* OpenBraceToken */); - if (nextToken() === 18 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* OpenBraceToken */); + if (nextToken() === 19 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -17199,7 +17513,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 86 /* ExtendsKeyword */ || next === 109 /* ImplementsKeyword */; } return true; } @@ -17216,8 +17530,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 108 /* ImplementsKeyword */ || - token() === 85 /* ExtendsKeyword */) { + if (token() === 109 /* ImplementsKeyword */ || + token() === 86 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -17245,37 +17559,37 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 23 /* ImportOrExportSpecifiers */: - return token() === 18 /* CloseBraceToken */; + return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */; + return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 21 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 22 /* CloseBracketToken */; + return token() === 23 /* CloseBracketToken */; case 17 /* JSDocParameters */: case 16 /* Parameters */: case 18 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 20 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 26 /* CommaToken */; + return token() !== 27 /* CommaToken */; case 22 /* HeritageClauses */: - return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */; + return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; + return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -17295,7 +17609,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() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -17465,20 +17779,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 155 /* Constructor */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 215 /* SemicolonClassElement */: + case 157 /* Constructor */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 217 /* SemicolonClassElement */: return true; - case 154 /* MethodDeclaration */: + case 156 /* 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 === 71 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 72 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 124 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -17487,8 +17801,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: return true; } } @@ -17497,58 +17811,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 217 /* VariableStatement */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 219 /* ExpressionStatement */: - case 232 /* ThrowStatement */: - case 228 /* ReturnStatement */: - case 230 /* SwitchStatement */: - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 218 /* EmptyStatement */: - case 233 /* TryStatement */: - case 231 /* LabeledStatement */: - case 221 /* DoStatement */: - case 234 /* DebuggerStatement */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 219 /* VariableStatement */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 221 /* ExpressionStatement */: + case 234 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 232 /* SwitchStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 220 /* EmptyStatement */: + case 235 /* TryStatement */: + case 233 /* LabeledStatement */: + case 223 /* DoStatement */: + case 236 /* DebuggerStatement */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 151 /* PropertySignature */: - case 158 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 153 /* PropertySignature */: + case 160 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 235 /* VariableDeclaration */) { + if (node.kind !== 237 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -17569,7 +17883,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 149 /* Parameter */) { + if (node.kind !== 151 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -17626,7 +17940,7 @@ var ts; var startPos = scanner.getStartPos(); list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -17636,13 +17950,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(26 /* CommaToken */); + parseExpected(27 /* CommaToken */); // 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() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -17693,8 +18007,8 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); - while (parseOptional(23 /* DotToken */)) { - if (token() === 27 /* LessThanToken */) { + while (parseOptional(24 /* DotToken */)) { + if (token() === 28 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -17705,7 +18019,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(146 /* QualifiedName */, entity.pos); + var node = createNode(148 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -17736,33 +18050,33 @@ 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(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(204 /* TemplateExpression */); + var template = createNode(206 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 16 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(214 /* TemplateSpan */); + var span = createNode(216 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 18 /* CloseBraceToken */) { + if (token() === 19 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(16 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */)); + literal = parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -17772,18 +18086,17 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind) { var node = createNode(kind); - var text = scanner.getTokenValue(); - node.text = text; + node.text = scanner.getTokenValue(); if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -17805,24 +18118,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 28 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: { + case 165 /* FunctionType */: + case 166 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17830,20 +18143,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(161 /* TypePredicate */, lhs.pos); + var node = createNode(163 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(176 /* ThisType */); + var node = createNode(178 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(282 /* JSDocAllType */); + var result = createNode(284 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(286 /* JSDocOptionalType */, result); + return createPostfixType(288 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17851,7 +18164,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(285 /* JSDocNonNullableType */); + var result = createNode(287 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17869,66 +18182,66 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 26 /* CommaToken */ || - token() === 18 /* CloseBraceToken */ || - token() === 20 /* CloseParenToken */ || - token() === 29 /* GreaterThanToken */ || - token() === 58 /* EqualsToken */ || - token() === 49 /* BarToken */) { - var result = createNode(283 /* JSDocUnknownType */, pos); + if (token() === 27 /* CommaToken */ || + token() === 19 /* CloseBraceToken */ || + token() === 21 /* CloseParenToken */ || + token() === 30 /* GreaterThanToken */ || + token() === 59 /* EqualsToken */ || + token() === 50 /* BarToken */) { + var result = createNode(285 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(284 /* JSDocNullableType */, pos); + var result = createNode(286 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); nextToken(); - fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { + var parameter = createNode(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */ || token() === 95 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); + var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 58 /* EqualsToken */) { - return createPostfixType(286 /* JSDocOptionalType */, type); + if (token() === 59 /* EqualsToken */) { + return createPostfixType(288 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(165 /* TypeQuery */); - parseExpected(103 /* TypeOfKeyword */); + var node = createNode(167 /* TypeQuery */); + parseExpected(104 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(85 /* ExtendsKeyword */)) { + if (parseOptional(86 /* 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 @@ -17947,39 +18260,39 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(58 /* EqualsToken */)) { + if (parseOptional(59 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 27 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (token() === 28 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(56 /* ColonToken */)) { + if (parseOptional(57 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter(isJSDocParameter) { - return token() === 24 /* DotDotDotToken */ || + return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 /* AtToken */ || + token() === 58 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */) { + var node = createNodeWithJSDoc(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -17994,7 +18307,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(55 /* QuestionToken */); + node.questionToken = parseOptionalToken(56 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18016,16 +18329,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 36 /* EqualsGreaterThanToken */) { + if (returnToken === 37 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(56 /* ColonToken */)) { + else if (parseOptional(57 /* ColonToken */)) { return true; } - else if (isType && token() === 36 /* EqualsGreaterThanToken */) { + else if (isType && token() === 37 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); nextToken(); return true; } @@ -18046,7 +18359,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(19 /* OpenParenToken */)) { + if (!parseExpected(20 /* OpenParenToken */)) { signature.parameters = createMissingList(); return false; } @@ -18059,12 +18372,12 @@ var ts; parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - return parseExpected(20 /* CloseParenToken */); + return parseExpected(21 /* CloseParenToken */); } 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(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -18072,15 +18385,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 159 /* ConstructSignature */) { - parseExpected(94 /* NewKeyword */); + if (kind === 161 /* ConstructSignature */) { + parseExpected(95 /* NewKeyword */); } - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - return token() === 21 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -18100,7 +18413,7 @@ var ts; // [] // nextToken(); - if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) { + if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -18119,39 +18432,39 @@ 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* 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() !== 55 /* QuestionToken */) { + if (token() !== 56 /* 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; + return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 160 /* IndexSignature */; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.kind = 162 /* IndexSignature */; + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 153 /* MethodSignature */; + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.kind = 155 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 151 /* PropertySignature */; + node.kind = 153 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { // 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. @@ -18163,7 +18476,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return true; } var idToken = false; @@ -18173,7 +18486,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -18184,21 +18497,21 @@ 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() === 19 /* OpenParenToken */ || - token() === 27 /* LessThanToken */ || - token() === 55 /* QuestionToken */ || - token() === 56 /* ColonToken */ || - token() === 26 /* CommaToken */ || + return token() === 20 /* OpenParenToken */ || + token() === 28 /* LessThanToken */ || + token() === 56 /* QuestionToken */ || + token() === 57 /* ColonToken */ || + token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(158 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + return parseSignatureMember(160 /* CallSignature */); } - if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(159 /* ConstructSignature */); + if (token() === 95 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(161 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -18209,30 +18522,30 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 23 /* DotToken */; + return nextToken() === 24 /* DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 19 /* OpenParenToken */: - case 27 /* LessThanToken */: - case 23 /* DotToken */: + case 20 /* OpenParenToken */: + case 28 /* LessThanToken */: + case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(166 /* TypeLiteral */); + var node = createNode(168 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { members = createMissingList(); @@ -18241,89 +18554,89 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { - return nextToken() === 132 /* ReadonlyKeyword */; + if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + return nextToken() === 133 /* ReadonlyKeyword */; } - if (token() === 132 /* ReadonlyKeyword */) { + if (token() === 133 /* ReadonlyKeyword */) { nextToken(); } - return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 93 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(92 /* InKeyword */); + parseExpected(93 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(179 /* MappedType */); - parseExpected(17 /* OpenBraceToken */); - if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + var node = createNode(181 /* MappedType */); + parseExpected(18 /* OpenBraceToken */); + if (token() === 133 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { - parseExpectedToken(132 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { + parseExpectedToken(133 /* ReadonlyKeyword */); } } - parseExpected(21 /* OpenBracketToken */); + parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); - parseExpected(22 /* CloseBracketToken */); - if (token() === 55 /* QuestionToken */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + parseExpected(23 /* CloseBracketToken */); + if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 55 /* QuestionToken */) { - parseExpectedToken(55 /* QuestionToken */); + if (node.questionToken.kind !== 56 /* QuestionToken */) { + parseExpectedToken(56 /* QuestionToken */); } } node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(24 /* DotDotDotToken */)) { - var node = createNode(170 /* RestType */, pos); + if (parseOptional(25 /* DotDotDotToken */)) { + var node = createNode(172 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 169 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 171 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + var node = createNode(170 /* TupleType */); + node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(175 /* ParenthesizedType */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(177 /* ParenthesizedType */); + parseExpected(20 /* OpenParenToken */); node.type = parseType(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(94 /* NewKeyword */) ? 164 /* ConstructorType */ : 163 /* FunctionType */; + var kind = parseOptional(95 /* NewKeyword */) ? 166 /* ConstructorType */ : 165 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 23 /* DotToken */ ? undefined : node; + return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(180 /* LiteralType */); + var node = createNode(182 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 38 /* MinusToken */; + unaryMinusExpression = createNode(202 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } - var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */ + var expression = token() === 102 /* TrueKeyword */ || token() === 87 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -18336,79 +18649,82 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 91 /* ImportKeyword */; + return token() === 92 /* ImportKeyword */; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(181 /* ImportType */); - if (parseOptional(103 /* TypeOfKeyword */)) { + var node = createNode(183 /* ImportType */); + if (parseOptional(104 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(91 /* ImportKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(92 /* ImportKeyword */); + parseExpected(20 /* OpenParenToken */); node.argument = parseType(); - parseExpected(20 /* CloseParenToken */); - if (parseOptional(23 /* DotToken */)) { + parseExpected(21 /* CloseParenToken */); + if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } node.typeArguments = tryParseTypeArguments(); return finishNode(node); } - function nextTokenIsNumericLiteral() { - return nextToken() === 8 /* NumericLiteral */; + function nextTokenIsNumericOrBigIntLiteral() { + nextToken(); + return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 138 /* SymbolKeyword */: - case 122 /* BooleanKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 139 /* SymbolKeyword */: + case 123 /* BooleanKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 61 /* AsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 51 /* ExclamationToken */: + case 52 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseLiteralTypeNode(); - case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 105 /* VoidKeyword */: - case 95 /* NullKeyword */: + case 39 /* MinusToken */: + return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); + case 106 /* VoidKeyword */: + case 96 /* NullKeyword */: return parseTokenNode(); - case 99 /* ThisKeyword */: { + case 100 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseTupleType(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportType(); default: return parseTypeReference(); @@ -18416,42 +18732,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 141 /* UniqueKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 103 /* TypeOfKeyword */: - case 131 /* NeverKeyword */: - case 17 /* OpenBraceToken */: - case 21 /* OpenBracketToken */: - case 27 /* LessThanToken */: - case 49 /* BarToken */: - case 48 /* AmpersandToken */: - case 94 /* NewKeyword */: - case 9 /* StringLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 142 /* UniqueKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 104 /* TypeOfKeyword */: + case 132 /* NeverKeyword */: + case 18 /* OpenBraceToken */: + case 22 /* OpenBracketToken */: + case 28 /* LessThanToken */: + case 50 /* BarToken */: + case 49 /* AmpersandToken */: + case 95 /* NewKeyword */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 135 /* ObjectKeyword */: - case 39 /* AsteriskToken */: - case 55 /* QuestionToken */: - case 51 /* ExclamationToken */: - case 24 /* DotDotDotToken */: - case 126 /* InferKeyword */: - case 91 /* ImportKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 136 /* ObjectKeyword */: + case 40 /* AsteriskToken */: + case 56 /* QuestionToken */: + case 52 /* ExclamationToken */: + case 25 /* DotDotDotToken */: + case 127 /* InferKeyword */: + case 92 /* ImportKeyword */: return true; - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return !inStartOfParameter; - case 38 /* MinusToken */: - return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); - case 19 /* OpenParenToken */: + case 39 /* MinusToken */: + return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); + case 20 /* 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); @@ -18461,35 +18779,35 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 20 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 51 /* ExclamationToken */: - type = createPostfixType(285 /* JSDocNonNullableType */, type); + case 52 /* ExclamationToken */: + type = createPostfixType(287 /* JSDocNonNullableType */, type); break; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(284 /* JSDocNullableType */, type); + type = createPostfixType(286 /* JSDocNullableType */, type); break; - case 21 /* OpenBracketToken */: - parseExpected(21 /* OpenBracketToken */); + case 22 /* OpenBracketToken */: + parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(178 /* IndexedAccessType */, type.pos); + var node = createNode(180 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(167 /* ArrayType */, type.pos); + var node = createNode(169 /* ArrayType */, type.pos); node.elementType = type; - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } break; @@ -18506,16 +18824,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(177 /* TypeOperator */); + var node = createNode(179 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(174 /* InferType */); - parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(148 /* TypeParameter */); + var node = createNode(176 /* InferType */); + parseExpected(127 /* InferKeyword */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -18523,10 +18841,10 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 128 /* KeyOfKeyword */: - case 141 /* UniqueKeyword */: + case 129 /* KeyOfKeyword */: + case 142 /* UniqueKeyword */: return parseTypeOperator(operator); - case 126 /* InferKeyword */: + case 127 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -18546,27 +18864,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(174 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(173 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { return true; } - return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 99 /* ThisKeyword */) { + if (isIdentifier() || token() === 100 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) { + if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -18576,7 +18894,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) { + if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -18584,17 +18902,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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || - token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 56 /* QuestionToken */ || token() === 59 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 20 /* CloseParenToken */) { + if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -18606,7 +18924,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(163 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -18617,7 +18935,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -18628,49 +18946,50 @@ var ts; return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 94 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 95 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(173 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(86 /* ExtendsKeyword */)) { + var node = createNode(175 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(55 /* QuestionToken */); + parseExpected(56 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(56 /* ColonToken */) ? parseType() : undefined; + return parseOptional(57 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 19 /* OpenParenToken */: - case 21 /* OpenBracketToken */: - case 17 /* OpenBraceToken */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 94 /* NewKeyword */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 71 /* Identifier */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 20 /* OpenParenToken */: + case 22 /* OpenBracketToken */: + case 18 /* OpenBraceToken */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 95 /* NewKeyword */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 72 /* Identifier */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -18681,18 +19000,18 @@ var ts; return true; } switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 27 /* LessThanToken */: - case 121 /* AwaitKeyword */: - case 116 /* YieldKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 28 /* LessThanToken */: + case 122 /* AwaitKeyword */: + case 117 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -18710,10 +19029,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 17 /* OpenBraceToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && - token() !== 57 /* AtToken */ && + return token() !== 18 /* OpenBraceToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && + token() !== 58 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -18727,7 +19046,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -18736,7 +19055,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(58 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(59 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -18781,7 +19100,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -18797,7 +19116,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 116 /* YieldKeyword */) { + if (token() === 117 /* 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()) { @@ -18826,15 +19145,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(205 /* YieldExpression */); + var node = createNode(207 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 39 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -18845,20 +19164,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(195 /* ArrowFunction */, asyncModifier.pos); + node = createNode(197 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(195 /* ArrowFunction */, identifier.pos); + node = createNode(197 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(149 /* Parameter */, identifier.pos); + var parameter = createNode(151 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -18883,8 +19202,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -18894,10 +19213,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 121 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* 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. @@ -18907,28 +19226,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 19 /* OpenParenToken */) { - if (second === 20 /* CloseParenToken */) { + if (first === 20 /* OpenParenToken */) { + if (second === 21 /* 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 36 /* EqualsGreaterThanToken */: - case 56 /* ColonToken */: - case 17 /* OpenBraceToken */: + case 37 /* EqualsGreaterThanToken */: + case 57 /* ColonToken */: + case 18 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -18940,42 +19259,42 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) { + if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 24 /* DotDotDotToken */) { + if (second === 25 /* DotDotDotToken */) { return 1 /* 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 !== 120 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 121 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 99 /* ThisKeyword */) { + if (!isIdentifier() && second !== 100 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 56 /* ColonToken */: + case 57 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 58 /* EqualsToken */ || token() === 20 /* CloseParenToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 59 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; - case 26 /* CommaToken */: - case 58 /* EqualsToken */: - case 20 /* CloseParenToken */: + case 27 /* CommaToken */: + case 59 /* EqualsToken */: + case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; } @@ -18983,7 +19302,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 27 /* LessThanToken */); + ts.Debug.assert(first === 28 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -18993,17 +19312,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 85 /* ExtendsKeyword */) { + if (third === 86 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 58 /* EqualsToken */: - case 29 /* GreaterThanToken */: + case 59 /* EqualsToken */: + case 30 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 26 /* CommaToken */) { + else if (third === 27 /* CommaToken */) { return true; } return false; @@ -19022,7 +19341,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19035,23 +19354,23 @@ 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() === 120 /* AsyncKeyword */) { + if (token() === 121 /* 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() === 36 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(195 /* ArrowFunction */); + var node = createNodeWithJSDoc(197 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19061,7 +19380,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(56 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -19072,19 +19391,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && token() !== 18 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } - if (token() !== 25 /* SemicolonToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && + if (token() !== 26 /* SemicolonToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -19109,20 +19428,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(55 /* QuestionToken */); + var questionToken = parseOptionalToken(56 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(205 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(56 /* ColonToken */); + node.colonToken = parseExpectedToken(57 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + : createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -19130,7 +19449,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; + return t === 93 /* InKeyword */ || t === 147 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -19159,16 +19478,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() === 40 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 92 /* InKeyword */ && inDisallowInContext()) { + if (token() === 93 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -19189,51 +19508,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 92 /* InKeyword */) { + if (inDisallowInContext() && token() === 93 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(202 /* BinaryExpression */, left.pos); + var node = createNode(204 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(210 /* AsExpression */, left.pos); + var node = createNode(212 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(200 /* PrefixUnaryExpression */); + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(196 /* DeleteExpression */); + var node = createNode(198 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(197 /* TypeOfExpression */); + var node = createNode(199 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(198 /* VoidExpression */); + var node = createNode(200 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 121 /* AwaitKeyword */) { + if (token() === 122 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -19243,7 +19562,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(199 /* AwaitExpression */); + var node = createNode(201 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -19267,7 +19586,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 40 /* AsteriskAsteriskToken */ ? + return token() === 41 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -19284,10 +19603,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 40 /* AsteriskAsteriskToken */) { + if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 194 /* 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 { @@ -19312,23 +19631,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 80 /* DeleteKeyword */: + case 81 /* DeleteKeyword */: return parseDeleteExpression(); - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return parseVoidExpression(); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 121 /* AwaitKeyword */: + case 122 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -19351,16 +19670,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 121 /* AwaitKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 122 /* AwaitKeyword */: return false; - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -19383,21 +19702,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(200 /* PrefixUnaryExpression */); + if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(203 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -19438,7 +19757,7 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 91 /* ImportKeyword */) { + if (token() === 92 /* 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: @@ -19453,8 +19772,8 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(212 /* MetaProperty */, fullStart); - node.keywordToken = 91 /* ImportKeyword */; + var node = createNode(214 /* MetaProperty */, fullStart); + node.keywordToken = 92 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; @@ -19464,7 +19783,7 @@ var ts; } } else { - expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 98 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression. As such, we need to consume the rest of it here to be complete. @@ -19523,22 +19842,22 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* 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. - var node = createNode(187 /* PropertyAccessExpression */, expression.pos); + var node = createNode(189 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 260 /* JsxOpeningElement */) { - var node = createNode(258 /* JsxElement */, opening.pos); + if (opening.kind === 262 /* JsxOpeningElement */) { + var node = createNode(260 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -19547,15 +19866,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 263 /* JsxOpeningFragment */) { - var node = createNode(262 /* JsxFragment */, opening.pos); + else if (opening.kind === 265 /* JsxOpeningFragment */) { + var node = createNode(264 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 261 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -19566,15 +19885,15 @@ 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() === 27 /* LessThanToken */) { + if (inExpressionContext && token() === 28 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(202 /* BinaryExpression */, result.pos); + var badNode = createNode(204 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 + badNode.operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -19582,8 +19901,8 @@ var ts; return result; } function parseJsxText() { - var node = createNode(10 /* JsxText */); - node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */; + var node = createNode(11 /* JsxText */); + node.containsOnlyWhiteSpaces = currentToken === 12 /* JsxTextAllWhiteSpaces */; currentToken = scanner.scanJsxToken(); return finishNode(node); } @@ -19599,15 +19918,15 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 28 /* LessThanSlashToken */: + case 29 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; - case 10 /* JsxText */: - case 11 /* JsxTextAllWhiteSpaces */: + case 11 /* JsxText */: + case 12 /* JsxTextAllWhiteSpaces */: return parseJsxText(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -19628,16 +19947,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(266 /* JsxAttributes */); + var jsxAttributes = createNode(268 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(27 /* LessThanToken */); - if (token() === 29 /* GreaterThanToken */) { + parseExpected(28 /* LessThanToken */); + if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(265 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -19645,23 +19964,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 29 /* GreaterThanToken */) { + if (token() === 30 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(260 /* JsxOpeningElement */, fullStart); + node = createNode(262 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(41 /* SlashToken */); + parseExpected(42 /* SlashToken */); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(259 /* JsxSelfClosingElement */, fullStart); + node = createNode(261 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -19675,10 +19994,10 @@ 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() === 99 /* ThisKeyword */ ? + var expression = token() === 100 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(24 /* DotToken */)) { + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -19686,33 +20005,33 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(268 /* JsxExpression */); - if (!parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(270 /* JsxExpression */); + if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } - if (token() !== 18 /* CloseBraceToken */) { - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + if (token() !== 19 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { - parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(265 /* JsxAttribute */); + var node = createNode(267 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { switch (scanJsxAttributeValue()) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: @@ -19723,72 +20042,72 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(267 /* JsxSpreadAttribute */); - parseExpected(17 /* OpenBraceToken */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(269 /* JsxSpreadAttribute */); + parseExpected(18 /* OpenBraceToken */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(261 /* JsxClosingElement */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(263 /* JsxClosingElement */); + parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(264 /* JsxClosingFragment */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(266 /* JsxClosingFragment */); + parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(192 /* TypeAssertionExpression */); - parseExpected(27 /* LessThanToken */); + var node = createNode(194 /* TypeAssertionExpression */); + parseExpected(28 /* LessThanToken */); node.type = parseType(); - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(23 /* DotToken */); + var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(211 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(213 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { + var indexedAccess = createNode(190 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; - if (token() === 22 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -19797,7 +20116,7 @@ var ts; } indexedAccess.argumentExpression = argument; } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } @@ -19809,13 +20128,13 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; + return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(193 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; - tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); return finishNode(tagExpression); @@ -19823,7 +20142,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { // 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 @@ -19836,15 +20155,15 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(189 /* CallExpression */, expression.pos); + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(189 /* CallExpression */, expression.pos); + else if (token() === 20 /* OpenParenToken */) { + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19854,17 +20173,17 @@ var ts; } } function parseArgumentList() { - parseExpected(19 /* OpenParenToken */); + parseExpected(20 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(27 /* LessThanToken */)) { + if (!parseOptional(28 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(29 /* GreaterThanToken */)) { + if (!parseExpected(30 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -19876,34 +20195,34 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 19 /* OpenParenToken */: // foo( - case 13 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 14 /* TemplateHead */: // foo `...${100}...` + case 20 /* OpenParenToken */: // foo( + case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. - case 23 /* DotToken */: // foo. - case 20 /* CloseParenToken */: // foo) - case 22 /* CloseBracketToken */: // foo] - case 56 /* ColonToken */: // foo: - case 25 /* SemicolonToken */: // foo; - case 55 /* QuestionToken */: // foo? - case 32 /* EqualsEqualsToken */: // foo == - case 34 /* EqualsEqualsEqualsToken */: // foo === - case 33 /* ExclamationEqualsToken */: // foo != - case 35 /* ExclamationEqualsEqualsToken */: // foo !== - case 53 /* AmpersandAmpersandToken */: // foo && - case 54 /* BarBarToken */: // foo || - case 50 /* CaretToken */: // foo ^ - case 48 /* AmpersandToken */: // foo & - case 49 /* BarToken */: // foo | - case 18 /* CloseBraceToken */: // foo } + case 24 /* DotToken */: // foo. + case 21 /* CloseParenToken */: // foo) + case 23 /* CloseBracketToken */: // foo] + case 57 /* ColonToken */: // foo: + case 26 /* SemicolonToken */: // foo; + case 56 /* QuestionToken */: // foo? + case 33 /* EqualsEqualsToken */: // foo == + case 35 /* EqualsEqualsEqualsToken */: // foo === + case 34 /* ExclamationEqualsToken */: // foo != + case 36 /* ExclamationEqualsEqualsToken */: // foo !== + case 54 /* AmpersandAmpersandToken */: // foo && + case 55 /* BarBarToken */: // foo || + case 51 /* CaretToken */: // foo ^ + case 49 /* AmpersandToken */: // foo & + case 50 /* BarToken */: // foo | + case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // 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. return true; - case 26 /* CommaToken */: // foo, - case 17 /* OpenBraceToken */: // foo { + case 27 /* CommaToken */: // foo, + case 18 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -19915,22 +20234,23 @@ var ts; function parsePrimaryExpression() { switch (token()) { case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseTokenNode(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedExpression(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 120 /* AsyncKeyword */: + case 121 /* 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. @@ -19938,76 +20258,76 @@ var ts; break; } return parseFunctionExpression(); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassExpression(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionExpression(); - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) { + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); - parseExpected(19 /* OpenParenToken */); + var node = createNodeWithJSDoc(195 /* ParenthesizedExpression */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(206 /* SpreadElement */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(208 /* SpreadElement */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : + return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* CommaToken */ ? createNode(210 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(185 /* ArrayLiteralExpression */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(187 /* ArrayLiteralExpression */); + parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); - if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 275 /* SpreadAssignment */; + if (parseOptionalToken(25 /* DotDotDotToken */)) { + node.kind = 277 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(51 /* ExclamationToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20015,30 +20335,30 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 274 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(58 /* EqualsToken */); + node.kind = 276 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(59 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 273 /* PropertyAssignment */; - parseExpected(56 /* ColonToken */); + node.kind = 275 /* PropertyAssignment */; + parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(186 /* ObjectLiteralExpression */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(188 /* ObjectLiteralExpression */); + parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -20051,10 +20371,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(194 /* FunctionExpression */); + var node = createNodeWithJSDoc(196 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -20062,7 +20382,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -20074,10 +20394,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(94 /* NewKeyword */); - if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(212 /* MetaProperty */, fullStart); - node_2.keywordToken = 94 /* NewKeyword */; + parseExpected(95 /* NewKeyword */); + if (parseOptional(24 /* DotToken */)) { + var node_2 = createNode(214 /* MetaProperty */, fullStart); + node_2.keywordToken = 95 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } @@ -20093,23 +20413,23 @@ var ts; } break; } - var node = createNode(190 /* NewExpression */, fullStart); + var node = createNode(192 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; - if (node.typeArguments || token() === 19 /* OpenParenToken */) { + if (node.typeArguments || token() === 20 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(216 /* Block */); - if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(218 /* Block */); + if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -20136,52 +20456,52 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(218 /* EmptyStatement */); - parseExpected(25 /* SemicolonToken */); + var node = createNode(220 /* EmptyStatement */); + parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(220 /* IfStatement */); - parseExpected(90 /* IfKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(222 /* IfStatement */); + parseExpected(91 /* IfKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(83 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(221 /* DoStatement */); - parseExpected(81 /* DoKeyword */); + var node = createNode(223 /* DoStatement */); + parseExpected(82 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); // 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(25 /* SemicolonToken */); + parseOptional(26 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(222 /* WhileStatement */); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(224 /* WhileStatement */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(88 /* ForKeyword */); - var awaitToken = parseOptionalToken(121 /* AwaitKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(89 /* ForKeyword */); + var awaitToken = parseOptionalToken(122 /* AwaitKeyword */); + parseExpected(20 /* OpenParenToken */); var initializer; - if (token() !== 25 /* SemicolonToken */) { - if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) { + if (token() !== 26 /* SemicolonToken */) { + if (token() === 105 /* VarKeyword */ || token() === 111 /* LetKeyword */ || token() === 77 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -20189,33 +20509,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(225 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(147 /* OfKeyword */) : parseOptional(147 /* OfKeyword */)) { + var forOfStatement = createNode(227 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(224 /* ForInStatement */, pos); + else if (parseOptional(93 /* InKeyword */)) { + var forInStatement = createNode(226 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(223 /* ForStatement */, pos); + var forStatement = createNode(225 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(25 /* SemicolonToken */); - if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(25 /* SemicolonToken */); - if (token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 21 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -20223,7 +20543,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 229 /* BreakStatement */ ? 73 /* BreakKeyword */ : 78 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -20231,8 +20551,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(228 /* ReturnStatement */); - parseExpected(96 /* ReturnKeyword */); + var node = createNode(230 /* ReturnStatement */); + parseExpected(97 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -20240,42 +20560,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(229 /* WithStatement */); - parseExpected(107 /* WithKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(231 /* WithStatement */); + parseExpected(108 /* WithKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(269 /* CaseClause */); - parseExpected(73 /* CaseKeyword */); + var node = createNode(271 /* CaseClause */); + parseExpected(74 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(270 /* DefaultClause */); - parseExpected(79 /* DefaultKeyword */); - parseExpected(56 /* ColonToken */); + var node = createNode(272 /* DefaultClause */); + parseExpected(80 /* DefaultKeyword */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 74 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(230 /* SwitchStatement */); - parseExpected(98 /* SwitchKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(232 /* SwitchStatement */); + parseExpected(99 /* SwitchKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(244 /* CaseBlock */); - parseExpected(17 /* OpenBraceToken */); + parseExpected(21 /* CloseParenToken */); + var caseBlock = createNode(246 /* CaseBlock */); + parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -20287,32 +20607,32 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(232 /* ThrowStatement */); - parseExpected(100 /* ThrowKeyword */); + var node = createNode(234 /* ThrowStatement */); + parseExpected(101 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(233 /* TryStatement */); - parseExpected(102 /* TryKeyword */); + var node = createNode(235 /* TryStatement */); + parseExpected(103 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 75 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 87 /* FinallyKeyword */) { - parseExpected(87 /* FinallyKeyword */); + if (!node.catchClause || token() === 88 /* FinallyKeyword */) { + parseExpected(88 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(272 /* CatchClause */); - parseExpected(74 /* CatchKeyword */); - if (parseOptional(19 /* OpenParenToken */)) { + var result = createNode(274 /* CatchClause */); + parseExpected(75 /* CatchKeyword */); + if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -20322,8 +20642,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(234 /* DebuggerStatement */); - parseExpected(78 /* DebuggerKeyword */); + var node = createNode(236 /* DebuggerStatement */); + parseExpected(79 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -20333,13 +20653,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 231 /* LabeledStatement */; + if (expression.kind === 72 /* Identifier */ && parseOptional(57 /* ColonToken */)) { + node.kind = 233 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 219 /* ExpressionStatement */; + node.kind = 221 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -20351,25 +20671,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 76 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 90 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* 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 @@ -20392,41 +20712,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 132 /* ReadonlyKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 133 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 144 /* GlobalKeyword */: + case 145 /* GlobalKeyword */: nextToken(); - return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; - case 91 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 72 /* Identifier */ || token() === 85 /* ExportKeyword */; + case 92 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 84 /* ExportKeyword */: + return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 85 /* ExportKeyword */: nextToken(); - if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ || - token() === 118 /* AsKeyword */) { + if (token() === 59 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 80 /* DefaultKeyword */ || + token() === 119 /* AsKeyword */) { return true; } continue; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: nextToken(); continue; default: @@ -20439,50 +20759,50 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 57 /* AtToken */: - case 25 /* SemicolonToken */: - case 17 /* OpenBraceToken */: - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 90 /* IfKeyword */: - case 81 /* DoKeyword */: - case 106 /* WhileKeyword */: - case 88 /* ForKeyword */: - case 77 /* ContinueKeyword */: - case 72 /* BreakKeyword */: - case 96 /* ReturnKeyword */: - case 107 /* WithKeyword */: - case 98 /* SwitchKeyword */: - case 100 /* ThrowKeyword */: - case 102 /* TryKeyword */: - case 78 /* DebuggerKeyword */: + case 58 /* AtToken */: + case 26 /* SemicolonToken */: + case 18 /* OpenBraceToken */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 91 /* IfKeyword */: + case 82 /* DoKeyword */: + case 107 /* WhileKeyword */: + case 89 /* ForKeyword */: + case 78 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 97 /* ReturnKeyword */: + case 108 /* WithKeyword */: + case 99 /* SwitchKeyword */: + case 101 /* ThrowKeyword */: + case 103 /* TryKeyword */: + case 79 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 76 /* ConstKeyword */: - case 84 /* ExportKeyword */: + case 77 /* ConstKeyword */: + case 85 /* ExportKeyword */: return isStartOfDeclaration(); - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 109 /* InterfaceKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 139 /* TypeKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 110 /* InterfaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 140 /* TypeKeyword */: + case 145 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 116 /* StaticKeyword */: + case 133 /* 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); @@ -20492,7 +20812,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */; + return isIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -20501,67 +20821,67 @@ var ts; } function parseStatement() { switch (token()) { - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: return parseEmptyStatement(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); - case 110 /* LetKeyword */: + case 105 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); + case 111 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); } break; - case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); - case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); - case 90 /* IfKeyword */: + case 90 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(239 /* FunctionDeclaration */)); + case 76 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(240 /* ClassDeclaration */)); + case 91 /* IfKeyword */: return parseIfStatement(); - case 81 /* DoKeyword */: + case 82 /* DoKeyword */: return parseDoStatement(); - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return parseWhileStatement(); - case 88 /* ForKeyword */: + case 89 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(226 /* ContinueStatement */); - case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(227 /* BreakStatement */); - case 96 /* ReturnKeyword */: + case 78 /* ContinueKeyword */: + return parseBreakOrContinueStatement(228 /* ContinueStatement */); + case 73 /* BreakKeyword */: + return parseBreakOrContinueStatement(229 /* BreakStatement */); + case 97 /* ReturnKeyword */: return parseReturnStatement(); - case 107 /* WithKeyword */: + case 108 /* WithKeyword */: return parseWithStatement(); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return parseSwitchStatement(); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return parseThrowStatement(); - case 102 /* TryKeyword */: + case 103 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return parseTryStatement(); - case 78 /* DebuggerKeyword */: + case 79 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 57 /* AtToken */: + case 58 /* AtToken */: return parseDeclaration(); - case 120 /* AsyncKeyword */: - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 83 /* EnumKeyword */: - case 84 /* ExportKeyword */: - case 91 /* ImportKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 117 /* AbstractKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 84 /* EnumKeyword */: + case 85 /* ExportKeyword */: + case 92 /* ImportKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 118 /* AbstractKeyword */: + case 116 /* StaticKeyword */: + case 133 /* ReadonlyKeyword */: + case 145 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -20570,7 +20890,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 124 /* DeclareKeyword */; + return modifier.kind === 125 /* DeclareKeyword */; } function parseDeclaration() { var node = createNodeWithJSDoc(0 /* Unknown */); @@ -20589,33 +20909,33 @@ var ts; } function parseDeclarationWorker(node) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: return parseVariableStatement(node); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassDeclaration(node); - case 109 /* InterfaceKeyword */: + case 110 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 139 /* TypeKeyword */: + case 140 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 83 /* EnumKeyword */: + case 84 /* EnumKeyword */: return parseEnumDeclaration(node); - case 144 /* GlobalKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 145 /* GlobalKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: nextToken(); switch (token()) { - case 79 /* DefaultKeyword */: - case 58 /* EqualsToken */: + case 80 /* DefaultKeyword */: + case 59 /* EqualsToken */: return parseExportAssignment(node); - case 118 /* AsKeyword */: + case 119 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -20624,7 +20944,7 @@ var ts; if (node.decorators || node.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(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(258 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -20635,10 +20955,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -20646,25 +20966,25 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 26 /* CommaToken */) { - return createNode(208 /* OmittedExpression */); + if (token() === 27 /* CommaToken */) { + return createNode(210 /* OmittedExpression */); } - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 56 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -20672,27 +20992,27 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(182 /* ObjectBindingPattern */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(184 /* ObjectBindingPattern */); + parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(183 /* ArrayBindingPattern */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(185 /* ArrayBindingPattern */); + parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier(); + return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); @@ -20701,10 +21021,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(235 /* VariableDeclaration */); + var node = createNode(237 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 71 /* Identifier */ && - token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 72 /* Identifier */ && + token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20714,14 +21034,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(236 /* VariableDeclarationList */); + var node = createNode(238 /* VariableDeclarationList */); switch (token()) { - case 104 /* VarKeyword */: + case 105 /* VarKeyword */: break; - case 110 /* LetKeyword */: + case 111 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -20737,7 +21057,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 147 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -20749,44 +21069,44 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 217 /* VariableStatement */; + node.kind = 219 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 237 /* FunctionDeclaration */; - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + node.kind = 239 /* FunctionDeclaration */; + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 155 /* Constructor */; - parseExpected(123 /* ConstructorKeyword */); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + node.kind = 157 /* Constructor */; + parseExpected(124 /* ConstructorKeyword */); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 154 /* MethodDeclaration */; + node.kind = 156 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 152 /* PropertyDeclaration */; - if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 154 /* PropertyDeclaration */; + if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20806,12 +21126,12 @@ var ts; return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.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. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -20819,13 +21139,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 57 /* AtToken */) { + if (token() === 58 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -20842,7 +21162,7 @@ var ts; } nextToken(); } - if (token() === 39 /* AsteriskToken */) { + if (token() === 40 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -20852,24 +21172,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* 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 === 136 /* SetKeyword */ || idToken === 125 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 137 /* SetKeyword */ || idToken === 126 /* 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 19 /* OpenParenToken */: // Method declaration - case 27 /* LessThanToken */: // Generic Method declaration - case 51 /* ExclamationToken */: // Non-null assertion on property name - case 56 /* ColonToken */: // Type Annotation for declaration - case 58 /* EqualsToken */: // Initializer for declaration - case 55 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* OpenParenToken */: // Method declaration + case 28 /* LessThanToken */: // Generic Method declaration + case 52 /* ExclamationToken */: // Non-null assertion on property name + case 57 /* ColonToken */: // Type Annotation for declaration + case 59 /* EqualsToken */: // Initializer for declaration + case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -20887,10 +21207,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(57 /* AtToken */)) { + if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(150 /* Decorator */, decoratorStart); + var decorator = createNode(152 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -20910,7 +21230,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 77 /* 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)) { @@ -20929,7 +21249,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -20939,21 +21259,21 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 25 /* SemicolonToken */) { - var result = createNode(215 /* SemicolonClassElement */); + if (token() === 26 /* SemicolonToken */) { + var result = createNode(217 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - if (token() === 123 /* ConstructorKeyword */) { + if (token() === 124 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); } if (isIndexSignature()) { @@ -20962,37 +21282,37 @@ 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() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 39 /* AsteriskToken */ || - token() === 21 /* OpenBracketToken */) { + token() === 40 /* AsteriskToken */ || + token() === 22 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(node); } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // '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(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 209 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 240 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(75 /* ClassKeyword */); + parseExpected(76 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21010,7 +21330,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 109 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21022,33 +21342,33 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(271 /* HeritageClause */); + ts.Debug.assert(tok === 86 /* ExtendsKeyword */ || tok === 109 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(273 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(209 /* ExpressionWithTypeArguments */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 27 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */) + return token() === 28 /* LessThanToken */ + ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 239 /* InterfaceDeclaration */; - parseExpected(109 /* InterfaceKeyword */); + node.kind = 241 /* InterfaceDeclaration */; + parseExpected(110 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21056,11 +21376,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 240 /* TypeAliasDeclaration */; - parseExpected(139 /* TypeKeyword */); + node.kind = 242 /* TypeAliasDeclaration */; + parseExpected(140 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -21070,18 +21390,18 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(276 /* EnumMember */); + var node = createNodeWithJSDoc(278 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 241 /* EnumDeclaration */; - parseExpected(83 /* EnumKeyword */); + node.kind = 243 /* EnumDeclaration */; + parseExpected(84 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21089,10 +21409,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(243 /* ModuleBlock */); - if (parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(245 /* ModuleBlock */); + if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -21100,20 +21420,20 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 242 /* ModuleDeclaration */; + node.kind = 244 /* ModuleDeclaration */; // 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 */; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(23 /* DotToken */) + node.body = parseOptional(24 /* DotToken */) ? parseModuleOrNamespaceDeclaration(createNode(0 /* Unknown */), 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 242 /* ModuleDeclaration */; - if (token() === 144 /* GlobalKeyword */) { + node.kind = 244 /* ModuleDeclaration */; + if (token() === 145 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -21122,7 +21442,7 @@ var ts; node.name = parseLiteralNode(); node.name.text = internIdentifier(node.name.text); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -21132,68 +21452,68 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 144 /* GlobalKeyword */) { + if (token() === 145 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(130 /* NamespaceKeyword */)) { + else if (parseOptional(131 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(129 /* ModuleKeyword */); - if (token() === 9 /* StringLiteral */) { + parseExpected(130 /* ModuleKeyword */); + if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } } return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 133 /* RequireKeyword */ && + return token() === 134 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 19 /* OpenParenToken */; + return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 41 /* SlashToken */; + return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 245 /* NamespaceExportDeclaration */; - parseExpected(118 /* AsKeyword */); - parseExpected(130 /* NamespaceKeyword */); + node.kind = 247 /* NamespaceExportDeclaration */; + parseExpected(119 /* AsKeyword */); + parseExpected(131 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(91 /* ImportKeyword */); + parseExpected(92 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 144 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 247 /* ImportDeclaration */; + node.kind = 249 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 39 /* AsteriskToken */ || // import * - token() === 17 /* OpenBraceToken */) { // import { + token() === 40 /* AsteriskToken */ || // import * + token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(143 /* FromKeyword */); + parseExpected(144 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 246 /* ImportEqualsDeclaration */; + node.kind = 248 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -21205,7 +21525,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(248 /* ImportClause */, fullStart); + var importClause = createNode(250 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -21214,8 +21534,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); + parseOptional(27 /* CommaToken */)) { + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(252 /* NamedImports */); } return finishNode(importClause); } @@ -21225,15 +21545,15 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(257 /* ExternalModuleReference */); - parseExpected(133 /* RequireKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(259 /* ExternalModuleReference */); + parseExpected(134 /* RequireKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { - if (token() === 9 /* StringLiteral */) { + if (token() === 10 /* StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -21248,9 +21568,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(249 /* NamespaceImport */); - parseExpected(39 /* AsteriskToken */); - parseExpected(118 /* AsKeyword */); + var namespaceImport = createNode(251 /* NamespaceImport */); + parseExpected(40 /* AsteriskToken */); + parseExpected(119 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -21263,14 +21583,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 252 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(255 /* ExportSpecifier */); + return parseImportOrExportSpecifier(257 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(251 /* ImportSpecifier */); + return parseImportOrExportSpecifier(253 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -21284,9 +21604,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(118 /* AsKeyword */); + parseExpected(119 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -21295,24 +21615,24 @@ var ts; else { node.name = identifierName; } - if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 253 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 253 /* ExportDeclaration */; - if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(143 /* FromKeyword */); + node.kind = 255 /* ExportDeclaration */; + if (parseOptional(40 /* AsteriskToken */)) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(254 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(256 /* 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() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(143 /* FromKeyword */); + if (token() === 144 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -21320,12 +21640,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 252 /* ExportAssignment */; - if (parseOptional(58 /* EqualsToken */)) { + node.kind = 254 /* ExportAssignment */; + if (parseOptional(59 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(79 /* DefaultKeyword */); + parseExpected(80 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -21340,10 +21660,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ - || node.kind === 247 /* ImportDeclaration */ - || node.kind === 252 /* ExportAssignment */ - || node.kind === 253 /* ExportDeclaration */ + || node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */ + || node.kind === 249 /* ImportDeclaration */ + || node.kind === 254 /* ExportAssignment */ + || node.kind === 255 /* ExportDeclaration */ ? node : undefined; } @@ -21356,7 +21676,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 91 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 92 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -21407,11 +21727,11 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); + var result = createNode(283 /* JSDocTypeExpression */); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } fixupParentReferences(result); return finishNode(result); @@ -21499,7 +21819,7 @@ var ts; } loop: while (true) { switch (token()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -21519,7 +21839,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -21570,7 +21890,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(289 /* JSDocComment */, start); + var result = createNode(291 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -21604,20 +21924,19 @@ var ts; } } var precedingLineBreak = scanner.hasPrecedingLineBreak(); - while ((precedingLineBreak && token() === 39 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; } - else if (token() === 39 /* AsteriskToken */) { + else if (token() === 40 /* AsteriskToken */) { precedingLineBreak = false; } nextJSDocToken(); } } function parseTag(indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getTokenPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); skipWhitespaceOrAsterisk(); @@ -21625,40 +21944,40 @@ var ts; switch (tagName.escapedText) { case "augments": case "extends": - tag = parseAugmentsTag(atToken, tagName); + tag = parseAugmentsTag(start, tagName); break; case "class": case "constructor": - tag = parseClassTag(atToken, tagName); + tag = parseClassTag(start, tagName); break; case "this": - tag = parseThisTag(atToken, tagName); + tag = parseThisTag(start, tagName); break; case "enum": - tag = parseEnumTag(atToken, tagName); + tag = parseEnumTag(start, tagName); break; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent); + return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, indent); case "return": case "returns": - tag = parseReturnTag(atToken, tagName); + tag = parseReturnTag(start, tagName); break; case "template": - tag = parseTemplateTag(atToken, tagName); + tag = parseTemplateTag(start, tagName); break; case "type": - tag = parseTypeTag(atToken, tagName); + tag = parseTypeTag(start, tagName); break; case "typedef": - tag = parseTypedefTag(atToken, tagName, indent); + tag = parseTypedefTag(start, tagName, indent); break; case "callback": - tag = parseCallbackTag(atToken, tagName, indent); + tag = parseCallbackTag(start, tagName, indent); break; default: - tag = parseUnknownTag(atToken, tagName); + tag = parseUnknownTag(start, tagName); break; } if (!tag.comment) { @@ -21688,7 +22007,7 @@ var ts; } indent = 0; break; - case 57 /* AtToken */: + case 58 /* AtToken */: scanner.setTextPos(scanner.getTextPos() - 1); // falls through case 1 /* EndOfFileToken */: @@ -21707,9 +22026,9 @@ var ts; indent += whitespace.length; } break; - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextJSDocToken() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextJSDocToken(); pushComment(scanner.getTokenText()); @@ -21717,7 +22036,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -21737,9 +22056,8 @@ var ts; removeTrailingWhitespace(comments); return comments.length === 0 ? undefined : comments.join(""); } - function parseUnknownTag(atToken, tagName) { - var result = createNode(292 /* JSDocTag */, atToken.pos); - result.atToken = atToken; + function parseUnknownTag(start, tagName) { + var result = createNode(294 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -21758,37 +22076,37 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { - if (token() === 13 /* NoSubstitutionTemplateLiteral */) { + if (token() === 14 /* NoSubstitutionTemplateLiteral */) { // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild return { name: createIdentifier(/*isIdentifier*/ true), isBracketed: false }; } // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptional(21 /* OpenBracketToken */); + var isBracketed = parseOptional(22 /* OpenBracketToken */); var name = parseJSDocEntityName(); if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(58 /* EqualsToken */)) { + if (parseOptionalToken(59 /* EqualsToken */)) { parseExpression(); } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; } } - function parseParameterOrPropertyTag(atToken, tagName, target, indent) { + function parseParameterOrPropertyTag(start, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); @@ -21798,15 +22116,14 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(303 /* JSDocPropertyTag */, atToken.pos) : - createNode(297 /* JSDocParameterTag */, atToken.pos); - var comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); + createNode(305 /* JSDocPropertyTag */, start) : + createNode(299 /* JSDocParameterTag */, start); + var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; result.name = name; @@ -21817,20 +22134,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) { + if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -21838,81 +22155,74 @@ var ts; } } } - function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 298 /* JSDocReturnTag */; })) { + function parseReturnTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(298 /* JSDocReturnTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(300 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } - function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocTypeTag */; })) { + function parseTypeTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocTypeTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(302 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } - function parseAugmentsTag(atToken, tagName) { - var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); - result.atToken = atToken; + function parseAugmentsTag(start, tagName) { + var result = createNode(295 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(209 /* ExpressionWithTypeArguments */); + var usedBrace = parseOptional(18 /* OpenBraceToken */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); if (usedBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var prop = createNode(187 /* PropertyAccessExpression */, node.pos); + while (parseOptional(24 /* DotToken */)) { + var prop = createNode(189 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); } return node; } - function parseClassTag(atToken, tagName) { - var tag = createNode(294 /* JSDocClassTag */, atToken.pos); - tag.atToken = atToken; + function parseClassTag(start, tagName) { + var tag = createNode(296 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } - function parseThisTag(atToken, tagName) { - var tag = createNode(299 /* JSDocThisTag */, atToken.pos); - tag.atToken = atToken; + function parseThisTag(start, tagName) { + var tag = createNode(301 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseEnumTag(atToken, tagName) { - var tag = createNode(296 /* JSDocEnumTag */, atToken.pos); - tag.atToken = atToken; + function parseEnumTag(start, tagName) { + var tag = createNode(298 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseTypedefTag(atToken, tagName, indent) { + function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); - typedefTag.atToken = atToken; + var typedefTag = createNode(304 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -21924,12 +22234,11 @@ var ts; var child = void 0; var jsdocTypeLiteral = void 0; var childTypeTag = void 0; - var start_3 = atToken.pos; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); } - if (child.kind === 300 /* JSDocTypeTag */) { + if (child.kind === 302 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21942,7 +22251,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -21960,8 +22269,8 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); + if (parseOptional(24 /* DotToken */)) { + var jsDocNamespaceNode = createNode(244 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21974,25 +22283,23 @@ var ts; } return typeNameOrNamespaceName; } - function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); - callbackTag.atToken = atToken; + function parseCallbackTag(start, tagName, indent) { + var callbackTag = createNode(297 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var start = scanner.getStartPos(); - var jsdocSignature = createNode(291 /* JSDocSignature */, start); + var jsdocSignature = createNode(293 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(57 /* AtToken */)) { + if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 298 /* JSDocReturnTag */) { + if (tag && tag.kind === 300 /* JSDocReturnTag */) { return tag; } } @@ -22034,10 +22341,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextJSDocToken()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) && + if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22050,13 +22357,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -22065,16 +22372,15 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getStartPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); skipWhitespace(); var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(atToken, tagName); + return target === 1 /* Property */ && parseTypeTag(start, tagName); case "prop": case "property": t = 1 /* Property */; @@ -22090,26 +22396,25 @@ var ts; if (!(target & t)) { return false; } - return parseParameterOrPropertyTag(atToken, tagName, target, indent); + return parseParameterOrPropertyTag(start, tagName, target, indent); } - function parseTemplateTag(atToken, tagName) { + function parseTemplateTag(start, tagName) { // the template tag looks like '@template {Constraint} T,U,V' var constraint; - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(148 /* TypeParameter */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); - } while (parseOptionalJsdoc(26 /* CommaToken */)); - var result = createNode(301 /* JSDocTemplateTag */, atToken.pos); - result.atToken = atToken; + } while (parseOptionalJsdoc(27 /* CommaToken */)); + var result = createNode(303 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22128,16 +22433,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* 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(23 /* DotToken */)) { + while (parseOptional(24 /* DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -22145,11 +22450,11 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(71 /* Identifier */, pos); + var result = createNode(72 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); nextJSDocToken(); @@ -22275,9 +22580,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 71 /* Identifier */: + case 72 /* Identifier */: return true; } return false; @@ -22855,10 +23160,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 71 /* Identifier */) { + if (lhs.kind === 72 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 99 /* ThisKeyword */) { + if (lhs.kind === 100 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -22915,7 +23220,8 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], - ["esnext.intl", "lib.esnext.intl.d.ts"] + ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.bigint", "lib.esnext.bigint.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -22972,6 +23278,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, { name: "traceResolution", type: "boolean", @@ -23022,11 +23335,11 @@ var ts; description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date }, { - name: "pretty", + name: "showConfig", type: "boolean", - showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + isCommandLineOnly: true, + description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, // Basic { @@ -23619,7 +23932,7 @@ var ts; { name: "maxNodeModuleJsDepth", type: "number", - // TODO: GH#27108 affectsModuleResolution: true, + affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, @@ -24075,6 +24388,9 @@ var ts; } var result = ts.parseJsonText(configFileName, configFileText); var cwd = host.getCurrentDirectory(); + result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd)); } ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile; @@ -24214,7 +24530,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 273 /* PropertyAssignment */) { + if (element.kind !== 275 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -24270,16 +24586,16 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 101 /* TrueKeyword */: + case 102 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -24296,13 +24612,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 200 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 202 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -24319,7 +24635,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -24359,6 +24675,115 @@ var ts; } return false; } + /** + * Generate an uncommented, complete tsconfig for use with "--showConfig" + * @param configParseResult options to be generated into tsconfig.json + * @param configFileName name of the parsed config file - output paths will be generated relative to this + * @param host provides current directory and case sensitivity services + */ + /** @internal */ + function convertToTSConfig(configParseResult, configFileName, host) { + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var files = ts.map(ts.filter(configParseResult.fileNames, !configParseResult.configFileSpecs ? function (_) { return false; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), f, getCanonicalFileName); }); + var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); + var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var _a; + return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), + exclude: configParseResult.configFileSpecs.validatedExcludeSpecs + } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + return config; + } + ts.convertToTSConfig = convertToTSConfig; + function filterSameAsDefaultInclude(specs) { + if (!ts.length(specs)) + return undefined; + if (ts.length(specs) !== 1) + return specs; + if (specs[0] === "**/*") + return undefined; + return specs; + } + function matchesSpecs(path, includeSpecs, excludeSpecs) { + if (!includeSpecs) + return function (_) { return false; }; + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + if (includeRe) { + if (excludeRe) { + return function (path) { return includeRe.test(path) && !excludeRe.test(path); }; + } + return function (path) { return includeRe.test(path); }; + } + if (excludeRe) { + return function (path) { return !excludeRe.test(path); }; + } + return function (_) { return false; }; + } + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + // this is of a type CommandLineOptionOfPrimitiveType + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + // There is a typeMap associated with this command-line option so use it to map value back to its name + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options, pathOptions) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); + var _loop_3 = function (name) { + if (ts.hasProperty(options, name)) { + // tsconfig only options cannot be specified via command line, + // so we can assume that only types that can appear here string | number | boolean + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + return "continue"; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap_1) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + if (pathOptions && optionDefinition.isFilePath) { + result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)); + } + else { + result.set(name, value); + } + } + else { + if (optionDefinition.type === "list") { + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 + } + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); + } + } + } + } + }; + for (var name in options) { + _loop_3(name); + } + return result; + } /** * Generate tsconfig configuration when running command line "--init" * @param options commandlineOptions to be generated into tsconfig.json @@ -24369,62 +24794,6 @@ var ts; var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var compilerOptionsMap = serializeCompilerOptions(compilerOptions); return writeConfigurations(); - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - // this is of a type CommandLineOptionOfPrimitiveType - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - // There is a typeMap associated with this command-line option so use it to map value back to its name - return ts.forEachEntry(customTypeMap, function (mapValue, key) { - if (mapValue === value) { - return key; - } - }); - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - var _loop_3 = function (name) { - if (ts.hasProperty(options, name)) { - // tsconfig only options cannot be specified via command line, - // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { - return "continue"; - } - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap_1) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result.set(name, value); - } - else { - if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); - } - } - } - } - }; - for (var name in options) { - _loop_3(name); - } - return result; - } function getDefaultValueForOption(option) { switch (option.type) { case "number": @@ -24813,20 +25182,24 @@ var ts; } function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) { extendedConfig = ts.normalizeSlashes(extendedConfig); - // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../"))) { - errors.push(createDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return undefined; - } - var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return undefined; + 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 */)) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; + } } + return extendedConfigPath; } - return extendedConfigPath; + // If the path isn't a rooted or relative path, resolve like a module + var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, /*cache*/ undefined, /*projectRefs*/ undefined, /*lookupConfig*/ true); + if (resolved.resolvedModule) { + return resolved.resolvedModule.resolvedFileName; + } + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; } function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors) { var _a; @@ -25276,7 +25649,7 @@ var ts; } } /** - * Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed. + * Produces a cleaned version of compiler options with personally identifying info (aka, paths) removed. * Also converts enum values back to strings. */ /* @internal */ @@ -25347,7 +25720,8 @@ var ts; Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; - Extensions[Extensions["DtsOnly"] = 3] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -25393,6 +25767,9 @@ var ts; return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state) || readPackageJsonPathField(jsonContent, "types", baseDirectory, state); } + function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) { + return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state); + } function readPackageJsonMainField(jsonContent, baseDirectory, state) { return readPackageJsonPathField(jsonContent, "main", baseDirectory, state); } @@ -25492,8 +25869,11 @@ var 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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { var traceEnabled = isTraceEnabled(options, host); + if (redirectedReference) { + options = redirectedReference.commandLine.options; + } var failedLookupLocations = []; var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -25514,6 +25894,9 @@ var ts; trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); } } + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var resolved = primaryLookup(); var primary = true; @@ -25523,13 +25906,12 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - if (!options.preserveSymlinks) { - resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); - } + var fileName = resolved.fileName, packageId = resolved.packageId; + var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -25538,7 +25920,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - return ts.forEach(typeRoots, function (typeRoot) { + return ts.firstDefined(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); var directoryExists = ts.directoryProbablyExists(candidateDirectory, host); @@ -25563,13 +25945,14 @@ var ts; } var result = void 0; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { - result = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined); + var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); + result = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = toSearchResult(nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true)); + result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - var resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25629,29 +26012,56 @@ var ts; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { - return createModuleResolutionCacheWithMaps(ts.createMap(), ts.createMap(), currentDirectory, getCanonicalFileName); + return createModuleResolutionCacheWithMaps(createCacheWithRedirects(), createCacheWithRedirects(), currentDirectory, getCanonicalFileName); } ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ + function createCacheWithRedirects() { + var ownMap = ts.createMap(); + var redirectsMap = ts.createMap(); + return { + ownMap: ownMap, + redirectsMap: redirectsMap, + getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, + clear: clear + }; + function getOrCreateMapOfCacheRedirects(redirectedReference) { + if (!redirectedReference) { + return ownMap; + } + var path = redirectedReference.sourceFile.path; + var redirects = redirectsMap.get(path); + if (!redirects) { + redirects = ts.createMap(); + redirectsMap.set(path, redirects); + } + return redirects; + } + function clear() { + ownMap.clear(); + redirectsMap.clear(); + } + } + ts.createCacheWithRedirects = createCacheWithRedirects; + /*@internal*/ function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; - function getOrCreateCacheForDirectory(directoryName) { + function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - var perFolderCache = directoryToModuleNameMap.get(path); - if (!perFolderCache) { - perFolderCache = ts.createMap(); - directoryToModuleNameMap.set(path, perFolderCache); - } - return perFolderCache; + return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap); } - function getOrCreateCacheForModuleName(nonRelativeModuleName) { + function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); - if (!perModuleNameCache) { - perModuleNameCache = createPerModuleNameCache(); - moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); } - return perModuleNameCache; + return result; } function createPerModuleNameCache() { var directoryPathMap = ts.createMap(); @@ -25726,13 +26136,19 @@ var ts; return perFolderCache && perFolderCache.get(moduleName); } ts.resolveModuleNameFromCache = resolveModuleNameFromCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); + if (redirectedReference) { + compilerOptions = redirectedReference.commandLine.options; + } if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var containingDirectory = ts.getDirectoryPath(containingFile); - var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference); var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -25754,10 +26170,10 @@ var ts; } switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); @@ -25766,7 +26182,7 @@ var ts; perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { // put result in per-module name cache - cache.getOrCreateCacheForModuleName(moduleName).set(containingDirectory, result); + cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result); } } } @@ -25842,6 +26258,9 @@ var ts; * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. */ function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) { + var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state); + if (resolved) + return resolved.value; if (!ts.isExternalModuleNameRelative(moduleName)) { return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state); } @@ -25849,6 +26268,16 @@ var ts; return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state); } } + function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { + var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + if (baseUrl && paths && !ts.pathIsRelative(moduleName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); + } + } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { if (!state.compilerOptions.rootDirs) { return undefined; @@ -25918,22 +26347,13 @@ var ts; return undefined; } function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var baseUrl = state.compilerOptions.baseUrl; if (!baseUrl) { return undefined; } if (state.traceEnabled) { trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); } - if (paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - var resolved = tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); - if (resolved) { - return resolved.value; - } - } var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName)); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate); @@ -25960,22 +26380,22 @@ var ts; return resolvedModule && resolvedModule.resolvedFileName; } ts.tryResolveJSModule = tryResolveJSModule; + var jsOnlyExtensions = [Extensions.JavaScript]; + var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; + var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { - return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true); + return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false); + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { + return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, jsOnly) { + function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; - var result = jsOnly ? - tryResolve(Extensions.JavaScript) : - (tryResolve(Extensions.TypeScript) || - tryResolve(Extensions.JavaScript) || - (compilerOptions.resolveJsonModule ? tryResolve(Extensions.Json) : undefined)); + var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); @@ -25985,13 +26405,13 @@ var ts; var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); if (resolved) { - return toSearchResult({ resolved: resolved, isExternalLibraryImport: ts.stringContains(resolved.path, ts.nodeModulesPathPart) }); + return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) }); } if (!ts.isExternalModuleNameRelative(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache); + var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved_1) return undefined; var resolvedValue = resolved_1.value; @@ -26057,6 +26477,11 @@ var ts; } /*@internal*/ ts.nodeModulesPathPart = "/node_modules/"; + /*@internal*/ + function pathContainsNodeModules(path) { + return ts.stringContains(path, ts.nodeModulesPathPart); + } + ts.pathContainsNodeModules = pathContainsNodeModules; /** * This will be called on the successfully resolved path from `loadModuleFromFile`. * (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.) @@ -26107,9 +26532,9 @@ var ts; * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { - if (extensions === Extensions.Json) { + if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, onlyRecordFailures, state); + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); @@ -26143,6 +26568,7 @@ var ts; return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); case Extensions.JavaScript: return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + case Extensions.TSConfig: case Extensions.Json: return tryExtension(".json" /* Json */); } @@ -26227,11 +26653,27 @@ var ts; } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { - var packageFile = jsonContent && (extensions !== Extensions.JavaScript && extensions !== Extensions.Json - ? readPackageJsonTypesFields(jsonContent, candidate, state) || - // When resolving typescript modules, try resolving using main field as well - (extensions === Extensions.TypeScript ? readPackageJsonMainField(jsonContent, candidate, state) : undefined) - : readPackageJsonMainField(jsonContent, candidate, state)); + var packageFile; + if (jsonContent) { + switch (extensions) { + case Extensions.JavaScript: + case Extensions.Json: + packageFile = readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.TypeScript: + // When resolving typescript modules, try resolving using main field as well + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.DtsOnly: + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state); + break; + case Extensions.TSConfig: + packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state); + break; + default: + return ts.Debug.assertNever(extensions); + } + } var loader = function (extensions, candidate, onlyRecordFailures, state) { var fromFile = tryFile(candidate, onlyRecordFailures, state); if (fromFile) { @@ -26250,7 +26692,7 @@ var ts; }; var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined; var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host); - var indexPath = ts.combinePaths(candidate, "index"); + var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index"); if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) { var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, /*ignoreCase*/ false); if (state.traceEnabled) { @@ -26277,6 +26719,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + case Extensions.TSConfig: case Extensions.Json: return extension === ".json" /* Json */; case Extensions.TypeScript: @@ -26294,15 +26737,15 @@ var ts; return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } ts.parsePackageName = parsePackageName; - function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache) { - return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache); + function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) { + return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference); } function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined); + return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined); } - function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state); @@ -26323,7 +26766,7 @@ var ts; if (packageResult) { return packageResult; } - if (extensions !== Extensions.JavaScript && extensions !== Extensions.Json) { + if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) { var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); var nodeModulesAtTypesExists = nodeModulesFolderExists; if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { @@ -26456,7 +26899,7 @@ var ts; return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + 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 }; @@ -26470,7 +26913,7 @@ var ts; return { value: resolvedUsingSettings }; } if (!ts.isExternalModuleNameRelative(moduleName)) { - var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName); + var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); // Climb up parent directories looking for a module. var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); @@ -26536,24 +26979,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 243 /* ModuleBlock */: { + case 245 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -26575,9 +27018,9 @@ var ts; }); return state_1; } - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(node); - case 71 /* Identifier */: + case 72 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -26738,7 +27181,7 @@ var ts; // 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 === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -26747,7 +27190,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -26759,36 +27202,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "__constructor" /* Constructor */; - case 163 /* FunctionType */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: return "__call" /* Call */; - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return "__new" /* New */; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "__index" /* Index */; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 149 /* Parameter */: + case 151 /* 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 === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (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; @@ -26886,7 +27329,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 === 252 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 254 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; } @@ -26913,7 +27356,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 257 /* ExportSpecifier */ || (node.kind === 248 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -26980,7 +27423,7 @@ var ts; // 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 !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -27012,7 +27455,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property intialization checks. - currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 157 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -27025,13 +27468,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -27074,8 +27517,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -27108,78 +27551,78 @@ var ts; return; } switch (node.kind) { - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: bindWhileStatement(node); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: bindDoStatement(node); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: bindForStatement(node); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: bindIfStatement(node); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: bindTryStatement(node); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: bindSwitchStatement(node); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: bindCaseBlock(node); break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: bindCaseClause(node); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: bindLabeledStatement(node); break; - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 277 /* SourceFile */: { + case 279 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -27190,26 +27633,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return hasNarrowableArgument(expr); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 200 /* PrefixUnaryExpression */: - return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 197 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 199 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || + return expr.kind === 72 /* Identifier */ || expr.kind === 100 /* ThisKeyword */ || expr.kind === 98 /* SuperKeyword */ || ts.isPropertyAccessExpression(expr) && isNarrowableReference(expr.expression) || ts.isElementAccessExpression(expr) && expr.argumentExpression && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && @@ -27224,7 +27667,7 @@ var ts; } } } - if (expr.expression.kind === 187 /* PropertyAccessExpression */ && + if (expr.expression.kind === 189 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -27238,32 +27681,32 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableReference(expr.left); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -27298,8 +27741,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 101 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 86 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 102 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 87 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -27337,34 +27780,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return parent.expression === node; - case 223 /* ForStatement */: - case 203 /* ConditionalExpression */: + case 225 /* ForStatement */: + case 205 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 193 /* ParenthesizedExpression */) { + if (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 202 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 54 /* BarBarToken */); + return node.kind === 204 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 193 /* ParenthesizedExpression */ || - node.parent.kind === 200 /* PrefixUnaryExpression */ && - node.parent.operator === 51 /* ExclamationToken */) { + while (node.parent.kind === 195 /* ParenthesizedExpression */ || + node.parent.kind === 202 /* PrefixUnaryExpression */ && + node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -27405,7 +27848,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 233 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -27439,13 +27882,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 225 /* ForOfStatement */) { + if (node.kind === 227 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 236 /* VariableDeclarationList */) { + if (node.initializer.kind !== 238 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -27467,7 +27910,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 228 /* ReturnStatement */) { + if (node.kind === 230 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -27487,7 +27930,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 229 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -27583,7 +28026,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 272 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -27650,14 +28093,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 223 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -27668,10 +28111,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 185 /* ArrayLiteralExpression */) { + else if (node.kind === 187 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 206 /* SpreadElement */) { + if (e.kind === 208 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -27679,16 +28122,16 @@ var ts; } } } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 273 /* PropertyAssignment */) { + if (p.kind === 275 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 274 /* ShorthandPropertyAssignment */) { + else if (p.kind === 276 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 275 /* SpreadAssignment */) { + else if (p.kind === 277 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -27696,7 +28139,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -27707,7 +28150,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 51 /* ExclamationToken */) { + if (node.operator === 52 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -27717,20 +28160,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -27744,7 +28187,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { + if (operator === 59 /* EqualsToken */ && node.left.kind === 190 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27755,7 +28198,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -27802,10 +28245,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 193 /* ParenthesizedExpression */) { + while (expr.kind === 195 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { + if (expr.kind === 196 /* FunctionExpression */ || expr.kind === 197 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -27813,7 +28256,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27822,54 +28265,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 266 /* JsxAttributes */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 268 /* JsxAttributes */: return 1 /* IsContainer */; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 287 /* JSDocFunctionType */: - case 163 /* FunctionType */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 164 /* ConstructorType */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 289 /* JSDocFunctionType */: + case 165 /* FunctionType */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 166 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 272 /* CatchClause */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 244 /* CaseBlock */: + case 274 /* CatchClause */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 246 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 216 /* Block */: + case 218 /* 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 @@ -27902,45 +28345,45 @@ 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 186 /* ObjectLiteralExpression */: - case 239 /* InterfaceDeclaration */: - case 266 /* JsxAttributes */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 188 /* ObjectLiteralExpression */: + case 241 /* InterfaceDeclaration */: + case 268 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 291 /* JSDocSignature */: - case 160 /* IndexSignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 287 /* JSDocFunctionType */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 293 /* JSDocSignature */: + case 162 /* IndexSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 242 /* TypeAliasDeclaration */: + case 181 /* 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 @@ -27961,11 +28404,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 277 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { + var body = node.kind === 279 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { + if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { return true; } } @@ -27993,7 +28436,7 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 9 /* StringLiteral */) { + if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; if (ts.hasZeroOrOneAsteriskCharacter(text)) { pattern = ts.tryParsePattern(text); @@ -28049,7 +28492,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 277 /* SpreadAssignment */ || prop.name.kind !== 72 /* Identifier */) { continue; } var identifier = prop.name; @@ -28061,7 +28504,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 275 /* PropertyAssignment */ || prop.kind === 276 /* ShorthandPropertyAssignment */ || prop.kind === 156 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -28093,10 +28536,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28127,7 +28570,7 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) { + if (!typeAlias.fullName || typeAlias.fullName.kind === 72 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); } @@ -28145,8 +28588,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 108 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 116 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 109 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 117 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !(node.flags & 4194304 /* Ambient */)) { // Report error only if there are no parse errors in file @@ -28182,7 +28625,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 71 /* Identifier */) { + if (inStrictMode && node.expression.kind === 72 /* 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); @@ -28193,7 +28636,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 71 /* Identifier */) { + if (name && name.kind === 72 /* 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 @@ -28234,8 +28677,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 277 /* SourceFile */ && - blockScopeContainer.kind !== 242 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 279 /* SourceFile */ && + blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -28261,7 +28704,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -28330,7 +28773,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 145 /* LastToken */) { + if (node.kind > 147 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -28392,7 +28835,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 71 /* Identifier */: + case 72 /* 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. @@ -28405,13 +28848,13 @@ var ts; break; } // falls through - case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { + case 100 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 276 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -28425,7 +28868,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -28450,142 +28893,155 @@ var ts; // Nothing to do break; default: - ts.Debug.fail("Unknown special property assignment kind"); + ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return checkStrictModeCatchClause(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkStrictModeWithStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 176 /* ThisType */: + case 178 /* ThisType */: seenThisKeyword = true; return; - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: break; // Binding the children will handle everything - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return bindTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return bindParameter(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return bindPropertyWorker(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* 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 */ : 67212223 /* MethodExcludes */); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: + case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 179 /* MappedType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 181 /* MappedType */: return bindAnonymousTypeWorker(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return bindFunctionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: + var assignmentKind = ts.getAssignmentDeclarationKind(node); + switch (assignmentKind) { + case 7 /* ObjectDefinePropertyValue */: + return bindObjectDefinePropertyAssignment(node); + case 8 /* ObjectDefinePropertyExports */: + return bindObjectDefinePropertyExport(node); + case 9 /* ObjectDefinePrototypeProperty */: + return bindObjectDefinePrototypeProperty(node); + case 0 /* None */: + break; // Nothing to do + default: + return ts.Debug.fail("Unknown call expression assignment declaration kind"); + } if (ts.isInJSFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return bindJsxAttributes(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return bindImportClause(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return bindExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 277 /* SourceFile */: + case 279 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 216 /* Block */: + case 218 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 297 /* JSDocParameterTag */: - if (node.parent.kind === 291 /* JSDocSignature */) { + case 299 /* JSDocParameterTag */: + if (node.parent.kind === 293 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { break; } // falls through - case 303 /* JSDocPropertyTag */: + case 305 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -28672,6 +29128,21 @@ var ts; } return true; } + function bindObjectDefinePropertyExport(node) { + if (!setCommonJsModuleIndicator(node)) { + return; + } + var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + } + return symbol; + }); + if (symbol) { + var flags = 4 /* Property */ | 1048576 /* ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + } + } function bindExportsPropertyAssignment(node) { // When we create a property via 'exports.foo = bar', the 'exports.foo' property access // expression is the declaration @@ -28708,17 +29179,17 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 58 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 59 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -28731,18 +29202,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -28751,10 +29222,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 99 /* ThisKeyword */) { + if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -28770,6 +29241,10 @@ var ts; var lhs = node.left; bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); } + function bindObjectDefinePrototypeProperty(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); + } /** * For `x.prototype.y = z`, declare a member `y` on `x` if `x` is a function or class, or not declared. * Note that jsdoc preceding an ExpressionStatement like `x.prototype.y;` is also treated as a declaration. @@ -28785,6 +29260,12 @@ var ts; classPrototype.parent = lhs; bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); } + function bindObjectDefinePropertyAssignment(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); + var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); + } function bindSpecialPropertyAssignment(node) { var lhs = node.left; // Class declarations in Typescript do not allow property declarations @@ -28813,16 +29294,12 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ - : propertyAccess.parent.parent.kind === 277 /* SourceFile */; + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; - namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_1); return symbol; @@ -28834,6 +29311,9 @@ var ts; } }); } + return namespaceSymbol; + } + function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) { return; } @@ -28841,10 +29321,18 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(propertyAccess)); + var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var isToplevel = ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ + : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** * Javascript expando values are: @@ -28861,6 +29349,9 @@ var ts; return true; } var node = symbol.valueDeclaration; + if (ts.isCallExpression(node)) { + return !!ts.getAssignedExpandoInitializer(node); + } var init = !node ? undefined : ts.isVariableDeclaration(node) ? node.initializer : ts.isBinaryExpression(node) ? node.right : @@ -28869,7 +29360,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 === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); } return false; } @@ -28911,7 +29402,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 238 /* ClassDeclaration */) { + if (node.kind === 240 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -28977,7 +29468,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 297 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { + if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -29054,7 +29545,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 174 /* InferType */) { + else if (node.parent.kind === 176 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -29082,11 +29573,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 220 /* EmptyStatement */) || // report error on class declarations - node.kind === 238 /* ClassDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 244 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -29130,18 +29621,17 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; } } - /* @internal */ function isExportsOrModuleExportsOrAlias(sourceFile, node) { return ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node) || @@ -29176,58 +29666,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 149 /* Parameter */: + case 151 /* Parameter */: return computeParameter(node, subtreeFlags); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 155 /* Constructor */: + case 157 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -29251,7 +29741,7 @@ var ts; transformFlags |= 8192 /* ContainsLexicalThis */; } } - if (expression.kind === 91 /* ImportKeyword */) { + if (expression.kind === 92 /* ImportKeyword */) { transformFlags |= 16777216 /* ContainsDynamicImport */; // A dynamic 'import()' call that contains a lexical 'this' will // require a captured 'this' when emitting down-level. @@ -29279,17 +29769,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 188 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 187 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 40 /* AsteriskAsteriskToken */ - || operatorTokenKind === 62 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ + || operatorTokenKind === 63 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 32 /* AssertES2016 */; } @@ -29333,8 +29823,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 210 /* AsExpression */ - || expressionKind === 192 /* TypeAssertionExpression */) { + if (expressionKind === 212 /* AsExpression */ + || expressionKind === 194 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -29391,11 +29881,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 85 /* ExtendsKeyword */: + case 86 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 108 /* ImplementsKeyword */: + case 109 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -29714,59 +30204,59 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 637535553 /* NodeExcludes */; switch (kind) { - case 120 /* AsyncKeyword */: - case 199 /* AwaitExpression */: + case 121 /* AsyncKeyword */: + case 201 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; break; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 211 /* NonNullExpression */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 213 /* NonNullExpression */: + case 133 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: - case 10 /* JsxText */: - case 261 /* JsxClosingElement */: - case 262 /* JsxFragment */: - case 263 /* JsxOpeningFragment */: - case 264 /* JsxClosingFragment */: - case 265 /* JsxAttribute */: - case 266 /* JsxAttributes */: - case 267 /* JsxSpreadAttribute */: - case 268 /* JsxExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 11 /* JsxText */: + case 263 /* JsxClosingElement */: + case 264 /* JsxFragment */: + case 265 /* JsxOpeningFragment */: + case 266 /* JsxClosingFragment */: + case 267 /* JsxAttribute */: + case 268 /* JsxAttributes */: + case 269 /* JsxSpreadAttribute */: + case 270 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - case 274 /* ShorthandPropertyAssignment */: - case 115 /* StaticKeyword */: - case 212 /* MetaProperty */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + case 276 /* ShorthandPropertyAssignment */: + case 116 /* StaticKeyword */: + case 214 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.hasExtendedUnicodeEscape) { transformFlags |= 192 /* AssertES2015 */; } @@ -29776,60 +30266,64 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ForOfStatement */: + case 9 /* BigIntLiteral */: + transformFlags |= 8 /* AssertESNext */; + break; + case 227 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 4194304 /* ContainsYield */; break; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 161 /* TypePredicate */: - case 162 /* TypeReference */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 165 /* TypeQuery */: - case 166 /* TypeLiteral */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 174 /* InferType */: - case 175 /* ParenthesizedType */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: - case 245 /* NamespaceExportDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 163 /* TypePredicate */: + case 164 /* TypeReference */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 167 /* TypeQuery */: + case 168 /* TypeLiteral */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 176 /* InferType */: + case 177 /* ParenthesizedType */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: + case 247 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -29846,43 +30340,43 @@ var ts; transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 131072 /* ContainsRestOrSpread */; break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; break; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 33554432 /* Super */; excludeFlags = 536872257 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 8192 /* ContainsLexicalThis */; break; - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; } excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 131072 /* ContainsRestOrSpread */; } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: excludeFlags = 638358849 /* ObjectLiteralExcludes */; if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -29900,8 +30394,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 185 /* ArrayLiteralExpression */: - case 190 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: + case 192 /* NewExpression */: excludeFlags = 637666625 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -29909,26 +30403,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -29942,68 +30436,68 @@ var ts; * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather * than calling this function. */ - /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { + if (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 185 /* ArrayLiteralExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: return 637666625 /* ArrayLiteralOrCallOrNewExcludes */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return 647001409 /* ModuleExcludes */; - case 149 /* Parameter */: + case 151 /* Parameter */: return 637535553 /* ParameterExcludes */; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return 653604161 /* ArrowFunctionExcludes */; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return 653620545 /* FunctionExcludes */; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return 639894849 /* VariableDeclarationListExcludes */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 638121281 /* ClassExcludes */; - case 155 /* Constructor */: + case 157 /* Constructor */: return 653616449 /* ConstructorExcludes */; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return 653616449 /* MethodOrAccessorExcludes */; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 137 /* StringKeyword */: - case 135 /* ObjectKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 138 /* StringKeyword */: + case 136 /* ObjectKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return 638358849 /* ObjectLiteralExcludes */; - case 272 /* CatchClause */: + case 274 /* CatchClause */: return 637797697 /* CatchClauseExcludes */; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return 637666625 /* BindingPatternExcludes */; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: - case 193 /* ParenthesizedExpression */: - case 97 /* SuperKeyword */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: + case 195 /* ParenthesizedExpression */: + case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 570426689 /* PropertyAccessExcludes */; default: return 637535553 /* NodeExcludes */; @@ -30064,7 +30558,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -30080,16 +30574,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { visitIndexType(type); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -30178,7 +30672,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 === 165 /* TypeQuery */) { + if (d.type && d.type.kind === 167 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -30268,6 +30762,7 @@ var ts; var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); @@ -30443,10 +30938,6 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { - var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); - return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; - }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isParameter); @@ -30479,6 +30970,7 @@ var ts; getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, + getObjectFlags: ts.getObjectFlags, isArrayLikeType: isArrayLikeType, isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, @@ -30486,7 +30978,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentExport: function (node, target) { return getSuggestionForNonexistentExport(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -30564,21 +31056,24 @@ var ts; var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(16384 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(65536 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */ | 134217728 /* ContainsWideningType */, "null"); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); - var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - falseType.flags |= 33554432 /* FreshLiteral */; - trueType.flags |= 33554432 /* FreshLiteral */; + 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"); trueType.regularType = regularTrueType; + trueType.freshType = trueType; + regularTrueType.regularType = regularTrueType; regularTrueType.freshType = trueType; falseType.regularType = regularFalseType; + falseType.freshType = falseType; + regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = createBooleanType([regularFalseType, regularTrueType]); // Also mark all combinations of fresh/regular booleans as "Boolean" so they print as `boolean` instead of `true | false` @@ -30586,15 +31081,18 @@ var ts; createBooleanType([regularFalseType, trueType]); createBooleanType([falseType, regularTrueType]); createBooleanType([falseType, trueType]); - var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(4096 /* Void */, "void"); - var neverType = createIntrinsicType(32768 /* Never */, "never"); - var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); + 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 implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; + var numberOrBigIntType = getUnionType([numberType, bigintType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -30607,16 +31105,15 @@ var ts; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var markerSuperType = createType(65536 /* TypeParameter */); - var markerSubType = createType(65536 /* TypeParameter */); + var markerSuperType = createType(262144 /* TypeParameter */); + var markerSubType = createType(262144 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(65536 /* TypeParameter */); + var markerOtherType = createType(262144 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignaturesArray = [resolvingSignature]; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var globals = ts.createSymbolTable(); /** Key is "/path/to/a.ts|/path/to/b.ts". */ @@ -30663,6 +31160,9 @@ var ts; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; var deferredGlobalExtractSymbol; + var deferredGlobalExcludeSymbol; + var deferredGlobalPickSymbol; + var deferredGlobalBigIntType; var allPotentiallyUnusedIdentifiers = ts.createMap(); // key is file name var flowLoopStart = 0; var flowLoopCount = 0; @@ -30670,6 +31170,7 @@ var ts; var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); + var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -30695,86 +31196,99 @@ var ts; TypeFacts[TypeFacts["None"] = 0] = "None"; TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["All"] = 4194303] = "All"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; // The following members encode facts about particular kinds of types for use in the getTypeFacts function. // The presence of a particular fact means that the given test is true for some (and possibly all) values // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 1972176] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 4184016] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 1970144] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 4181984] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 4079615] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 4194303] = "EmptyObjectFacts"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMapFromTemplate({ string: 1 /* TypeofEQString */, number: 2 /* TypeofEQNumber */, - boolean: 4 /* TypeofEQBoolean */, - symbol: 8 /* TypeofEQSymbol */, - undefined: 16384 /* EQUndefined */, - object: 16 /* TypeofEQObject */, - function: 32 /* TypeofEQFunction */ + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ }); var typeofNEFacts = ts.createMapFromTemplate({ - string: 128 /* TypeofNEString */, - number: 256 /* TypeofNENumber */, - boolean: 512 /* TypeofNEBoolean */, - symbol: 1024 /* TypeofNESymbol */, - undefined: 131072 /* NEUndefined */, - object: 2048 /* TypeofNEObject */, - function: 4096 /* TypeofNEFunction */ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ }); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, + bigint: bigintType, boolean: booleanType, symbol: esSymbolType, undefined: undefinedType @@ -30996,7 +31510,7 @@ var ts; (source.flags | target.flags) & 67108864 /* Assignment */) { ts.Debug.assert(source !== target); if (!(target.flags & 33554432 /* Transient */)) { - target = cloneSymbol(target); + target = cloneSymbol(resolveSymbol(target)); } // 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) { @@ -31027,7 +31541,7 @@ var ts; else if (target.flags & 1024 /* NamespaceModule */) { error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } - else { + else { // error var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); var message = isEitherEnum @@ -31092,7 +31606,8 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); + var targetSymbol = target.get(id); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -31154,7 +31669,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -31212,17 +31727,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 184 /* BindingElement */) { + if (declaration.kind === 186 /* 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, 184 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 186 /* 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, 235 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 237 /* VariableDeclaration */), usage); } - else if (declaration.kind === 235 /* VariableDeclaration */) { + else if (declaration.kind === 237 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -31241,12 +31756,12 @@ 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 === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 257 /* ExportSpecifier */ || (usage.parent.kind === 254 /* 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 === 252 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 254 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -31254,9 +31769,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 217 /* VariableStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 219 /* VariableStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -31277,16 +31792,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 152 /* PropertyDeclaration */ && + current.parent.kind === 154 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 154 /* MethodDeclaration */) { + if (declaration.kind === 156 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -31328,12 +31843,12 @@ 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 & 67897832 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 149 /* Parameter */ || - lastLocation.kind === 148 /* TypeParameter */ + lastLocation.kind === 151 /* Parameter */ || + lastLocation.kind === 150 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -31350,13 +31865,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 151 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 173 /* ConditionalType */) { + else if (location.kind === 175 /* 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; @@ -31370,14 +31885,14 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -31401,7 +31916,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 257 /* ExportSpecifier */)) { break; } } @@ -31415,13 +31930,13 @@ var ts; } } break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -31438,9 +31953,9 @@ var ts; } } break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* 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! @@ -31459,7 +31974,7 @@ var ts; } break loop; } - if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 209 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -31467,9 +31982,9 @@ var ts; } } break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 86 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { if (nameNotFoundMessage) { @@ -31487,9 +32002,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 241 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -31497,19 +32012,19 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -31522,7 +32037,7 @@ var ts; } } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -31531,7 +32046,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 === 149 /* Parameter */) { + if (location.parent && location.parent.kind === 151 /* Parameter */) { location = location.parent; } // @@ -31544,8 +32059,8 @@ var ts; location = location.parent; } break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -31564,7 +32079,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -31637,8 +32152,7 @@ var ts; } // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { - var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { + if (ts.some(result.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -31647,12 +32161,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: // For `namespace N { N; }` + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -31664,7 +32178,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 148 /* TypeParameter */) { + if (decl.kind === 150 /* 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 @@ -31719,10 +32233,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -31789,7 +32303,7 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 243 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -31824,13 +32338,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 248 /* ImportClause */: + case 250 /* ImportClause */: return node.parent; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -31840,7 +32354,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -32032,20 +32546,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 252 /* ExportAssignment */: - case 202 /* BinaryExpression */: + case 254 /* ExportAssignment */: + case 204 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -32106,11 +32620,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 255 /* ExportSpecifier */) { + else if (node.kind === 257 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -32128,17 +32642,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 71 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 72 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* QualifiedName */) { + if (entityName.kind === 72 /* Identifier */ || entityName.parent.kind === 148 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 248 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -32154,7 +32668,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); var symbol; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name).escapedText); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -32162,9 +32676,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { - var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 148 /* QualifiedName */ || name.kind === 189 /* PropertyAccessExpression */) { + var left = name.kind === 148 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 148 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -32247,6 +32761,9 @@ var ts; } function getDeclarationOfJSPrototypeContainer(symbol) { var decl = symbol.parent.valueDeclaration; + if (!decl) { + return undefined; + } var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) : ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) : undefined; @@ -32365,10 +32882,15 @@ var ts; return getPackagesSet().has(ts.getTypesPackageName(packageName)); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; + if (moduleSymbol) { + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + return getMergedSymbol(exported) || moduleSymbol; + } + return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || moduleSymbol.exports.size === 1) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } var merged = cloneSymbol(exported); @@ -32389,7 +32911,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -32457,7 +32979,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -32602,7 +33124,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 157 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -32625,7 +33147,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(131072 /* Object */); + var type = createType(524288 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -32680,12 +33202,12 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -32749,7 +33271,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 255 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -32785,7 +33307,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, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -32800,10 +33322,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: continue; default: return false; @@ -32920,10 +33442,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -32970,14 +33492,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 165 /* TypeQuery */ || + if (entityName.parent.kind === 167 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 147 /* ComputedPropertyName */) { + entityName.parent.kind === 149 /* ComputedPropertyName */) { // Typeof value meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || - entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 148 /* QualifiedName */ || entityName.kind === 189 /* PropertyAccessExpression */ || + entityName.parent.kind === 248 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -33026,15 +33548,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 166 /* ConstructorType */ : 165 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 161 /* ConstructSignature */ : 160 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 return writer; } } @@ -33099,7 +33621,8 @@ var ts; getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) } : undefined }, encounteredError: false, - visitedSymbols: undefined, + visitedTypes: undefined, + symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; @@ -33123,48 +33646,55 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + return ts.createKeywordTypeNode(143 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* StringKeyword */); + return ts.createKeywordTypeNode(138 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(134 /* NumberKeyword */); + return ts.createKeywordTypeNode(135 /* NumberKeyword */); + } + if (type.flags & 64 /* BigInt */) { + context.approximateLength += 6; + return ts.createKeywordTypeNode(146 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(122 /* BooleanKeyword */); + return ts.createKeywordTypeNode(123 /* BooleanKeyword */); } - if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { + if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToName(parentSymbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); + var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type + ? parentName + : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); + return enumLiteralName; } - if (type.flags & 544 /* EnumLike */) { - var name = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + if (type.flags & 1056 /* EnumLike */) { + return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); } - if (type.flags & 64 /* StringLiteral */) { + if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & 128 /* NumberLiteral */) { + if (type.flags & 256 /* NumberLiteral */) { context.approximateLength += (("" + type.value).length); return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 2048 /* BigIntLiteral */) { + context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; + return ts.createLiteralTypeNode((ts.createLiteral(type.value))); + } + if (type.flags & 512 /* BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; @@ -33175,33 +33705,33 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(142 /* UniqueKeyword */, ts.createKeywordTypeNode(139 /* SymbolKeyword */)); } - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(105 /* VoidKeyword */); + return ts.createKeywordTypeNode(106 /* VoidKeyword */); } - if (type.flags & 8192 /* Undefined */) { + if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(141 /* UndefinedKeyword */); } - if (type.flags & 16384 /* Null */) { + if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(95 /* NullKeyword */); + return ts.createKeywordTypeNode(96 /* NullKeyword */); } - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(131 /* NeverKeyword */); + return ts.createKeywordTypeNode(132 /* NeverKeyword */); } - if (type.flags & 1024 /* ESSymbol */) { + if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(138 /* SymbolKeyword */); + return ts.createKeywordTypeNode(139 /* SymbolKeyword */); } - if (type.flags & 16777216 /* NonPrimitive */) { + if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(135 /* ObjectKeyword */); + return ts.createKeywordTypeNode(136 /* ObjectKeyword */); } - if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { + if (type.flags & 262144 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -33215,16 +33745,16 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 65536 /* TypeParameter */ && + type.flags & 262144 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && @@ -33244,14 +33774,14 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); } - if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { - var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { + var types = type.flags & 1048576 /* 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) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 173 /* UnionType */ : 174 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -33262,23 +33792,23 @@ var ts; } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 4194304 /* Conditional */) { + if (type.flags & 16777216 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -33289,12 +33819,12 @@ var ts; context.approximateLength += 15; return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 8388608 /* Substitution */) { + if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -33313,6 +33843,7 @@ var ts; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); } function createAnonymousTypeNode(type) { + var typeId = "" + type.id; var symbol = type.symbol; var id; if (symbol) { @@ -33324,12 +33855,12 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 209 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67220415 /* Value */); } - else if (context.visitedSymbols && context.visitedSymbols.has(id)) { + else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { @@ -33338,18 +33869,34 @@ var ts; } else { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } } else { // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedSymbols) { - context.visitedSymbols = ts.createMap(); + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); } - context.visitedSymbols.set(id, true); + if (!context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + context.approximateLength += 3; + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); + } + context.symbolDepth.set(id, depth + 1); + context.visitedTypes.set(typeId, true); var result = createTypeNodeFromObjectType(type); - context.visitedSymbols.delete(id); + context.visitedTypes.delete(typeId); + context.symbolDepth.set(id, depth); return result; } } @@ -33363,11 +33910,11 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; + return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively + return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } @@ -33384,12 +33931,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 165 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* ConstructorType */, context); return signatureNode; } } @@ -33521,11 +34068,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 160 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -33576,12 +34123,12 @@ var ts; var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(55 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length) { var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 155 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -33594,9 +34141,9 @@ var ts; else { var savedFlags = context.flags; context.flags |= !!(ts.getCheckFlags(propertySymbol) & 2048 /* ReverseMapped */) ? 33554432 /* InReverseMappedType */ : 0; - var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(120 /* AnyKeyword */); context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -33647,7 +34194,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 137 /* StringKeyword */ : 134 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 138 /* StringKeyword */ : 135 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -33660,7 +34207,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -33671,7 +34218,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 157 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -33690,12 +34237,12 @@ var ts; returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 119 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 120 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(119 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(120 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -33724,9 +34271,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 297 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -33735,16 +34282,16 @@ var ts; var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; - var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; + var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 72 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 148 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -33758,7 +34305,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 184 /* BindingElement */) { + if (clone.kind === 186 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -33857,7 +34404,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -34057,10 +34604,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 24576 /* Nullable */)) { - if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { - var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 262144 /* Union */) { + 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 */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -34072,9 +34619,9 @@ var ts; result.push(t); } } - if (flags & 16384 /* Null */) + if (flags & 65536 /* Null */) result.push(nullType); - if (flags & 8192 /* Undefined */) + if (flags & 32768 /* Undefined */) result.push(undefinedType); return result || types; } @@ -34089,8 +34636,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); - if (node.kind === 240 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 177 /* ParenthesizedType */; }); + if (node.kind === 242 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -34098,11 +34645,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 243 /* ModuleBlock */ && + node.parent.kind === 245 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -34125,27 +34672,30 @@ var ts; var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { + if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + return ts.symbolName(symbol); + } return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 237 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 209 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 128 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 8192 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -34162,27 +34712,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: // 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 184 /* BindingElement */: + case 186 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 235 /* VariableDeclaration */: + case 237 /* 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 237 /* FunctionDeclaration */: - case 241 /* EnumDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 243 /* EnumDeclaration */: + case 248 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -34190,53 +34740,53 @@ var ts; 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 !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 155 /* Constructor */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 149 /* Parameter */: - case 243 /* ModuleBlock */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 162 /* TypeReference */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 175 /* ParenthesizedType */: + case 157 /* Constructor */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 151 /* Parameter */: + case 245 /* ModuleBlock */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 164 /* TypeReference */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 177 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: return false; // Type parameters are always visible - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 277 /* SourceFile */: - case 245 /* NamespaceExportDeclaration */: + case 279 /* SourceFile */: + case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return false; default: return false; @@ -34245,10 +34795,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 254 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 255 /* ExportSpecifier */) { + else if (node.parent.kind === 257 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -34344,12 +34894,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 235 /* VariableDeclaration */: - case 236 /* VariableDeclarationList */: - case 251 /* ImportSpecifier */: - case 250 /* NamedImports */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 237 /* VariableDeclaration */: + case 238 /* VariableDeclarationList */: + case 253 /* ImportSpecifier */: + case 252 /* NamedImports */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: return false; default: return true; @@ -34379,28 +34929,36 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 149 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); - if (source.flags & 32768 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); + if (source.flags & 131072 /* Never */) { return emptyObjectType; } - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } - var members = ts.createSymbolTable(); - var names = ts.createUnderscoreEscapedMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; - names.set(ts.getTextOfPropertyName(name), true); + var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); + if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) { + if (omitKeyType.flags & 131072 /* Never */) { + return source; + } + var pickTypeAlias = getGlobalPickSymbol(); + var excludeTypeAlias = getGlobalExcludeSymbol(); + if (!pickTypeAlias || !excludeTypeAlias) { + return errorType; + } + var pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]); + return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]); } - for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { - var prop = _b[_a]; - if (!names.has(prop.escapedName) + var members = ts.createSymbolTable(); + for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), omitKeyType) && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { - members.set(prop.escapedName, getNonReadonlySymbol(prop)); + members.set(prop.escapedName, getSpreadSymbol(prop)); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -34424,8 +34982,12 @@ var ts; if (isTypeAny(parentType)) { return parentType; } + // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation + if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + parentType = getNonNullableType(parentType); + } var type; - if (pattern.kind === 182 /* ObjectBindingPattern */) { + if (pattern.kind === 184 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -34443,51 +35005,9 @@ var ts; else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; - var isLate = isLateBindableName(name); - var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); - if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { - var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); - } - return anyType; - } - var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); - if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { - if (getIndexTypeOfType(parentType, 1 /* Number */)) { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); - } - else { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(parentType)); - } - } - return indexerType || anyType; - } - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - var nameType = isLate ? checkComputedPropertyName(name) : undefined; - var text = isLate ? getLateBoundNameFromType(nameType) : - isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : - ts.getTextOfPropertyName(name); - // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { - parentType = getNonNullableType(parentType); - } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); - } - return anyType; - } - var declaredType = getConstraintForLocation(getTypeOfPropertyOfType(parentType, text), declaration.name); - type = declaredType && getFlowTypeOfReference(declaration, declaredType) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return errorType; - } + var exprType = getLiteralTypeFromPropertyName(name); + var declaredType = checkIndexedAccessIndexType(getIndexedAccessType(parentType, exprType, name), name); + type = getFlowTypeOfReference(declaration, getConstraintForLocation(declaredType, declaration.name)); } } else { @@ -34523,8 +35043,8 @@ var ts; } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 8192 /* Undefined */)) { - type = getTypeWithFacts(type, 131072 /* NEUndefined */); + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */)) { + type = getTypeWithFacts(type, 524288 /* NEUndefined */); } return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkDeclarationInitializer(declaration)], 2 /* Subtype */) : @@ -34539,11 +35059,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 95 /* NullKeyword */ || expr.kind === 71 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 96 /* NullKeyword */ || expr.kind === 72 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 187 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -34553,11 +35073,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 224 /* ForInStatement */) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 226 /* ForInStatement */) { + var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); + return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* 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, @@ -34576,7 +35096,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 237 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* 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 @@ -34590,11 +35110,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); + if (func.kind === 159 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 158 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -34658,7 +35178,7 @@ var ts; var types; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - var expression = ts.isBinaryExpression(declaration) ? declaration : + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { @@ -34673,9 +35193,11 @@ var ts; definedInMethod = true; } } - jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + if (!ts.isCallExpression(expression)) { + jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } if (!jsdocType) { - (types || (types = [])).push(ts.isBinaryExpression(expression) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } var type = jsdocType; @@ -34689,11 +35211,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(98304 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -34734,8 +35256,33 @@ var ts; } /** If we don't have an explicit JSDoc type, get the type from the initializer. */ function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) { + if (ts.isCallExpression(expression)) { + if (resolvedSymbol) { + return getTypeOfSymbol(resolvedSymbol); // This shouldn't happen except under some hopefully forbidden merges of export assignments and object define assignments + } + var objectLitType = checkExpressionCached(expression.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + return valueType; + } + var getFunc = getTypeOfPropertyOfType(objectLitType, "get"); + if (getFunc) { + var getSig = getSingleCallSignature(getFunc); + if (getSig) { + return getReturnTypeOfSignature(getSig); + } + } + var setFunc = getTypeOfPropertyOfType(objectLitType, "set"); + if (setFunc) { + var setSig = getSingleCallSignature(setFunc); + if (setSig) { + return getTypeOfFirstParameterOfSignature(setSig); + } + } + return anyType; + } var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 131072 /* Object */ && + if (type.flags & 524288 /* Object */ && kind === 2 /* ModuleExports */ && symbol.escapedName === "export=" /* ExportEquals */) { var exportedType_1 = resolveStructuredTypeMembers(type); @@ -34769,9 +35316,9 @@ var ts; 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 === 155 /* Constructor */ || - thisContainer.kind === 237 /* FunctionDeclaration */ || - (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 157 /* Constructor */ || + thisContainer.kind === 239 /* FunctionDeclaration */ || + (thisContainer.kind === 196 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -34846,7 +35393,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 186 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -34869,7 +35416,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 182 /* ObjectBindingPattern */ + return pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -34891,7 +35438,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -34908,7 +35455,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 151 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -34948,12 +35495,12 @@ var ts; return emptyObjectType; } var type_1 = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression)); - if (type_1.flags & 131072 /* Object */) { + if (type_1.flags & 524288 /* Object */) { return getRegularTypeOfObjectLiteral(type_1); } return type_1; } - if (declaration.kind === 252 /* ExportAssignment */) { + if (declaration.kind === 254 /* ExportAssignment */) { return widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } // Handle variable, parameter or property @@ -34962,7 +35509,7 @@ var ts; } var type; if (ts.isInJSFile(declaration) && - (ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { type = getWidenedTypeFromAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) @@ -34999,6 +35546,14 @@ var ts; || ts.isBindingElement(declaration)) { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); } + // getTypeOfSymbol dispatches some JS merges incorrectly because their symbol flags are not mutually exclusive. + // Re-dispatch based on valueDeclaration.kind instead. + else if (ts.isEnumDeclaration(declaration)) { + type = getTypeOfFuncClassEnumModule(symbol); + } + else if (ts.isEnumMember(declaration)) { + type = getTypeOfEnumMember(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } @@ -35009,7 +35564,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -35036,8 +35591,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 159 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -35080,7 +35635,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -35088,7 +35643,7 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -35120,8 +35675,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 202 /* BinaryExpression */ || - declaration.kind === 187 /* PropertyAccessExpression */ && declaration.parent.kind === 202 /* BinaryExpression */) { + else if (declaration.kind === 204 /* BinaryExpression */ || + declaration.kind === 189 /* PropertyAccessExpression */ && declaration.parent.kind === 204 /* BinaryExpression */) { return getWidenedTypeFromAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -35233,7 +35788,7 @@ var ts; var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, check); } return false; @@ -35257,35 +35812,35 @@ var ts; return undefined; } switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 179 /* MappedType */: - case 173 /* ConditionalType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 181 /* MappedType */: + case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 179 /* MappedType */) { + if (node.kind === 181 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 173 /* ConditionalType */) { + else if (node.kind === 175 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && + (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */ || node.kind === 241 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -35293,7 +35848,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, 239 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -35302,9 +35857,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 238 /* ClassDeclaration */ || - node.kind === 207 /* ClassExpression */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || + node.kind === 209 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -35331,7 +35886,7 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } @@ -35374,7 +35929,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 & (131072 /* Object */ | 524288 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* 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); @@ -35384,7 +35939,18 @@ var ts; return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + if (baseConstructorType.flags & 262144 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(baseConstructorType); + var ctorReturn = unknownType; + if (constraint) { + var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + if (ctorSig[0]) { + ctorReturn = getReturnTypeOfSignature(ctorSig[0]); + } + } + addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; @@ -35413,7 +35979,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -35480,14 +36046,14 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || - !!(type.flags & 524288 /* Intersection */) && ts.every(type.types, isValidBaseType); + return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 241 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -35523,7 +36089,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */) { + if (declaration.kind === 241 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -35564,7 +36130,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -35581,7 +36147,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 242 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -35605,10 +36171,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 9 /* StringLiteral */) { + if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 202 /* BinaryExpression */) { + else if (expr.kind === 204 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -35619,15 +36185,15 @@ var ts; return !(member.flags & 4194304 /* Ambient */); } switch (expr.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 38 /* MinusToken */ && + case 202 /* PrefixUnaryExpression */: + return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -35641,10 +36207,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { + if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -35656,7 +36222,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -35668,7 +36234,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getFreshTypeOfLiteralType(getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member))); // TODO: GH#18217 @@ -35679,8 +36245,8 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 262144 /* Union */) { - enumType_1.flags |= 512 /* EnumLiteral */; + if (enumType_1.flags & 1048576 /* Union */) { + enumType_1.flags |= 1024 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; @@ -35703,7 +36269,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(65536 /* TypeParameter */); + var type = createType(262144 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -35747,22 +36313,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: - case 180 /* LiteralType */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: + case 182 /* LiteralType */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isThislessType(node.elementType); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -35788,7 +36355,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 157 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -35804,12 +36371,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -35853,7 +36420,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -35896,10 +36463,10 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -36064,7 +36631,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -36193,7 +36760,7 @@ var ts; function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { var s = signatureList_1[_i]; - if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { + if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) { return s; } } @@ -36227,8 +36794,7 @@ var ts; // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional // parameters and may differ in return types. When signatures differ in return types, the resulting return // type is the union of the constituent return types. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + function getUnionSignatures(signatureLists) { var result; for (var i = 0; i < signatureLists.length; i++) { for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { @@ -36274,8 +36840,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(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 0 /* Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -36371,7 +36937,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -36405,7 +36971,7 @@ var ts; var modifiers = getMappedTypeModifiers(type.mappedType); var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; - var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType), readonlyMask && indexInfo.isReadonly); + var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly); var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -36415,6 +36981,7 @@ var ts; inferredProp.nameType = prop.nameType; inferredProp.propertyType = getTypeOfSymbol(prop); inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -36433,12 +37000,12 @@ 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 ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; - addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include)); + addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); } if (modifiersType.flags & 1 /* Any */ || getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); @@ -36448,11 +37015,9 @@ var ts; } } else { - // First, if the constraint type is a type parameter, obtain the base constraint. Then, - // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. - // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + // If the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. + // Then iterate over the constituents of the key type. + var iterationType = constraintType.flags & 4194304 /* Index */ ? getIndexType(getApparentType(constraintType.type)) : constraintType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -36464,7 +37029,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 8576 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -36476,7 +37041,7 @@ var ts; // 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. prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; @@ -36512,8 +37077,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 177 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; + return constraintDeclaration.kind === 179 /* TypeOperator */ && + constraintDeclaration.operator === 129 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -36529,16 +37094,16 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 38 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 38 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -36557,7 +37122,7 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -36574,10 +37139,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 262144 /* Union */) { + else if (type.flags & 1048576 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -36585,7 +37150,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -36594,7 +37159,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -36618,7 +37183,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 - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { break; } } @@ -36628,12 +37193,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 786432 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { - return obj.properties.some(function (property) { + var list = obj.properties; + return list.some(function (property) { var name = property.name && ts.getTextOfPropertyName(property.name); var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && typeIsLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); @@ -36641,7 +37207,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 262144 /* Union */)) { + if (!(unionType.flags & 1048576 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -36660,9 +37226,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -36682,7 +37248,11 @@ var ts; function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = !(rootTrueType.flags & 33554432 /* Substitution */) + ? rootTrueType + : (rootTrueType.substitute).flags & 3 /* AnyOrUnknown */ + ? rootTrueType.typeVariable + : getIntersectionType([rootTrueType.substitute, rootTrueType.typeVariable]); type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -36699,7 +37269,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 32768 /* Never */)) { + if (!(instantiated.flags & 131072 /* Never */)) { return instantiated; } } @@ -36714,23 +37284,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 15794176 /* Instantiable */) { + if (t.flags & 63176704 /* 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 & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 262144 /* Union */)) { + if (!(constraint.flags & 1048576 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 16809468 /* DisjointDomains */) { + else if (t.flags & 67238908 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -36742,7 +37312,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 16809468 /* DisjointDomains */) { + if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -36752,11 +37322,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { + if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 1048576 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -36805,13 +37375,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 65536 /* TypeParameter */) { + if (t.flags & 262144 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 786432 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -36821,24 +37391,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 1048576 /* Index */) { + if (t.flags & 4194304 /* Index */) { return keyofConstraintType; } - if (t.flags & 2097152 /* IndexedAccess */) { + if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType, /*accessNode*/ undefined, errorType) : undefined; return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 4194304 /* Conditional */) { + if (t.flags & 16777216 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 8388608 /* Substitution */) { + if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -36910,21 +37480,22 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + var t = type.flags & 63176704 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 68 /* StringLike */ ? globalStringType : - t.flags & 168 /* NumberLike */ ? globalNumberType : - t.flags & 272 /* BooleanLike */ ? globalBooleanType : - t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : - t.flags & 1048576 /* Index */ ? keyofConstraintType : - t; + t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 132 /* StringLike */ ? globalStringType : + t.flags & 296 /* NumberLike */ ? globalNumberType : + t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 6 /* ESNext */) : + 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; } function createUnionOrIntersectionProperty(containingType, name) { var props; var indexTypes; - var isUnion = containingType.flags & 262144 /* Union */; + var isUnion = containingType.flags & 1048576 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -37037,7 +37608,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -37055,13 +37626,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -37075,7 +37646,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -37131,10 +37702,10 @@ 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 === 286 /* JSDocOptionalType */ + node.type && node.type.kind === 288 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -37168,7 +37739,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -37193,30 +37764,32 @@ var ts; } function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); - if (numTypeParameters) { - var numTypeArguments = ts.length(typeArguments); - if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { - if (!typeArguments) { - typeArguments = []; - } - // Map an unsatisfied type parameter with a default type. - // If a type parameter does not have a default type, or if the default type - // is a forward reference, the empty object type is used. - for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - for (var i = numTypeArguments; i < numTypeParameters; i++) { - var mapper = createTypeMapper(typeParameters, typeArguments); - var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { - defaultType = anyType; - } - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - typeArguments.length = typeParameters.length; - } + if (!numTypeParameters) { + return []; } - return typeArguments; + var numTypeArguments = ts.length(typeArguments); + if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { + var result = typeArguments ? typeArguments.slice() : []; + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + var baseDefaultType_1 = getDefaultTypeArgumentType(isJavaScriptImplicitAny); + var circularityMapper = createTypeMapper(typeParameters, ts.map(typeParameters, function () { return baseDefaultType_1; })); + for (var i = numTypeArguments; i < numTypeParameters; i++) { + result[i] = instantiateType(getConstraintFromTypeParameter(typeParameters[i]) || baseDefaultType_1, circularityMapper); + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, result); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { + defaultType = anyType; + } + result[i] = defaultType ? instantiateType(defaultType, mapper) : baseDefaultType_1; + } + result.length = typeParameters.length; + return result; + } + return typeArguments && typeArguments.slice(); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); @@ -37252,7 +37825,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 180 /* LiteralType */) { + if (type && type.kind === 182 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -37266,16 +37839,16 @@ 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 === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && + if ((declaration.kind === 158 /* GetAccessor */ || declaration.kind === 159 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = declaration.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 155 /* Constructor */ ? + var classType = declaration.kind === 157 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -37333,13 +37906,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return node.name.kind === 147 /* ComputedPropertyName */ + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return node.name.kind === 149 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -37414,7 +37987,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, func) { var parameterName = node.parameterName; var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 71 /* Identifier */) { + if (parameterName.kind === 72 /* Identifier */) { return createIdentifierTypePredicate(parameterName.escapedText, getTypePredicateParameterIndex(func.parameters, parameterName), type); } else { @@ -37424,7 +37997,7 @@ var ts; function getTypePredicateParameterIndex(parameterList, parameter) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 71 /* Identifier */ && param.name.escapedText === parameter.escapedText) { + if (param.name.kind === 72 /* Identifier */ && param.name.escapedText === parameter.escapedText) { return i; } } @@ -37464,7 +38037,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 155 /* Constructor */) { + if (declaration.kind === 157 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -37474,12 +38047,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 158 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 159 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -37557,7 +38130,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 + var isConstructor = signature.declaration.kind === 157 /* Constructor */ || signature.declaration.kind === 161 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -37571,7 +38144,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 134 /* NumberKeyword */ : 137 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 135 /* NumberKeyword */ : 138 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -37598,7 +38171,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 150 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -37606,13 +38179,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 174 /* InferType */) { + if (declaration.parent.kind === 176 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 162 /* TypeReference */) { + if (grandParent.kind === 164 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -37637,7 +38210,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 151 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -37661,7 +38234,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 150 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -37794,9 +38367,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -37840,7 +38413,7 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : + res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { @@ -37897,13 +38470,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(8388608 /* Substitution */); + var result = createType(33554432 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 170 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -37912,9 +38485,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -37925,7 +38498,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 162 /* TypeReference */ || node.kind === 181 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 164 /* TypeReference */ || node.kind === 183 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -37983,7 +38556,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -38026,9 +38599,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return declaration; } } @@ -38037,7 +38610,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 131072 /* Object */)) { + if (!(type.flags & 524288 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -38114,6 +38687,15 @@ var ts; function getGlobalExtractSymbol() { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } + function getGlobalExcludeSymbol() { + return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalPickSymbol() { + return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalBigIntType(reportErrors) { + return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors)) || emptyObjectType; + } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -38162,7 +38744,7 @@ var ts; if (arity) { typeParameters = new Array(arity); for (var i = 0; i < arity; i++) { - var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + var typeParameter = typeParameters[i] = createType(262144 /* TypeParameter */); if (i < maxLength) { var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); property.type = typeParameter; @@ -38184,7 +38766,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -38219,8 +38801,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 172 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 171 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -38267,16 +38849,17 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { + if (t.flags & 109440 /* Unit */ && combined & 109440 /* Unit */) { return true; } combined |= t.flags; - if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || - combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || - combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || - combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || - combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || - combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { + if (combined & 98304 /* Nullable */ && combined & (524288 /* Object */ | 67108864 /* NonPrimitive */) || + combined & 67108864 /* NonPrimitive */ && combined & (67238908 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || + combined & 132 /* StringLike */ && combined & (67238908 /* DisjointDomains */ & ~132 /* StringLike */) || + combined & 296 /* NumberLike */ && combined & (67238908 /* DisjointDomains */ & ~296 /* NumberLike */) || + combined & 2112 /* BigIntLike */ && combined & (67238908 /* DisjointDomains */ & ~2112 /* BigIntLike */) || + combined & 12288 /* ESSymbolLike */ && combined & (67238908 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || + combined & 49152 /* VoidLike */ && combined & (67238908 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return true; } } @@ -38284,20 +38867,18 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Union */) { + if (flags & 1048576 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + if (!(flags & 131072 /* Never */ || flags & 2097152 /* Intersection */ && isEmptyIntersectionType(type))) { includes |= flags & ~939524096 /* ConstructionFlags */; - if (flags & 3 /* AnyOrUnknown */) { - if (type === wildcardType) - includes |= 268435456 /* Wildcard */; - } - else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (type === wildcardType) + includes |= 268435456 /* Wildcard */; + if (!strictNullChecks && flags & 98304 /* Nullable */) { if (!(flags & 134217728 /* ContainsWideningType */)) includes |= 134217728 /* NonWideningType */; } @@ -38333,11 +38914,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 512 /* EnumLiteral */) { + if (first.flags & 1024 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -38362,10 +38943,11 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || - t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || - t.flags & 448 /* Literal */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 128 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || + t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38388,25 +38970,27 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + if (unionReduction !== 0 /* None */) { + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + } + switch (unionReduction) { + case 1 /* Literal */: + if (includes & 8576 /* StringOrNumberLiteralOrUnique */ | 512 /* BooleanLiteral */) { + removeRedundantLiteralTypes(typeSet, includes); + } + break; + case 2 /* Subtype */: + removeSubtypes(typeSet); + break; + } + if (typeSet.length === 0) { + return includes & 65536 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : + neverType; + } } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & 2240 /* StringOrNumberLiteralOrUnique */ | 256 /* BooleanLiteral */) { - removeRedundantLiteralTypes(typeSet, includes); - } - break; - case 2 /* Subtype */: - removeSubtypes(typeSet); - break; - } - if (typeSet.length === 0) { - return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : - includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : - neverType; - } - return getUnionTypeFromSortedList(typeSet, includes & 16748579 /* NotPrimitiveUnion */ ? 0 : 67108864 /* UnionOfPrimitiveTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, !(includes & 66994211 /* NotPrimitiveUnion */), aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -38443,7 +39027,7 @@ var ts; : !ts.isIdentifierTypePredicate(b); } // This function assumes the constituent type list is sorted and deduplicated. - function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) { + function getUnionTypeFromSortedList(types, primitiveTypesOnly, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { return neverType; } @@ -38453,10 +39037,11 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* Union */ | propagatedFlags); unionTypes.set(id, type); type.types = types; + type.primitiveTypesOnly = primitiveTypesOnly; /* Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. @@ -38478,11 +39063,14 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 536870912 /* EmptyObject */; + if (isEmptyAnonymousObjectType(type)) { + if (!(includes & 536870912 /* EmptyObject */)) { + includes |= 536870912 /* EmptyObject */; + typeSet.push(type); + } } else { includes |= flags & ~939524096 /* ConstructionFlags */; @@ -38490,7 +39078,7 @@ var ts; if (type === wildcardType) includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type)) { + else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !ts.contains(typeSet, type)) { typeSet.push(type); } } @@ -38510,9 +39098,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; + 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 */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38525,10 +39114,11 @@ 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 & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - undefined; + var primitive = type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + undefined; if (!primitive || !containsType(u.types, primitive)) { return false; } @@ -38541,13 +39131,16 @@ 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 (t.flags & 67108864 /* UnionOfPrimitiveTypes */) !== 0; }); + var index = ts.findIndex(types, function (t) { return !!(t.flags & 1048576 /* Union */) && t.primitiveTypesOnly; }); + if (index < 0) { + return false; + } var i = index + 1; // Remove all but the first union of primitive types and collect them in // the unionTypes array. while (i < types.length) { var t = types[i]; - if (t.flags & 67108864 /* UnionOfPrimitiveTypes */) { + if (t.flags & 1048576 /* Union */ && t.primitiveTypesOnly) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -38576,7 +39169,7 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 67108864 /* UnionOfPrimitiveTypes */); + types[index] = getUnionTypeFromSortedList(result, /*primitiveTypesOnly*/ true); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -38592,22 +39185,23 @@ var ts; function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 32768 /* Never */) { + if (includes & 131072 /* Never */) { return neverType; } if (includes & 1 /* Any */) { return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 24576 /* Nullable */) { - return includes & 8192 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* Nullable */) { + return includes & 32768 /* Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { + 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 */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { - typeSet.push(emptyObjectType); + if (includes & 536870912 /* EmptyObject */ && includes & 524288 /* Object */) { + ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { return unknownType; @@ -38615,8 +39209,8 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 262144 /* Union */) { - if (includes & 67108864 /* UnionOfPrimitiveTypes */ && intersectUnionsOfPrimitiveTypes(typeSet)) { + if (includes & 1048576 /* 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. @@ -38624,15 +39218,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(524288 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(2097152 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -38649,7 +39243,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(1048576 /* Index */); + var result = createType(4194304 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -38659,14 +39253,22 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } - function getLiteralTypeFromPropertyName(prop, include) { + function getLiteralTypeFromPropertyName(name) { + return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : + getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); + } + function getBigIntLiteralType(node) { + return getLiteralType({ + negative: false, + base10Value: ts.parsePseudoBigInt(node.text) + }); + } + function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : - getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { return type; @@ -38674,8 +39276,8 @@ var ts; } return neverType; } - function getLiteralTypeFromPropertyNames(type, include) { - return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromPropertyName(t, include); })); + function getLiteralTypeFromProperties(type, include) { + return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromProperty(t, include); })); } function getNonEnumNumberIndexInfo(type) { var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); @@ -38683,16 +39285,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromProperties(type, 128 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 /* StringLiteral */ | 8192 /* UniqueESSymbol */)]) : + getLiteralTypeFromProperties(type, 8576 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -38703,17 +39305,17 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 32768 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 128 /* KeyOfKeyword */: + case 129 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 141 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ + case 142 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 139 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; @@ -38722,7 +39324,7 @@ var ts; return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(2097152 /* IndexedAccess */); + var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; @@ -38743,28 +39345,32 @@ var ts; if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { return true; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { return isJSLiteralType(getResolvedBaseConstraint(type)); } return false; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol, missingType) { - var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; - var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - undefined; + var accessExpression = accessNode && accessNode.kind === 190 /* ElementAccessExpression */ ? accessNode : undefined; + var propName = isTypeUsableAsLateBoundName(indexType) + ? getLateBoundNameFromType(indexType) + : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) + ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) + : accessNode && ts.isPropertyName(accessNode) + // late bound names are handled in the first branch, so here we only need to handle normal names + ? ts.getPropertyNameForPropertyNameNode(accessNode) + : undefined; if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 100 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); return missingType; @@ -38780,22 +39386,22 @@ var ts; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; })) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; }); } } - if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 32768 /* Never */)) { + if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { + if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -38803,7 +39409,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 32768 /* Never */) { + if (indexType.flags & 131072 /* Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -38836,8 +39442,8 @@ var ts; return anyType; } if (accessNode) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + var indexNode = getIndexNodeForAccessExpression(accessNode); + if (indexType.flags & (128 /* StringLiteral */ | 256 /* 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 */)) { @@ -38852,14 +39458,33 @@ var ts; } return missingType; } + function getIndexNodeForAccessExpression(accessNode) { + return accessNode.kind === 190 /* ElementAccessExpression */ + ? accessNode.argumentExpression + : accessNode.kind === 180 /* IndexedAccessType */ + ? accessNode.indexType + : accessNode.kind === 149 /* ComputedPropertyName */ + ? accessNode.expression + : accessNode; + } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */); } function getSimplifiedType(type) { - return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + } + function distributeIndexOverObjectType(objectType, indexType) { + // (T | U)[K] -> T[K] | U[K] + if (objectType.flags & 1048576 /* Union */) { + return mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); + } + // (T & U)[K] -> T[K] & U[K] + if (objectType.flags & 2097152 /* Intersection */) { + return getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + } } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -38873,18 +39498,14 @@ var ts; var objectType = getSimplifiedType(type.objectType); var indexType = getSimplifiedType(type.indexType); // T[A | B] -> T[A] | T[B] - if (indexType.flags & 262144 /* Union */) { + if (indexType.flags & 1048576 /* Union */) { return type.simplified = mapType(indexType, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t)); }); } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 15794176 /* Instantiable */)) { - // (T | U)[K] -> T[K] | U[K] - if (objectType.flags & 262144 /* Union */) { - return type.simplified = mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); - } - // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 524288 /* Intersection */) { - return type.simplified = getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + if (!(indexType.flags & 63176704 /* Instantiable */)) { + var simplified = distributeIndexOverObjectType(objectType, indexType); + if (simplified) { + return type.simplified = simplified; } } // So ultimately: @@ -38896,7 +39517,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 65536 /* TypeParameter */) { + if (objectType.flags & 262144 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -38919,7 +39540,7 @@ var ts; // 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 === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 180 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -38935,7 +39556,7 @@ 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 = getApparentType(objectType); - if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { @@ -38966,7 +39587,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -38988,7 +39609,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; + return type.flags & 33554432 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -38999,7 +39620,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 63176704 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -39038,7 +39659,7 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(4194304 /* Conditional */); + var result = createType(16777216 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -39070,7 +39691,7 @@ var ts; return true; } while (node) { - if (node.kind === 173 /* ConditionalType */) { + if (node.kind === 175 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -39093,7 +39714,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -39213,6 +39834,9 @@ var ts; function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } + function isNonGenericObjectType(type) { + return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + } /** * Since the source of spread types are object literals, which are not binary, * this function should be called in a left folding style, with left = previous result of getSpreadType @@ -39225,21 +39849,37 @@ var ts; if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { return unknownType; } - if (left.flags & 32768 /* Never */) { + if (left.flags & 131072 /* Never */) { return right; } - if (right.flags & 32768 /* Never */) { + if (right.flags & 131072 /* Never */) { return left; } - if (left.flags & 262144 /* Union */) { + if (left.flags & 1048576 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 262144 /* Union */) { + if (right.flags & 1048576 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { + if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { return left; } + if (isGenericObjectType(left) || isGenericObjectType(right)) { + if (isEmptyObjectType(left)) { + return right; + } + // 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 */) { + var types = left.types; + var lastLeft = types[types.length - 1]; + if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { + return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, typeFlags, objectFlags)])); + } + } + return getIntersectionType([left, right]); + } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); var stringIndexInfo; @@ -39259,7 +39899,7 @@ var ts; skippedPrivateMembers.set(rightProp.escapedName, true); } else if (isSpreadableProperty(rightProp)) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSpreadSymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -39274,7 +39914,7 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -39283,27 +39923,28 @@ var ts; } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSpreadSymbol(leftProp)); } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; - spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); + spread.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 1024 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */) - ? !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }) - : !(prop.flags & 65536 /* SetAccessor */); // Setter without getter is not spreadable + return !(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }); } - function getNonReadonlySymbol(prop) { - if (!isReadonlySymbol(prop)) { + function getSpreadSymbol(prop) { + var isReadonly = isReadonlySymbol(prop); + var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (!isReadonly && !isSetonlyAccessor) { return prop; } var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); var result = createSymbol(flags, prop.escapedName); - result.type = getTypeOfSymbol(prop); + result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = prop.nameType; result.syntheticOrigin = prop; @@ -39322,10 +39963,11 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 448 /* Literal */ && !(type.flags & 33554432 /* FreshLiteral */)) { - if (!type.freshType) { // NOTE: Safe because all freshable intrinsics always have fresh types already - var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); + if (type.flags & 2944 /* Literal */) { + if (!type.freshType) { + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; + freshType.freshType = freshType; type.freshType = freshType; } return type.freshType; @@ -39333,21 +39975,27 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + return type.flags & 2944 /* Literal */ ? type.regularType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : type; } + function isFreshLiteralType(type) { + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', // where NNN is the text representation of a numeric literal and SSS are the characters // of a string literal. For literal enum members we use 'EEE#NNN' and 'EEE@SSS', where // EEE is a unique id for the containing enum type. - var qualifier = typeof value === "number" ? "#" : "@"; - var key = enumId ? enumId + qualifier + value : qualifier + value; + var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; + var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value); var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 256 /* NumberLiteral */ : + typeof value === "string" ? 128 /* StringLiteral */ : 2048 /* BigIntLiteral */) | + (enumId ? 1024 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); + type.regularType = type; } return type; } @@ -39359,7 +40007,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(2048 /* UniqueESSymbol */); + var type = createType(8192 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -39374,9 +40022,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 241 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 157 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -39392,87 +40040,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 120 /* AnyKeyword */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return anyType; - case 142 /* UnknownKeyword */: + case 143 /* UnknownKeyword */: return unknownType; - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return stringType; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return numberType; - case 122 /* BooleanKeyword */: + case 146 /* BigIntKeyword */: + return bigintType; + case 123 /* BooleanKeyword */: return booleanType; - case 138 /* SymbolKeyword */: + case 139 /* SymbolKeyword */: return esSymbolType; - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return voidType; - case 140 /* UndefinedKeyword */: + case 141 /* UndefinedKeyword */: return undefinedType; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullType; - case 131 /* NeverKeyword */: + case 132 /* NeverKeyword */: return neverType; - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return getTypeFromTypeReference(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return booleanType; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 175 /* ParenthesizedType */: - case 170 /* RestType */: - case 285 /* JSDocNonNullableType */: - case 281 /* JSDocTypeExpression */: + case 177 /* ParenthesizedType */: + case 172 /* RestType */: + case 287 /* JSDocNonNullableType */: + case 283 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 174 /* InferType */: + case 176 /* InferType */: return getTypeFromInferTypeNode(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -39553,10 +40203,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; + return type.flags & 262144 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(65536 /* TypeParameter */); + var result = createType(262144 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -39602,7 +40252,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -39682,8 +40332,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 146 /* QualifiedName */ || - node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 148 /* QualifiedName */ || + node.parent.kind === 164 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -39691,19 +40341,19 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 218 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 176 /* ThisType */: + case 178 /* ThisType */: return !!tp.isThisType; - case 71 /* Identifier */: + case 72 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -39711,9 +40361,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 1048576 /* Index */) { + if (constraintType.flags & 4194304 /* Index */) { var typeVariable = constraintType.type; - if (typeVariable.flags & 65536 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeParameter */) { return typeVariable; } } @@ -39743,7 +40393,7 @@ var ts; } type.instantiating = true; var result = mapType(mappedTypeVariable, function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */) && t !== wildcardType) { + if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType) { var replacementMapper = createReplacementMapper(typeVariable, t, mapper); return isArrayType(t) ? createArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : isReadonlyArrayType(t) ? createReadonlyArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : @@ -39774,7 +40424,7 @@ var ts; var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper) { @@ -39819,7 +40469,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -39842,10 +40492,10 @@ var ts; } function instantiateTypeWorker(type, mapper) { var flags = type.flags; - if (flags & 65536 /* TypeParameter */) { + if (flags & 262144 /* TypeParameter */) { return mapper(type); } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or @@ -39864,32 +40514,32 @@ var ts; } return type; } - if (flags & 262144 /* Union */ && !(flags & 32764 /* Primitive */)) { + if (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 1048576 /* Index */) { + if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } return type; } function getWildcardInstantiation(type) { - return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : + return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -39898,34 +40548,34 @@ 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 !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 202 /* BinaryExpression */: - return node.operatorToken.kind === 54 /* BarBarToken */ && + case 204 /* BinaryExpression */: + return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 266 /* JsxAttributes */: - return ts.some(node.properties, isContextSensitive); - case 265 /* JsxAttribute */: { + case 268 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); + case 267 /* 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 268 /* JsxExpression */: { + case 270 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -39942,7 +40592,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* 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); @@ -39955,14 +40605,14 @@ var ts; function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 216 /* Block */ ? false : isContextSensitive(body); + return body.kind === 218 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -39973,7 +40623,7 @@ var ts; return result; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -39988,6 +40638,9 @@ var ts; function compareTypesAssignable(source, target) { return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; } + function compareTypesSubtypeOf(source, target) { + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); } @@ -40003,11 +40656,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : - target === globalObjectType ? !!(source.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 131072 /* Object */) && isFunctionObjectType(source) : + 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) || emptyObjectType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)); } /** @@ -40045,7 +40698,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 4194304 /* Conditional */ || (type.flags & 524288 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage) { if (!node || isOrHasGenericConditional(target)) @@ -40054,23 +40707,23 @@ var ts; return true; } switch (node.kind) { - case 268 /* JsxExpression */: - case 193 /* ParenthesizedExpression */: + case 270 /* JsxExpression */: + case 195 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage); } break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return elaborateJsxAttributes(node, source, target, relation); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation); } return false; @@ -40082,7 +40735,7 @@ var ts; var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 32768 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = {}; checkTypeAssignableTo(source, target, node, headMessage, /*containingChain*/ undefined, resultObj); @@ -40139,8 +40792,10 @@ var ts; var reportedError = false; 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 sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); var targetPropType = getIndexedAccessType(target, nameType, /*accessNode*/ undefined, errorType); + if (targetPropType === errorType || targetPropType.flags & 8388608 /* IndexedAccess */) + continue; // Don't elaborate on indexes on generic variables + var sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); if (sourcePropType !== errorType && targetPropType !== errorType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined); if (elaborated) { @@ -40162,7 +40817,7 @@ var ts; var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; var issuedElaboration = false; if (!targetProp) { - var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(nameType, 296 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || getIndexInfoOfType(target, 0 /* String */) || undefined; if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) { @@ -40173,7 +40828,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) { - addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + 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))); } } } @@ -40266,17 +40921,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 32768 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 157 /* SetAccessor */: return [3 /*break*/, 2]; - case 156 /* GetAccessor */: return [3 /*break*/, 2]; - case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 159 /* SetAccessor */: return [3 /*break*/, 2]; + case 158 /* GetAccessor */: return [3 /*break*/, 2]; + case 156 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 276 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 275 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -40335,8 +40990,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && - kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 156 /* MethodDeclaration */ && + kind !== 155 /* MethodSignature */ && kind !== 157 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -40370,7 +41025,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : @@ -40462,12 +41117,15 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 16777216 /* NonPrimitive */ ? true : - type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 524288 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* Object */ ? 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) : false; } + function isEmptyAnonymousObjectType(type) { + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && isEmptyObjectType(type); + } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { if (sourceSymbol === targetSymbol) { return true; @@ -40504,43 +41162,45 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) return true; - if (t & 32768 /* Never */) + if (t & 131072 /* Never */) return false; - if (s & 68 /* StringLike */ && t & 4 /* String */) + if (s & 132 /* StringLike */ && t & 4 /* String */) return true; - if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && - t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && + t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 168 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && - t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && + t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true; - if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) + if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + return true; + if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true; if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { - if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { + if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 448 /* Literal */ && t & 448 /* Literal */ && + if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) + if (s & 32768 /* Undefined */ && (!strictNullChecks || t & (32768 /* Undefined */ | 16384 /* Void */))) return true; - if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) + if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */)) return true; - if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) + if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) return true; - if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) + if (s & 8192 /* UniqueESSymbol */ || t & 8192 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -40548,30 +41208,30 @@ var ts; // 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 */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { + if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { + if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -40591,6 +41251,7 @@ var ts; */ function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; + var relatedInfo; var maybeKeys; var sourceStack; var targetStack; @@ -40598,7 +41259,7 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var isIntersectionConstituent = false; + var suppressNextError = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { @@ -40625,15 +41286,27 @@ var ts; } } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (relatedInfo) { + addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + } if (errorOutputContainer) { errorOutputContainer.error = diag; } diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { + function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); + } + function associateRelatedInfo(info) { + ts.Debug.assert(!!errorInfo); + if (!relatedInfo) { + relatedInfo = [info]; + } + else { + relatedInfo.push(info); + } } function reportRelationError(message, source, target) { var sourceType = typeToString(source); @@ -40666,7 +41339,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 786432 /* UnionOrIntersection */)) { + if (!(type.flags & 3145728 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -40674,7 +41347,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 24576 /* Nullable */) { + if (t.flags & 98304 /* Nullable */) { continue; } if (seenNonNullable) { @@ -40690,24 +41363,24 @@ var ts; * * Ternary.Maybe if they are related with assumptions of other relationships, or * * Ternary.False if they are not related. */ - function isRelatedTo(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage, isApparentIntersectionConstituent) { if (reportErrors === void 0) { reportErrors = false; } - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } - if (source.flags & 8388608 /* Substitution */) { + if (source.flags & 33554432 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 8388608 /* Substitution */) { + if (target.flags & 33554432 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8388608 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 2097152 /* IndexedAccess */) { + if (target.flags & 8388608 /* IndexedAccess */) { target = getSimplifiedType(target); } // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. @@ -40719,10 +41392,10 @@ var ts; // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" // when dealing with generics. // * We also don't deal with primitive source types, since we already halt elaboration below. - if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && - target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { - var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); - if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); + if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { target = nullStrippedTarget; } } @@ -40732,11 +41405,12 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { - var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + if (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */) { + var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -40751,11 +41425,11 @@ var ts; source = getRegularTypeOfObjectLiteral(source); } } - if (relation !== comparableRelation && !isIntersectionConstituent && - source.flags & (32764 /* Primitive */ | 131072 /* Object */ | 524288 /* Intersection */) && source !== globalObjectType && - target.flags & (131072 /* Object */ | 524288 /* Intersection */) && isWeakType(target) && + if (relation !== comparableRelation && !isApparentIntersectionConstituent && + source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && + target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target)) { + !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -40771,25 +41445,24 @@ var ts; } var result = 0 /* False */; var saveErrorInfo = errorInfo; - var saveIsIntersectionConstituent = isIntersectionConstituent; - isIntersectionConstituent = false; + var isIntersectionConstituent = !!isApparentIntersectionConstituent; // 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 & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { - if (target.flags & 262144 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); + if (target.flags & 1048576 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); } - else if (target.flags & 524288 /* Intersection */) { - isIntersectionConstituent = true; + else if (target.flags & 2097152 /* Intersection */) { + isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 524288 /* Intersection */) { + else if (source.flags & 2097152 /* Intersection */) { // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually @@ -40805,13 +41478,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { - if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { + if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 524288 /* Intersection */) { + if (!result && source.flags & 2097152 /* Intersection */) { // 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 @@ -40821,22 +41494,23 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { + if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { + var maybeSuppress = suppressNextError; + suppressNextError = false; + if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* 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) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -40846,6 +41520,10 @@ var ts; return result; } } + if (!headMessage && maybeSuppress) { + // Used by, eg, missing property checking to replace the top-level message with a more informative one + return result; + } reportRelationError(headMessage, source, target); } return result; @@ -40853,10 +41531,10 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 131072 /* Object */ || flags & 2097152 /* IndexedAccess */ || flags & 4194304 /* Conditional */ || flags & 1048576 /* Index */ || flags & 8388608 /* Substitution */) { - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); + if (flags & 524288 /* Object */ || flags & 8388608 /* IndexedAccess */ || flags & 16777216 /* Conditional */ || flags & 4194304 /* Index */ || flags & 33554432 /* Substitution */) { + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); } - if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { + if (flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -40869,7 +41547,7 @@ var ts; if (!noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 524288 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -40880,16 +41558,17 @@ var ts; return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } var _loop_6 = function (prop) { - if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. if (!errorNode) return { value: ts.Debug.fail() }; - if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. + // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -40925,8 +41604,8 @@ var ts; } return false; } - function isPropertyFromSpread(prop, container) { - return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + function shouldCheckAsExcessProperty(prop, container) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration; } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; @@ -40943,7 +41622,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -40964,9 +41643,9 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 131072 /* Object */) { + if (target.flags & 524288 /* Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); if (overlapObjFlags & 4 /* Reference */) { return source.target === target.target; @@ -40994,11 +41673,13 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - if (sourceProperties) { - var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); - if (sourcePropertiesFiltered) { - return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + if (target.flags & 1048576 /* Union */) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (sourcePropertiesFiltered) { + return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + } } } return undefined; @@ -41008,7 +41689,7 @@ var ts; 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, reportErrors); + var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, /*isIntersectionConstituent*/ true); if (!related) { return 0 /* False */; } @@ -41018,7 +41699,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -41043,9 +41724,10 @@ var ts; } return result; } - function typeArgumentsRelatedTo(source, target, variances, reportErrors) { - var sources = source.typeArguments || ts.emptyArray; - var targets = target.typeArguments || ts.emptyArray; + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + if (sources === void 0) { sources = ts.emptyArray; } + if (targets === void 0) { targets = ts.emptyArray; } + if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { return 0 /* False */; } @@ -41099,7 +41781,7 @@ var ts; // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function recursiveTypeRelatedTo(source, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0 /* False */; } @@ -41142,7 +41824,7 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; - var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -41165,21 +41847,21 @@ var ts; function getConstraintForRelation(type) { return relation === definitelyAssignableRelation ? undefined : getConstraintOfType(type); } - function structuredTypeRelatedTo(source, target, reportErrors) { + function structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { var flags = source.flags & target.flags; - if (relation === identityRelation && !(flags & 131072 /* Object */)) { - if (flags & 1048576 /* Index */) { + if (relation === identityRelation && !(flags & 524288 /* Object */)) { + if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } var result_2 = 0 /* False */; - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { if (result_2 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result_2; } } } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result_2 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -41192,7 +41874,7 @@ var ts; } } } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; @@ -41200,9 +41882,22 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 65536 /* TypeParameter */) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + // 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 (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && + source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && + !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { + var variances = getAliasVariances(source.aliasSymbol); + if (result = typeArgumentsRelatedTo(source.aliasTypeArguments, target.aliasTypeArguments, variances, reportErrors)) { + return result; + } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; + } + if (target.flags & 262144 /* 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 */ && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); @@ -41212,9 +41907,9 @@ var ts; } } } - else if (target.flags & 1048576 /* Index */) { + else if (target.flags & 4194304 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 1048576 /* Index */) { + if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -41235,7 +41930,7 @@ var ts; } } } - else if (target.flags & 2097152 /* IndexedAccess */) { + else if (target.flags & 8388608 /* IndexedAccess */) { // A type S is related to a type T[K], where T and K aren't both type variables, if S is related to C, // where C is the base constraint of T[K] if (relation !== identityRelation && !(isGenericObjectType(target.objectType) && isGenericIndexType(target.indexType))) { @@ -41252,22 +41947,24 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 8388608 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (!isGenericMappedType(source) && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + // A source type T is related to a target type { [P in Q]: X } if Q is related to keyof T and T[Q] is related to X. + if (!isGenericMappedType(source) && isRelatedTo(getConstraintTypeFromMappedType(target), getIndexType(source))) { var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { return result; } } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; } } - if (source.flags & 2162688 /* TypeVariable */) { - if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8650752 /* TypeVariable */) { + if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { // 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, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); @@ -41278,29 +41975,32 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { + if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } } - else { - var instantiated = getTypeWithThisArgument(constraint, source); - if (result = isRelatedTo(instantiated, target, reportErrors)) { - errorInfo = 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, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = 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, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = saveErrorInfo; + return result; } } - else if (source.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 4194304 /* Conditional */) { - if (target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */) { + if (target.flags & 16777216 /* 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. @@ -41349,7 +42049,7 @@ var ts; if (relation === definitelyAssignableRelation && isGenericMappedType(source)) { return 0 /* False */; } - var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } @@ -41359,7 +42059,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - if (result = typeArgumentsRelatedTo(source, target, variances, reportErrors)) { + if (result = typeArgumentsRelatedTo(source.typeArguments, target.typeArguments, variances, reportErrors)) { return result; } // The type arguments did not relate appropriately, but it may be because we have no variance @@ -41394,7 +42094,7 @@ var ts; // 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 (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors); @@ -41444,7 +42144,24 @@ var ts; var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties)); + if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code && + headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) { + suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it + } + if (props.length === 1) { + var propName = symbolToString(unmatchedProperty); + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, typeToString(source), typeToString(target)); + if (ts.length(unmatchedProperty.declarations)) { + associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); + } + } + else if (props.length > 5) { // arbitrary cutoff for too-long list form + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, typeToString(source), typeToString(target), ts.map(props.slice(0, 4), function (p) { return symbolToString(p); }).join(", "), props.length - 4); + } + else { + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); + } } return 0 /* False */; } @@ -41491,8 +42208,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { - var targetProp = properties_3[_b]; + for (var _b = 0, properties_2 = properties; _b < properties_2.length; _b++) { + var targetProp = properties_2[_b]; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { @@ -41563,7 +42280,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { + if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -41691,7 +42408,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 8192 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -41810,20 +42527,19 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; } - function hasCommonProperties(source, target) { - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + function hasCommonProperties(source, target, isComparingJsxAttributes) { for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { @@ -41839,62 +42555,71 @@ var ts; result.objectFlags |= 8192 /* MarkerType */; return result; } + 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 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 if we're not in strictFunctionTypes mode or if the function // has been invoked recursively for the given generic type. + function getVariancesWorker(typeParameters, cache, createMarkerType) { + if (typeParameters === void 0) { typeParameters = ts.emptyArray; } + var variances = cache.variances; + if (!variances) { + // The emptyArray singleton is used to signal a recursive invocation. + cache.variances = ts.emptyArray; + variances = []; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var tp = typeParameters_1[_i]; + // 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 */; + } + variances.push(variance); + } + cache.variances = variances; + } + return variances; + } function getVariances(type) { if (!strictFunctionTypes) { return ts.emptyArray; } - var typeParameters = type.typeParameters || ts.emptyArray; - var variances = type.variances; - if (!variances) { - if (type === globalArrayType || type === globalReadonlyArrayType) { - // Arrays are known to be covariant, no need to spend time computing this - variances = [1 /* Covariant */]; - } - else { - // The emptyArray singleton is used to signal a recursive invocation. - type.variances = ts.emptyArray; - variances = []; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - // 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 = getMarkerTypeReference(type, tp, markerSuperType); - var typeWithSub = getMarkerTypeReference(type, 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(getMarkerTypeReference(type, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; - } - variances.push(variance); - } - } - type.variances = variances; + if (type === globalArrayType || type === globalReadonlyArrayType) { + // Arrays are known to be covariant, no need to spend time computing this (emptyArray implies covariance for all parameters) + return ts.emptyArray; } - return variances; + return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference); } // 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(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 16384 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 65536 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); @@ -41987,13 +42712,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 131072 /* Object */) { + if (depth >= 5 && type.flags & 524288 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 131072 /* Object */ && t.symbol === symbol) { + if (t.flags & 524288 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -42099,7 +42824,7 @@ var ts; for (var i = 0; i < targetLen; i++) { var s = getTypeAtPosition(source, i); var t = getTypeAtPosition(target, i); - var related = compareTypes(s, t); + var related = compareTypes(t, s); if (!related) { return 0 /* False */; } @@ -42144,9 +42869,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -42163,7 +42888,7 @@ var ts; // 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 return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -42183,35 +42908,37 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); + return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 27072 /* Unit */); + return !!(type.flags & 109440 /* Unit */); } function isLiteralType(type) { return type.flags & 16 /* Boolean */ ? true : - type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : - type; + return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 512 /* BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type; } function getWidenedLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, 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 */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -42237,6 +42964,10 @@ var ts; function getLengthOfTupleType(type) { return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); } + function isZeroBigInt(_a) { + var value = _a.value; + return value.base10Value === "0"; + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -42249,15 +42980,16 @@ 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 & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : - type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : - type.flags & 256 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 256 /* BooleanLiteral */ : 0 : - type.flags & 29148 /* PossiblyFalsy */; + 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 */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { @@ -42266,12 +42998,14 @@ var ts; function getDefinitelyFalsyPartOfType(type) { return type.flags & 4 /* String */ ? emptyStringType : type.flags & 8 /* Number */ ? zeroType : - type === regularFalseType || - type === falseType || - type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || - type.flags & 64 /* StringLiteral */ && type.value === "" || - type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : - neverType; + type.flags & 64 /* BigInt */ ? zeroBigIntType : + type === regularFalseType || + type === falseType || + type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */) || + type.flags & 128 /* StringLiteral */ && type.value === "" || + type.flags & 256 /* NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + neverType; } /** * Add undefined or null or both to a type if they are missing. @@ -42279,15 +43013,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); return missing === 0 ? type : - missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 16384 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -42297,7 +43031,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -42340,7 +43074,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -42350,7 +43084,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; + regularNew.flags = resolved.flags; regularNew.objectFlags |= 128 /* ObjectLiteral */ | (ts.getObjectFlags(resolved) & 16384 /* JSLiteral */); type.regularType = regularNew; return regularNew; @@ -42438,15 +43172,15 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (type.flags & 402653184 /* RequiresWidening */) { - if (type.flags & 24576 /* Nullable */) { + if (type.flags & 98304 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* 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 {}). @@ -42472,7 +43206,7 @@ var ts; function reportWideningErrorsInType(type) { var errorReported = false; if (type.flags & 134217728 /* ContainsWideningType */) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -42516,39 +43250,42 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 202 /* BinaryExpression */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + case 204 /* BinaryExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* 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 149 /* Parameter */: + case 151 /* Parameter */: diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + 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 184 /* BindingElement */: + case 186 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + diagnostic = noImplicitAny ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type : ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage; break; - case 179 /* MappedType */: + case 181 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } return; default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + diagnostic = noImplicitAny ? ts.Diagnostics.Variable_0_implicitly_has_an_1_type : ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; } errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } @@ -42627,11 +43364,11 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 15794176 /* Instantiable */ || + return !!(type.flags & 63176704 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -42640,13 +43377,13 @@ var ts; return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 3145728 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, 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 & 64 /* StringLiteral */)) { + if (!(t.flags & 128 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -42667,25 +43404,25 @@ var ts; * property is computed by inferring from the source property type to X for the type * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ - function inferTypeForHomomorphicMappedType(source, target) { - var key = source.id + "," + target.id; + function inferTypeForHomomorphicMappedType(source, target, constraint) { + var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } reverseMappedCache.set(key, undefined); - var type = createReverseMappedType(source, target); + var type = createReverseMappedType(source, target, constraint); reverseMappedCache.set(key, type); return type; } - function createReverseMappedType(source, target) { + function createReverseMappedType(source, target, constraint) { var properties = getPropertiesOfType(source); if (properties.length === 0 && !getIndexInfoOfType(source, 0 /* String */)) { return undefined; } // If any property contains context sensitive functions that have been skipped, the source type // is incomplete and we can't infer a meaningful input type. - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var prop = properties_3[_i]; if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } @@ -42693,13 +43430,13 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isReadonlyArrayType(source)) { - return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target); }); + var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.associatedNames); @@ -42709,30 +43446,46 @@ var ts; var reversed = createObjectType(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; + reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType); + return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); } - function inferReverseMappedType(sourceType, target) { - var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target)); + function inferReverseMappedType(sourceType, target, constraint) { + var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); var inference = createInferenceInfo(typeParameter); inferTypes([inference], sourceType, templateType); return getTypeFromInference(inference); } - function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; - if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (!sourceProp) { - return targetProp; - } + function getUnmatchedProperties(source, target, requireOptionalProperties) { + var properties, _i, properties_4, targetProp, sourceProp; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + properties = target.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + _i = 0, properties_4 = properties; + _a.label = 1; + case 1: + if (!(_i < properties_4.length)) return [3 /*break*/, 4]; + targetProp = properties_4[_i]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */))) return [3 /*break*/, 3]; + sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (!!sourceProp) return [3 /*break*/, 3]; + return [4 /*yield*/, targetProp]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; } - } - return undefined; + }); + } + function getUnmatchedProperty(source, target, requireOptionalProperties) { + return getUnmatchedProperties(source, target, requireOptionalProperties).next().value; } function tupleTypesDefinitelyUnrelated(source, target) { return target.target.minLength > source.target.minLength || @@ -42782,8 +43535,8 @@ var ts; } return; } - if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || - source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { + if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || + source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -42806,7 +43559,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { + else if (t.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -42821,7 +43574,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 2162688 /* TypeVariable */) { + if (target.flags & 8650752 /* 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 @@ -42829,7 +43582,7 @@ 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.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType || (priority & 8 /* ReturnType */ && (source === autoType || source === autoArrayType))) { return; } var inference = getInferenceInfoForType(target); @@ -42851,12 +43604,30 @@ var ts; inference.candidates = ts.appendIfUnique(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } return; } + else { + // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine + var simplified = getSimplifiedType(target); + if (simplified !== target) { + inferFromTypesOnce(source, simplified); + } + else if (target.flags & 8388608 /* IndexedAccess */) { + var indexType = getSimplifiedType(target.indexType); + // 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 & 63176704 /* Instantiable */) { + var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType), indexType); + if (simplified_1 && simplified_1 !== target) { + inferFromTypesOnce(source, simplified_1); + } + } + } + } } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments @@ -42873,12 +43644,12 @@ var ts; } } } - else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -42887,20 +43658,20 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */ && target.flags & 16777216 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 4194304 /* Conditional */) { + else if (target.flags & 16777216 /* Conditional */) { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } - else if (target.flags & 786432 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -42925,7 +43696,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 262144 /* Union */) { + else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -42934,12 +43705,12 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 63176704 /* 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 & (131072 /* Object */ | 524288 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* 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 @@ -42952,7 +43723,7 @@ var ts; } source = apparentSource; } - if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -42962,7 +43733,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 131072 /* Object */ && + var isNonConstructorObject = target.flags & 524288 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -42978,6 +43749,13 @@ var ts; } } } + function inferFromTypesOnce(source, target) { + var key = source.id + "," + target.id; + if (!visited || !visited.get(key)) { + (visited || (visited = ts.createMap())).set(key, true); + inferFromTypes(source, target); + } + } } function inferFromContravariantTypes(source, target) { if (strictFunctionTypes || priority & 64 /* AlwaysStrict */) { @@ -42990,7 +43768,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -43000,6 +43778,44 @@ var ts; } return undefined; } + function inferFromMappedTypeConstraint(source, target, constraintType) { + if (constraintType.flags & 1048576 /* Union */) { + var result = false; + for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { + var type = _a[_i]; + result = inferFromMappedTypeConstraint(source, target, type) || result; + } + return result; + } + if (constraintType.flags & 4194304 /* 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 + // such that direct inferences to T get priority over inferences to Partial, for example. + var inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + var savePriority = priority; + priority |= 2 /* HomomorphicMappedType */; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + return true; + } + if (constraintType.flags & 262144 /* TypeParameter */) { + // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type + // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. + var savePriority = priority; + priority |= 4 /* MappedTypeConstraint */; + inferFromTypes(getIndexType(source), constraintType); + priority = savePriority; + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return true; + } + return false; + } function inferFromObjectTypes(source, target) { if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer @@ -43009,31 +43825,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 1048576 /* 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 - // such that direct inferences to T get priority over inferences to Partial, for example. - var inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - var inferredType = inferTypeForHomomorphicMappedType(source, target); - if (inferredType) { - var savePriority = priority; - priority |= 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - return; - } - if (constraintType.flags & 65536 /* TypeParameter */) { - // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type - // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. - var savePriority = priority; - priority |= 4 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; - inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + if (inferFromMappedTypeConstraint(source, target, constraintType)) { return; } } @@ -43073,8 +43865,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -43097,7 +43889,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ || kind === 155 /* Constructor */; + bivariant = bivariant || kind === 156 /* MethodDeclaration */ || kind === 155 /* MethodSignature */ || kind === 157 /* Constructor */; forEachMatchingParameterType(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -43151,11 +43943,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 4194304 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 32764 /* Primitive */ | 1048576 /* Index */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -43204,7 +43996,7 @@ var ts; var inferredContravariantType = getContravariantInference(inference); // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype and not 'never'. - inferredType = inferredCovariantType && !(inferredCovariantType.flags & 32768 /* Never */) && + inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ? inferredCovariantType : inferredContravariantType; } @@ -43263,17 +44055,17 @@ var ts; case "console": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; case "$": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig; case "describe": case "suite": case "it": case "test": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig; case "process": case "require": case "Buffer": case "module": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig; case "Map": case "Set": case "Promise": @@ -43299,7 +44091,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 === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 167 /* TypeQuery */ ? true : n.kind === 72 /* Identifier */ || n.kind === 148 /* 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 @@ -43308,20 +44100,20 @@ var ts; // occurring in an apparent type position with '@' because the control flow type // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; } - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { return "0"; } - if (node.kind === 187 /* PropertyAccessExpression */) { + if (node.kind === 189 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 184 /* BindingElement */) { + if (node.kind === 186 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 186 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -43330,14 +44122,14 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 182 /* ObjectBindingPattern */) { + if (parent.kind === 184 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; default: @@ -43351,29 +44143,29 @@ var ts; } function isMatchingReference(source, target) { switch (source.kind) { - case 71 /* Identifier */: - return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && + case 72 /* Identifier */: + return target.kind === 72 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 237 /* VariableDeclaration */ || target.kind === 186 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 99 /* ThisKeyword */: - return target.kind === 99 /* ThisKeyword */; - case 97 /* SuperKeyword */: - return target.kind === 97 /* SuperKeyword */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 100 /* ThisKeyword */: + return target.kind === 100 /* ThisKeyword */; + case 98 /* SuperKeyword */: + return target.kind === 98 /* SuperKeyword */; + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return (ts.isPropertyAccessExpression(target) || ts.isElementAccessExpression(target)) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 184 /* BindingElement */: - if (target.kind !== 187 /* PropertyAccessExpression */) + case 186 /* BindingElement */: + if (target.kind !== 189 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 186 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 235 /* VariableDeclaration */) { + if (source.parent.parent.kind === 237 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -43386,7 +44178,7 @@ var ts; undefined; } function containsMatchingReference(source, target) { - while (source.kind === 187 /* PropertyAccessExpression */) { + while (source.kind === 189 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -43399,23 +44191,23 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 187 /* PropertyAccessExpression */ && + return target.kind === 189 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 71 /* Identifier */) { + if (expr.kind === 72 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 187 /* PropertyAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantType(type) { - if (type.flags & 262144 /* Union */) { - if (type.flags & (16 /* Boolean */ | 512 /* EnumLiteral */)) { + if (type.flags & 1048576 /* Union */) { + if (type.flags & (16 /* Boolean */ | 1024 /* EnumLiteral */)) { return true; } var combined = 0; @@ -43423,14 +44215,14 @@ var ts; var t = _a[_i]; combined |= t.flags; } - if (combined & 27072 /* Unit */ && !(combined & 15794176 /* Instantiable */)) { + if (combined & 109440 /* Unit */ && !(combined & 63176704 /* Instantiable */)) { return true; } } return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 262144 /* Union */) { + if (type && type.flags & 1048576 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { @@ -43441,6 +44233,10 @@ var ts; } return false; } + function hasNarrowableDeclaredType(expr) { + var type = getDeclaredTypeOfReference(expr); + return !!(type && type.flags & 1048576 /* Union */); + } function findDiscriminantProperties(sourceProperties, target) { var result; for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { @@ -43467,7 +44263,7 @@ var ts; } } } - if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 189 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -43481,7 +44277,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 262144 /* Union */)) { + if (!(source.flags & 1048576 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -43497,11 +44293,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 32768 /* Never */) { + if (assignedType.flags & 131072 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 33554432 /* FreshLiteral */ && assignedType.flags & 256 /* BooleanLiteral */) { + if (assignedType.flags & 512 /* 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. @@ -43532,57 +44328,66 @@ var ts; function getTypeFacts(type) { var flags = type.flags; if (flags & 4 /* String */) { - return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; + return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; } - if (flags & 64 /* StringLiteral */) { + if (flags & 128 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : - isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; } if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; + return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; } - if (flags & 128 /* NumberLiteral */) { + if (flags & 256 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : - isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; + isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + } + if (flags & 64 /* BigInt */) { + return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + } + if (flags & 2048 /* BigIntLiteral */) { + var isZero = isZeroBigInt(type); + return strictNullChecks ? + isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; } if (flags & 16 /* Boolean */) { - return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; + return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; } - if (flags & 272 /* BooleanLike */) { + if (flags & 528 /* BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 4079615 /* EmptyObjectStrictFacts */ : 4194303 /* EmptyObjectFacts */ : + strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : - strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : + strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { - return 2457472 /* UndefinedFacts */; + if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { + return 9830144 /* UndefinedFacts */; } - if (flags & 16384 /* Null */) { - return 2340752 /* NullFacts */; + if (flags & 65536 /* Null */) { + return 9363232 /* NullFacts */; } - if (flags & 3072 /* ESSymbolLike */) { - return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; + if (flags & 12288 /* ESSymbolLike */) { + return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; } - if (flags & 16777216 /* NonPrimitive */) { - return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + if (flags & 67108864 /* NonPrimitive */) { + return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & 15794176 /* Instantiable */) { + if (flags & 63176704 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 786432 /* UnionOrIntersection */) { + if (flags & 3145728 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } - return 4194303 /* All */; + return 16777215 /* All */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -43590,7 +44395,7 @@ var ts; function getTypeWithDefault(type, defaultExpression) { if (defaultExpression) { var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 131072 /* NEUndefined */), defaultType]); + return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); } return type; } @@ -43610,15 +44415,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 187 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 275 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 204 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 227 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -43635,21 +44440,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return stringType; - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return undefinedType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -43657,7 +44462,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 182 /* ObjectBindingPattern */ ? + var type = pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -43675,39 +44480,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 224 /* ForInStatement */) { + if (node.parent.parent.kind === 226 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.parent.kind === 227 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 235 /* VariableDeclaration */ ? + return node.kind === 237 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 235 /* VariableDeclaration */ && node.initializer && + return node.kind === 237 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && + node.kind !== 186 /* BindingElement */ && node.parent.kind === 204 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return getReferenceCandidate(node.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return getReferenceCandidate(node.right); } } @@ -43715,13 +44520,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 193 /* ParenthesizedExpression */ || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 195 /* ParenthesizedExpression */ || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */ && parent.left === node || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -43743,8 +44548,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 269 /* CaseClause */) { - if (clause.expression.kind === 9 /* StringLiteral */) { + if (clause.kind === 271 /* CaseClause */) { + if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; } @@ -43755,13 +44560,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* 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 & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -43770,30 +44575,30 @@ var ts; } return true; } - if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 262144 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfPrimitiveTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.primitiveTypesOnly); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return type; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return mapper(type); } var types = type.types; @@ -43823,12 +44628,14 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) || + isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : - t; + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : + t; }); } return typeWithPrimitives; @@ -43862,9 +44669,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 32768 /* Never */ ? + return elementType.flags & 131072 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 262144 /* Union */ ? + createArrayType(elementType.flags & 1048576 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -43882,7 +44689,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - if (!(t.flags & 32768 /* Never */)) { + if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -43904,15 +44711,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 189 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 191 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 190 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 202 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 58 /* EqualsToken */ && + parent.parent.kind === 204 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 59 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -43923,7 +44730,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 97 /* SuperKeyword */) { + if (node.expression.kind !== 98 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -43945,7 +44752,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -43955,8 +44762,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent && reference.parent.kind === 213 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -44028,9 +44835,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 187 /* PropertyAccessExpression */ && - reference.kind !== 188 /* ElementAccessExpression */ && - reference.kind !== 99 /* ThisKeyword */) { + reference.kind !== 189 /* PropertyAccessExpression */ && + reference.kind !== 190 /* ElementAccessExpression */ && + reference.kind !== 100 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -44068,7 +44875,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 262144 /* Union */) { + if (declaredType.flags & 1048576 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); } return declaredType; @@ -44082,19 +44889,23 @@ 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 === 194 /* FunctionExpression */ || init.kind === 195 /* ArrowFunction */)) { + if (init && (init.kind === 196 /* FunctionExpression */ || init.kind === 197 /* 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 === 226 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + } // Assignment doesn't affect reference return undefined; } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 189 /* CallExpression */ ? + var expr = node.kind === 191 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -44102,7 +44913,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -44111,7 +44922,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, 168 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -44125,7 +44936,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -44142,7 +44953,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 131072 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -44158,7 +44969,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 197 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 199 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } return createFlowType(type, isIncomplete(flowType)); @@ -44274,8 +45085,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 262144 /* Union */) || - expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (!(computedType.flags & 1048576 /* Union */) || + expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { return false; } var access = expr; @@ -44296,10 +45107,10 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); + return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } if (isMatchingReferenceDiscriminant(expr, declaredType)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); }); + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; @@ -44317,7 +45128,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -44325,19 +45136,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -44356,15 +45167,15 @@ var ts; return declaredType; } break; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 92 /* InKeyword */: + case 93 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); } break; - case 26 /* CommaToken */: + case 27 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -44373,28 +45184,28 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 24576 /* Nullable */) { + if (valueType.flags & 98304 /* Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; + var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 16384 /* Null */ ? - assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : - assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; + assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : + valueType.flags & 65536 /* Null */ ? + assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : + assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 16909315 /* NotUnionOrUnit */) { + if (type.flags & 67637251 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 131072 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -44406,22 +45217,22 @@ var ts; // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { - // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, target)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, a + // 'typeof x === ...' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, target) && hasNarrowableDeclaredType(target)) { return declaredType; } return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); function narrowTypeForTypeof(type) { if (type.flags & 2 /* Unknown */ && literal.text === "object") { @@ -44438,7 +45249,7 @@ var ts; if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -44457,13 +45268,37 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + } + function getImpliedTypeFromTypeofCase(type, text) { + switch (text) { + case "function": + return type.flags & 1 /* Any */ ? type : globalFunctionType; + case "object": + return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + default: + return typeofTypesByName.get(text) || type; + } + } + function narrowTypeForTypeofSwitch(candidate) { + return function (type) { + if (isTypeSubtypeOf(candidate, type)) { + return candidate; + } + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(candidate, constraint)) { + return getIntersectionType([type, candidate]); + } + } + return type; + }; } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); @@ -44482,7 +45317,7 @@ var ts; // that we don't have to worry about undefined // in the witness array. var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; }); - // The adjust clause start and end after removing the `default` statement. + // The adjusted clause start and end after removing the `default` statement. var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart; var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd; clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd); @@ -44492,6 +45327,9 @@ var ts; clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); } + if (hasDefaultClause) { + return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }); + } /* The implied type is the raw type suggested by a value being caught in this clause. @@ -44520,33 +45358,18 @@ var ts; boolean. We know that number cannot be selected because it is caught in the first clause. */ - if (!(hasDefaultClause || (type.flags & 262144 /* Union */))) { - var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return typeofTypesByName.get(text) || neverType; })), switchFacts); - if (impliedType.flags & 262144 /* Union */) { - impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOfType(type) || type); - } - if (!(impliedType.flags & 32768 /* Never */)) { - if (isTypeSubtypeOf(impliedType, type)) { - return impliedType; - } - if (type.flags & 15794176 /* Instantiable */) { - var constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(impliedType, constraint)) { - return getIntersectionType([type, impliedType]); - } - } - } + var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts); + if (impliedType.flags & 1048576 /* Union */) { + impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type)); } - return hasDefaultClause ? - filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }) : - getTypeWithFacts(type, switchFacts); + return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { - // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, left)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, an + // 'x instanceof T' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, left) && hasNarrowableDeclaredType(left)) { return declaredType; } return type; @@ -44583,9 +45406,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 & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 32768 /* Never */)) { + if (!(assignableType.flags & 131072 /* Never */)) { return assignableType; } } @@ -44625,7 +45448,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 190 /* ElementAccessExpression */ || invokedExpression.kind === 189 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -44642,20 +45465,20 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 200 /* PrefixUnaryExpression */: - if (expr.operator === 51 /* ExclamationToken */) { + case 202 /* PrefixUnaryExpression */: + if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -44669,7 +45492,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 === 71 /* Identifier */) { + if (location.kind === 72 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -44690,9 +45513,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 243 /* ModuleBlock */ || - node.kind === 277 /* SourceFile */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 245 /* ModuleBlock */ || + node.kind === 279 /* SourceFile */ || + node.kind === 154 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -44711,10 +45534,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 151 /* Parameter */) { symbol.isAssigned = true; } } @@ -44729,21 +45552,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 149 /* Parameter */ && + declaration.kind === 151 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 8192 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; + getFalsyFlags(declaredType) & 32768 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 187 /* PropertyAccessExpression */ || - parent.kind === 189 /* CallExpression */ && parent.expression === node || - parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 189 /* PropertyAccessExpression */ || + parent.kind === 191 /* CallExpression */ && parent.expression === node || + parent.kind === 190 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 186 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); + return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 98304 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -44774,7 +45597,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -44795,7 +45618,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 238 /* ClassDeclaration */ + if (declaration.kind === 240 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -44807,14 +45630,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 207 /* ClassExpression */) { + else if (declaration.kind === 209 /* 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 !== 277 /* SourceFile */) { + while (container.kind !== 279 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -44858,7 +45681,7 @@ 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 === 149 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 151 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -44867,8 +45690,8 @@ var ts; // 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 === 194 /* FunctionExpression */ || - flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 196 /* FunctionExpression */ || + flowContainer.kind === 197 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -44877,9 +45700,9 @@ var ts; // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || - node.parent.kind === 211 /* NonNullExpression */ || - declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 257 /* ExportSpecifier */) || + node.parent.kind === 213 /* NonNullExpression */ || + declaration.kind === 237 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -44888,7 +45711,7 @@ var ts; // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType || type === autoArrayType) { + if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) { if (flowType === autoType || flowType === autoArrayType) { if (noImplicitAny) { error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); @@ -44897,7 +45720,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* 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; @@ -44913,7 +45736,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -44936,7 +45759,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -44954,8 +45777,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 223 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && + if (container.kind === 225 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -44973,7 +45796,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 193 /* ParenthesizedExpression */) { + while (current.parent.kind === 195 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -44981,9 +45804,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 202 /* PrefixUnaryExpression */ || current.parent.kind === 203 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; + isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -44994,7 +45817,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { + if (container.kind === 154 /* PropertyDeclaration */ || container.kind === 157 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -45062,37 +45885,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 155 /* Constructor */) { + if (container.kind === 157 /* 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 === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* 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 241 /* EnumDeclaration */: + case 243 /* 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 155 /* Constructor */: + case 157 /* 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 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -45103,9 +45926,15 @@ var ts; var type = tryGetThisTypeAt(node, container); if (!type && noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' - error(node, capturedByArrowFunction && container.kind === 277 /* SourceFile */ ? + var diag = error(node, capturedByArrowFunction && container.kind === 279 /* SourceFile */ ? ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + if (!ts.isSourceFile(container)) { + var outsideThis = tryGetThisTypeAt(container); + if (outsideThis) { + addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + } + } } return type || anyType; } @@ -45131,7 +45960,7 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 194 /* FunctionExpression */ || container.kind === 237 /* FunctionDeclaration */) && + (container.kind === 196 /* FunctionExpression */ || container.kind === 239 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { var classType = getJSClassType(container.symbol); if (classType) { @@ -45157,7 +45986,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 194 /* FunctionExpression */ && + if (container.kind === 196 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -45167,24 +45996,49 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 154 /* MethodDeclaration */ && - container.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 156 /* MethodDeclaration */ && + container.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 194 /* FunctionExpression */ && - container.parent.kind === 273 /* PropertyAssignment */ && - container.parent.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 196 /* FunctionExpression */ && + container.parent.kind === 275 /* PropertyAssignment */ && + container.parent.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* 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 === 196 /* 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 */) { + return container.parent.parent.parent.arguments[0].expression; + } + // Object.defineProperty(x, "method", { value() { } }); + // Object.defineProperty(x, "method", { set(x: () => void) {} }); + // Object.defineProperty(x, "method", { get() { return () => {} } }); + else if (ts.isMethodDeclaration(container) && + ts.isIdentifier(container.name) && + (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") && + ts.isObjectLiteralExpression(container.parent) && + ts.isCallExpression(container.parent.parent) && + container.parent.parent.arguments[2] === container.parent && + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + return container.parent.parent.arguments[0].expression; + } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -45198,15 +46052,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 151 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 189 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 191 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 195 /* ArrowFunction */) { + while (container && container.kind === 197 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -45219,14 +46073,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); - if (current && current.kind === 147 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 149 /* ComputedPropertyName */; }); + if (current && current.kind === 149 /* 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 === 186 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -45234,7 +46088,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 155 /* Constructor */) { + if (!isCallExpression && container.kind === 157 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -45303,7 +46157,7 @@ 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 === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 156 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -45317,7 +46171,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (container.parent.kind === 188 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -45338,7 +46192,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 155 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 157 /* 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; @@ -45353,7 +46207,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 === 155 /* Constructor */; + return container.kind === 157 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -45361,21 +46215,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */; } else { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */ || - container.kind === 152 /* PropertyDeclaration */ || - container.kind === 151 /* PropertySignature */ || - container.kind === 155 /* Constructor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */ || + container.kind === 154 /* PropertyDeclaration */ || + container.kind === 153 /* PropertySignature */ || + container.kind === 157 /* Constructor */; } } } @@ -45383,10 +46237,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 154 /* MethodDeclaration */ || - func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 156 /* MethodDeclaration */ || + func.kind === 158 /* GetAccessor */ || + func.kind === 159 /* SetAccessor */) && func.parent.kind === 188 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 196 /* FunctionExpression */ && func.parent.kind === 275 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -45394,11 +46248,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -45425,7 +46279,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 273 /* PropertyAssignment */) { + if (literal.parent.kind !== 275 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -45439,9 +46293,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */) { var target = parent.left; - if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { + if (target.kind === 189 /* PropertyAccessExpression */ || target.kind === 190 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -45501,7 +46355,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -45513,7 +46367,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 184 /* BindingElement */) { + if (parentDeclaration.kind !== 186 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -45603,10 +46457,13 @@ var ts; // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); + if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { + return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 191 /* TaggedTemplateExpression */) { + if (template.parent.kind === 193 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -45615,7 +46472,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: if (node !== right) { return undefined; } @@ -45624,15 +46481,15 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); return !type && node === right && !ts.isDefaultedExpandoInitializer(binaryExpression) ? getTypeOfExpression(left) : type; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression) : undefined; default: return undefined; @@ -45699,13 +46556,17 @@ var ts; } var thisType = checkThisExpression(thisAccess.expression); return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - if (t.flags & 917504 /* StructuredType */) { + if (t.flags & 3670016 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -45716,8 +46577,8 @@ var ts; return restType; } } - return isNumericLiteralName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); + return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1 /* Number */) || + getIndexTypeOfContextualType(t, 0 /* String */); } return undefined; }, /*noReductions*/ true); @@ -45761,7 +46622,6 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || getIndexTypeOfContextualType(arrayContextualType, 1 /* Number */) || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -45803,35 +46663,36 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 71 /* Identifier */: - case 140 /* UndefinedKeyword */: + case 9 /* BigIntLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: + case 141 /* UndefinedKeyword */: return true; - case 187 /* PropertyAccessExpression */: - case 193 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 195 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 273 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 275 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 265 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 267 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (contextualType && contextualType.flags & 262144 /* Union */) { + if (contextualType && contextualType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, contextualType); } @@ -45868,54 +46729,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 186 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 195 /* ArrowFunction */: - case 228 /* ReturnStatement */: + case 197 /* ArrowFunction */: + case 230 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 185 /* ArrayLiteralExpression */: { + case 187 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 214 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); + case 216 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 206 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 193 /* ParenthesizedExpression */: { + case 195 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -45931,67 +46792,10 @@ var ts; // (as below) instead! return node.parent.contextualType; } - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - var valueType = checkExpression(node.tagName); - if (isTypeAny(valueType)) { - // Short-circuit if the class tag is using an element type 'any' - return anyType; - } - var isJs = ts.isInJSFile(node); - return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); + return getContextualTypeForArgumentAtIndex(node, 0); } - function getJsxSignaturesParameterTypes(valueType, isJs, context) { - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 4 /* String */) { - return anyType; - } - else if (valueType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = valueType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - } - return anyType; - } - // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(valueType, 1 /* Construct */); - var ctor = true; - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(valueType, 0 /* Call */); - ctor = false; - if (signatures.length === 0) { - // We found no signatures at all, which is an error - return errorType; - } - } - var links = getNodeLinks(context); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(valueType); - var cachedResolved = links.resolvedSignatures.get(cacheKey); - if (cachedResolved && cachedResolved !== resolvingSignaturesArray) { - signatures = cachedResolved; - } - else if (!cachedResolved) { - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); - links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures)); - } - return getUnionType(ts.map(signatures, ctor ? function (t) { return getJsxPropsTypeFromClassType(t, isJs, context, /*reportErrors*/ false); } : function (t) { return getJsxPropsTypeFromCallSignature(t, context); }), 0 /* None */); + function getEffectiveFirstArgumentForJsxSignature(signature, node) { + return getJsxReferenceKind(node) !== 0 /* Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); @@ -46006,22 +46810,40 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getStaticTypeOfReferencedJsxConstructor(context) { + if (isJsxIntrinsicIdentifier(context.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context); + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + var tagType = checkExpressionCached(context.tagName); + if (tagType.flags & 128 /* StringLiteral */) { + var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); + if (!result) { + return errorType; + } + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + return tagType; + } function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var ctorType = getStaticTypeOfReferencedJsxConstructor(context); if (ts.length(declaredManagedType.typeParameters) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); } } return attributesType; } - function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { + function getJsxPropsTypeFromClassType(sig, context) { var ns = getJsxNamespaceAt(context); var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined @@ -46034,7 +46856,7 @@ var ts; : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation); if (!attributesType) { // There is no property named 'props' on this instance type - if (reportErrors && !!forcedLookupLocation && !!ts.length(context.attributes.properties)) { + if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) { error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation)); } return emptyObjectType; @@ -46052,7 +46874,7 @@ var ts; var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams - ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isJs)) + ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context))) : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); @@ -46088,7 +46910,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; + return node.kind === 196 /* FunctionExpression */ || node.kind === 197 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -46107,7 +46929,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -46116,7 +46938,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -46155,8 +46977,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 184 /* BindingElement */ && !!node.initializer) || - (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 186 /* BindingElement */ && !!node.initializer) || + (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -46167,7 +46989,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 208 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -46192,12 +47014,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 208 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 208 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -46224,15 +47046,15 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 185 /* ArrayBindingPattern */ || pattern.kind === 187 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementCount; i < patternElements.length; i++) { var e = patternElements[i]; if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { - if (e.kind !== 208 /* OmittedExpression */) { + else if (i < patternElements.length - 1 || !(e.kind === 186 /* BindingElement */ && e.dotDotDotToken || e.kind === 208 /* SpreadElement */)) { + if (e.kind !== 210 /* OmittedExpression */) { error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -46250,12 +47072,12 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isNumericComputedName(name); - case 71 /* Identifier */: + case 72 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return isNumericLiteralName(name.text); default: return false; @@ -46264,7 +47086,7 @@ 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), 168 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -46299,8 +47121,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 24576 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -46327,10 +47149,10 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 33554432 /* FreshLiteral */; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 184 /* ObjectBindingPattern */ || contextualType.pattern.kind === 188 /* ObjectLiteralExpression */); var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -46343,13 +47165,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 149 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 273 /* PropertyAssignment */ || - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 275 /* PropertyAssignment */ || + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 275 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -46362,7 +47184,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -46373,8 +47195,8 @@ var ts; 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 === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 275 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 276 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -46399,12 +47221,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 275 /* SpreadAssignment */) { + else if (memberDecl.kind === 277 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); propertiesArray = []; propertiesTable = ts.createSymbolTable(); hasComputedStringProperty = false; @@ -46416,7 +47238,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 32768 /* FreshLiteral */); offset = i + 1; continue; } @@ -46426,10 +47248,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 === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 158 /* GetAccessor */ || memberDecl.kind === 159 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -46463,7 +47285,7 @@ var ts; } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); } return spread; } @@ -46472,9 +47294,8 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; - result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); - result.objectFlags |= 128 /* ObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags & 939524096 /* PropagatingFlags */; + result.objectFlags |= 128 /* ObjectLiteral */ | freshObjectLiteralFlag; if (isJSObjectLiteral) { result.objectFlags |= 16384 /* JSLiteral */; } @@ -46484,20 +47305,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 24576 /* Nullable */)) { - propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); - } + propagatedFlags |= result.flags & 939524096 /* PropagatingFlags */; return result; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || - getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 131072 /* Object */ && !isGenericMappedType(type) || - type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); + return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { - checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node); } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); @@ -46505,7 +47323,7 @@ var ts; } function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -46513,18 +47331,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } + checkJsxChildren(node); } function checkJsxElement(node, _checkMode) { checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxFragment(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment, checkMode); + function checkJsxFragment(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment); if (compilerOptions.jsx === 2 /* React */ && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) { error(node, compilerOptions.jsxFactory ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma); } + checkJsxChildren(node); return getJsxElementTypeAt(node) || anyType; } /** @@ -46538,7 +47358,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 === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 72 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -46557,18 +47377,19 @@ var ts; function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createSymbolTable(); - var spread = emptyObjectType; + var spread = emptyJsxObjectType; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var propagatingFlags = 0; + var typeFlags = 0; + var objectFlags = 4096 /* 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); - propagatingFlags |= (exprType.flags & 939524096 /* PropagatingFlags */); + typeFlags |= exprType.flags & 939524096 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | 33554432 /* Transient */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -46583,9 +47404,9 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 269 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); attributesTable = ts.createSymbolTable(); } var exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -46593,7 +47414,7 @@ var ts; hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, openingLikeElement.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, exprType, attributes.symbol, typeFlags, objectFlags); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -46602,11 +47423,11 @@ var ts; } if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 260 /* 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); @@ -46626,25 +47447,26 @@ var ts; (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, /*hasRestElement*/ false) || createArrayType(getUnionType(childrenTypes))); var childPropMap = ts.createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); - spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, typeFlags, objectFlags); } } if (hasSpreadAnyType) { return anyType; } - if (typeToIntersect && spread !== emptyObjectType) { + if (typeToIntersect && spread !== emptyJsxObjectType) { return getIntersectionType([typeToIntersect, spread]); } - return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); + return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread); /** * Create anonymous type from given attributes symbol table. * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable * @param attributesTable a symbol table of attributes property */ function createJsxAttributesType() { + objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= (propagatingFlags |= 268435456 /* ContainsObjectLiteral */); - result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + result.objectFlags |= 128 /* ObjectLiteral */ | objectFlags; return result; } } @@ -46654,7 +47476,7 @@ 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 === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { if (!child.containsOnlyWhiteSpaces) { childrenTypes.push(stringType); } @@ -46717,57 +47539,6 @@ var ts; } return links.resolvedSymbol; } - function instantiateJsxSignatures(node, signatures) { - var instantiatedSignatures = []; - var candidateForTypeArgumentError; - var hasTypeArgumentError = !!node.typeArguments; - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; - if (signature.typeParameters) { - var isJavascript = ts.isInJSFile(node); - var typeArgumentInstantiated = getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, /*reportErrors*/ false); - if (typeArgumentInstantiated) { - hasTypeArgumentError = false; - instantiatedSignatures.push(typeArgumentInstantiated); - } - else { - if (node.typeArguments && hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - candidateForTypeArgumentError = signature; - } - var inferenceContext = createInferenceContext(signature.typeParameters, signature, /*flags*/ isJavascript ? 2 /* AnyDefault */ : 0 /* None */); - var typeArguments = inferJsxTypeArguments(signature, node, inferenceContext); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); - } - } - else { - instantiatedSignatures.push(signature); - } - } - if (node.typeArguments && hasTypeArgumentError) { - if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true); - } - // Length check to avoid issuing an arity error on length=0, the "Type argument list cannot be empty" grammar error alone is fine - else if (node.typeArguments.length !== 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, node.typeArguments)); - } - } - return instantiatedSignatures; - } - function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { - if (reportErrors === void 0) { reportErrors = false; } - if (!node.typeArguments) { - return; - } - if (!hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - return; - } - var args = checkTypeArguments(signature, node.typeArguments, reportErrors); - if (!args) { - return; - } - return getSignatureInstantiation(signature, args, isJavascript); - } function getJsxNamespaceAt(location) { var links = location && getNodeLinks(location); if (links && links.jsxNamespace) { @@ -46838,217 +47609,63 @@ var ts; function getJsxElementChildrenPropertyName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } - function getApparentTypeOfJsxPropsType(propsType) { - if (!propsType) { - return undefined; - } - if (propsType.flags & 524288 /* Intersection */) { - var propsApparentType = []; - for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { - var t = _a[_i]; - propsApparentType.push(getApparentType(t)); - } - return getIntersectionType(propsApparentType); - } - return getApparentType(propsType); - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return only attributes type of successfully resolved call signature. - * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) - * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. - var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined, /*isForSignatureHelp*/ false); - if (callSignature !== unknownSignature) { - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } - } - } - return undefined; - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return all attributes type of resolved call signature including candidate signatures. - * This function assumes that the caller handled other possible element type of the JSX element. - * This function is a behavior used by language service when looking up completion in JSX element. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. - var candidatesOutArray = []; - getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, /*isForSignatureHelp*/ false); - var result = void 0; - var allMatchingAttributesType = void 0; - for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { - var candidate = candidatesOutArray_1[_i]; - var callReturnType = getReturnTypeOfSignature(candidate); - // TODO: GH#18217: callReturnType should always be defined... - var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - var shouldBeCandidate = true; - for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { - var attribute = _b[_a]; - if (ts.isJsxAttribute(attribute) && - isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 - shouldBeCandidate = false; - break; - } - } - if (shouldBeCandidate) { - result = intersectTypes(result, paramType); - } - allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); - } - } - // If we can't find any matching, just return everything. - if (!result) { - result = allMatchingAttributesType; - } - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - result = intersectTypes(intrinsicAttributes, result); - } - return result; - } - } - return undefined; - } - function getInstantiatedJsxSignatures(openingLikeElement, elementType, reportErrors) { - var links = getNodeLinks(openingLikeElement); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(elementType); - if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) === resolvingSignaturesArray) { - return; - } - else if (links.resolvedSignatures.get(cacheKey)) { - return links.resolvedSignatures.get(cacheKey); - } - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + function getUninstantiatedJsxSignaturesOfType(elementType) { // Resolve the signatures, preferring constructor var signatures = getSignaturesOfType(elementType, 1 /* Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures signatures = getSignaturesOfType(elementType, 0 /* Call */); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - if (reportErrors) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(openingLikeElement.tagName)); - } + } + if (signatures.length === 0 && elementType.flags & 1048576 /* Union */) { + // If each member has some combination of new/call signatures; make a union signature list for those + signatures = getUnionSignatures(ts.map(elementType.types, getUninstantiatedJsxSignaturesOfType)); + } + return signatures; + } + function getIntrinsicAttributesTypeFromStringLiteralType(type, location) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location); + if (intrinsicElementsType !== errorType) { + var stringLiteralTypeName = type.value; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + return indexSignatureType; + } + return undefined; + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } + function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { + if (refKind === 1 /* Function */) { + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + if (sfcReturnConstraint) { + checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else if (refKind === 0 /* Component */) { + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (classConstraint) { + // Issue an error if this return type isn't assignable to JSX.ElementClass or JSX.Element, failing that + checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else { // Mixed + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (!sfcReturnConstraint || !classConstraint) { return; } + var combined = getUnionType([sfcReturnConstraint, classConstraint]); + checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } - // Instantiate in context of source type - var results = instantiateJsxSignatures(openingLikeElement, signatures); - links.resolvedSignatures.set(cacheKey, results); - return results; - } - /** - * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. - * For instance: - * declare function Foo(attr: { p1: string}): JSX.Element; - * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" - * - * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. - * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component - * - * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement - * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature - * @param sourceAttributesType Is the attributes type the user passed, and is used to create inferences in the target type if present - * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) - * @return attributes type if able to resolve the type of node - * anyType if there is no type ElementAttributesProperty or there is an error - * emptyObjectType if there is no "prop" in the element instance type - */ - function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 262144 /* Union */) { - var types = elementType.types; - return getUnionType(types.map(function (type) { - return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); - }), 2 /* Subtype */); - } - // Shortcircuit any - if (isTypeAny(elementType)) { - return elementType; - } - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 4 /* String */) { - return anyType; - } - else if (elementType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = elementType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); - } - // If we need to report an error, we already done so here. So just return any to prevent any more error downstream - return anyType; - } - // Get the element instance type (the result of newing or invoking this tag) - var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); - if (!ts.length(instantiatedSignatures)) { - return errorType; - } - var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); - // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. - // Otherwise get only attributes type from the signature picked by choose-overload logic. - var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? - tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : - defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); - if (statelessAttributesType) { - return statelessAttributesType; - } - // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elementClassType) { - checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - var isJs = ts.isInJSFile(openingLikeElement); - return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -47072,53 +47689,6 @@ var ts; } return links.resolvedJsxElementAttributesType; } - /** - * Get attributes type of the given custom opening-like JSX element. - * This function is intended to be called from a caller that handles intrinsic JSX element already. - * @param node a custom JSX opening-like element - * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component - */ - function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { - return resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, checkExpression(node.tagName), getJsxElementClassTypeAt(node)); - } - /** - * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. - * This function is called by language service (see: completions-tryGetGlobalSymbols). - * @param node a JSX opening-like element to get attributes type for - */ - function getAllAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - // Because in language service, the given JSX opening-like element may be incomplete and therefore, - // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); - } - } - /** - * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. - * @param node a JSXOpeningLikeElement node - * @return an attributes type of the given node - */ - function getAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); - } - } - /** - * Given a JSX attribute, returns the symbol for the corresponds property - * of the element attributes type. Will return unknownSymbol for attributes - * that have no matching element attributes type property. - */ - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); - var prop = getPropertyOfType(attributesType, attrib.name.escapedText); - return prop || unknownSymbol; - } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); if (type === errorType) @@ -47152,7 +47722,7 @@ var ts; } } } - function checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode) { + function checkJsxOpeningLikeElementOrOpeningFragment(node) { var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node); if (isNodeOpeningLikeElement) { checkGrammarJsxElement(node); @@ -47174,10 +47744,8 @@ var ts; } } if (isNodeOpeningLikeElement) { - checkJsxAttributesAssignableToTagNameAttributes(node, checkMode); - } - else { - checkJsxChildren(node.parent); + var sig = getResolvedSignature(node); + checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(node), getReturnTypeOfSignature(sig), node); } } /** @@ -47194,7 +47762,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 131072 /* Object */) { + if (targetType.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -47204,7 +47772,7 @@ var ts; return true; } } - else if (targetType.flags & 786432 /* UnionOrIntersection */) { + else if (targetType.flags & 3145728 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -47212,55 +47780,12 @@ var ts; } } } - else if (targetType.flags & 4194304 /* Conditional */) { + else if (targetType.flags & 16777216 /* Conditional */) { return isKnownProperty(targetType.root.trueType, name, isComparingJsxAttributes) || isKnownProperty(targetType.root.falseType, name, isComparingJsxAttributes); } return false; } - /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ - function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement, checkMode) { - // The function involves following steps: - // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. - // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) - // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. - // 3. Check if the two are assignable to each other - // targetAttributesType is a type of an attribute from resolving tagName of an opening-like JSX element. - var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? - getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : - getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); - // sourceAttributesType is a type of an attributes properties. - // i.e
- // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); - // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties - var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); - // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. - // This will allow excess properties in spread type as it is very common pattern to spread outer attributes into React component in its render method. - if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { - for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { - var attribute = _a[_i]; - if (!ts.isJsxAttribute(attribute)) { - continue; - } - var attrName = attribute.name; - var isNotIgnoredJsxProperty = (isUnhyphenatedJsxName(ts.idText(attrName)) || !!(getPropertyOfType(targetAttributesType, attrName.escapedText))); - if (isNotIgnoredJsxProperty && !isKnownProperty(targetAttributesType, attrName.escapedText, /*isComparingJsxAttributes*/ true)) { - error(attribute, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(attrName), typeToString(targetAttributesType)); - // We break here so that errors won't be cascading - break; - } - } - } - else if (!isSourceAttributeTypeAssignableToTarget) { - checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); - } - } function checkJsxExpression(node, checkMode) { if (node.expression) { var type = checkExpression(node.expression, checkMode); @@ -47300,7 +47825,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 146 /* QualifiedName */ ? node.right : node.kind === 181 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 148 /* QualifiedName */ ? node.right : node.kind === 183 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -47372,13 +47897,13 @@ var ts; return false; } var thisType = getTypeFromTypeNode(thisParameter.type); - enclosingClass = ((thisType.flags & 65536 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); + enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); } // No further restrictions for static properties if (flags & 32 /* Static */) { return true; } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -47398,19 +47923,26 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function getNonNullableTypeIfNeeded(type) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + if (kind) { + return getNonNullableType(type); + } + return type; + } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? + error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; + return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } @@ -47443,7 +47975,7 @@ var ts; return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } return errorType; } @@ -47454,9 +47986,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 100 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 97 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 98 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); @@ -47468,9 +48000,9 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 187 /* PropertyAccessExpression */ || + if (node.kind !== 189 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -47478,11 +48010,11 @@ 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 && left.kind === 99 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && left.kind === 100 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 157 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -47494,7 +48026,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { error(right, 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; @@ -47513,8 +48045,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && - node.parent.kind !== 162 /* TypeReference */ && + else if (valueDeclaration.kind === 240 /* ClassDeclaration */ && + node.parent.kind !== 164 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -47526,9 +48058,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -47566,7 +48098,7 @@ var ts; function reportNonexistentProperty(propNode, containingType) { var errorInfo; var relatedInfo; - if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { + if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -47675,16 +48207,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 97 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 98 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 148 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 181 /* ImportType */: + case 183 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind !== 181 /* ImportType */ && node.expression.kind === 97 /* SuperKeyword */, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind !== 183 /* ImportType */ && node.expression.kind === 98 /* SuperKeyword */, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -47711,20 +48243,20 @@ var ts; var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, isSuper, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJSFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); + : ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer.kind === 238 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 71 /* Identifier */) { + else if (initializer.kind === 72 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -47741,13 +48273,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 71 /* Identifier */) { + if (e.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 224 /* ForInStatement */ && + if (node.kind === 226 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -47765,7 +48297,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 190 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 192 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -47781,7 +48313,7 @@ var ts; if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -47796,7 +48328,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -47823,8 +48355,7 @@ var ts; return true; } function callLikeExpressionMayHaveTypeArguments(node) { - // TODO: Also include tagged templates (https://github.com/Microsoft/TypeScript/issues/11947) - return ts.isCallOrNewExpression(node); + return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); } function resolveUntypedCall(node) { if (callLikeExpressionMayHaveTypeArguments(node)) { @@ -47832,10 +48363,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 150 /* Decorator */) { + else if (ts.isJsxOpeningLikeElement(node)) { + checkExpression(node.attributes); + } + else if (node.kind !== 152 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -47862,8 +48396,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var signature = signatures_4[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -47899,22 +48433,23 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 208 /* SpreadElement */ || arg.kind === 215 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } + function acceptsVoid(t) { + return !!(t.flags & 16384 /* Void */); + } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } - if (ts.isJsxOpeningLikeElement(node)) { - // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". - return true; - } var argCount; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 191 /* TaggedTemplateExpression */) { + var effectiveParameterCount = getParameterCount(signature); + var effectiveMinimumArguments = getMinArgumentCount(signature); + if (node.kind === 193 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 204 /* TemplateExpression */) { + if (node.template.kind === 206 /* 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. @@ -47925,17 +48460,26 @@ 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 === 13 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 150 /* Decorator */) { + else if (node.kind === 152 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } + else if (ts.isJsxOpeningLikeElement(node)) { + callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + argCount = effectiveMinimumArguments === 0 ? args.length : 1; + effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1; // class may have argumentless ctor functions - still resolve ctor and compare vs props member type + effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1); // sfc may specify context argument - handled by framework and not typechecked + } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 190 /* NewExpression */); + ts.Debug.assert(node.kind === 192 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -47948,12 +48492,21 @@ var ts; } } // Too many arguments implies incorrect arity. - if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { + if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= getMinArgumentCount(signature); - return callIsIncomplete || hasEnoughArguments; + // JSX signatures can have extra parameters provided by the library which we don't check + if (callIsIncomplete || argCount >= effectiveMinimumArguments) { + return true; + } + for (var i = argCount; i < effectiveMinimumArguments; i++) { + var type = getTypeAtPosition(signature, i); + if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + return false; + } + } + return true; } function hasCorrectTypeArgumentArity(signature, typeArguments) { // If the user supplied type arguments, but the number of type arguments does not match @@ -47965,7 +48518,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -47987,14 +48540,9 @@ var ts; } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); } - function inferJsxTypeArguments(signature, node, context) { - // Skip context sensitive pass - var skipContextParamType = getTypeAtPosition(signature, 0); - var checkAttrTypeSkipContextSensitive = checkExpressionWithContextualType(node.attributes, skipContextParamType, identityMapper); - inferTypes(context.inferences, checkAttrTypeSkipContextSensitive, skipContextParamType); - // Standard pass - var paramType = getTypeAtPosition(signature, 0); - var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context); + function inferJsxTypeArguments(node, signature, excludeArgument, context) { + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] !== undefined ? identityMapper : context); inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } @@ -48010,11 +48558,14 @@ var ts; inference.inferredType = undefined; } } + if (ts.isJsxOpeningLikeElement(node)) { + return inferJsxTypeArguments(node, signature, excludeArgument, context); + } // If a contextual type is available, infer from that type to the return type of the call expression. For // example, given a 'function wrap(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 !== 150 /* Decorator */) { + if (node.kind !== 152 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -48047,7 +48598,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards @@ -48063,7 +48614,7 @@ var ts; return getInferredTypes(context); } function getArrayifiedType(type) { - if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 15794176 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { + if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 63176704 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { return createArrayType(getIndexTypeOfType(type, 1 /* Number */) || errorType); } return type; @@ -48074,13 +48625,13 @@ 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 arg.kind === 213 /* SyntheticExpression */ ? + return arg.kind === 215 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context)); } } var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */); var types = []; var spreadIndex = -1; for (var i = index; i < argCount; i++) { @@ -48116,6 +48667,19 @@ var ts; } return typeArgumentTypes; } + function getJsxReferenceKind(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return 2 /* Mixed */; + } + var tagType = getApparentType(checkExpression(node.tagName)); + if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { + return 0 /* Component */; + } + if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { + return 1 /* Function */; + } + return 2 /* Mixed */; + } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. * @param node a JSX opening-like element we are trying to figure its call signature @@ -48123,37 +48687,20 @@ var ts; * @param relation a relationship to check parameter and argument type * @param excludeArgument */ - function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { - // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: - // 1. callIsIncomplete - // 2. attributes property has same number of properties as the parameter object type. - // We can figure that out by resolving attributes property and check number of properties in the resolved type - // If the call has correct arity, we will then check if the argument type and parameter type is assignable - var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete - if (callIsIncomplete) { - return true; - } - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors) { // Stateless function components can have maximum of three arguments: "props", "context", and "updater". // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, // can be specified by users through attributes property. - var paramType = getTypeAtPosition(signature, 0); - var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); - var argProperties = getPropertiesOfType(attributesType); - for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { - var arg = argProperties_1[_i]; - if (!getPropertyOfType(paramType, arg.escapedName) && isUnhyphenatedJsxName(arg.escapedName)) { - return false; - } - } - return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] ? identityMapper : undefined); + return checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes); } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { if (ts.isJsxOpeningLikeElement(node)) { - return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 190 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 192 /* 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. @@ -48170,7 +48717,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), @@ -48193,15 +48740,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { + if (callee.kind === 189 /* PropertyAccessExpression */ || callee.kind === 190 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(213 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(215 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -48211,21 +48758,21 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - if (node.kind === 150 /* Decorator */) { + if (node.kind === 152 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { - return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; + return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray; } var args = node.arguments || ts.emptyArray; var length = args.length; @@ -48251,30 +48798,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 149 /* Parameter */: + case 151 /* 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 === 155 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 157 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 !== 152 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 154 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -48288,17 +48835,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 1; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return 2; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 149 /* Parameter */: + case 151 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -48311,8 +48858,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -48356,8 +48903,8 @@ var ts; function getTypeArgumentArityError(node, signatures, typeArguments) { var min = Infinity; var max = -Infinity; - for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { - var sig = signatures_6[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); max = Math.max(max, ts.length(sig.typeParameters)); } @@ -48365,14 +48912,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp, fallbackError) { - var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 150 /* Decorator */; + var isTaggedTemplate = node.kind === 193 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 152 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); + 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 !== 97 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 98 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -48380,7 +48928,9 @@ var ts; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + if (reportErrors) { + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + } return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -48425,7 +48975,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 = isForSignatureHelp && node.kind === 189 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = isForSignatureHelp && node.kind === 191 /* 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 @@ -48449,34 +48999,32 @@ var ts; // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. - if (candidateForArgumentError) { - if (isJsxOpeningOrSelfClosingElement) { - // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". - return candidateForArgumentError; + if (reportErrors) { + if (candidateForArgumentError) { + // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] + // The importance of excludeArgument is to prevent us from typing function expression parameters + // in arguments too early. If possible, we'd like to only type them once we know the correct + // overload. However, this matters for the case where the call is correct. When the call is + // an error, we don't need to exclude any arguments, although it would cause no harm to do so. + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } - // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] - // The importance of excludeArgument is to prevent us from typing function expression parameters - // in arguments too early. If possible, we'd like to only type them once we know the correct - // overload. However, this matters for the case where the call is correct. When the call is - // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); - } - else if (candidateForArgumentArityError) { - diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); - } - else if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); - } - else { - var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); - if (signaturesWithCorrectTypeArgumentArity.length === 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + else if (candidateForArgumentArityError) { + diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); } - else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + else if (candidateForTypeArgumentError) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); } - else if (fallbackError) { - diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + else { + var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); + if (signaturesWithCorrectTypeArgumentArity.length === 0) { + diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + } + else if (!isDecorator) { + diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + } + else if (fallbackError) { + diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + } } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); @@ -48679,7 +49227,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, isForSignatureHelp) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -48734,7 +49282,7 @@ var ts; } else { var relatedInformation = void 0; - if (node.arguments.length === 1 && isTypeAssertion(ts.first(node.arguments))) { + if (node.arguments.length === 1) { var text = ts.getSourceFileOfNode(node).text; if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); @@ -48758,8 +49306,8 @@ 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 & 65536 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 262144 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 /* Union */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, isForSignatureHelp) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -48837,7 +49385,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 524288 /* Intersection */) { + if (firstBase.flags & 2097152 /* Intersection */) { var types = firstBase.types; var mixinCount = ts.countWhere(types, isMixinConstructorType); var i = 0; @@ -48937,16 +49485,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -48982,6 +49530,58 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp, 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, 67897832 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(120 /* AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + parameterSymbol.type = result; + return createSignature(declaration, + /*typeParameters*/ undefined, + /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, + /*returnTypePredicate*/ undefined, 1, + /*hasRestparameter*/ false, + /*hasLiteralTypes*/ false); + } + function resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + var fakeSignature = createSignatureForJSXIntrinsic(node, result); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), result, node.tagName, node.attributes); + return fakeSignature; + } + var exprTypes = checkExpression(node.tagName); + var apparentType = getApparentType(exprTypes); + if (apparentType === errorType) { + return resolveErrorCall(node); + } + if (exprTypes.flags & 128 /* StringLiteral */) { + var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(exprTypes, node); + if (!intrinsicType) { + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, exprTypes.value, "JSX." + JsxNames.IntrinsicElements); + return resolveUntypedCall(node); + } + else { + var fakeSignature = createSignatureForJSXIntrinsic(node, intrinsicType); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), intrinsicType, node.tagName, node.attributes); + return fakeSignature; + } + } + var signatures = getUninstantiatedJsxSignaturesOfType(apparentType); + if (exprTypes.flags & 4 /* String */ || isUntypedFunctionCall(exprTypes, apparentType, signatures.length, /*constructSignatures*/ 0)) { + return resolveUntypedCall(node); + } + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return resolveErrorCall(node); + } + return resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp); + } /** * Sometimes, we have a decorator that could accept zero arguments, * but is receiving too many arguments as part of the decorator invocation. @@ -48994,49 +49594,19 @@ var ts; signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } - /** - * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. - * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName - * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) - * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. - * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function - * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. - * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; - * the function will fill it up with appropriate candidate signatures - */ - function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, isForSignatureHelp) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); - if (callSignatures && callSignatures.length > 0) { - return resolveCall(openingLikeElement, callSignatures, candidatesOutArray, isForSignatureHelp); - } - return undefined; - } function resolveSignature(node, candidatesOutArray, isForSignatureHelp) { switch (node.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, isForSignatureHelp); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, isForSignatureHelp); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, isForSignatureHelp); - case 150 /* Decorator */: + case 152 /* Decorator */: return resolveDecorator(node, candidatesOutArray, isForSignatureHelp); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - // This code-path is called by language service - var exprTypes = checkExpression(node.tagName); - return forEachType(exprTypes, function (exprType) { - var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray, isForSignatureHelp); - if (sfcResult && sfcResult !== unknownSignature) { - return sfcResult; - } - var sigs = getInstantiatedJsxSignatures(node, exprType); - if (candidatesOutArray && ts.length(sigs)) { - candidatesOutArray.push.apply(candidatesOutArray, sigs); - } - return ts.length(sigs) ? sigs[0] : unknownSignature; - }) || unknownSignature; + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + return resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -49088,7 +49658,7 @@ var ts; return false; } function isJSConstructorType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); } @@ -49123,10 +49693,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 187 /* PropertyAccessExpression */) { + while (parent && parent.kind === 189 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 59 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -49152,15 +49722,15 @@ var ts; if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return voidType; } - if (node.kind === 190 /* NewExpression */) { + if (node.kind === 192 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 155 /* Constructor */ && - declaration.kind !== 159 /* ConstructSignature */ && - declaration.kind !== 164 /* ConstructorType */ && + declaration.kind !== 157 /* Constructor */ && + declaration.kind !== 161 /* ConstructSignature */ && + declaration.kind !== 166 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -49168,7 +49738,7 @@ var ts; // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. var funcSymbol = checkExpression(node.expression).symbol; - if (!funcSymbol && node.expression.kind === 71 /* Identifier */) { + if (!funcSymbol && node.expression.kind === 72 /* Identifier */) { funcSymbol = getResolvedSymbol(node.expression); } var type = funcSymbol && getJSClassType(funcSymbol); @@ -49188,7 +49758,7 @@ 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 & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } var jsAssignmentType; @@ -49234,7 +49804,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -49287,9 +49857,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 237 /* FunctionDeclaration */ + ? 239 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 235 /* VariableDeclaration */ + ? 237 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -49325,10 +49895,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 94 /* NewKeyword */) { + if (node.keywordToken === 95 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 91 /* ImportKeyword */) { + if (node.keywordToken === 92 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -49339,7 +49909,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 === 155 /* Constructor */) { + else if (container.kind === 157 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -49510,7 +50080,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71 /* Identifier */) { + if (element.name.kind === 72 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -49524,7 +50094,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* Identifier */) { // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType) { links.type = getTypeFromBindingPattern(decl.name); @@ -49574,7 +50144,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 216 /* Block */) { + if (func.body.kind !== 218 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -49684,7 +50254,7 @@ var ts; 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]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -49694,7 +50264,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -49702,7 +50272,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]) || 64 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -49716,14 +50286,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 197 /* TypeOfExpression */) { + if (node.expression.kind === 199 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // 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_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 32768 /* Never */); + return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -49739,7 +50309,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 232 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -49761,7 +50331,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, 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 & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -49782,11 +50352,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 154 /* MethodDeclaration */: - return func.parent.kind === 186 /* ObjectLiteralExpression */; + case 156 /* MethodDeclaration */: + return func.parent.kind === 188 /* ObjectLiteralExpression */; default: return false; } @@ -49805,16 +50375,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 4096 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 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 === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 155 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 218 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 32768 /* Never */) { + if (returnType && returnType.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -49843,7 +50413,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -49863,7 +50433,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 196 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -49908,7 +50478,7 @@ var ts; getAwaitedType(type) || errorType : type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -49924,7 +50494,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 216 /* Block */) { + if (node.body.kind === 218 /* Block */) { checkSourceElement(node.body); } else { @@ -49947,34 +50517,66 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { + if (!isTypeAssignableTo(type, numberOrBigIntType)) { error(operand, diagnostic); return false; } return true; } + function isReadonlyAssignmentDeclaration(d) { + if (!ts.isCallExpression(d)) { + return false; + } + if (!ts.isBindableObjectDefinePropertyCall(d)) { + return false; + } + var objectLitType = checkExpressionCached(d.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + var writableProp = getPropertyOfType(objectLitType, "writable"); + var writableType = writableProp && getTypeOfSymbol(writableProp); + if (!writableType || writableType === falseType || writableType === regularFalseType) { + return true; + } + // We include this definition whereupon we walk back and check the type at the declaration because + // The usual definition of `Object.defineProperty` will _not_ cause literal types to be preserved in the + // argument types, should the type be contextualized by the call itself. + if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) { + var initializer = writableProp.valueDeclaration.initializer; + var rawOriginalType = checkExpression(initializer); + if (rawOriginalType === falseType || rawOriginalType === regularFalseType) { + return true; + } + } + return false; + } + var setProp = getPropertyOfType(objectLitType, "set"); + return !setProp; + } function isReadonlySymbol(symbol) { // The following symbols are considered read-only: // Properties with a 'readonly' modifier // Variables declared with 'const' // Get accessors without matching set accessors // 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 */); + symbol.flags & 8 /* EnumMember */ || + ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && - expr.expression.kind === 99 /* ThisKeyword */) { + (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) && + expr.expression.kind === 100 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 155 /* Constructor */)) { + if (!(func && func.kind === 157 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -49987,13 +50589,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 249 /* NamespaceImport */; + return !!declaration && declaration.kind === 251 /* NamespaceImport */; } } } @@ -50002,7 +50604,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 72 /* Identifier */ && node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -50011,7 +50613,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -50048,37 +50650,52 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operand.kind === 8 /* NumericLiteral */) { - if (node.operator === 38 /* MinusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - } - else if (node.operator === 37 /* PlusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); - } + switch (node.operand.kind) { + case 8 /* NumericLiteral */: + switch (node.operator) { + case 39 /* MinusToken */: + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + case 38 /* PlusToken */: + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } + break; + case 9 /* BigIntLiteral */: + if (node.operator === 39 /* MinusToken */) { + return getFreshTypeOfLiteralType(getLiteralType({ + negative: true, + base10Value: ts.parsePseudoBigInt(node.operand.text) + })); + } } switch (node.operator) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - return numberType; - case 51 /* ExclamationToken */: + if (node.operator === 38 /* PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + } + return numberType; + } + return getUnaryResultType(operandType); + case 52 /* ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); - return facts === 1048576 /* Truthy */ ? falseType : - facts === 2097152 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); + return facts === 4194304 /* Truthy */ ? falseType : + facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + case 44 /* PlusPlusToken */: + case 45 /* 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } - return numberType; + return getUnaryResultType(operandType); } return errorType; } @@ -50087,11 +50704,20 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } + return getUnaryResultType(operandType); + } + function getUnaryResultType(operandType) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + ? numberOrBigIntType + : bigintType; + } + // If it's not a bigint type, implicit coercion will result in a number return numberType; } // Return true if type might be of the given kind. A union or intersection type might be of a given @@ -50100,7 +50726,7 @@ var ts; if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -50115,21 +50741,22 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { return false; } - return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 132 /* 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); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 262144 /* Union */ ? + return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } @@ -50149,7 +50776,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, 32764 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* 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 @@ -50168,10 +50795,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -50181,8 +50808,8 @@ var ts; if (strictNullChecks && properties.length === 0) { return checkNonNullType(sourceType, node); } - for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { - var p = properties_7[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var p = properties_6[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis); } return sourceType; @@ -50190,9 +50817,9 @@ var ts; /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) { if (rightIsThis === void 0) { rightIsThis = false; } - if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */ || property.kind === 276 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -50201,13 +50828,13 @@ var ts; var type = getTypeOfObjectLiteralDestructuringProperty(objectLiteralType, name, property, rightIsThis); if (type) { // non-shorthand property assignments should always have initializers - return checkDestructuringAssignment(property.kind === 274 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 276 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } else { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 275 /* SpreadAssignment */) { + else if (property.kind === 277 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -50259,8 +50886,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 208 /* OmittedExpression */) { - if (element.kind !== 206 /* SpreadElement */) { + if (element.kind !== 210 /* OmittedExpression */) { + if (element.kind !== 208 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType : everyType(sourceType, isTupleLikeType) ? getTupleElementType(sourceType, elementIndex) : @@ -50284,7 +50911,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 204 /* BinaryExpression */ && restExpression.operatorToken.kind === 59 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -50301,14 +50928,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 276 /* 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)) & 8192 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -50317,21 +50944,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 204 /* BinaryExpression */ && target.operatorToken.kind === 59 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 186 /* ObjectLiteralExpression */) { + if (target.kind === 188 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 185 /* ArrayLiteralExpression */) { + if (target.kind === 187 /* 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 === 275 /* SpreadAssignment */ ? + var error = target.parent.kind === 277 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -50350,58 +50977,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 191 /* TaggedTemplateExpression */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 193 /* TaggedTemplateExpression */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 140 /* UndefinedKeyword */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 197 /* TypeOfExpression */: - case 211 /* NonNullExpression */: - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 141 /* UndefinedKeyword */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 199 /* TypeOfExpression */: + case 213 /* NonNullExpression */: + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: return true; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 51 /* ExclamationToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 52 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 198 /* VoidExpression */: // Explicit opt-out - case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 200 /* VoidExpression */: // Explicit opt-out + case 194 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 212 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { @@ -50411,11 +51039,11 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 99 /* ThisKeyword */); + if (operator === 59 /* EqualsToken */ && (left.kind === 188 /* ObjectLiteralExpression */ || left.kind === 187 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 100 /* ThisKeyword */); } var leftType; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -50423,28 +51051,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 39 /* AsteriskToken */: - case 40 /* AsteriskAsteriskToken */: - case 61 /* AsteriskEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 42 /* PercentToken */: - case 64 /* PercentEqualsToken */: - case 38 /* MinusToken */: - case 60 /* MinusEqualsToken */: - case 45 /* LessThanLessThanToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: + case 40 /* AsteriskToken */: + case 41 /* AsteriskAsteriskToken */: + case 62 /* AsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 43 /* PercentToken */: + case 65 /* PercentEqualsToken */: + case 39 /* MinusToken */: + case 61 /* MinusEqualsToken */: + case 46 /* LessThanLessThanToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -50453,36 +51081,61 @@ 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 & 272 /* BooleanLike */) && - (rightType.flags & 272 /* BooleanLike */) && + if ((leftType.flags & 528 /* BooleanLike */) && + (rightType.flags & 528 /* 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; } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + 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 */)) || + // Or, if neither could be bigint, implicit coercion results in a number result + !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + resultType_1 = numberType; } + // At least one is assignable to bigint, so both should be only assignable to bigint + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + switch (operator) { + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + reportOperatorError(); + } + resultType_1 = bigintType; + } + else { + reportOperatorError(); + resultType_1 = errorType; + } + if (leftOk && rightOk) { + checkAssignmentOperator(resultType_1); + } + return resultType_1; } - return numberType; - case 37 /* PlusToken */: - case 59 /* PlusEqualsToken */: + case 38 /* PlusToken */: + case 60 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 132 /* StringLike */) && !isTypeAssignableToKind(rightType, 132 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* 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, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* 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, 132 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 132 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -50499,26 +51152,27 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 59 /* PlusEqualsToken */) { + if (operator === 60 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); - if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { + if (!(isTypeComparableTo(leftType, rightType) || isTypeComparableTo(rightType, leftType) || + (isTypeAssignableTo(leftType, numberOrBigIntType) && isTypeAssignableTo(rightType, numberOrBigIntType)))) { reportOperatorError(); } } return booleanType; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -50529,19 +51183,19 @@ var ts; reportOperatorError(); } return booleanType; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 53 /* AmpersandAmpersandToken */: - return getTypeFacts(leftType) & 1048576 /* Truthy */ ? + case 54 /* AmpersandAmpersandToken */: + return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 54 /* BarBarToken */: - return getTypeFacts(leftType) & 2097152 /* Falsy */ ? + case 55 /* BarBarToken */: + return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, right); if (isAssignmentDeclaration(declKind)) { @@ -50551,7 +51205,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 26 /* CommaToken */: + case 27 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -50577,12 +51231,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 72 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 12288 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -50592,15 +51246,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - return 54 /* BarBarToken */; - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - return 35 /* ExclamationEqualsEqualsToken */; - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: - return 53 /* AmpersandAmpersandToken */; + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + return 55 /* BarBarToken */; + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + return 36 /* ExclamationEqualsEqualsToken */; + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: + return 54 /* AmpersandAmpersandToken */; default: return undefined; } @@ -50647,11 +51301,11 @@ var ts; } function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { switch (operatorToken.kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); } return undefined; @@ -50729,14 +51383,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } }); return stringType; } function getContextNode(node) { - if (node.kind === 266 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 268 /* 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; @@ -50772,7 +51426,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; + return node.kind === 194 /* TypeAssertionExpression */ || node.kind === 212 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -50781,7 +51435,7 @@ var ts; ts.isDeclarationReadonly(declaration) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 24576 /* Nullable */) { + if (widened.flags & 98304 /* Nullable */) { reportImplicitAny(declaration, anyType); return anyType; } @@ -50794,26 +51448,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 786432 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* 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) || emptyObjectType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || + 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 */) || 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 & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || - contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */) && 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 false; } @@ -50829,7 +51485,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -50840,7 +51496,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -50871,14 +51527,14 @@ var ts; var 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 (expr.kind === 189 /* CallExpression */ && expr.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 191 /* CallExpression */ && expr.expression.kind !== 98 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - else if (expr.kind === 192 /* TypeAssertionExpression */ || expr.kind === 210 /* AsExpression */) { + else if (expr.kind === 194 /* TypeAssertionExpression */ || expr.kind === 212 /* AsExpression */) { return getTypeFromTypeNode(expr.type); } // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions @@ -50913,7 +51569,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode, forceTuple) { var type; - if (node.kind === 146 /* QualifiedName */) { + if (node.kind === 148 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -50925,10 +51581,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 167 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } @@ -50944,94 +51600,97 @@ var ts; } function checkExpressionWorker(node, checkMode, forceTuple) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return checkIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return checkThisExpression(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkSuperExpression(node); - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullWideningType; - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101 /* TrueKeyword */: + case 9 /* BigIntLiteral */: + checkGrammarBigIntLiteral(node); + return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); + case 102 /* TrueKeyword */: return trueType; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: return falseType; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return checkTemplateExpression(node); - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 189 /* CallExpression */: - if (node.expression.kind === 91 /* ImportKeyword */) { + case 191 /* CallExpression */: + if (node.expression.kind === 92 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 190 /* NewExpression */: + case 192 /* NewExpression */: return checkCallExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return checkClassExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return checkAssertion(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return checkNonNullAssertion(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return checkMetaProperty(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkDeleteExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return checkVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return checkAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return undefinedWideningType; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return checkYieldExpression(node); - case 213 /* SyntheticExpression */: + case 215 /* SyntheticExpression */: return node.type; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return checkJsxElement(node, checkMode); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 262 /* JsxFragment */: - return checkJsxFragment(node, checkMode); - case 266 /* JsxAttributes */: + case 264 /* JsxFragment */: + return checkJsxFragment(node); + case 268 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -51069,7 +51728,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 157 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -51080,10 +51739,10 @@ 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 === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { + if (func.kind === 157 /* Constructor */ || func.kind === 161 /* ConstructSignature */ || func.kind === 166 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -51138,13 +51797,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 195 /* ArrowFunction */: - case 158 /* CallSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 163 /* FunctionType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 197 /* ArrowFunction */: + case 160 /* CallSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 165 /* FunctionType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -51158,11 +51817,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 71 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 72 /* 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 === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { + else if (name.kind === 185 /* ArrayBindingPattern */ || name.kind === 184 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -51171,13 +51830,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* 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 === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || - node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || - node.kind === 159 /* ConstructSignature */) { + else if (node.kind === 165 /* FunctionType */ || node.kind === 239 /* FunctionDeclaration */ || node.kind === 166 /* ConstructorType */ || + node.kind === 160 /* CallSignature */ || node.kind === 157 /* Constructor */ || + node.kind === 161 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -51207,10 +51866,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -51240,7 +51899,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -51257,7 +51916,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 155 /* Constructor */) { + if (member.kind === 157 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -51272,16 +51931,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: addName(names, name, memberName, 1 /* Getter */); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: addName(names, name, memberName, 2 /* Setter */); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* Property */); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: addName(names, name, memberName, 4 /* Method */); break; } @@ -51344,15 +52003,15 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* PropertySignature */) { + if (member.kind === 153 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: memberName = name.text; break; - case 71 /* Identifier */: + case 72 /* Identifier */: memberName = ts.idText(name); break; default: @@ -51369,7 +52028,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* 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 @@ -51389,7 +52048,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -51397,7 +52056,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -51424,7 +52083,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 156 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -51449,7 +52108,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 152 /* PropertyDeclaration */ && + return n.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -51479,7 +52138,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -51504,7 +52163,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -51514,13 +52173,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -51538,7 +52197,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -51586,7 +52245,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 164 /* 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); } var type = getTypeFromTypeReference(node); @@ -51634,7 +52293,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 170 /* RestType */) { + if (e.kind === 172 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -51643,7 +52302,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 169 /* OptionalType */) { + else if (e.kind === 171 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -51658,14 +52317,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 2097152 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* 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 === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 190 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -51673,7 +52332,7 @@ 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. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -51705,7 +52364,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 175 /* 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); @@ -51722,9 +52381,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 239 /* InterfaceDeclaration */ && - n.parent.kind !== 238 /* ClassDeclaration */ && - n.parent.kind !== 207 /* ClassExpression */ && + if (n.parent.kind !== 241 /* InterfaceDeclaration */ && + n.parent.kind !== 240 /* ClassDeclaration */ && + n.parent.kind !== 209 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* 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 @@ -51815,7 +52474,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && + var reportError = (node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -51854,7 +52513,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 241 /* InterfaceDeclaration */ || node.parent.kind === 168 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -51865,7 +52524,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 239 /* FunctionDeclaration */ || node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */ || node.kind === 157 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -51917,8 +52576,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_7 = signatures; _a < signatures_7.length; _a++) { - var signature = signatures_7[_a]; + for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { + var signature = signatures_6[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -51994,22 +52653,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -52017,17 +52676,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: var result_4 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_4 |= getDeclarationSpaces(d); }); return result_4; - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 237 /* FunctionDeclaration */: - case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 239 /* FunctionDeclaration */: + case 253 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -52074,7 +52733,7 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } @@ -52105,7 +52764,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -52256,7 +52915,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 71 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 72 /* 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 { @@ -52295,24 +52954,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 149 /* Parameter */: + case 151 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -52333,7 +52992,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 71 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 72 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -52358,50 +53017,55 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 172 /* IntersectionType */: - case 171 /* UnionType */: - var commonEntityName = void 0; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { - typeNode = typeNode.type; // Skip parens if need be - } - if (typeNode.kind === 131 /* NeverKeyword */) { - continue; // Always elide `never` from the union/intersection if possible - } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* 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); - if (!individualEntityName) { - // Individual is something like string number - // So it would be serialized to either that type or object - // Safe to return here - return undefined; - } - if (commonEntityName) { - // Note this is in sync with the transformation that happens for type node. - // Keep this in sync with serializeUnionOrIntersectionType - // Verify if they refer to same entity and is identifier - // return undefined if they dont match because we would emit object - if (!ts.isIdentifier(commonEntityName) || - !ts.isIdentifier(individualEntityName) || - commonEntityName.escapedText !== individualEntityName.escapedText) { - return undefined; - } - } - else { - commonEntityName = individualEntityName; - } - } - return commonEntityName; - case 175 /* ParenthesizedType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return getEntityNameForDecoratorMetadataFromTypeList(node.types); + case 175 /* ConditionalType */: + return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + case 177 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; } } } + function getEntityNameForDecoratorMetadataFromTypeList(types) { + var commonEntityName; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { + typeNode = typeNode.type; // Skip parens if need be + } + if (typeNode.kind === 132 /* NeverKeyword */) { + continue; // Always elide `never` from the union/intersection if possible + } + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); + if (!individualEntityName) { + // Individual is something like string number + // So it would be serialized to either that type or object + // Safe to return here + return undefined; + } + if (commonEntityName) { + // Note this is in sync with the transformation that happens for type node. + // Keep this in sync with serializeUnionOrIntersectionType + // Verify if they refer to same entity and is identifier + // return undefined if they dont match because we would emit object + if (!ts.isIdentifier(commonEntityName) || + !ts.isIdentifier(individualEntityName) || + commonEntityName.escapedText !== individualEntityName.escapedText) { + return undefined; + } + } + else { + commonEntityName = individualEntityName; + } + } + return commonEntityName; + } function getParameterTypeNodeForDecoratorCheck(node) { var typeNode = ts.getEffectiveTypeAnnotationNode(node); return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode; @@ -52421,14 +53085,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -52437,23 +53101,23 @@ var ts; } } break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 154 /* MethodDeclaration */: + case 156 /* 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 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 149 /* Parameter */: + case 151 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -52506,16 +53170,22 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } } } } + function checkJSDocFunctionType(node) { + if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) { + reportImplicitAny(node, anyType); + } + checkSignatureDeclaration(node); + } function checkJSDocAugmentsTag(node) { var classLike = ts.getJSDocHost(node); if (!ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { @@ -52538,9 +53208,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -52553,7 +53223,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 === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -52582,7 +53252,7 @@ var ts; } } } - var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 155 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); @@ -52627,42 +53297,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 277 /* SourceFile */: - case 242 /* ModuleDeclaration */: - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 279 /* SourceFile */: + case 244 /* ModuleDeclaration */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 240 /* TypeAliasDeclaration */: - case 174 /* InferType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 242 /* TypeAliasDeclaration */: + case 176 /* InferType */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -52683,11 +53353,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 154 /* MethodDeclaration */: - case 152 /* PropertyDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 156 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + if (member.kind === 159 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -52696,7 +53366,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -52704,8 +53374,8 @@ var ts; } } break; - case 160 /* IndexSignature */: - case 215 /* SemicolonClassElement */: + case 162 /* IndexSignature */: + case 217 /* SemicolonClassElement */: // Can't be private break; default: @@ -52717,9 +53387,9 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (node.flags & 4194304 /* Ambient */ || node.kind !== 174 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) + if (node.flags & 4194304 /* Ambient */ || node.kind !== 176 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) return; - if (node.kind === 174 /* InferType */) { + if (node.kind === 176 /* InferType */) { 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))); @@ -52734,7 +53404,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 174 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 176 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -52820,7 +53490,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 251 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -52838,7 +53508,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 237 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 238 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -52859,7 +53529,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -52871,24 +53541,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; + return node.kind === 250 /* ImportClause */ || node.kind === 253 /* ImportSpecifier */ || node.kind === 251 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 250 /* ImportClause */ ? decl : decl.kind === 251 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 216 /* Block */) { + if (node.kind === 218 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -52918,12 +53588,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 152 /* PropertyDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 154 /* MethodDeclaration */ || - node.kind === 153 /* MethodSignature */ || - node.kind === 156 /* GetAccessor */ || - node.kind === 157 /* SetAccessor */) { + if (node.kind === 154 /* PropertyDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 156 /* MethodDeclaration */ || + node.kind === 155 /* MethodSignature */ || + node.kind === 158 /* GetAccessor */ || + node.kind === 159 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -52932,7 +53602,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 151 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -52942,7 +53612,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 71 /* Identifier */; + var isDeclaration_1 = node.kind !== 72 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -52957,7 +53627,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 71 /* Identifier */; + var isDeclaration_2 = node.kind !== 72 /* 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); } @@ -52983,7 +53653,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -52998,7 +53668,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -53033,7 +53703,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 237 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -53045,17 +53715,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 217 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 238 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 219 /* 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 === 216 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 243 /* ModuleBlock */ || - container.kind === 242 /* ModuleDeclaration */ || - container.kind === 277 /* SourceFile */); + (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 245 /* ModuleBlock */ || + container.kind === 244 /* ModuleDeclaration */ || + container.kind === 279 /* 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 @@ -53070,7 +53740,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 151 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -53081,11 +53751,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 187 /* PropertyAccessExpression */) { + if (n.kind === 189 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 71 /* Identifier */) { + else if (n.kind === 72 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.escapedText, 67220415 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -53100,8 +53770,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 184 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 151 /* Parameter */ || + symbol.valueDeclaration.kind === 186 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -53115,7 +53785,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 152 /* PropertyDeclaration */ && + (current.parent.kind === 154 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -53148,18 +53818,18 @@ 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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 184 /* BindingElement */) { - if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 186 /* BindingElement */) { + if (node.parent.kind === 184 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -53172,27 +53842,27 @@ var ts; var property = getPropertyOfType(parentType, nameText); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { - checkPropertyAccessibility(parent, parent.initializer.kind === 97 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, parent.initializer.kind === 98 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 185 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 151 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 226 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -53215,11 +53885,16 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 226 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } + if (symbol.declarations.length > 1) { + if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); + } + } } else { // Node is a secondary declaration, check that type is identical to primary declaration and check that @@ -53234,14 +53909,13 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { - error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { + if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -53250,14 +53924,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* PropertySignature */ + var message = nextDeclaration.kind === 154 /* PropertyDeclaration */ || nextDeclaration.kind === 153 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || - (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 151 /* Parameter */ && right.kind === 237 /* VariableDeclaration */) || + (left.kind === 237 /* VariableDeclaration */ && right.kind === 151 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -53296,7 +53970,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 218 /* EmptyStatement */) { + if (node.thenStatement.kind === 220 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -53315,7 +53989,7 @@ var ts; } function checkTruthinessExpression(node, checkMode) { var type = checkExpression(node, checkMode); - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -53323,12 +53997,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 238 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -53362,14 +54036,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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. @@ -53395,13 +54069,13 @@ var ts; function checkForInStatement(node) { // Grammar checking checkGrammarForInOrForOfStatement(node); - var rightType = checkNonNullExpression(node.expression); + var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); // TypeScript 1.0 spec (April 2014): 5.4 // In a 'for-in' statement of the form // 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 === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* 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); @@ -53415,7 +54089,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 === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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)) { @@ -53428,7 +54102,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, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* 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); @@ -53483,16 +54157,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 262144 /* Union */) { + if (arrayType.flags & 1048576 /* 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 & 68 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 68 /* StringLike */) { + else if (arrayType.flags & 132 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -53505,7 +54179,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 & 32768 /* Never */) { + if (arrayType.flags & 131072 /* Never */) { return stringType; } } @@ -53536,7 +54210,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 68 /* StringLike */) { + if (arrayElementType.flags & 132 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -53750,7 +54424,7 @@ var ts; var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -53766,7 +54440,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -53775,12 +54449,12 @@ var ts; // for generators. return; } - else if (func.kind === 157 /* SetAccessor */) { + else if (func.kind === 159 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 155 /* Constructor */) { + else if (func.kind === 157 /* 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); } @@ -53801,7 +54475,7 @@ var ts; } } } - else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 157 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -53830,7 +54504,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 === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 272 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -53842,7 +54516,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 271 /* 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. @@ -53871,7 +54545,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 233 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -53978,8 +54652,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 202 /* BinaryExpression */ || - name.kind === 147 /* ComputedPropertyName */ || + (propDeclaration.kind === 204 /* BinaryExpression */ || + name.kind === 149 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -54008,6 +54682,7 @@ var ts; case "any": case "unknown": case "number": + case "bigint": case "boolean": case "string": case "symbol": @@ -54187,10 +54862,10 @@ var ts; // 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 & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 8650752 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { + 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. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -54285,7 +54960,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; + return d.kind === 240 /* ClassDeclaration */ || d.kind === 241 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -54324,7 +54999,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 207 /* ClassExpression */) { + if (derivedClassDecl.kind === 209 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -54374,8 +55049,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { - var prop = properties_8[_a]; + for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { + var prop = properties_7[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -54406,7 +55081,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* 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)); } @@ -54416,7 +55091,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 152 /* PropertyDeclaration */ && + return node.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -54427,7 +55102,7 @@ var ts; reference.parent = constructor; reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 8192 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -54440,7 +55115,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -54545,60 +55220,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 37 /* PlusToken */: return value_2; - case 38 /* MinusToken */: return -value_2; - case 52 /* TildeToken */: return ~value_2; + case 38 /* PlusToken */: return value_2; + case 39 /* MinusToken */: return -value_2; + case 53 /* TildeToken */: return ~value_2; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 49 /* BarToken */: return left | right; - case 48 /* AmpersandToken */: return left & right; - case 46 /* GreaterThanGreaterThanToken */: return left >> right; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 45 /* LessThanLessThanToken */: return left << right; - case 50 /* CaretToken */: return left ^ right; - case 39 /* AsteriskToken */: return left * right; - case 41 /* SlashToken */: return left / right; - case 37 /* PlusToken */: return left + right; - case 38 /* MinusToken */: return left - right; - case 42 /* PercentToken */: return left % right; - case 40 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 50 /* BarToken */: return left | right; + case 49 /* AmpersandToken */: return left & right; + case 47 /* GreaterThanGreaterThanToken */: return left >> right; + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 46 /* LessThanLessThanToken */: return left << right; + case 51 /* CaretToken */: return left ^ right; + case 40 /* AsteriskToken */: return left * right; + case 42 /* SlashToken */: return left / right; + case 38 /* PlusToken */: return left + right; + case 39 /* MinusToken */: return left - right; + case 43 /* PercentToken */: return left % right; + case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 37 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { return left + right; } break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 71 /* Identifier */: + case 72 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 187 /* PropertyAccessExpression */) { + if (ex.kind === 189 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -54629,10 +55304,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 71 /* Identifier */ || - node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 9 /* StringLiteral */; + return node.kind === 72 /* Identifier */ || + node.kind === 189 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 190 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -54669,7 +55344,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 !== 241 /* EnumDeclaration */) { + if (declaration.kind !== 243 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -54692,8 +55367,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 238 /* ClassDeclaration */ || - (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 240 /* ClassDeclaration */ || + (declaration.kind === 239 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -54730,7 +55405,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 9 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -54756,7 +55431,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 240 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -54806,23 +55481,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -54833,12 +55508,12 @@ var ts; break; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 237 /* FunctionDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -54851,7 +55526,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -54859,17 +55534,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; } } @@ -54883,9 +55558,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 253 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -54918,14 +55593,14 @@ var ts; (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 255 /* ExportSpecifier */ ? + var message = node.kind === 257 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 255 /* ExportSpecifier */ + && node.kind === 257 /* ExportSpecifier */ && !(target.flags & 67220415 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -54952,7 +55627,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -54976,7 +55651,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 259 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67220415 /* Value */) { @@ -55012,10 +55687,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -55032,7 +55707,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -55061,8 +55736,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 === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -55075,7 +55750,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { markExportAsReferenced(node); if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); @@ -55150,7 +55825,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 239 /* FunctionDeclaration */ && declaration.kind !== 156 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -55168,158 +55843,158 @@ 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return checkTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return checkParameter(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return checkPropertyDeclaration(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return checkSignatureDeclaration(node); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return checkMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return checkConstructorDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return checkAccessorDeclaration(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return checkTypeReferenceNode(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return checkTypePredicate(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return checkTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return checkTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return checkArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return checkTupleType(node); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 175 /* ParenthesizedType */: - case 169 /* OptionalType */: - case 170 /* RestType */: + case 177 /* ParenthesizedType */: + case 171 /* OptionalType */: + case 172 /* RestType */: return checkSourceElement(node.type); - case 176 /* ThisType */: + case 178 /* ThisType */: return checkThisType(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return checkTypeOperator(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return checkConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return checkInferType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return checkImportType(node); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 287 /* JSDocFunctionType */: - checkSignatureDeclaration(node); + case 289 /* JSDocFunctionType */: + checkJSDocFunctionType(node); // falls through - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: - case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: + case 292 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 281 /* JSDocTypeExpression */: + case 283 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return checkMappedType(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return checkBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return checkVariableStatement(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return checkExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return checkIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return checkDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return checkWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return checkForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return checkForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkForOfStatement(node); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return checkReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return checkSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return checkThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return checkTryStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return checkBindingElement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return checkClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return checkImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return checkExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return checkExportAssignment(node); - case 218 /* EmptyStatement */: - case 234 /* DebuggerStatement */: + case 220 /* EmptyStatement */: + case 236 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -55410,23 +56085,23 @@ var ts; } links.deferredNodes.forEach(function (node) { switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 258 /* JsxElement */: + case 260 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -55463,6 +56138,7 @@ var ts; ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); ts.forEach(node.statements, checkSourceElement); + checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); if (ts.isExternalOrCommonJsModule(node)) { registerForUnusedIdentifiersCheck(node); @@ -55555,13 +56231,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) + break; + // falls through + case 244 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -55569,8 +56249,8 @@ var ts; // falls through // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* 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. @@ -55579,7 +56259,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -55621,17 +56301,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 71 /* Identifier */ && + return name.kind === 72 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 148 /* TypeParameter */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 150 /* TypeParameter */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -55639,16 +56319,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 162 /* TypeReference */; + return node.parent.kind === 164 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 187 /* PropertyAccessExpression */) { + while (node.parent.kind === 189 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 209 /* ExpressionWithTypeArguments */; + return node.parent.kind === 211 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -55676,13 +56356,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 148 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 248 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 254 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -55708,7 +56388,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 183 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -55718,7 +56398,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 187 /* PropertyAccessExpression */ && + entityName.parent.kind === 189 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -55726,7 +56406,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 254 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -55736,7 +56416,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 248 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -55754,7 +56434,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 211 /* ExpressionWithTypeArguments */) { meaning = 67897832 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -55770,10 +56450,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 297 /* JSDocParameterTag */) { + if (entityName.parent.kind === 299 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 301 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -55783,19 +56463,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 71 /* Identifier */) { + if (entityName.kind === 72 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 189 /* PropertyAccessExpression */ || entityName.kind === 148 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 187 /* PropertyAccessExpression */) { + if (entityName.kind === 189 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -55805,20 +56485,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 164 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 265 /* JsxAttribute */) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 161 /* TypePredicate */) { + if (entityName.parent.kind === 163 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -55834,12 +56511,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 184 /* BindingElement */ && - grandParent.kind === 182 /* ObjectBindingPattern */ && + else if (parent.kind === 186 /* BindingElement */ && + grandParent.kind === 184 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -55849,11 +56526,11 @@ var ts; } } switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -55865,29 +56542,32 @@ var ts; return checkExpression(node).symbol; } // falls through - case 176 /* ThisType */: + case 178 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkExpression(node).symbol; - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 157 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: + case 14 /* 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 === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 249 /* ImportDeclaration */ || node.parent.kind === 255 /* 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); } + if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) { + return getSymbolOfNode(parent); + } // falls through case 8 /* NumericLiteral */: // index access @@ -55897,19 +56577,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 79 /* DefaultKeyword */: - case 89 /* FunctionKeyword */: - case 36 /* EqualsGreaterThanToken */: - case 75 /* ClassKeyword */: + case 80 /* DefaultKeyword */: + case 90 /* FunctionKeyword */: + case 37 /* EqualsGreaterThanToken */: + case 76 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; + case 85 /* ExportKeyword */: + return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 276 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -55977,28 +56659,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 188 /* ObjectLiteralExpression */ || expr.kind === 187 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 225 /* ForOfStatement */) { + if (expr.parent.kind === 227 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 202 /* BinaryExpression */) { + if (expr.parent.kind === 204 /* 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 === 273 /* PropertyAssignment */) { + if (expr.parent.kind === 275 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 187 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -56034,14 +56716,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return getLiteralType(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: ts.Debug.fail("Unsupported property name."); return errorType; @@ -56096,7 +56778,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -56152,7 +56834,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* 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. @@ -56207,7 +56889,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 218 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -56248,18 +56930,18 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return node.expression - && node.expression.kind === 71 /* Identifier */ + && node.expression.kind === 72 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -56267,7 +56949,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -56294,7 +56976,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -56367,15 +57050,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 276 /* EnumMember */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 278 /* EnumMember */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 276 /* EnumMember */) { + if (node.kind === 278 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -56389,7 +57072,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. @@ -56426,22 +57109,25 @@ var ts; else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + return ts.TypeReferenceSerializationKind.BigIntLikeType; + } + else if (isTypeAssignableToKind(type, 132 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -56457,14 +57143,14 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* 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 */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 2048 /* UniqueESSymbol */ && + if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -56476,7 +57162,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56484,7 +57170,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56522,19 +57208,18 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } - function literalTypeToNode(type, enclosing) { - var enumResult = type.flags & 512 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing) + function literalTypeToNode(type, enclosing, tracker) { + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } - function createLiteralConstValue(node) { + function createLiteralConstValue(node, tracker) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return literalTypeToNode(type, node); + return literalTypeToNode(type, node, tracker); } function createResolver() { // this variable and functions that use it are deliberately moved here from the outer scope @@ -56607,12 +57292,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* SetAccessor */; + var otherKind = accessor.kind === 159 /* SetAccessor */ ? 158 /* GetAccessor */ : 159 /* 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 === 157 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 159 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 158 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -56628,7 +57313,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; + return node.parent && node.parent.kind === 211 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 273 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -56640,7 +57325,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 72 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 189 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -56691,7 +57376,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -56706,12 +57391,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 244 /* 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, 277 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -56889,14 +57574,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 154 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 156 /* 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 === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */) { + else if (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* 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); @@ -56913,23 +57598,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { + if (modifier.kind !== 133 /* ReadonlyKeyword */) { + if (node.kind === 153 /* PropertySignature */ || node.kind === 155 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 76 /* ConstKeyword */: - if (node.kind !== 241 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); + case 77 /* ConstKeyword */: + if (node.kind !== 243 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(77 /* ConstKeyword */)); } break; - case 114 /* PublicKeyword */: - case 113 /* ProtectedKeyword */: - case 112 /* PrivateKeyword */: + case 115 /* PublicKeyword */: + case 114 /* ProtectedKeyword */: + case 113 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -56943,11 +57628,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* 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 === 112 /* PrivateKeyword */) { + if (modifier.kind === 113 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -56956,7 +57641,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -56966,10 +57651,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -56978,18 +57663,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 132 /* ReadonlyKeyword */: + case 133 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { + else if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */ && node.kind !== 162 /* IndexSignature */ && node.kind !== 151 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -57002,52 +57687,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 79 /* DefaultKeyword */: - var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 80 /* DefaultKeyword */: + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 124 /* DeclareKeyword */: + case 125 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 245 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 117 /* AbstractKeyword */: + case 118 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 238 /* ClassDeclaration */) { - if (node.kind !== 154 /* MethodDeclaration */ && - node.kind !== 152 /* PropertyDeclaration */ && - node.kind !== 156 /* GetAccessor */ && - node.kind !== 157 /* SetAccessor */) { + if (node.kind !== 240 /* ClassDeclaration */) { + if (node.kind !== 156 /* MethodDeclaration */ && + node.kind !== 154 /* PropertyDeclaration */ && + node.kind !== 158 /* GetAccessor */ && + node.kind !== 159 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 240 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -57059,14 +57744,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -57074,7 +57759,7 @@ var ts; break; } } - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -57089,13 +57774,13 @@ var ts; } return false; } - else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 249 /* ImportDeclaration */ || node.kind === 248 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -57116,38 +57801,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 242 /* ModuleDeclaration */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 149 /* Parameter */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 244 /* ModuleDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 151 /* Parameter */: return false; default: - if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return false; } switch (node.kind) { - case 237 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 238 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 239 /* InterfaceDeclaration */: - case 217 /* VariableStatement */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AsyncKeyword */); + case 240 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 118 /* AbstractKeyword */); + case 241 /* InterfaceDeclaration */: + case 219 /* VariableStatement */: + case 242 /* TypeAliasDeclaration */: return true; - case 241 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); + case 243 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 77 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -57159,10 +57844,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -57280,12 +57965,12 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { + if (parameter.type.kind !== 138 /* StringKeyword */ && parameter.type.kind !== 135 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(getTypeFromTypeNode(node.type))); } - if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -57316,7 +58001,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 208 /* OmittedExpression */) { + if (arg.kind === 210 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -57346,7 +58031,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 === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -57359,7 +58044,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -57375,14 +58060,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -57393,20 +58078,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 147 /* ComputedPropertyName */) { + if (node.kind !== 149 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 204 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 237 /* FunctionDeclaration */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 154 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 239 /* FunctionDeclaration */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 156 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -57432,15 +58117,15 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */) { + if (prop.kind === 277 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 274 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 276 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -57449,7 +58134,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { + if (mod.kind !== 121 /* AsyncKeyword */ || prop.kind !== 156 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -57464,23 +58149,23 @@ 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 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); /* tslint:disable:no-switch-case-fall-through */ - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: @@ -57517,7 +58202,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 267 /* JsxSpreadAttribute */) { + if (attr.kind === 269 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -57527,7 +58212,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 270 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -57536,12 +58221,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 227 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 238 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -57556,20 +58241,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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); @@ -57596,11 +58281,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 158 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 157 /* SetAccessor */) { + else if (kind === 159 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -57624,23 +58309,23 @@ 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 === 156 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 141 /* UniqueKeyword */) { - if (node.type.kind !== 138 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(138 /* SymbolKeyword */)); + if (node.operator === 142 /* UniqueKeyword */) { + if (node.type.kind !== 139 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(139 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* 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)) { @@ -57650,13 +58335,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { 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 151 /* PropertySignature */: + case 153 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* 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); } @@ -57675,10 +58360,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 156 /* MethodDeclaration */) { + if (node.parent.kind === 188 /* 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 === 120 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 121 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -57704,14 +58389,14 @@ var ts; if (node.flags & 4194304 /* 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 === 154 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 156 /* 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 === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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 === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* 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); } } @@ -57722,11 +58407,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 231 /* LabeledStatement */: + case 233 /* 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 === 226 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 228 /* 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); @@ -57734,8 +58419,8 @@ var ts; return false; } break; - case 230 /* SwitchStatement */: - if (node.kind === 227 /* BreakStatement */ && !node.label) { + case 232 /* SwitchStatement */: + if (node.kind === 229 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -57750,13 +58435,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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 === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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); @@ -57779,34 +58464,43 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } + function isBigIntLiteralExpression(expr) { + return expr.kind === 9 /* BigIntLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.operand.kind === 9 /* BigIntLiteral */; + } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) - return !!(checkExpressionCached(expr).flags & 512 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); } function checkAmbientInitializer(node) { - if (node.initializer) { - var isInvalidInitializer = !(isStringOrNumberLiteralExpression(node.initializer) || isSimpleLiteralEnumReference(node.initializer) || node.initializer.kind === 101 /* TrueKeyword */ || node.initializer.kind === 86 /* FalseKeyword */); + var initializer = node.initializer; + if (initializer) { + var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || + isSimpleLiteralEnumReference(initializer) || + initializer.kind === 102 /* TrueKeyword */ || initializer.kind === 87 /* FalseKeyword */ || + isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { if (isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); + return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); } } else { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { + if (node.parent.parent.kind !== 226 /* ForInStatement */ && node.parent.parent.kind !== 227 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -57819,7 +58513,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 219 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -57836,7 +58530,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -57853,8 +58547,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 71 /* Identifier */) { - if (name.originalKeywordKind === 110 /* LetKeyword */) { + if (name.kind === 72 /* Identifier */) { + if (name.originalKeywordKind === 111 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -57881,15 +58575,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return false; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -57907,12 +58601,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 94 /* NewKeyword */: + case 95 /* 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 91 /* ImportKeyword */: + case 92 /* 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"); } @@ -57967,7 +58661,7 @@ var ts; return true; } } - else if (node.parent.kind === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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; } @@ -57975,7 +58669,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -58004,13 +58698,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 240 /* TypeAliasDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 253 /* ExportDeclaration */ || - node.kind === 252 /* ExportAssignment */ || - node.kind === 245 /* NamespaceExportDeclaration */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 242 /* TypeAliasDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 255 /* ExportDeclaration */ || + node.kind === 254 /* ExportAssignment */ || + node.kind === 247 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -58019,7 +58713,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 === 217 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 219 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -58046,7 +58740,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 === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -58068,20 +58762,32 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 182 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 278 /* 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 === 38 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } return false; } + function checkGrammarBigIntLiteral(node) { + var literalType = ts.isLiteralTypeNode(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); + if (!literalType) { + if (languageVersion < 6 /* ESNext */) { + if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ESNext)) { + return true; + } + } + } + return false; + } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -58126,8 +58832,8 @@ var ts; /** 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 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -58135,14 +58841,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 248 /* ImportClause */: // For default import - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: // For rename import `x as y` + case 250 /* ImportClause */: // For default import + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: // For rename import `x as y` return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 251 /* ImportSpecifier */; + return decl.parent.kind === 253 /* ImportSpecifier */; default: return false; } @@ -58162,7 +58868,7 @@ var ts; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function typeIsLiteralType(type) { - return !!(type.flags & 448 /* Literal */); + return !!(type.flags & 2944 /* Literal */); } })(ts || (ts = {})); var ts; @@ -58226,6 +58932,9 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt + return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); + } if (typeof value === "boolean") { return value ? createTrue() : createFalse(); } @@ -58245,14 +58954,20 @@ var ts; return node; } ts.createNumericLiteral = createNumericLiteral; + function createBigIntLiteral(value) { + var node = createSynthesizedNode(9 /* BigIntLiteral */); + node.text = value; + return node; + } + ts.createBigIntLiteral = createBigIntLiteral; function createStringLiteral(text) { - var node = createSynthesizedNode(9 /* StringLiteral */); + var node = createSynthesizedNode(10 /* StringLiteral */); node.text = text; return node; } ts.createStringLiteral = createStringLiteral; function createRegularExpressionLiteral(text) { - var node = createSynthesizedNode(12 /* RegularExpressionLiteral */); + var node = createSynthesizedNode(13 /* RegularExpressionLiteral */); node.text = text; return node; } @@ -58263,7 +58978,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(71 /* Identifier */); + var node = createSynthesizedNode(72 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -58344,23 +59059,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(97 /* SuperKeyword */); + return createSynthesizedNode(98 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(99 /* ThisKeyword */); + return createSynthesizedNode(100 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(95 /* NullKeyword */); + return createSynthesizedNode(96 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(101 /* TrueKeyword */); + return createSynthesizedNode(102 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(86 /* FalseKeyword */); + return createSynthesizedNode(87 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -58371,44 +59086,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(84 /* ExportKeyword */)); + result.push(createModifier(85 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(124 /* DeclareKeyword */)); + result.push(createModifier(125 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(79 /* DefaultKeyword */)); + result.push(createModifier(80 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(76 /* ConstKeyword */)); + result.push(createModifier(77 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(114 /* PublicKeyword */)); + result.push(createModifier(115 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(112 /* PrivateKeyword */)); + result.push(createModifier(113 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(113 /* ProtectedKeyword */)); + result.push(createModifier(114 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(117 /* AbstractKeyword */)); + result.push(createModifier(118 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(115 /* StaticKeyword */)); + result.push(createModifier(116 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(132 /* ReadonlyKeyword */)); + result.push(createModifier(133 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(120 /* AsyncKeyword */)); + result.push(createModifier(121 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(146 /* QualifiedName */); + var node = createSynthesizedNode(148 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -58427,7 +59142,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(147 /* ComputedPropertyName */); + var node = createSynthesizedNode(149 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -58440,7 +59155,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(148 /* TypeParameter */); + var node = createSynthesizedNode(150 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -58456,7 +59171,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(149 /* Parameter */); + var node = createSynthesizedNode(151 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -58480,7 +59195,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(150 /* Decorator */); + var node = createSynthesizedNode(152 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -58493,7 +59208,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertySignature */); + var node = createSynthesizedNode(153 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -58513,12 +59228,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(152 /* PropertyDeclaration */); + var node = createSynthesizedNode(154 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -58528,8 +59243,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -58537,7 +59252,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(155 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -58554,7 +59269,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(154 /* MethodDeclaration */); + var node = createSynthesizedNode(156 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -58582,7 +59297,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(155 /* Constructor */); + var node = createSynthesizedNode(157 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -58602,7 +59317,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(156 /* GetAccessor */); + var node = createSynthesizedNode(158 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58625,7 +59340,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(157 /* SetAccessor */); + var node = createSynthesizedNode(159 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58646,7 +59361,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(160 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -58654,7 +59369,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(161 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -58662,7 +59377,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(160 /* IndexSignature */); + var node = createSynthesizedNode(162 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -58702,7 +59417,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(161 /* TypePredicate */); + var node = createSynthesizedNode(163 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -58716,7 +59431,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(162 /* TypeReference */); + var node = createSynthesizedNode(164 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -58730,7 +59445,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -58738,7 +59453,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(166 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -58746,7 +59461,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(165 /* TypeQuery */); + var node = createSynthesizedNode(167 /* TypeQuery */); node.exprName = exprName; return node; } @@ -58758,7 +59473,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(166 /* TypeLiteral */); + var node = createSynthesizedNode(168 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -58770,7 +59485,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(167 /* ArrayType */); + var node = createSynthesizedNode(169 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -58782,7 +59497,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(168 /* TupleType */); + var node = createSynthesizedNode(170 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -58794,7 +59509,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(169 /* OptionalType */); + var node = createSynthesizedNode(171 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -58806,7 +59521,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(170 /* RestType */); + var node = createSynthesizedNode(172 /* RestType */); node.type = type; return node; } @@ -58818,7 +59533,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(173 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -58826,7 +59541,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(174 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -58845,7 +59560,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(173 /* ConditionalType */); + var node = createSynthesizedNode(175 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -58863,7 +59578,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(174 /* InferType */); + var node = createSynthesizedNode(176 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -58875,7 +59590,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(181 /* ImportType */); + var node = createSynthesizedNode(183 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -58893,7 +59608,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(175 /* ParenthesizedType */); + var node = createSynthesizedNode(177 /* ParenthesizedType */); node.type = type; return node; } @@ -58905,12 +59620,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(176 /* ThisType */); + return createSynthesizedNode(178 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(177 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; + var node = createSynthesizedNode(179 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 129 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -58920,7 +59635,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(178 /* IndexedAccessType */); + var node = createSynthesizedNode(180 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -58934,7 +59649,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(179 /* MappedType */); + var node = createSynthesizedNode(181 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -58952,7 +59667,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(180 /* LiteralType */); + var node = createSynthesizedNode(182 /* LiteralType */); node.literal = literal; return node; } @@ -58965,7 +59680,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(182 /* ObjectBindingPattern */); + var node = createSynthesizedNode(184 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58977,7 +59692,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(183 /* ArrayBindingPattern */); + var node = createSynthesizedNode(185 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58989,7 +59704,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(184 /* BindingElement */); + var node = createSynthesizedNode(186 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -59008,7 +59723,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(187 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -59022,7 +59737,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(188 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -59036,7 +59751,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(187 /* PropertyAccessExpression */); + var node = createSynthesizedNode(189 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -59053,7 +59768,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(188 /* ElementAccessExpression */); + var node = createSynthesizedNode(190 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -59067,7 +59782,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(189 /* CallExpression */); + var node = createSynthesizedNode(191 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -59083,7 +59798,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(190 /* NewExpression */); + var node = createSynthesizedNode(192 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -59099,7 +59814,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(193 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -59122,7 +59837,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(192 /* TypeAssertionExpression */); + var node = createSynthesizedNode(194 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -59136,7 +59851,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(193 /* ParenthesizedExpression */); + var node = createSynthesizedNode(195 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -59148,7 +59863,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(194 /* FunctionExpression */); + var node = createSynthesizedNode(196 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -59172,12 +59887,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(195 /* ArrowFunction */); + var node = createSynthesizedNode(197 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -59194,7 +59909,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(196 /* DeleteExpression */); + var node = createSynthesizedNode(198 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59206,7 +59921,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(197 /* TypeOfExpression */); + var node = createSynthesizedNode(199 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59218,7 +59933,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(198 /* VoidExpression */); + var node = createSynthesizedNode(200 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59230,7 +59945,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(199 /* AwaitExpression */); + var node = createSynthesizedNode(201 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59242,7 +59957,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(202 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -59255,7 +59970,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(203 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -59268,7 +59983,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(202 /* BinaryExpression */); + var node = createSynthesizedNode(204 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -59285,11 +60000,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(203 /* ConditionalExpression */); + var node = createSynthesizedNode(205 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(56 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -59305,7 +60020,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(204 /* TemplateExpression */); + var node = createSynthesizedNode(206 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -59319,33 +60034,33 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createTemplateHead(text) { - var node = createSynthesizedNode(14 /* TemplateHead */); + var node = createSynthesizedNode(15 /* TemplateHead */); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; function createTemplateMiddle(text) { - var node = createSynthesizedNode(15 /* TemplateMiddle */); + var node = createSynthesizedNode(16 /* TemplateMiddle */); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; function createTemplateTail(text) { - var node = createSynthesizedNode(16 /* TemplateTail */); + var node = createSynthesizedNode(17 /* TemplateTail */); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(13 /* NoSubstitutionTemplateLiteral */); + var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); node.text = text; return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(205 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(207 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -59357,7 +60072,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(206 /* SpreadElement */); + var node = createSynthesizedNode(208 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -59369,7 +60084,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(207 /* ClassExpression */); + var node = createSynthesizedNode(209 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59390,11 +60105,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(208 /* OmittedExpression */); + return createSynthesizedNode(210 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(211 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -59408,7 +60123,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(210 /* AsExpression */); + var node = createSynthesizedNode(212 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -59422,7 +60137,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(211 /* NonNullExpression */); + var node = createSynthesizedNode(213 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -59434,7 +60149,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(212 /* MetaProperty */); + var node = createSynthesizedNode(214 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -59448,7 +60163,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(214 /* TemplateSpan */); + var node = createSynthesizedNode(216 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -59462,12 +60177,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(215 /* SemicolonClassElement */); + return createSynthesizedNode(217 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(216 /* Block */); + var block = createSynthesizedNode(218 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -59481,7 +60196,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(217 /* VariableStatement */); + var node = createSynthesizedNode(219 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -59496,11 +60211,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(218 /* EmptyStatement */); + return createSynthesizedNode(220 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(219 /* ExpressionStatement */); + var node = createSynthesizedNode(221 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -59516,7 +60231,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(220 /* IfStatement */); + var node = createSynthesizedNode(222 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -59532,7 +60247,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(221 /* DoStatement */); + var node = createSynthesizedNode(223 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -59546,7 +60261,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(222 /* WhileStatement */); + var node = createSynthesizedNode(224 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -59560,7 +60275,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(223 /* ForStatement */); + var node = createSynthesizedNode(225 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -59578,7 +60293,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(224 /* ForInStatement */); + var node = createSynthesizedNode(226 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -59594,7 +60309,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(225 /* ForOfStatement */); + var node = createSynthesizedNode(227 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -59612,7 +60327,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(226 /* ContinueStatement */); + var node = createSynthesizedNode(228 /* ContinueStatement */); node.label = asName(label); return node; } @@ -59624,7 +60339,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(227 /* BreakStatement */); + var node = createSynthesizedNode(229 /* BreakStatement */); node.label = asName(label); return node; } @@ -59636,7 +60351,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(228 /* ReturnStatement */); + var node = createSynthesizedNode(230 /* ReturnStatement */); node.expression = expression; return node; } @@ -59648,7 +60363,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(229 /* WithStatement */); + var node = createSynthesizedNode(231 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -59662,7 +60377,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(230 /* SwitchStatement */); + var node = createSynthesizedNode(232 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -59676,7 +60391,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(231 /* LabeledStatement */); + var node = createSynthesizedNode(233 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -59690,7 +60405,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(232 /* ThrowStatement */); + var node = createSynthesizedNode(234 /* ThrowStatement */); node.expression = expression; return node; } @@ -59702,7 +60417,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(233 /* TryStatement */); + var node = createSynthesizedNode(235 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -59718,11 +60433,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(234 /* DebuggerStatement */); + return createSynthesizedNode(236 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(235 /* VariableDeclaration */); + var node = createSynthesizedNode(237 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -59739,7 +60454,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(236 /* VariableDeclarationList */); + var node = createSynthesizedNode(238 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -59752,7 +60467,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(237 /* FunctionDeclaration */); + var node = createSynthesizedNode(239 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -59778,7 +60493,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(238 /* ClassDeclaration */); + var node = createSynthesizedNode(240 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59800,7 +60515,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(239 /* InterfaceDeclaration */); + var node = createSynthesizedNode(241 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59822,7 +60537,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(242 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59842,7 +60557,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(241 /* EnumDeclaration */); + var node = createSynthesizedNode(243 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59861,7 +60576,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(242 /* ModuleDeclaration */); + var node = createSynthesizedNode(244 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -59880,7 +60595,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(243 /* ModuleBlock */); + var node = createSynthesizedNode(245 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -59892,7 +60607,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(244 /* CaseBlock */); + var node = createSynthesizedNode(246 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -59904,7 +60619,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(247 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -59916,7 +60631,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(248 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59934,7 +60649,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(247 /* ImportDeclaration */); + var node = createSynthesizedNode(249 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -59952,7 +60667,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(248 /* ImportClause */); + var node = createSynthesizedNode(250 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -59966,7 +60681,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(249 /* NamespaceImport */); + var node = createSynthesizedNode(251 /* NamespaceImport */); node.name = name; return node; } @@ -59978,7 +60693,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(250 /* NamedImports */); + var node = createSynthesizedNode(252 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -59990,7 +60705,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ImportSpecifier */); + var node = createSynthesizedNode(253 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -60004,11 +60719,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(252 /* ExportAssignment */); + var node = createSynthesizedNode(254 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(58 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(59 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -60021,7 +60736,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(253 /* ExportDeclaration */); + var node = createSynthesizedNode(255 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -60039,7 +60754,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(254 /* NamedExports */); + var node = createSynthesizedNode(256 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -60051,7 +60766,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(255 /* ExportSpecifier */); + var node = createSynthesizedNode(257 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -60066,7 +60781,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(257 /* ExternalModuleReference */); + var node = createSynthesizedNode(259 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -60077,9 +60792,57 @@ var ts; : node; } ts.updateExternalModuleReference = updateExternalModuleReference; + // JSDoc + /* @internal */ + function createJSDocTypeExpression(type) { + var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + node.type = type; + return node; + } + ts.createJSDocTypeExpression = createJSDocTypeExpression; + /* @internal */ + function createJSDocTypeTag(typeExpression, comment) { + var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocTypeTag = createJSDocTypeTag; + /* @internal */ + function createJSDocReturnTag(typeExpression, comment) { + var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocReturnTag = createJSDocReturnTag; + /* @internal */ + function createJSDocParamTag(name, isBracketed, typeExpression, comment) { + var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + tag.typeExpression = typeExpression; + tag.name = name; + tag.isBracketed = isBracketed; + tag.comment = comment; + return tag; + } + ts.createJSDocParamTag = createJSDocParamTag; + /* @internal */ + function createJSDocComment(comment, tags) { + var node = createSynthesizedNode(291 /* JSDocComment */); + node.comment = comment; + node.tags = tags; + return node; + } + ts.createJSDocComment = createJSDocComment; + /* @internal */ + function createJSDocTag(kind, tagName) { + var node = createSynthesizedNode(kind); + node.tagName = createIdentifier(tagName); + return node; + } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(258 /* JsxElement */); + var node = createSynthesizedNode(260 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -60095,7 +60858,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(261 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60111,7 +60874,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(260 /* JsxOpeningElement */); + var node = createSynthesizedNode(262 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60127,7 +60890,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(261 /* JsxClosingElement */); + var node = createSynthesizedNode(263 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -60139,7 +60902,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(262 /* JsxFragment */); + var node = createSynthesizedNode(264 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -60155,7 +60918,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(265 /* JsxAttribute */); + var node = createSynthesizedNode(267 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -60169,7 +60932,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(266 /* JsxAttributes */); + var node = createSynthesizedNode(268 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -60181,7 +60944,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(269 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -60193,7 +60956,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(268 /* JsxExpression */); + var node = createSynthesizedNode(270 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -60207,7 +60970,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(269 /* CaseClause */); + var node = createSynthesizedNode(271 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -60221,7 +60984,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(270 /* DefaultClause */); + var node = createSynthesizedNode(272 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -60233,7 +60996,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(271 /* HeritageClause */); + var node = createSynthesizedNode(273 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -60246,7 +61009,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(272 /* CatchClause */); + var node = createSynthesizedNode(274 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -60261,7 +61024,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(273 /* PropertyAssignment */); + var node = createSynthesizedNode(275 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -60276,7 +61039,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(276 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -60290,7 +61053,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(275 /* SpreadAssignment */); + var node = createSynthesizedNode(277 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -60303,7 +61066,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(276 /* EnumMember */); + var node = createSynthesizedNode(278 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -60324,7 +61087,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(277 /* SourceFile */); + var updated = createSynthesizedNode(279 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -60408,7 +61171,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(305 /* NotEmittedStatement */); + var node = createSynthesizedNode(307 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -60420,7 +61183,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(309 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60432,7 +61195,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(308 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60447,7 +61210,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(306 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -60463,17 +61226,17 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 307 /* CommaListExpression */) { + if (node.kind === 309 /* CommaListExpression */) { return node.elements; } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { return [node.left, node.right]; } } return node; } function createCommaList(elements) { - var node = createSynthesizedNode(307 /* CommaListExpression */); + var node = createSynthesizedNode(309 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -60486,14 +61249,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(278 /* Bundle */); + var node = ts.createNode(280 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(279 /* UnparsedSource */); + var node = ts.createNode(281 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -60501,7 +61264,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(280 /* InputFiles */); + var node = ts.createNode(282 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -60543,47 +61306,47 @@ var ts; } ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { - return createBinary(left, 26 /* CommaToken */, right); + return createBinary(left, 27 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 27 /* LessThanToken */, right); + return createBinary(left, 28 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 58 /* EqualsToken */, right); + return createBinary(left, 59 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 34 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 35 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 37 /* PlusToken */, right); + return createBinary(left, 38 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 38 /* MinusToken */, right); + return createBinary(left, 39 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 43 /* PlusPlusToken */); + return createPostfix(operand, 44 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 53 /* AmpersandAmpersandToken */, right); + return createBinary(left, 54 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 54 /* BarBarToken */, right); + return createBinary(left, 55 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(51 /* ExclamationToken */, operand); + return createPrefix(52 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -60644,7 +61407,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 === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -61155,7 +61918,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 233 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -61167,19 +61930,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return cacheIdentifiers; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: return false; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -61194,7 +61958,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 97 /* SuperKeyword */) { + else if (callee.kind === 98 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -61206,7 +61970,7 @@ var ts; } else { switch (callee.kind) { - case 187 /* PropertyAccessExpression */: { + case 189 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61219,7 +61983,7 @@ var ts; } break; } - case 188 /* ElementAccessExpression */: { + case 190 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61276,14 +62040,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -61291,7 +62055,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_9 = []; + var properties_8 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -61302,7 +62066,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_9.push(getter); + properties_8.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -61314,15 +62078,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_9.push(setter); + properties_8.push(setter); } - properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_9, multiLine) + ts.createObjectLiteral(properties_8, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -61609,7 +62373,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 === 193 /* ParenthesizedExpression */) { + if (skipped.kind === 195 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -61643,10 +62407,10 @@ 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(202 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(204 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 195 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 197 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -61658,7 +62422,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 205 /* YieldExpression */) { + && operand.kind === 207 /* YieldExpression */) { return false; } return true; @@ -61695,7 +62459,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 37 /* PlusToken */) { + if (binaryOperator === 38 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -61730,10 +62494,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 === 39 /* AsteriskToken */ - || binaryOperator === 49 /* BarToken */ - || binaryOperator === 48 /* AmpersandToken */ - || binaryOperator === 50 /* CaretToken */; + return binaryOperator === 40 /* AsteriskToken */ + || binaryOperator === 50 /* BarToken */ + || binaryOperator === 49 /* AmpersandToken */ + || binaryOperator === 51 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -61746,7 +62510,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -61761,7 +62525,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(205 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -61796,8 +62560,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: needsParens = true; } } @@ -61813,9 +62577,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.createParen(expression); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -61838,7 +62602,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 192 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -61876,7 +62640,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -61887,29 +62651,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { + if (kind === 196 /* FunctionExpression */ || kind === 197 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { + if (leftmostExpressionKind === 188 /* ObjectLiteralExpression */ || leftmostExpressionKind === 196 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 175 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -61917,9 +62681,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 174 /* InferType */: + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 176 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -61945,28 +62709,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: node = node.operand; continue; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: node = node.left; continue; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: node = node.condition; continue; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: node = node.tag; continue; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 210 /* AsExpression */: - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: - case 211 /* NonNullExpression */: - case 306 /* PartiallyEmittedExpression */: + case 212 /* AsExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 213 /* NonNullExpression */: + case 308 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -61974,15 +62738,15 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 188 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || - node.kind === 307 /* CommaListExpression */; + return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 309 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -61995,13 +62759,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 211 /* NonNullExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -62026,7 +62790,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 213 /* NonNullExpression */) { node = node.expression; } return node; @@ -62034,11 +62798,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 306 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 195 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -62056,7 +62820,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 193 /* ParenthesizedExpression */ + return node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -62121,10 +62885,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 249 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 255 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -62140,7 +62904,7 @@ var ts; */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 - if (moduleName.kind === 9 /* StringLiteral */) { + if (moduleName.kind === 10 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) || ts.getSynthesizedClone(moduleName); @@ -62243,7 +63007,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -62255,11 +63019,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -62291,12 +63055,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 151 /* Parameter */: + case 186 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 206 /* SpreadElement */: - case 275 /* SpreadAssignment */: + case 208 /* SpreadElement */: + case 277 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -62308,7 +63072,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 184 /* BindingElement */: + case 186 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -62320,7 +63084,7 @@ var ts; : propertyName; } break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -62332,7 +63096,7 @@ var ts; : propertyName; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -62347,7 +63111,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ + return kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */; } /** @@ -62355,13 +63119,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -62401,11 +63165,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -62566,276 +63330,276 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */) || kind === 178 /* ThisType */) { return node; } switch (kind) { // Names - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 150 /* Decorator */: + case 152 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 155 /* Constructor */: + case 157 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 168 /* TupleType */: + case 170 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 170 /* RestType */: + case 172 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 171 /* UnionType */: + case 173 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 174 /* InferType */: + case 176 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 179 /* MappedType */: + case 181 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 216 /* Block */: + case 218 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -62877,58 +63641,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { + if ((kind >= 163 /* TypePredicate */ && kind <= 182 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 215 /* SemicolonClassElement */: - case 218 /* EmptyStatement */: - case 208 /* OmittedExpression */: - case 234 /* DebuggerStatement */: - case 305 /* NotEmittedStatement */: + case 217 /* SemicolonClassElement */: + case 220 /* EmptyStatement */: + case 210 /* OmittedExpression */: + case 236 /* DebuggerStatement */: + case 307 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 149 /* Parameter */: + case 151 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 150 /* Decorator */: + case 152 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62937,12 +63701,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* Constructor */: + case 157 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62950,7 +63714,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62958,49 +63722,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 190 /* NewExpression */: + case 192 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -63008,123 +63773,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ParenthesizedExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 210 /* AsExpression */: + case 212 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 216 /* Block */: + case 218 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 222 /* WhileStatement */: - case 229 /* WithStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63133,7 +63898,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63141,139 +63906,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); + result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -63346,7 +64112,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 211 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -63396,7 +64162,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -63433,288 +64199,623 @@ var ts; /* @internal */ var ts; (function (ts) { - function createSourceFileLikeCache(host) { - var cached = ts.createMap(); + function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) { + var _a = generatorOptions.extendedDiagnostics + ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap") + : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit; + // Current source map file and its index in the sources list + var rawSources = []; + var sources = []; + var sourceToSourceIndexMap = ts.createMap(); + var sourcesContent; + var names = []; + var nameToNameIndexMap; + var mappings = ""; + // Last recorded and encoded mappings + var lastGeneratedLine = 0; + var lastGeneratedCharacter = 0; + var lastSourceIndex = 0; + var lastSourceLine = 0; + var lastSourceCharacter = 0; + var lastNameIndex = 0; + var hasLast = false; + var pendingGeneratedLine = 0; + var pendingGeneratedCharacter = 0; + var pendingSourceIndex = 0; + var pendingSourceLine = 0; + var pendingSourceCharacter = 0; + var pendingNameIndex = 0; + var hasPending = false; + var hasPendingSource = false; + var hasPendingName = false; return { - get: function (path) { - if (cached.has(path)) { - return cached.get(path); + getSources: function () { return rawSources; }, + addSource: addSource, + setSourceContent: setSourceContent, + addName: addName, + addMapping: addMapping, + appendSourceMap: appendSourceMap, + toJSON: toJSON, + toString: function () { return JSON.stringify(toJSON()); } + }; + function addSource(fileName) { + enter(); + var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + var sourceIndex = sourceToSourceIndexMap.get(source); + if (sourceIndex === undefined) { + sourceIndex = sources.length; + sources.push(source); + rawSources.push(fileName); + sourceToSourceIndexMap.set(source, sourceIndex); + } + exit(); + return sourceIndex; + } + function setSourceContent(sourceIndex, content) { + enter(); + if (content !== null) { + if (!sourcesContent) + sourcesContent = []; + while (sourcesContent.length < sourceIndex) { + // tslint:disable-next-line:no-null-keyword boolean-trivia + sourcesContent.push(null); } - if (!host.fileExists || !host.readFile || !host.fileExists(path)) - return; - // And failing that, check the disk - var text = host.readFile(path); // TODO: GH#18217 - var file = { - text: text, - lineMap: undefined, - getLineAndCharacterOfPosition: function (pos) { - return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + sourcesContent[sourceIndex] = content; + } + exit(); + } + function addName(name) { + enter(); + if (!nameToNameIndexMap) + nameToNameIndexMap = ts.createMap(); + var nameIndex = nameToNameIndexMap.get(name); + if (nameIndex === undefined) { + nameIndex = names.length; + names.push(name); + nameToNameIndexMap.set(name, nameIndex); + } + exit(); + return nameIndex; + } + function isNewGeneratedPosition(generatedLine, generatedCharacter) { + return !hasPending + || pendingGeneratedLine !== generatedLine + || pendingGeneratedCharacter !== generatedCharacter; + } + function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) { + return sourceIndex !== undefined + && sourceLine !== undefined + && sourceCharacter !== undefined + && pendingSourceIndex === sourceIndex + && (pendingSourceLine > sourceLine + || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter); + } + function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) { + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative"); + ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative"); + ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative"); + enter(); + // If this location wasn't recorded or the location in source is going backwards, record the mapping + if (isNewGeneratedPosition(generatedLine, generatedCharacter) || + isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) { + commitPendingMapping(); + pendingGeneratedLine = generatedLine; + pendingGeneratedCharacter = generatedCharacter; + hasPendingSource = false; + hasPendingName = false; + hasPending = true; + } + if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) { + pendingSourceIndex = sourceIndex; + pendingSourceLine = sourceLine; + pendingSourceCharacter = sourceCharacter; + hasPendingSource = true; + if (nameIndex !== undefined) { + pendingNameIndex = nameIndex; + hasPendingName = true; + } + } + exit(); + } + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + var _a; + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + enter(); + // First, decode the old component sourcemap + var sourceIndexToNewSourceIndexMap = []; + var nameIndexToNewNameIndexMap; + var mappingIterator = decodeMappings(map.mappings); + for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + // Then reencode all the updated mappings into the overall map + var newSourceIndex = void 0; + var newSourceLine = void 0; + var newSourceCharacter = void 0; + var newNameIndex = void 0; + if (raw.sourceIndex !== undefined) { + newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex]; + if (newSourceIndex === undefined) { + // Apply offsets to each position and fixup source entries + var rawPath = map.sources[raw.sourceIndex]; + var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath); + sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath); + if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") { + setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]); + } } - }; - cached.set(path, file); - return file; + newSourceLine = raw.sourceLine; + newSourceCharacter = raw.sourceCharacter; + if (map.names && raw.nameIndex !== undefined) { + if (!nameIndexToNewNameIndexMap) + nameIndexToNewNameIndexMap = []; + newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex]; + if (newNameIndex === undefined) { + nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]); + } + } + } + var newGeneratedLine = raw.generatedLine + generatedLine; + var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); + } + exit(); + } + function shouldCommitMapping() { + return !hasLast + || lastGeneratedLine !== pendingGeneratedLine + || lastGeneratedCharacter !== pendingGeneratedCharacter + || lastSourceIndex !== pendingSourceIndex + || lastSourceLine !== pendingSourceLine + || lastSourceCharacter !== pendingSourceCharacter + || lastNameIndex !== pendingNameIndex; + } + function commitPendingMapping() { + if (!hasPending || !shouldCommitMapping()) { + return; + } + enter(); + // Line/Comma delimiters + if (lastGeneratedLine < pendingGeneratedLine) { + // Emit line delimiters + do { + mappings += ";"; + lastGeneratedLine++; + lastGeneratedCharacter = 0; + } while (lastGeneratedLine < pendingGeneratedLine); + } + else { + ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); + // Emit comma to separate the entry + if (hasLast) { + mappings += ","; + } + } + // 1. Relative generated character + mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + lastGeneratedCharacter = pendingGeneratedCharacter; + if (hasPendingSource) { + // 2. Relative sourceIndex + mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + lastSourceIndex = pendingSourceIndex; + // 3. Relative source line + mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + lastSourceLine = pendingSourceLine; + // 4. Relative source character + mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + lastSourceCharacter = pendingSourceCharacter; + if (hasPendingName) { + // 5. Relative nameIndex + mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + lastNameIndex = pendingNameIndex; + } + } + hasLast = true; + exit(); + } + function toJSON() { + commitPendingMapping(); + return { + version: 3, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings, + sourcesContent: sourcesContent, + }; + } + } + ts.createSourceMapGenerator = createSourceMapGenerator; + // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + /** + * Tries to find the sourceMappingURL comment at the end of a file. + * @param text The source text of the file. + * @param lineStarts The line starts of the file. + */ + function tryGetSourceMappingURL(text, lineStarts) { + if (lineStarts === void 0) { lineStarts = ts.computeLineStarts(text); } + for (var index = lineStarts.length - 1; index >= 0; index--) { + var line = text.substring(lineStarts[index], lineStarts[index + 1]); + var comment = sourceMapCommentRegExp.exec(line); + if (comment) { + return comment[1]; + } + // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!line.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + function isStringOrNull(x) { + // tslint:disable-next-line:no-null-keyword + return typeof x === "string" || x === null; + } + function isRawSourceMap(x) { + // tslint:disable-next-line:no-null-keyword + return x !== null + && typeof x === "object" + && x.version === 3 + && typeof x.file === "string" + && typeof x.mappings === "string" + && ts.isArray(x.sources) && ts.every(x.sources, ts.isString) + && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string") + && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull)) + && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); + } + ts.isRawSourceMap = isRawSourceMap; + function tryParseRawSourceMap(text) { + try { + var parsed = JSON.parse(text); + if (isRawSourceMap(parsed)) { + return parsed; + } + } + catch (_a) { + // empty + } + return undefined; + } + ts.tryParseRawSourceMap = tryParseRawSourceMap; + function decodeMappings(mappings) { + var done = false; + var pos = 0; + var generatedLine = 0; + var generatedCharacter = 0; + var sourceIndex = 0; + var sourceLine = 0; + var sourceCharacter = 0; + var nameIndex = 0; + var error; + return { + get pos() { return pos; }, + get error() { return error; }, + get state() { return captureMapping(/*hasSource*/ true, /*hasName*/ true); }, + next: function () { + while (!done && pos < mappings.length) { + var ch = mappings.charCodeAt(pos); + if (ch === 59 /* semicolon */) { + // new line + generatedLine++; + generatedCharacter = 0; + pos++; + continue; + } + if (ch === 44 /* comma */) { + // Next entry is on same line - no action needed + pos++; + continue; + } + var hasSource = false; + var hasName = false; + generatedCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (generatedCharacter < 0) + return setErrorAndStopIterating("Invalid generatedCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasSource = true; + sourceIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceIndex < 0) + return setErrorAndStopIterating("Invalid sourceIndex found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex"); + sourceLine += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceLine < 0) + return setErrorAndStopIterating("Invalid sourceLine found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine"); + sourceCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceCharacter < 0) + return setErrorAndStopIterating("Invalid sourceCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasName = true; + nameIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (nameIndex < 0) + return setErrorAndStopIterating("Invalid nameIndex found"); + if (!isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex"); + } + } + return { value: captureMapping(hasSource, hasName), done: done }; + } + return stopIterating(); } }; + function captureMapping(hasSource, hasName) { + return { + generatedLine: generatedLine, + generatedCharacter: generatedCharacter, + sourceIndex: hasSource ? sourceIndex : undefined, + sourceLine: hasSource ? sourceLine : undefined, + sourceCharacter: hasSource ? sourceCharacter : undefined, + nameIndex: hasName ? nameIndex : undefined + }; + } + function stopIterating() { + done = true; + return { value: undefined, done: true }; + } + function setError(message) { + if (error === undefined) { + error = message; + } + } + function setErrorAndStopIterating(message) { + setError(message); + return stopIterating(); + } + function hasReportedError() { + return error !== undefined; + } + function isSourceMappingSegmentEnd() { + return (pos === mappings.length || + mappings.charCodeAt(pos) === 44 /* comma */ || + mappings.charCodeAt(pos) === 59 /* semicolon */); + } + function base64VLQFormatDecode() { + var moreDigits = true; + var shiftCount = 0; + var value = 0; + for (; moreDigits; pos++) { + if (pos >= mappings.length) + return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1; + // 6 digit number + var currentByte = base64FormatDecode(mappings.charCodeAt(pos)); + if (currentByte === -1) + return setError("Invalid character in VLQ"), -1; + // If msb is set, we still have more bits to continue + moreDigits = (currentByte & 32) !== 0; + // least significant 5 bits are the next msbs in the final value. + value = value | ((currentByte & 31) << shiftCount); + shiftCount += 5; + } + // Least significant bit if 1 represents negative and rest of the msb is actual absolute value + if ((value & 1) === 0) { + // + number + value = value >> 1; + } + else { + // - number + value = value >> 1; + value = -value; + } + return value; + } } - ts.createSourceFileLikeCache = createSourceFileLikeCache; -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - var sourcemaps; - (function (sourcemaps) { - sourcemaps.identitySourceMapper = { getOriginalPosition: ts.identity, getGeneratedPosition: ts.identity }; - function decode(host, mapPath, map, program, fallbackCache) { - if (fallbackCache === void 0) { fallbackCache = ts.createSourceFileLikeCache(host); } - var currentDirectory = ts.getDirectoryPath(mapPath); - var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory; - var decodedMappings; - var generatedOrderedMappings; - var sourceOrderedMappings; - return { - getOriginalPosition: getOriginalPosition, - getGeneratedPosition: getGeneratedPosition - }; - function getGeneratedPosition(loc) { - var maps = getSourceOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { sourcePath: loc.fileName, sourcePosition: loc.position }, ts.identity, compareProcessedPositionSourcePositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - if (!maps[targetIndex] || ts.comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot) !== 0) { - return loc; - } - return { fileName: ts.toPath(map.file, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].emittedPosition }; // Closest pos - } - function getOriginalPosition(loc) { - var maps = getGeneratedOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { emittedPosition: loc.position }, ts.identity, compareProcessedPositionEmittedPositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - return { fileName: ts.toPath(maps[targetIndex].sourcePath, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].sourcePosition }; // Closest pos - } - function getSourceFileLike(fileName, location) { - // Lookup file in program, if provided - var path = ts.toPath(fileName, location, host.getCanonicalFileName); - var file = program && program.getSourceFile(path); - // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file - if (!file || file.resolvedPath !== path) { - // Otherwise check the cache (which may hit disk) - return fallbackCache.get(path); - } - return file; - } - function getPositionOfLineAndCharacterUsingName(fileName, directory, line, character) { - var file = getSourceFileLike(fileName, directory); - if (!file) { - return -1; - } - return ts.getPositionOfLineAndCharacter(file, line, character); - } - function getDecodedMappings() { - return decodedMappings || (decodedMappings = calculateDecodedMappings(map, processPosition, host)); - } - function getSourceOrderedMappings() { - return sourceOrderedMappings || (sourceOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionSourcePositions)); - } - function getGeneratedOrderedMappings() { - return generatedOrderedMappings || (generatedOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionEmittedPositions)); - } - function compareProcessedPositionSourcePositions(a, b) { - return ts.comparePaths(a.sourcePath, b.sourcePath, sourceRoot) || - ts.compareValues(a.sourcePosition, b.sourcePosition); - } - function compareProcessedPositionEmittedPositions(a, b) { - return ts.compareValues(a.emittedPosition, b.emittedPosition); - } - function processPosition(position) { - var sourcePath = map.sources[position.sourceIndex]; - return { - emittedPosition: getPositionOfLineAndCharacterUsingName(map.file, currentDirectory, position.emittedLine, position.emittedColumn), - sourcePosition: getPositionOfLineAndCharacterUsingName(sourcePath, sourceRoot, position.sourceLine, position.sourceColumn), - sourcePath: sourcePath, - }; - } + ts.decodeMappings = decodeMappings; + function sameMapping(left, right) { + return left === right + || left.generatedLine === right.generatedLine + && left.generatedCharacter === right.generatedCharacter + && left.sourceIndex === right.sourceIndex + && left.sourceLine === right.sourceLine + && left.sourceCharacter === right.sourceCharacter + && left.nameIndex === right.nameIndex; + } + ts.sameMapping = sameMapping; + function isSourceMapping(mapping) { + return mapping.sourceIndex !== undefined + && mapping.sourceLine !== undefined + && mapping.sourceCharacter !== undefined; + } + 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 */ : + ts.Debug.fail(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 : + -1; + } + function base64VLQFormatEncode(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; } - sourcemaps.decode = decode; - /*@internal*/ - function decodeMappings(map) { - var state = { - encodedText: map.mappings, - currentNameIndex: undefined, - sourceMapNamesLength: map.names ? map.names.length : undefined, - currentEmittedColumn: 0, - currentEmittedLine: 0, - currentSourceColumn: 0, - currentSourceLine: 0, - currentSourceIndex: 0, - decodingIndex: 0 - }; - function captureSpan() { - return { - emittedColumn: state.currentEmittedColumn, - emittedLine: state.currentEmittedLine, - sourceColumn: state.currentSourceColumn, - sourceIndex: state.currentSourceIndex, - sourceLine: state.currentSourceLine, - nameIndex: state.currentNameIndex - }; + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + return encodedStr; + } + function isSourceMappedPosition(value) { + return value.sourceIndex !== undefined + && value.sourcePosition !== undefined; + } + function sameMappedPosition(left, right) { + return left.generatedPosition === right.generatedPosition + && left.sourceIndex === right.sourceIndex + && left.sourcePosition === right.sourcePosition; + } + function compareSourcePositions(left, right) { + return ts.compareValues(left.sourceIndex, right.sourceIndex); + } + function compareGeneratedPositions(left, right) { + return ts.compareValues(left.generatedPosition, right.generatedPosition); + } + function getSourcePositionOfMapping(value) { + return value.sourcePosition; + } + function getGeneratedPositionOfMapping(value) { + return value.generatedPosition; + } + function createDocumentPositionMapper(host, map, mapPath) { + var mapDirectory = ts.getDirectoryPath(mapPath); + var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory; + var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory); + var generatedCanonicalFilePath = host.getCanonicalFileName(generatedAbsoluteFilePath); + var generatedFile = host.getSourceFileLike(generatedCanonicalFilePath); + var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); }); + var sourceFileCanonicalPaths = sourceFileAbsolutePaths.map(function (source) { return host.getCanonicalFileName(source); }); + var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileCanonicalPaths.map(function (source, i) { return [source, i]; })); + var decodedMappings; + var generatedMappings; + var sourceMappings; + return { + getSourcePosition: getSourcePosition, + getGeneratedPosition: getGeneratedPosition + }; + function processMapping(mapping) { + var generatedPosition = generatedFile !== undefined + ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter) + : -1; + var source; + var sourcePosition; + if (isSourceMapping(mapping)) { + var sourceFilePath = sourceFileCanonicalPaths[mapping.sourceIndex]; + var sourceFile = host.getSourceFileLike(sourceFilePath); + source = map.sources[mapping.sourceIndex]; + sourcePosition = sourceFile !== undefined + ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter) + : -1; } return { - get decodingIndex() { return state.decodingIndex; }, - get error() { return state.error; }, - get lastSpan() { return captureSpan(); }, - next: function () { - if (hasCompletedDecoding(state) || state.error) - return { done: true, value: undefined }; - if (!decodeSinglePosition(state)) - return { done: true, value: undefined }; - return { done: false, value: captureSpan() }; - } + generatedPosition: generatedPosition, + source: source, + sourceIndex: mapping.sourceIndex, + sourcePosition: sourcePosition, + nameIndex: mapping.nameIndex }; } - sourcemaps.decodeMappings = decodeMappings; - function calculateDecodedMappings(map, processPosition, host) { - var decoder = decodeMappings(map); - var positions = ts.arrayFrom(decoder, processPosition); - if (decoder.error) { - if (host && host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); - } - return []; - } - return positions; - } - function hasCompletedDecoding(state) { - return state.decodingIndex === state.encodedText.length; - } - function decodeSinglePosition(state) { - while (state.decodingIndex < state.encodedText.length) { - var char = state.encodedText.charCodeAt(state.decodingIndex); - if (char === 59 /* semicolon */) { - // New line - state.currentEmittedLine++; - state.currentEmittedColumn = 0; - state.decodingIndex++; - continue; - } - if (char === 44 /* comma */) { - // Next entry is on same line - no action needed - state.decodingIndex++; - continue; - } - // Read the current position - // 1. Column offset from prev read jsColumn - state.currentEmittedColumn += base64VLQFormatDecode(); - // Incorrect emittedColumn dont support this map - if (createErrorIfCondition(state.currentEmittedColumn < 0, "Invalid emittedColumn found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted column")) { - return false; - } - // 2. Relative sourceIndex - state.currentSourceIndex += base64VLQFormatDecode(); - // Incorrect sourceIndex dont support this map - if (createErrorIfCondition(state.currentSourceIndex < 0, "Invalid sourceIndex found")) { - return false; - } - // Dont support reading mappings that dont have information about original source position - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after sourceIndex")) { - return false; - } - // 3. Relative sourceLine 0 based - state.currentSourceLine += base64VLQFormatDecode(); - // Incorrect sourceLine dont support this map - if (createErrorIfCondition(state.currentSourceLine < 0, "Invalid sourceLine found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted Line")) { - return false; - } - // 4. Relative sourceColumn 0 based - state.currentSourceColumn += base64VLQFormatDecode(); - // Incorrect sourceColumn dont support this map - if (createErrorIfCondition(state.currentSourceColumn < 0, "Invalid sourceLine found")) { - return false; - } - // 5. Check if there is name: - if (!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex)) { - if (state.currentNameIndex === undefined) { - state.currentNameIndex = 0; + function getDecodedMappings() { + if (decodedMappings === undefined) { + var decoder = decodeMappings(map.mappings); + var mappings = ts.arrayFrom(decoder, processMapping); + if (decoder.error !== undefined) { + if (host.log) { + host.log("Encountered error while decoding sourcemap: " + decoder.error); } - state.currentNameIndex += base64VLQFormatDecode(); - // Incorrect nameIndex dont support this map - // TODO: If we start using `name`s, issue errors when they aren't correct in the sourcemap - // if (createErrorIfCondition(state.currentNameIndex < 0 || state.currentNameIndex >= state.sourceMapNamesLength, "Invalid name index for the source map entry")) { - // return; - // } - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: There are more entries after " + (state.currentNameIndex === undefined ? "sourceColumn" : "nameIndex"))) { - return false; - } - // Entry should be complete - return true; - } - createErrorIfCondition(/*condition*/ true, "No encoded entry found"); - return false; - function createErrorIfCondition(condition, errormsg) { - if (state.error) { - // An error was already reported - return true; - } - if (condition) { - state.error = errormsg; - } - return condition; - } - function base64VLQFormatDecode() { - var moreDigits = true; - var shiftCount = 0; - var value = 0; - for (; moreDigits; state.decodingIndex++) { - if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return undefined; // TODO: GH#18217 - } - // 6 digit number - var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); - // If msb is set, we still have more bits to continue - moreDigits = (currentByte & 32) !== 0; - // least significant 5 bits are the next msbs in the final value. - value = value | ((currentByte & 31) << shiftCount); - shiftCount += 5; - } - // Least significant bit if 1 represents negative and rest of the msb is actual absolute value - if ((value & 1) === 0) { - // + number - value = value >> 1; + decodedMappings = ts.emptyArray; } else { - // - number - value = value >> 1; - value = -value; + decodedMappings = mappings; } - return value; } + return decodedMappings; } - function base64FormatDecode(char) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(char); + function getSourceMappings(sourceIndex) { + if (sourceMappings === undefined) { + var lists = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + if (!isSourceMappedPosition(mapping)) + continue; + var list = lists[mapping.sourceIndex]; + if (!list) + lists[mapping.sourceIndex] = list = []; + list.push(mapping); + } + sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); }); + } + return sourceMappings[sourceIndex]; } - function isSourceMappingSegmentEnd(encodedText, pos) { - return (pos === encodedText.length || - encodedText.charCodeAt(pos) === 44 /* comma */ || - encodedText.charCodeAt(pos) === 59 /* semicolon */); + function getGeneratedMappings() { + if (generatedMappings === undefined) { + var list = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + list.push(mapping); + } + generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition); + } + return generatedMappings; } - })(sourcemaps = ts.sourcemaps || (ts.sourcemaps = {})); + function getGeneratedPosition(loc) { + var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName)); + if (sourceIndex === undefined) + return loc; + var sourceMappings = getSourceMappings(sourceIndex); + if (!ts.some(sourceMappings)) + return loc; + var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = sourceMappings[targetIndex]; + if (mapping === undefined || mapping.sourceIndex !== sourceIndex) { + return loc; + } + return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition }; // Closest pos + } + function getSourcePosition(loc) { + var generatedMappings = getGeneratedMappings(); + if (!ts.some(generatedMappings)) + return loc; + var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = generatedMappings[targetIndex]; + if (mapping === undefined || !isSourceMappedPosition(mapping)) { + return loc; + } + return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition }; // Closest pos + } + } + ts.createDocumentPositionMapper = createDocumentPositionMapper; + ts.identitySourceMapConsumer = { + getSourcePosition: ts.identity, + getGeneratedPosition: ts.identity + }; })(ts || (ts = {})); /* @internal */ var ts; @@ -63737,7 +64838,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -63783,7 +64884,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -63791,13 +64892,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 246 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + case 248 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -63827,13 +64928,13 @@ var ts; } } break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -63841,7 +64942,7 @@ var ts; } } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -63861,7 +64962,7 @@ var ts; } } break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -64477,8 +65578,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -64508,14 +65609,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -64564,16 +65665,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 243 /* ModuleBlock */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 245 /* ModuleBlock */: + case 218 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -64585,7 +65686,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 === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 240 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -64633,10 +65734,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -64657,13 +65758,13 @@ var ts; return node; } switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -64683,11 +65784,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 253 /* ExportDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 248 /* ImportClause */ || - (node.kind === 246 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 257 /* ExternalModuleReference */)) { + if (node.kind === 255 /* ExportDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 250 /* ImportClause */ || + (node.kind === 248 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 259 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -64717,19 +65818,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 152 /* PropertyDeclaration */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -64739,7 +65840,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 84 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 85 /* ExportKeyword */) { return undefined; } return node; @@ -64756,67 +65857,67 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 133 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 166 /* TypeLiteral */: - case 161 /* TypePredicate */: - case 148 /* TypeParameter */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 122 /* BooleanKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 105 /* VoidKeyword */: - case 138 /* SymbolKeyword */: - case 164 /* ConstructorType */: - case 163 /* FunctionType */: - case 165 /* TypeQuery */: - case 162 /* TypeReference */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 175 /* ParenthesizedType */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 168 /* TypeLiteral */: + case 163 /* TypePredicate */: + case 150 /* TypeParameter */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 123 /* BooleanKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 132 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 139 /* SymbolKeyword */: + case 166 /* ConstructorType */: + case 165 /* FunctionType */: + case 167 /* TypeQuery */: + case 164 /* TypeReference */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 177 /* ParenthesizedType */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: // TypeScript type nodes are elided. - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: // TypeScript index signatures are elided. - case 150 /* Decorator */: + case 152 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 152 /* PropertyDeclaration */: + case 154 /* 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 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructor(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64827,7 +65928,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64838,35 +65939,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -64876,35 +65977,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -64941,7 +66042,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -65010,7 +66111,7 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -65212,7 +66313,7 @@ var ts; pendingExpressions = undefined; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85 /* ExtendsKeyword */; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 86 /* ExtendsKeyword */; })); var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); @@ -65388,7 +66489,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -65459,7 +66560,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 152 /* PropertyDeclaration */ + return member.kind === 154 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -65470,8 +66571,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -65487,8 +66588,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); ts.startOnNewLine(expression); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -65599,12 +66700,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -65757,7 +66858,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 152 /* PropertyDeclaration */ + ? member.kind === 154 /* 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`. ? ts.createVoidZero() @@ -65858,13 +66959,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -65880,10 +66981,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 152 /* PropertyDeclaration */; + return kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 154 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -65893,7 +66994,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -65904,12 +67005,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; } return false; @@ -65926,15 +67027,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: return serializeTypeNode(node.type); - case 157 /* SetAccessor */: - case 156 /* GetAccessor */: + case 159 /* SetAccessor */: + case 158 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 156 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -65971,7 +67072,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 156 /* GetAccessor */) { + if (container && node.kind === 158 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -66016,77 +67117,83 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: return ts.createVoidZero(); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createIdentifier("Function"); - case 167 /* ArrayType */: - case 168 /* TupleType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: return ts.createIdentifier("Array"); - case 161 /* TypePredicate */: - case 122 /* BooleanKeyword */: + case 163 /* TypePredicate */: + case 123 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return ts.createIdentifier("String"); - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 180 /* LiteralType */: + case 182 /* LiteralType */: switch (node.literal.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + return getGlobalBigIntNameWithFallback(); + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 138 /* SymbolKeyword */: + case 146 /* BigIntKeyword */: + return getGlobalBigIntNameWithFallback(); + case 139 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return serializeTypeReferenceNode(node); - case 172 /* IntersectionType */: - case 171 /* UnionType */: - return serializeUnionOrIntersectionType(node); - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 166 /* TypeLiteral */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 176 /* ThisType */: - case 181 /* ImportType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return serializeTypeList(node.types); + case 175 /* ConditionalType */: + return serializeTypeList([node.trueType, node.falseType]); + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 168 /* TypeLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 178 /* ThisType */: + case 183 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); } return ts.createIdentifier("Object"); } - function serializeUnionOrIntersectionType(node) { + function serializeTypeList(types) { // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 131 /* NeverKeyword */) { + if (typeNode.kind === 132 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); @@ -66122,6 +67229,10 @@ var ts; var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: + // From conditional type type reference that cannot be resolved is Similar to any or unknown + if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { + return ts.createIdentifier("Object"); + } var serialized = serializeEntityNameAsExpressionFallback(node.typeName); var temp = ts.createTempVariable(hoistVariableDeclaration); return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object")); @@ -66129,6 +67240,8 @@ var ts; return serializeEntityNameAsExpression(node.typeName); case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.createVoidZero(); + case ts.TypeReferenceSerializationKind.BigIntLikeType: + return getGlobalBigIntNameWithFallback(); case ts.TypeReferenceSerializationKind.BooleanType: return ts.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -66160,12 +67273,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 71 /* Identifier */) { + if (node.left.kind === 72 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -66181,7 +67294,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* 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.getMutableClone(node); @@ -66189,7 +67302,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -66210,6 +67323,15 @@ var ts; function getGlobalSymbolNameWithFallback() { return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object")); } + /** + * Gets an expression that points to the global "BigInt" constructor at runtime if it is + * available. + */ + function getGlobalBigIntNameWithFallback() { + return languageVersion < 6 /* ESNext */ + ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object")) + : ts.createIdentifier("BigInt"); + } /** * A simple inlinable expression is an expression which can be copied into multiple locations * without risk of repeating any sideeffects and whose value could not possibly change between @@ -66290,9 +67412,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 85 /* ExtendsKeyword */) { + if (node.token === 86 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(85 /* ExtendsKeyword */, types), node); + return ts.setTextRange(ts.createHeritageClause(86 /* ExtendsKeyword */, types), node); } return undefined; } @@ -66688,7 +67810,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -66769,12 +67891,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 241 /* EnumDeclaration */) { + if (node.kind === 243 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -66899,7 +68021,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 243 /* ModuleBlock */) { + if (body.kind === 245 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -66945,13 +68067,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 243 /* ModuleBlock */) { + if (body.kind !== 245 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -66992,7 +68114,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 249 /* NamespaceImport */) { + if (node.kind === 251 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -67205,7 +68327,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -67213,7 +68335,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -67223,17 +68345,17 @@ var ts; enabledSubstitutions |= 2 /* 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(71 /* Identifier */); - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); + context.enableSubstitution(72 /* Identifier */); + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(242 /* ModuleDeclaration */); + context.enableEmitNotification(244 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 244 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 243 /* EnumDeclaration */; } /** * Hook for node emit. @@ -67292,11 +68414,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -67334,9 +68456,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 !== 277 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); + if (container && container.kind !== 279 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -67476,26 +68598,26 @@ var ts; return node; } switch (node.kind) { - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -67506,27 +68628,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 216 /* Block */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 229 /* WithStatement */: - case 231 /* LabeledStatement */: + case 218 /* Block */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 231 /* WithStatement */: + case 233 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -67727,7 +68849,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 195 /* ArrowFunction */; + var isArrowFunction = node.kind === 197 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -67812,17 +68934,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -67870,23 +68992,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -67906,11 +69028,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -67977,7 +69099,7 @@ var ts; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -68045,7 +69167,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 120 /* AsyncKeyword */) { + if (node.kind === 121 /* AsyncKeyword */) { return undefined; } return node; @@ -68055,55 +69177,55 @@ var ts; return node; } switch (node.kind) { - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitVoidExpression(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructorDeclaration(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -68139,7 +69261,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 227 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -68151,7 +69273,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 275 /* SpreadAssignment */) { + if (e.kind === 277 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -68160,7 +69282,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 275 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -68178,7 +69300,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 188 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -68206,7 +69328,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 262144 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -68434,7 +69556,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); @@ -68503,17 +69625,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -68561,23 +69683,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -68597,11 +69719,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -68710,13 +69832,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -68724,15 +69846,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 10 /* JsxText */: + case 11 /* JsxText */: return visitJsxText(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -68800,14 +69922,14 @@ var ts; if (node === undefined) { return ts.createTrue(); } - else if (node.kind === 9 /* StringLiteral */) { + else if (node.kind === 10 /* 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 literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text); literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 268 /* JsxExpression */) { + else if (node.kind === 270 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -68901,7 +70023,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 258 /* JsxElement */) { + if (node.kind === 260 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -69207,7 +70329,7 @@ var ts; return node; } switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69215,9 +70337,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 62 /* AsteriskAsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69445,13 +70567,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 228 /* ReturnStatement */ + && node.kind === 230 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 218 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -69470,104 +70592,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: return undefined; // elide static keyword - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return visitClassExpression(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 71 /* Identifier */: + case 72 /* Identifier */: return visitIdentifier(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return visitTemplateLiteral(node); - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitSpreadElement(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return visitThisKeyword(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitMetaProperty(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -69654,14 +70776,14 @@ 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 === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 229 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -69672,7 +70794,7 @@ var ts; } } else { - if (node.kind === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -69691,10 +70813,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 26 /* CommaToken */, copyExpr); + expr = ts.createBinary(expr, 27 /* CommaToken */, copyExpr); } } - returnExpression = ts.createBinary(expr, 26 /* CommaToken */, returnExpression); + returnExpression = ts.createBinary(expr, 27 /* CommaToken */, returnExpression); } return ts.createReturn(returnExpression); } @@ -69828,7 +70950,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -69933,7 +71055,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -69972,11 +71094,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 228 /* ReturnStatement */) { + if (statement.kind === 230 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 220 /* IfStatement */) { + else if (statement.kind === 222 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -69984,7 +71106,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 216 /* Block */) { + else if (statement.kind === 218 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -70042,7 +71164,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -70052,8 +71174,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (8192 /* ContainsLexicalThis */ | 16384 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 202 /* BinaryExpression */ - || superCallExpression.left.kind !== 189 /* CallExpression */) { + if (superCallExpression.kind !== 204 /* BinaryExpression */ + || superCallExpression.left.kind !== 191 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -70198,7 +71320,7 @@ var ts; * synthesized call to `super` */ function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 71 /* Identifier */ && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 72 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** * Adds statements to the body of a function-like node if it contains a rest parameter. @@ -70250,7 +71372,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { + if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 197 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -70269,25 +71391,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return statements; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 94 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70315,20 +71437,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -70520,7 +71642,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 239 /* FunctionDeclaration */ || node.kind === 196 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -70565,7 +71687,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 195 /* ArrowFunction */); + ts.Debug.assert(node.kind === 197 /* 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 @@ -70603,7 +71725,7 @@ var ts; ts.setEmitFlags(block, 1 /* SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 18 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -70633,9 +71755,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -70654,9 +71776,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -70691,7 +71813,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 58 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 59 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -70865,14 +71987,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -71056,7 +72178,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 147 /* ComputedPropertyName */) { + if (property.name.kind === 149 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -71111,7 +72233,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -71177,11 +72299,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 223 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 224 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 225 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 221 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 222 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 225 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 226 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 227 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 223 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 224 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -71206,11 +72328,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 238 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -71361,7 +72483,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -71423,7 +72545,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(51 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -71461,7 +72583,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -71472,7 +72594,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 58 /* EqualsToken */, source); + return ts.createBinary(target, 59 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -71485,7 +72607,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -71499,7 +72621,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -71520,10 +72642,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -71609,20 +72731,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -71733,7 +72855,7 @@ var ts; var body = node.transformFlags & (16384 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -71910,10 +73032,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 131072 /* ContainsRestOrSpread */ || - node.expression.kind === 97 /* SuperKeyword */ || + node.expression.kind === 98 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -71946,7 +73068,7 @@ var ts; resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -72011,7 +73133,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 187 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -72128,7 +73250,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 === 13 /* NoSubstitutionTemplateLiteral */ || node.kind === 16 /* TemplateTail */; + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's @@ -72226,7 +73348,7 @@ var ts; : ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 94 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 95 /* NewKeyword */ && node.name.escapedText === "target") { if (hierarchyFacts & 8192 /* ComputedPropertyName */) { hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; } @@ -72263,7 +73385,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } /** @@ -72273,14 +73395,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(155 /* Constructor */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(195 /* ArrowFunction */); - context.enableEmitNotification(194 /* FunctionExpression */); - context.enableEmitNotification(237 /* FunctionDeclaration */); + context.enableSubstitution(100 /* ThisKeyword */); + context.enableEmitNotification(157 /* Constructor */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(197 /* ArrowFunction */); + context.enableEmitNotification(196 /* FunctionExpression */); + context.enableEmitNotification(239 /* FunctionDeclaration */); } } /** @@ -72321,10 +73443,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 237 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -72337,9 +73459,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -72406,19 +73528,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 221 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 191 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 98 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 208 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -72471,15 +73593,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(260 /* JsxOpeningElement */); - context.enableEmitNotification(261 /* JsxClosingElement */); - context.enableEmitNotification(259 /* JsxSelfClosingElement */); + context.enableEmitNotification(262 /* JsxOpeningElement */); + context.enableEmitNotification(263 /* JsxClosingElement */); + context.enableEmitNotification(261 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(273 /* PropertyAssignment */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(275 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -72498,9 +73620,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -72557,7 +73679,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -72832,13 +73954,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -72851,24 +73973,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return visitBreakStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return visitContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 4194304 /* ContainsYield */) { @@ -72889,21 +74011,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitConditionalExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -72916,9 +74038,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -73117,23 +74239,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 59 /* FirstCompoundAssignment */ - && kind <= 70 /* LastCompoundAssignment */; + return kind >= 60 /* FirstCompoundAssignment */ + && kind <= 71 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 59 /* PlusEqualsToken */: return 37 /* PlusToken */; - case 60 /* MinusEqualsToken */: return 38 /* MinusToken */; - case 61 /* AsteriskEqualsToken */: return 39 /* AsteriskToken */; - case 62 /* AsteriskAsteriskEqualsToken */: return 40 /* AsteriskAsteriskToken */; - case 63 /* SlashEqualsToken */: return 41 /* SlashToken */; - case 64 /* PercentEqualsToken */: return 42 /* PercentToken */; - case 65 /* LessThanLessThanEqualsToken */: return 45 /* LessThanLessThanToken */; - case 66 /* GreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanToken */; - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanGreaterThanToken */; - case 68 /* AmpersandEqualsToken */: return 48 /* AmpersandToken */; - case 69 /* BarEqualsToken */: return 49 /* BarToken */; - case 70 /* CaretEqualsToken */: return 50 /* CaretToken */; + case 60 /* PlusEqualsToken */: return 38 /* PlusToken */; + case 61 /* MinusEqualsToken */: return 39 /* MinusToken */; + case 62 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; + case 63 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; + case 64 /* SlashEqualsToken */: return 42 /* SlashToken */; + case 65 /* PercentEqualsToken */: return 43 /* PercentToken */; + case 66 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; + case 67 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; + case 69 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; + case 70 /* BarEqualsToken */: return 50 /* BarToken */; + case 71 /* CaretEqualsToken */: return 51 /* CaretToken */; } } /** @@ -73146,7 +74268,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -73158,7 +74280,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -73190,7 +74312,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -73245,7 +74367,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 === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -73276,7 +74398,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -73534,35 +74656,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: return transformAndEmitBlock(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return transformAndEmitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return transformAndEmitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return transformAndEmitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return transformAndEmitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -73992,7 +75114,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 272 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -74005,7 +75127,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -74317,7 +75439,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -75233,12 +76355,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(279 /* 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. @@ -75566,23 +76688,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -75609,24 +76731,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -76104,7 +77226,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -76159,10 +77281,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -76344,8 +77466,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -76361,7 +77483,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -76423,12 +77545,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -76449,7 +77571,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -76517,15 +77639,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 203 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 60 /* PlusEqualsToken */ : 61 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -76599,12 +77721,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(279 /* 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. @@ -76825,7 +77947,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 255 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -76850,7 +77972,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 253 /* ExportDeclaration */) { + if (externalImport.kind !== 255 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -76928,19 +78050,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -76990,15 +78112,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -77174,7 +78296,7 @@ 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 === 277 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -77238,7 +78360,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -77300,10 +78422,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -77483,43 +78605,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitDefaultClause(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitTryStatement(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -77702,7 +78824,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 202 /* BinaryExpression */) { + && node.kind === 204 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -77767,7 +78889,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 277 /* SourceFile */; + return container !== undefined && container.kind === 279 /* SourceFile */; } else { return false; @@ -77783,8 +78905,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -77800,7 +78922,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -77848,7 +78970,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -77882,12 +79004,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -77973,22 +79095,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ + var expression = node.kind === 203 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 201 /* PostfixUnaryExpression */) { - expression = node.operator === 43 /* PlusPlusToken */ + if (node.kind === 203 /* PostfixUnaryExpression */) { + expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -78009,7 +79131,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -78048,8 +79170,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(277 /* SourceFile */); - context.enableSubstitution(71 /* Identifier */); + context.enableEmitNotification(279 /* SourceFile */); + context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -78077,10 +79199,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -78187,7 +79309,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78216,7 +79338,7 @@ var ts; 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 === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78263,7 +79385,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78272,8 +79394,8 @@ var ts; } // 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 === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || - (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 154 /* PropertyDeclaration */ || node.kind === 153 /* PropertySignature */ || + (node.kind === 151 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -78282,7 +79404,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 240 /* ClassDeclaration */ || node.kind === 151 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78307,7 +79429,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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.hasModifier(node, 32 /* Static */)) { @@ -78346,26 +79468,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78373,7 +79495,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78387,7 +79509,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78412,30 +79534,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 159 /* ConstructSignature */: - case 164 /* ConstructorType */: + case 161 /* ConstructSignature */: + case 166 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78443,7 +79565,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78456,8 +79578,8 @@ 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 237 /* FunctionDeclaration */: - case 163 /* FunctionType */: + case 239 /* FunctionDeclaration */: + case 165 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78471,34 +79593,34 @@ 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 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* 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 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -78513,9 +79635,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + if (node.parent.parent.kind === 240 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 108 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 109 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -78680,10 +79802,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -78706,14 +79828,14 @@ 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_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(124 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(125 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -78827,11 +79949,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { return name; } else { - if (name.kind === 183 /* ArrayBindingPattern */) { + if (name.kind === 185 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -78839,7 +79961,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 208 /* OmittedExpression */) { + if (elem.kind === 210 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -78852,7 +79974,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(55 /* QuestionToken */)) : undefined, ensureType(p, 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 || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -78864,7 +79986,7 @@ var ts; } function ensureNoInitializer(node) { if (shouldPrintWithInitializer(node)) { - return resolver.createLiteralConstValue(ts.getParseTreeNode(node)); // TODO: Make safe + return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker); // TODO: Make safe } return undefined; } @@ -78877,19 +79999,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 149 /* Parameter */ && + var shouldUseResolverType = node.kind === 151 /* 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) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(120 /* AnyKeyword */); } - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -78897,12 +80019,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 149 /* Parameter */ - || node.kind === 152 /* PropertyDeclaration */ - || node.kind === 151 /* PropertySignature */) { + if (node.kind === 151 /* Parameter */ + || node.kind === 154 /* PropertyDeclaration */ + || node.kind === 153 /* 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)); @@ -78913,26 +80035,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(119 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(120 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return false; } return false; @@ -78986,7 +80108,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 244 /* ModuleDeclaration */ && parent.kind !== 183 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -79006,7 +80128,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 259 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -79033,7 +80155,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 251 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -79138,68 +80260,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 168 /* TypeLiteral */ || input.kind === 181 /* MappedType */) && input.parent.kind !== 242 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 209 /* ExpressionWithTypeArguments */: { + case 211 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 162 /* TypeReference */: { + case 164 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 155 /* Constructor */: { + case 157 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(157 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 154 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 156 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(155 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 156 /* GetAccessor */: { + case 158 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 157 /* SetAccessor */: { + case 159 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 153 /* MethodSignature */: { + case 155 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 158 /* CallSignature */: { + case 160 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 160 /* IndexSignature */: { + case 162 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(120 /* AnyKeyword */))); } - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -79207,13 +80329,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 148 /* TypeParameter */: { + case 150 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 173 /* ConditionalType */: { + case 175 /* 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); @@ -79225,13 +80347,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 163 /* FunctionType */: { + case 165 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 164 /* ConstructorType */: { + case 166 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 181 /* ImportType */: { + case 183 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -79260,7 +80382,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 156 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -79270,7 +80392,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 253 /* ExportDeclaration */: { + case 255 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -79279,13 +80401,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 252 /* ExportAssignment */: { + case 254 /* 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 === 71 /* Identifier */) { + if (input.expression.kind === 72 /* Identifier */) { return input; } else { @@ -79295,7 +80417,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -79309,10 +80431,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -79333,14 +80455,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 242 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 239 /* InterfaceDeclaration */: { + case 241 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 237 /* FunctionDeclaration */: { + case 239 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), @@ -79362,10 +80484,10 @@ var ts; return clean; } } - case 242 /* ModuleDeclaration */: { + case 244 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 243 /* ModuleBlock */) { + if (inner && inner.kind === 245 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -79386,7 +80508,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 238 /* ClassDeclaration */: { + case 240 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -79397,7 +80519,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 71 /* Identifier */) { + if (param.name.kind === 72 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -79427,7 +80549,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 96 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ @@ -79436,16 +80558,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 85 /* ExtendsKeyword */) { + if (clause.token === 86 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 96 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -79456,10 +80578,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 241 /* EnumDeclaration */: { + case 243 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -79478,7 +80600,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 242 /* ModuleDeclaration */) { + if (input.kind === 244 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -79499,7 +80621,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 208 /* OmittedExpression */) { + if (e.kind === 210 /* OmittedExpression */) { return; } if (e.name) { @@ -79562,7 +80684,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 277 /* SourceFile */; + var parentIsFile = node.parent.kind === 279 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -79604,13 +80726,13 @@ var ts; } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 85 /* ExtendsKeyword */ && t.expression.kind === 95 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 86 /* ExtendsKeyword */ && t.expression.kind === 96 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* InterfaceDeclaration */) { return true; } return false; @@ -79635,7 +80757,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 156 /* GetAccessor */ + return accessor.kind === 158 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -79644,52 +80766,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 217 /* VariableStatement */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 219 /* VariableStatement */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 235 /* VariableDeclaration */: - case 148 /* TypeParameter */: - case 209 /* ExpressionWithTypeArguments */: - case 162 /* TypeReference */: - case 173 /* ConditionalType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 181 /* ImportType */: + case 161 /* ConstructSignature */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 237 /* VariableDeclaration */: + case 150 /* TypeParameter */: + case 211 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 175 /* ConditionalType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 183 /* ImportType */: return true; } return false; @@ -79754,6 +80876,14 @@ var ts; return transformers; } ts.getTransformers = getTransformers; + function noEmitSubstitution(_hint, node) { + return node; + } + ts.noEmitSubstitution = noEmitSubstitution; + function noEmitNotification(hint, node, callback) { + callback(hint, node); + } + ts.noEmitNotification = noEmitNotification; /** * Transforms an array of SourceFiles by passing them through each transformer. * @@ -79765,7 +80895,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(310 /* Count */); + var enabledSyntaxKindFeatures = new Array(312 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -79773,8 +80903,8 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; - var onSubstituteNode = function (_, node) { return node; }; - var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var onSubstituteNode = noEmitSubstitution; + var onEmitNode = noEmitNotification; var state = 0 /* Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer @@ -80023,825 +81153,11 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans - var defaultLastEncodedSourceMapSpan = { - emittedLine: 0, - emittedColumn: 0, - sourceLine: 0, - sourceColumn: 0, - sourceIndex: 0 - }; - function createSourceMapWriter(host, writer, compilerOptions) { - if (compilerOptions === void 0) { compilerOptions = host.getCompilerOptions(); } - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var currentSource; - var currentSourceText; - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex; - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan; - var lastEncodedNameIndex; - // Source map data - var sourceMapData; - var sourceMapDataList; - var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); - return { - initialize: initialize, - reset: reset, - setSourceFile: setSourceFile, - emitPos: emitPos, - emitNodeWithSourceMap: emitNodeWithSourceMap, - emitTokenWithSourceMap: emitTokenWithSourceMap, - getText: getText, - getSourceMappingURL: getSourceMappingURL, - }; - /** - * Skips trivia such as comments and white-space that can optionally overriden by the source map source - */ - function skipSourceTrivia(pos) { - return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); - } - /** - * Initialize the SourceMapWriter for a new output file. - * - * @param filePath The path to the generated output file. - * @param sourceMapFilePath The path to the output source map file. - * @param sourceFileOrBundle The input source file or bundle for the program. - */ - function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { - return; - } - if (sourceMapData) { - reset(); - } - sourceMapDataList = outputSourceMapDataList; - currentSource = undefined; - currentSourceText = undefined; - // Current source map file and its index in the sources list - sourceMapSourceIndex = -1; - // Last recorded and encoded spans - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; - lastEncodedNameIndex = 0; - // Initialize source map data - sourceMapData = { - sourceMapFilePath: sourceMapFilePath, - jsSourceMappingURL: !compilerOptions.inlineSourceMap ? ts.getBaseFileName(ts.normalizeSlashes(sourceMapFilePath)) : undefined, - sourceMapFile: ts.getBaseFileName(ts.normalizeSlashes(filePath)), - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 277 /* SourceFile */) { // emitting single module file - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle.fileName, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(filePath)); - } - } - /** - * Reset the SourceMapWriter to an empty state. - */ - function reset() { - if (disabled) { - return; - } - // Record source map data for the test harness. - if (sourceMapDataList) { - sourceMapDataList.push(sourceMapData); - } - currentSource = undefined; - sourceMapDir = undefined; - sourceMapSourceIndex = undefined; - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = undefined; - lastEncodedNameIndex = undefined; - sourceMapData = undefined; - sourceMapDataList = undefined; - } - function captureSection() { - return { - version: 3, - file: sourceMapData.sourceMapFile, - sourceRoot: sourceMapData.sourceMapSourceRoot, - sources: sourceMapData.sourceMapSources, - names: sourceMapData.sourceMapNames, - mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent, - }; - } - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - ts.Debug.assert(lastRecordedSourceMapSpan.emittedColumn >= 0, "lastEncodedSourceMapSpan.emittedColumn was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceIndex >= 0, "lastEncodedSourceMapSpan.sourceIndex was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceLine >= 0, "lastEncodedSourceMapSpan.sourceLine was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceColumn >= 0, "lastEncodedSourceMapSpan.sourceColumn was negative"); - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 0; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - } - /** - * Emits a mapping. - * - * If the position is synthetic (undefined or a negative value), no mapping will be - * created. - * - * @param pos The position. - */ - function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeSourcemap"); - } - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSource, pos); - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - sourceIndex: sourceMapSourceIndex - }; - } - else { - // Take the new pos instead since there is no change in emittedLine and column since last location - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - if (extendedDiagnostics) { - ts.performance.mark("afterSourcemap"); - ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); - } - } - function isPossiblySourceMap(x) { - return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; - } - /** - * Emits a node with possible leading and trailing source maps. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to emit. - * @param emitCallback The callback used to emit the node. - */ - function emitNodeWithSourceMap(hint, node, emitCallback) { - var _a; - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(hint, node); - } - if (node) { - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var text = node.sourceMapText; - var parsed = void 0; - try { - parsed = JSON.parse(text); - } - catch (_b) { - // empty - } - if (!parsed || !isPossiblySourceMap(parsed)) { - return emitCallback(hint, node); - } - var offsetLine = writer.getLine(); - var firstLineColumnOffset = writer.getColumn(); - // First, decode the old component sourcemap - var originalMap = parsed; - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache = ts.createMap(); - var absolutePathCache = ts.createMap(); - var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); - for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { - var pathCacheKey = "" + raw.sourceIndex; - // Apply offsets to each position and fixup source entries - if (!resolvedPathCache.has(pathCacheKey)) { - var rawPath = originalMap.sources[raw.sourceIndex]; - var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - resolvedPathCache.set(pathCacheKey, resolvedPath_1); - absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); - } - var resolvedPath = resolvedPathCache.get(pathCacheKey); - var absolutePath = absolutePathCache.get(pathCacheKey); - // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? - var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); - // Then reencode all the updated spans into the overall map - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); - } - // And actually emit the text these sourcemaps are for - return emitCallback(hint, node); - } - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.sourceMapRange; - var _d = range || node, pos = _d.pos, end = _d.end; - var source = range && range.source; - var oldSource = currentSource; - if (source === oldSource) - source = undefined; - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitPos(skipSourceTrivia(pos)); - } - if (source) - setSourceFile(oldSource); - if (emitFlags & 64 /* NoNestedSourceMaps */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitPos(end); - } - if (source) - setSourceFile(oldSource); - } - } - /** - * Emits a token of a node with possible leading and trailing source maps. - * - * @param node The node containing the token. - * @param token The token to emit. - * @param tokenStartPos The start pos of the token. - * @param emitCallback The callback used to emit the token. - */ - function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(token, writer, tokenPos); - } - var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; - tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - tokenPos = emitCallback(token, writer, tokenPos); - if (range) - tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - return tokenPos; - } - function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); - } - /** - * Set the current source file. - * - * @param sourceFile The source file. - */ - function setSourceFile(sourceFile) { - if (disabled) { - return; - } - currentSource = sourceFile; - currentSourceText = currentSource.text; - if (isJsonSourceMapSource(sourceFile)) { - return; - } - setupSourceEntry(sourceFile.fileName, sourceFile.text); - } - function setupSourceEntry(fileName, content, source) { - if (!source) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); - if (sourceMapSourceIndex === -1) { - sourceMapSourceIndex = sourceMapData.sourceMapSources.length; - sourceMapData.sourceMapSources.push(source); - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(fileName); - if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent.push(content); - } - } - } - /** - * Gets the text for the source map. - */ - function getText() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - encodeLastRecordedSourceMapSpan(); - return JSON.stringify(captureSection()); - } - /** - * Gets the SourceMappingURL for the source map. - */ - function getSourceMappingURL() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.base64encode(ts.sys, getText()); - return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; - } - else { - return sourceMapData.jsSourceMappingURL; - } - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - function base64FormatEncode(inValue) { - if (inValue < 64) { - return base64Chars.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - function createCommentWriter(printerOptions, emitPos) { - var extendedDiagnostics = printerOptions.extendedDiagnostics; - var newLine = ts.getNewLineCharacter(printerOptions); - var writer; - var containerPos = -1; - var containerEnd = -1; - var declarationListContainerEnd = -1; - var currentSourceFile; - var currentText; - var currentLineMap; - var detachedCommentsInfo; - var hasWrittenComment = false; - var disabled = !!printerOptions.removeComments; - return { - reset: reset, - setWriter: setWriter, - setSourceFile: setSourceFile, - emitNodeWithComments: emitNodeWithComments, - emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, - emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, - }; - function emitNodeWithComments(hint, node, emitCallback) { - if (disabled) { - emitCallback(hint, node); - return; - } - if (node) { - hasWrittenComment = false; - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; - if ((pos < 0 && end < 0) || (pos === end)) { - // Both pos and end are synthesized, so just emit the node without comments. - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - } - else { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithComment"); - } - var isEmittedNode = node.kind !== 305 /* NotEmittedStatement */; - // 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 === 10 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 10 /* JsxText */; - // 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); - } - // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { - // Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments. - containerPos = pos; - } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* 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 === 236 /* VariableDeclarationList */) { - declarationListContainerEnd = end; - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithComment"); - } - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithComment"); - } - // Restore previous container state. - containerPos = savedContainerPos; - containerEnd = savedContainerEnd; - 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 && isEmittedNode) { - emitTrailingComments(end); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithComment"); - } - } - } - } - function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { - var leadingComments = emitNode && emitNode.leadingComments; - if (ts.some(leadingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithSynthesizedComments"); - } - ts.forEach(leadingComments, emitLeadingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); - } - } - emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); - var trailingComments = emitNode && emitNode.trailingComments; - if (ts.some(trailingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithSynthesizedComments"); - } - ts.forEach(trailingComments, emitTrailingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); - } - } - } - function emitLeadingSynthesizedComment(comment) { - if (comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function emitTrailingSynthesizedComment(comment) { - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - } - function writeSynthesizedComment(comment) { - var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; - ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); - } - function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; - } - function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - } - function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitBodyWithDetachedComments"); - } - var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = disabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; - if (!skipLeadingComments) { - emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); - } - if (emitFlags & 2048 /* NoNestedComments */ && !disabled) { - disabled = true; - emitCallback(node); - disabled = false; - } - else { - emitCallback(node); - } - if (extendedDiagnostics) { - ts.performance.mark("beginEmitBodyWithDetachedComments"); - } - if (!skipTrailingComments) { - emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); - if (hasWrittenComment && !writer.isAtStartOfLine()) { - writer.writeLine(); - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitBodyWithDetachedComments"); - } - } - function emitLeadingComments(pos, isEmittedNode) { - hasWrittenComment = false; - if (isEmittedNode) { - forEachLeadingCommentToEmit(pos, emitLeadingComment); - } - else if (pos === 0) { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted - forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); - } - } - function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); - } - } - function shouldWriteComment(text, pos) { - if (printerOptions.onlyPrintJsDocStyle) { - return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); - } - return true; - } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (!hasWrittenComment) { - ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); - hasWrittenComment = true; - } - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else if (kind === 3 /* MultiLineCommentTrivia */) { - writer.write(" "); - } - } - function emitLeadingCommentsOfPosition(pos) { - if (disabled || pos === -1) { - return; - } - emitLeadingComments(pos, /*isEmittedNode*/ true); - } - function emitTrailingComments(pos) { - forEachTrailingCommentToEmit(pos, emitTrailingComment); - } - function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - } - function emitTrailingCommentsOfPosition(pos, prefixSpace) { - if (disabled) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); - } - forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); - } - } - function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function forEachLeadingCommentToEmit(pos, cb) { - // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments - if (containerPos === -1 || pos !== containerPos) { - if (hasDetachedComments(pos)) { - forEachLeadingCommentWithoutDetachedComments(cb); - } - else { - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - } - } - function forEachTrailingCommentToEmit(end, cb) { - // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments - if (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd)) { - ts.forEachTrailingCommentRange(currentText, end, cb); - } - } - function reset() { - currentSourceFile = undefined; - currentText = undefined; - currentLineMap = undefined; - detachedCommentsInfo = undefined; - } - function setWriter(output) { - writer = output; - } - function setSourceFile(sourceFile) { - currentSourceFile = sourceFile; - currentText = currentSourceFile.text; - currentLineMap = ts.getLineStarts(currentSourceFile); - detachedCommentsInfo = undefined; - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; - } - function forEachLeadingCommentWithoutDetachedComments(cb) { - // get the leading comments from detachedPos - var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentText, currentLineMap, writer, writeComment, range, newLine, disabled); - if (currentDetachedCommentInfo) { - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - */ - function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); - } - } - ts.createCommentWriter = createCommentWriter; -})(ts || (ts = {})); var ts; (function (ts) { var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); + var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. @@ -80879,7 +81195,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 278 /* Bundle */) { + if (sourceFile.kind === 280 /* Bundle */) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); @@ -80941,22 +81257,16 @@ var ts; var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); - var newLine = host.getNewLine(); + var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); - var sourceMap = ts.createSourceMapWriter(host, writer); - var declarationSourceMap = ts.createSourceMapWriter(host, writer, { - sourceMap: compilerOptions.declarationMap, - sourceRoot: compilerOptions.sourceRoot, - mapRoot: compilerOptions.mapRoot, - extendedDiagnostics: compilerOptions.extendedDiagnostics, - }); + var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; var bundleInfo = createDefaultBundleInfo(); var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file - ts.performance.mark("beforePrint"); + enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); - ts.performance.measure("printTime", "beforePrint"); + exit(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -80999,22 +81309,27 @@ var ts; } // Transform the source files var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], transformers, /*allowDtsFiles*/ false); + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: compilerOptions.noEmitHelpers, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + inlineSources: compilerOptions.inlineSources, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }; // Create a printer to print the nodes - var printer = createPrinter(__assign({}, compilerOptions, { noEmitHelpers: compilerOptions.noEmitHelpers }), { + var printer = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, // transform hooks onEmitNode: transform.emitNodeWithNotification, substituteNode: transform.substituteNode, - // sourcemap hooks - onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: sourceMap.emitPos, - // emitter hooks - onSetSourceFile: setSourceFile, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, sourceMap); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); } @@ -81038,14 +81353,20 @@ var ts; emitterDiagnostics.add(diagnostic); } } - var declarationPrinter = createPrinter(__assign({}, compilerOptions, { onlyPrintJsDocStyle: true, noEmitHelpers: true }), { + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: true, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + onlyPrintJsDocStyle: true, + }; + var declarationPrinter = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, - // sourcemap hooks - onEmitSourceMapOfNode: declarationSourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: declarationSourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: declarationSourceMap.emitPos, - onSetSourceFile: setSourceFileForDeclarationSourceMaps, // transform hooks onEmitNode: declarationTransform.emitNodeWithNotification, substituteNode: declarationTransform.substituteNode, @@ -81054,8 +81375,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, declarationSourceMap); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 277 /* SourceFile */) { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + sourceMap: compilerOptions.declarationMap, + sourceRoot: compilerOptions.sourceRoot, + mapRoot: compilerOptions.mapRoot, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }); + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -81064,7 +81390,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -81075,25 +81401,41 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; - mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); + var sourceMapGenerator; + if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { + sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); + } if (bundle) { - printer.writeBundle(bundle, writer, bundleInfo); + printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); } else { - printer.writeFile(sourceFile, writer); + printer.writeFile(sourceFile, writer, sourceMapGenerator); } - writer.writeLine(); - var sourceMappingURL = mapRecorder.getSourceMappingURL(); - if (sourceMappingURL) { - writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + if (sourceMapGenerator) { + if (sourceMapDataList) { + sourceMapDataList.push({ + inputSourceFileNames: sourceMapGenerator.getSources(), + sourceMap: sourceMapGenerator.toJSON() + }); + } + var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile); + if (sourceMappingURL) { + if (!writer.isAtStartOfLine()) + writer.rawWrite(newLine); + writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + } + // Write the source map + if (sourceMapFilePath) { + var sourceMap = sourceMapGenerator.toString(); + ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); + } } - // Write the source map - if (sourceMapFilePath) { - ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); + else { + writer.writeLine(); } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); @@ -81103,32 +81445,84 @@ var ts; ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); } // Reset state - mapRecorder.reset(); writer.clear(); bundleInfo = createDefaultBundleInfo(); } - function setSourceFile(node) { - sourceMap.setSourceFile(node); + function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { + return (mapOptions.sourceMap || mapOptions.inlineSourceMap) + && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } - function setSourceFileForDeclarationSourceMaps(node) { - declarationSourceMap.setSourceFile(node); + function getSourceRoot(mapOptions) { + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); + return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot; + } + function getSourceMapDirectory(mapOptions, filePath, sourceFile) { + if (mapOptions.sourceRoot) + return host.getCommonSourceDirectory(); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + } + return sourceMapDir; + } + return ts.getDirectoryPath(ts.normalizePath(filePath)); + } + function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) { + if (mapOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var sourceMapText = sourceMapGenerator.toString(); + var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); + return "data:application/json;base64," + base64SourceMapText; + } + var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath))); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapFile), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + return ts.combinePaths(sourceMapDir, sourceMapFile); + } + } + return sourceMapFile; } } ts.emitFiles = emitFiles; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; - PipelinePhase[PipelinePhase["Comments"] = 1] = "Comments"; - PipelinePhase[PipelinePhase["SourceMaps"] = 2] = "SourceMaps"; - PipelinePhase[PipelinePhase["Emit"] = 3] = "Emit"; + PipelinePhase[PipelinePhase["Substitution"] = 1] = "Substitution"; + PipelinePhase[PipelinePhase["Comments"] = 2] = "Comments"; + PipelinePhase[PipelinePhase["SourceMaps"] = 3] = "SourceMaps"; + PipelinePhase[PipelinePhase["Emit"] = 4] = "Emit"; })(PipelinePhase || (PipelinePhase = {})); function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); - var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var moduleKind = ts.getEmitModuleKind(printerOptions); + var bundledHelpers = ts.createMap(); var currentSourceFile; var nodeIdToGeneratedName; // Map of generated names for specific nodes. var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. @@ -81138,19 +81532,23 @@ var ts; var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes. var reservedNames; // TempFlags to reserve in nested name generation scopes. var writer; - var ownWriter; + var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; - var commitPendingSemicolon = ts.noop; - var writeSemicolon = writeSemicolonInternal; - var pendingSemicolon = false; - if (printerOptions.omitTrailingSemicolon) { - commitPendingSemicolon = commitPendingSemicolonInternal; - writeSemicolon = deferWriteSemicolon; - } - var syntheticParent = { pos: -1, end: -1 }; - var moduleKind = ts.getEmitModuleKind(printerOptions); - var bundledHelpers = ts.createMap(); var isOwnFileEmit; + // Source Maps + var sourceMapsDisabled = true; + var sourceMapGenerator; + var sourceMapSource; + var sourceMapSourceIndex = -1; + // Comments + var containerPos = -1; + var containerEnd = -1; + var declarationListContainerEnd = -1; + var currentLineMap; + var detachedCommentsInfo; + var hasWrittenComment = false; + var commentsDisabled = !!printerOptions.removeComments; + var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { // public API @@ -81177,9 +81575,9 @@ var ts; break; } switch (node.kind) { - case 277 /* SourceFile */: return printFile(node); - case 278 /* Bundle */: return printBundle(node); - case 279 /* UnparsedSource */: return printUnparsedSource(node); + case 279 /* SourceFile */: return printFile(node); + case 280 /* Bundle */: return printBundle(node); + case 281 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -81189,11 +81587,11 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, beginPrint()); + writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { - writeFile(sourceFile, beginPrint()); + writeFile(sourceFile, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printUnparsedSource(unparsed) { @@ -81202,14 +81600,14 @@ var ts; } function writeNode(hint, node, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(hint, node, sourceFile); reset(); writer = previousWriter; } function writeList(format, nodes, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); if (sourceFile) { setSourceFile(sourceFile); } @@ -81217,18 +81615,18 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, output, bundleInfo) { + function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { isOwnFileEmit = false; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(bundle); emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { var prepend = _b[_a]; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); writeLine(); + print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); } if (bundleInfo) { bundleInfo.originalOffset = writer.getTextPos(); @@ -81242,15 +81640,15 @@ var ts; } function writeUnparsedSource(unparsed, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } - function writeFile(sourceFile, output) { + function writeFile(sourceFile, output, sourceMapGenerator) { isOwnFileEmit = true; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); print(0 /* SourceFile */, sourceFile, sourceFile); @@ -81269,19 +81667,24 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, hint); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; - comments.setSourceFile(sourceFile); - if (onSetSourceFile) { - onSetSourceFile(sourceFile); + currentLineMap = undefined; + detachedCommentsInfo = undefined; + if (sourceFile) { + setSourceMapSource(sourceFile); } } - function setWriter(output) { - writer = output; // TODO: GH#18217 - comments.setWriter(output); + function setWriter(_writer, _sourceMapGenerator) { + if (_writer && printerOptions.omitTrailingSemicolon) { + _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + } + writer = _writer; // TODO: GH#18217 + sourceMapGenerator = _sourceMapGenerator; + sourceMapsDisabled = !writer || !sourceMapGenerator; } function reset() { nodeIdToGeneratedName = []; @@ -81290,68 +81693,66 @@ var ts; tempFlagsStack = []; tempFlags = 0 /* Auto */; reservedNamesStack = []; - comments.reset(); - setWriter(/*output*/ undefined); + currentSourceFile = undefined; + currentLineMap = undefined; + detachedCommentsInfo = undefined; + setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); + } + function getCurrentLineMap() { + return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } function emit(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 4 /* Unspecified */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); } function emitIdentifierName(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 2 /* IdentifierName */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(2 /* IdentifierName */, node); } function emitExpression(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(1 /* Expression */, node); } - function getPipelinePhase(phase, hint) { + function getPipelinePhase(phase, node) { switch (phase) { case 0 /* Notification */: - if (onEmitNode) { + if (onEmitNode !== ts.noEmitNotification) { return pipelineEmitWithNotification; } // falls through - case 1 /* Comments */: - if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + case 1 /* Substitution */: + if (substituteNode !== ts.noEmitSubstitution) { + return pipelineEmitWithSubstitution; + } + // falls through + case 2 /* Comments */: + if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { return pipelineEmitWithComments; } - return pipelineEmitWithoutComments; - case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { + // falls through + case 3 /* SourceMaps */: + if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through - case 3 /* Emit */: + case 4 /* Emit */: return pipelineEmitWithHint; default: - return ts.Debug.assertNever(phase, "Unexpected value for PipelinePhase: " + phase); + return ts.Debug.assertNever(phase); } } - function getNextPipelinePhase(currentPhase, hint) { - return getPipelinePhase(currentPhase + 1, hint); + function getNextPipelinePhase(currentPhase, node) { + return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); - } - function pipelineEmitWithComments(hint, node) { - ts.Debug.assertDefined(emitNodeWithComments); - ts.Debug.assert(hint !== 0 /* SourceFile */); - emitNodeWithComments(hint, trySubstituteNode(hint, node), getNextPipelinePhase(1 /* Comments */, hint)); - } - function pipelineEmitWithoutComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Comments */, hint); - pipelinePhase(hint, trySubstituteNode(hint, node)); - } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */); - ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); + var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); + onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -81360,254 +81761,285 @@ var ts; return emitIdentifier(ts.cast(node, ts.isIdentifier)); if (hint === 3 /* MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + if (hint === 5 /* EmbeddedStatement */) { + ts.Debug.assertNode(node, ts.isEmptyStatement); + return emitEmptyStatement(/*isEmbeddedStatement*/ true); + } if (hint === 4 /* Unspecified */) { if (ts.isKeyword(node.kind)) return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return emitLiteral(node); - case 279 /* UnparsedSource */: + case 281 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return emitQualifiedName(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return emitTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return emitParameter(node); - case 150 /* Decorator */: + case 152 /* Decorator */: return emitDecorator(node); // Type members - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return emitPropertySignature(node); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return emitMethodSignature(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return emitConstructor(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return emitAccessorDeclaration(node); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return emitCallSignature(node); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return emitConstructSignature(node); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return emitIndexSignature(node); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return emitTypePredicate(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return emitTypeReference(node); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return emitFunctionType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return emitConstructorType(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return emitTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return emitTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return emitArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return emitTupleType(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return emitOptionalType(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return emitUnionType(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return emitIntersectionType(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return emitConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return emitInferType(node); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return emitParenthesizedType(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return emitThisType(); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return emitTypeOperator(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return emitMappedType(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return emitLiteralType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return emitImportTypeNode(node); - case 282 /* JSDocAllType */: - write("*"); + case 284 /* JSDocAllType */: + writePunctuation("*"); return; - case 283 /* JSDocUnknownType */: - write("?"); + case 285 /* JSDocUnknownType */: + writePunctuation("?"); return; - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 170 /* RestType */: - case 288 /* JSDocVariadicType */: + case 172 /* RestType */: + case 290 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return emitBindingElement(node); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return emitTemplateSpan(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 216 /* Block */: + case 218 /* Block */: return emitBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return emitVariableStatement(node); - case 218 /* EmptyStatement */: - return emitEmptyStatement(); - case 219 /* ExpressionStatement */: + case 220 /* EmptyStatement */: + return emitEmptyStatement(/*isEmbeddedStatement*/ false); + case 221 /* ExpressionStatement */: return emitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return emitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return emitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return emitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return emitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return emitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return emitForOfStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return emitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return emitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return emitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return emitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return emitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return emitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return emitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return emitTryStatement(node); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return emitClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return emitModuleBlock(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return emitCaseBlock(node); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return emitImportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return emitImportClause(node); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return emitNamespaceImport(node); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return emitNamedImports(node); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return emitImportSpecifier(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return emitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return emitExportDeclaration(node); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return emitNamedExports(node); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return emitExportSpecifier(node); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 10 /* JsxText */: + case 11 /* JsxText */: return emitJsxText(node); - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 261 /* JsxClosingElement */: - case 264 /* JsxClosingFragment */: + case 263 /* JsxClosingElement */: + case 266 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return emitJsxAttribute(node); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return emitJsxAttributes(node); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return emitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return emitDefaultClause(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return emitHeritageClause(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return emitEnumMember(node); - // JSDoc nodes (ignored) + // JSDoc nodes (only used in codefixes currently) + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + return emitJSDocPropertyLikeTag(node); + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 301 /* JSDocThisTag */: + case 298 /* JSDocEnumTag */: + return emitJSDocSimpleTypedTag(node); + case 295 /* JSDocAugmentsTag */: + return emitJSDocAugmentsTag(node); + case 303 /* JSDocTemplateTag */: + return emitJSDocTemplateTag(node); + case 304 /* JSDocTypedefTag */: + return emitJSDocTypedefTag(node); + case 297 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + case 293 /* JSDocSignature */: + return emitJSDocSignature(node); + case 292 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 296 /* JSDocClassTag */: + case 294 /* JSDocTag */: + return emitJSDocSimpleTag(node); + case 291 /* JSDocComment */: + return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; - node = trySubstituteNode(1 /* Expression */, node); + if (substituteNode !== ts.noEmitSubstitution) { + node = substituteNode(hint, node); + } } else if (ts.isToken(node)) { return writeTokenNode(node, writePunctuation); @@ -81617,89 +82049,90 @@ var ts; switch (node.kind) { // Literals case 8 /* NumericLiteral */: - return emitNumericLiteral(node); - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + return emitNumericOrBigIntLiteral(node); + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Reserved words - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 101 /* TrueKeyword */: - case 99 /* ThisKeyword */: - case 91 /* ImportKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 102 /* TrueKeyword */: + case 100 /* ThisKeyword */: + case 92 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return emitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return emitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return emitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return emitArrowFunction(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return emitDeleteExpression(node); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return emitVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return emitAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return emitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return emitConditionalExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return emitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return emitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return emitSpreadExpression(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return emitClassExpression(node); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: return emitAsExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return emitNonNullExpression(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return emitJsxElement(node); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return emitCommaList(node); } } @@ -81711,12 +82144,13 @@ var ts; writeSpace(); emit(node.constraint); } - function trySubstituteNode(hint, node) { - return node && substituteNode && substituteNode(hint, node) || node; + function pipelineEmitWithSubstitution(hint, node) { + var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); + pipelinePhase(hint, substituteNode(hint, node)); } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 278 /* Bundle */ ? node : undefined; + var bundle = node.kind === 280 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -81765,7 +82199,8 @@ var ts; // Literals/Pseudo-literals // // SyntaxKind.NumericLiteral - function emitNumericLiteral(node) { + // SyntaxKind.BigIntLiteral + function emitNumericOrBigIntLiteral(node) { emitLiteral(node); } // SyntaxKind.StringLiteral @@ -81777,7 +82212,7 @@ var ts; function emitLiteral(node) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -81795,7 +82230,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 26896 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -81806,7 +82241,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -81842,7 +82277,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -81864,7 +82299,7 @@ var ts; emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitPropertyDeclaration(node) { emitDecorators(node, node.decorators); @@ -81874,7 +82309,7 @@ var ts; emit(node.exclamationToken); emitTypeAnnotation(node.type); emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node); - writeSemicolon(); + writeTrailingSemicolon(); } function emitMethodSignature(node) { pushNameGenerationScope(node); @@ -81885,7 +82320,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitMethodDeclaration(node) { @@ -81904,7 +82339,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 158 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -81916,7 +82351,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitConstructSignature(node) { @@ -81928,7 +82363,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitIndexSignature(node) { @@ -81936,10 +82371,10 @@ var ts; emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitSemicolonClassElement() { - writeSemicolon(); + writeTrailingSemicolon(); } // // Types @@ -81966,22 +82401,22 @@ var ts; popNameGenerationScope(node); } function emitJSDocFunctionType(node) { - write("function"); + writeKeyword("function"); emitParameters(node, node.parameters); - write(":"); + writePunctuation(":"); emit(node.type); } function emitJSDocNullableType(node) { - write("?"); + writePunctuation("?"); emit(node.type); } function emitJSDocNonNullableType(node) { - write("!"); + writePunctuation("!"); emit(node.type); } function emitJSDocOptionalType(node) { emit(node.type); - write("="); + writePunctuation("="); } function emitConstructorType(node) { pushNameGenerationScope(node); @@ -82002,8 +82437,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineTypeLiteralMembers */ : 16449 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 262144 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -82012,23 +82447,23 @@ var ts; writePunctuation("]"); } function emitRestOrJSDocVariadicType(node) { - write("..."); + writePunctuation("..."); emit(node.type); } function emitTupleType(node) { writePunctuation("["); - emitList(node, node.elementTypes, 272 /* TupleTypeElements */); + emitList(node, node.elementTypes, 528 /* TupleTypeElements */); writePunctuation("]"); } function emitOptionalType(node) { emit(node.type); - write("?"); + writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 260 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */); } function emitIntersectionType(node) { - emitList(node, node.types, 264 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */); } function emitConditionalType(node) { emit(node.checkType); @@ -82081,25 +82516,25 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 3 /* MappedTypeParameter */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 55 /* QuestionToken */) { + if (node.questionToken.kind !== 56 /* QuestionToken */) { writePunctuation("?"); } } writePunctuation(":"); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); if (emitFlags & 1 /* SingleLine */) { writeSpace(); } @@ -82132,12 +82567,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 262448 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -82155,8 +82590,8 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -82164,9 +82599,9 @@ var ts; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + 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); if (indentedFlag) { decreaseIndent(); } @@ -82177,20 +82612,20 @@ var ts; if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = ts.createToken(23 /* DotToken */); + var dotToken = ts.createToken(24 /* DotToken */); dotToken.pos = dotRangeStart; dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } emitExpression(node.expression); - increaseIndentIf(indentBeforeDot); + increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(23 /* DotToken */, node.expression.end, writePunctuation, node); - increaseIndentIf(indentAfterDot); + emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } @@ -82202,7 +82637,7 @@ var ts; // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); return !expression.numericLiteralFlags - && !ts.stringContains(text, ts.tokenToString(23 /* DotToken */)); + && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -82215,21 +82650,21 @@ var ts; } function emitElementAccessExpression(node) { emitExpression(node.expression); - emitTokenWithComment(21 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(22 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(94 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(95 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { emitExpression(node.tag); @@ -82244,9 +82679,9 @@ var ts; emitExpression(node.expression); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(19 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -82265,22 +82700,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(80 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(103 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(105 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(121 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(122 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -82305,24 +82740,24 @@ 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 === 200 /* PrefixUnaryExpression */ - && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) - || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); + return operand.kind === 202 /* PrefixUnaryExpression */ + && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) + || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator, writeOperator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 26 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); - increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 93 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - increaseIndentIf(indentAfterOperator, " "); + increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); } @@ -82332,23 +82767,23 @@ var ts; var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken); var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); - increaseIndentIf(indentBeforeQuestion, " "); + increaseIndentIf(indentBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); - increaseIndentIf(indentAfterQuestion, " "); + increaseIndentIf(indentAfterQuestion, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); - increaseIndentIf(indentBeforeColon, " "); + increaseIndentIf(indentBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); - increaseIndentIf(indentAfterColon, " "); + increaseIndentIf(indentAfterColon, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 131072 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(116 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(117 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -82396,38 +82831,45 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineBlockStatements */ : 65 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(18 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); emit(node.declarationList); - writeSemicolon(); + writeTrailingSemicolon(); } - function emitEmptyStatement() { - writeSemicolon(); + function emitEmptyStatement(isEmbeddedStatement) { + // While most trailing semicolons are possibly insignificant, an embedded "empty" + // statement is significant and cannot be elided by a trailing-semicolon-omitting writer. + if (isEmbeddedStatement) { + writePunctuation(";"); + } + else { + writeTrailingSemicolon(); + } } function emitExpressionStatement(node) { emitExpression(node.expression); // 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)) { - writeSemicolon(); + writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(91 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 220 /* IfStatement */) { + emitTokenWithComment(83 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 222 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -82437,14 +82879,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(106 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(81 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -82460,45 +82902,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.condition ? node.condition.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(20 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(92 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(93 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(147 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 236 /* VariableDeclarationList */) { + if (node.kind === 238 /* VariableDeclarationList */) { emit(node); } else { @@ -82507,14 +82949,14 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(77 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(78 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(72 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(73 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) { var node = ts.getParseTreeNode(contextNode); @@ -82540,40 +82982,40 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(96 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(97 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(107 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(108 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(98 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(56 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(100 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(101 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(102 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -82582,14 +83024,14 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(87 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(88 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(78 /* DebuggerKeyword */, node.pos, writeKeyword); - writeSemicolon(); + writeToken(79 /* DebuggerKeyword */, node.pos, writeKeyword); + writeTrailingSemicolon(); } // // Declarations @@ -82602,7 +83044,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 272 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -82650,7 +83092,7 @@ var ts; } else { emitSignatureHead(node); - writeSemicolon(); + writeTrailingSemicolon(); } } function emitSignatureHead(node) { @@ -82702,7 +83144,7 @@ var ts; emitBlockFunctionBody(body); } decreaseIndent(); - writeToken(18 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -82714,7 +83156,7 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); increaseIndent(); } else { @@ -82741,7 +83183,7 @@ var ts; emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* ClassMembers */); + emitList(node, node.members, 129 /* ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -82754,10 +83196,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 256 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* InterfaceMembers */); + emitList(node, node.members, 129 /* InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -82771,7 +83213,7 @@ var ts; writePunctuation("="); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitEnumDeclaration(node) { emitModifiers(node, node.modifiers); @@ -82780,7 +83222,7 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 81 /* EnumMembers */); + emitList(node, node.members, 145 /* EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { @@ -82792,8 +83234,8 @@ var ts; emit(node.name); var body = node.body; if (!body) - return writeSemicolon(); - while (body.kind === 242 /* ModuleDeclaration */) { + return writeTrailingSemicolon(); + while (body.kind === 244 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -82808,23 +83250,23 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 65 /* CaseBlockClauses */); - emitTokenWithComment(18 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* CaseBlockClauses */); + emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(59 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); - writeSemicolon(); + writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -82833,29 +83275,29 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); - writeSemicolon(); + writeTrailingSemicolon(); } function emitImportClause(node) { emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(26 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(39 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -82866,45 +83308,45 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(58 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(59 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(79 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(80 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(39 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(118 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(119 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(130 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(131 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamedExports(node) { emitNamedImportsOrExports(node); @@ -82914,14 +83356,14 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -82940,7 +83382,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -82952,7 +83394,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -82967,7 +83409,6 @@ var ts; writePunctuation(">"); } function emitJsxText(node) { - commitPendingSemicolon(); writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); } function emitJsxClosingElementOrFragment(node) { @@ -82978,7 +83419,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 131328 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -82998,7 +83439,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -83009,13 +83450,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(73 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(74 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(79 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(80 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -83025,14 +83466,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 81985 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 64 /* Indented */); + format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -83040,15 +83481,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 272 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(74 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(75 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(20 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -83097,6 +83538,142 @@ var ts; emitInitializer(node.initializer, node.name.end, node); } // + // JSDoc + // + function emitJSDoc(node) { + write("/**"); + if (node.comment) { + var lines = node.comment.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } + } + if (node.tags) { + if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + writeSpace(); + emit(node.tags[0]); + } + else { + emitList(node, node.tags, 33 /* JSDocComment */); + } + } + writeSpace(); + write("*/"); + } + function emitJSDocSimpleTypedTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.typeExpression); + emitJSDocComment(tag.comment); + } + function emitJSDocAugmentsTag(tag) { + emitJSDocTagName(tag.tagName); + writeSpace(); + writePunctuation("{"); + emit(tag.class); + writePunctuation("}"); + emitJSDocComment(tag.comment); + } + function emitJSDocTemplateTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.constraint); + writeSpace(); + emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitJSDocComment(tag.comment); + } + function emitJSDocTypedefTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.typeExpression) { + if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + emitJSDocTypeExpression(tag.typeExpression); + } + else { + writeSpace(); + writePunctuation("{"); + write("Object"); + if (tag.typeExpression.isArrayType) { + writePunctuation("["); + writePunctuation("]"); + } + writePunctuation("}"); + } + } + if (tag.fullName) { + writeSpace(); + emit(tag.fullName); + } + emitJSDocComment(tag.comment); + if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + emitJSDocTypeLiteral(tag.typeExpression); + } + } + function emitJSDocCallbackTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.name) { + writeSpace(); + emit(tag.name); + } + emitJSDocComment(tag.comment); + emitJSDocSignature(tag.typeExpression); + } + function emitJSDocSimpleTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocComment(tag.comment); + } + function emitJSDocTypeLiteral(lit) { + emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + } + function emitJSDocSignature(sig) { + if (sig.typeParameters) { + emitList(sig, ts.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + } + if (sig.parameters) { + emitList(sig, ts.createNodeArray(sig.parameters), 33 /* JSDocComment */); + } + if (sig.type) { + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + emit(sig.type); + } + } + function emitJSDocPropertyLikeTag(param) { + emitJSDocTagName(param.tagName); + emitJSDocTypeExpression(param.typeExpression); + writeSpace(); + if (param.isBracketed) { + writePunctuation("["); + } + emit(param.name); + if (param.isBracketed) { + writePunctuation("]"); + } + emitJSDocComment(param.comment); + } + function emitJSDocTagName(tagName) { + writePunctuation("@"); + emit(tagName); + } + function emitJSDocComment(comment) { + if (comment) { + writeSpace(); + write(comment); + } + } + function emitJSDocTypeExpression(typeExpression) { + if (typeExpression) { + writeSpace(); + writePunctuation("{"); + emit(typeExpression.type); + writePunctuation("}"); + } + } + // // Top-level nodes // function emitSourceFile(node) { @@ -83124,38 +83701,38 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - write("/// "); + writeComment("/// "); } else { - write("/// "); + writeComment("/// "); } writeLine(); } } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; - write("/// "); + writeComment("/// "); writeLine(); } - for (var _d = 0, types_16 = types; _d < types_16.length; _d++) { - var directive = types_16[_d]; - write("/// "); + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; + writeComment("/// "); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; - write("/// "); + writeComment("/// "); writeLine(); } } @@ -83174,7 +83751,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 272 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -83214,13 +83791,14 @@ var ts; setSourceFile(sourceFile); emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); } + setSourceFile(undefined); } } function emitShebangIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { - write(shebang); + writeComment(shebang); writeLine(); return true; } @@ -83248,7 +83826,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 131328 /* Modifiers */); + emitList(node, modifiers, 262656 /* Modifiers */); writeSpace(); } } @@ -83262,7 +83840,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(59 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -83299,24 +83877,30 @@ var ts; else { writeLine(); increaseIndent(); - emit(node); + if (ts.isEmptyStatement(node)) { + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); + pipelinePhase(5 /* EmbeddedStatement */, node); + } + else { + emit(node); + } decreaseIndent(); } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 24577 /* Decorators */); + emitList(parentNode, decorators, 49153 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 26896 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */); } 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, 26896 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 1296 /* Parameters */); + emitList(parentNode, parameters, 2576 /* Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -83337,14 +83921,14 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 1296 /* Parameters */ & ~1024 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 4432 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } function emitList(parentNode, children, format, start, count) { emitNodeList(emit, parentNode, children, format, start, count); @@ -83353,7 +83937,7 @@ var ts; emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { - switch (format & 28 /* DelimitersMask */) { + switch (format & 60 /* DelimitersMask */) { case 0 /* None */: break; case 16 /* CommaDelimited */: @@ -83363,6 +83947,11 @@ var ts; writeSpace(); writePunctuation("|"); break; + case 32 /* AsteriskDelimited */: + writeSpace(); + writePunctuation("*"); + writeSpace(); + break; case 8 /* AmpersandDelimited */: writeSpace(); writePunctuation("&"); @@ -83373,11 +83962,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 & 8192 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 16384 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -83386,7 +83975,7 @@ var ts; } return; } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { // TODO: GH#18217 @@ -83401,23 +83990,23 @@ var ts; if (format & 1 /* MultiLine */) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */ && !(format & 262144 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { writeSpace(); } } else { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { increaseIndent(); } // Emit each child. @@ -83426,14 +84015,19 @@ 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 (previousSibling) { + if (format & 32 /* AsteriskDelimited */) { + // always write JSDoc in the format "\n *" + writeLine(); + writeDelimiter(format); + } + else if (previousSibling) { // i.e // function commentedParameters( // /* Parameter a */ // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -83441,14 +84035,14 @@ var ts; if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 64 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 256 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { writeSpace(); } } @@ -83470,7 +84064,7 @@ var ts; previousSibling = child; } // Write a trailing comma, if requested. - var hasTrailingComma = (format & 32 /* AllowTrailingComma */) && children.hasTrailingComma; + var hasTrailingComma = (format & 64 /* AllowTrailingComma */) && children.hasTrailingComma; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { writePunctuation(","); } @@ -83480,25 +84074,25 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { + if (previousSibling && format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { emitLeadingCommentsOfPosition(previousSibling.end); } // Decrease the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { decreaseIndent(); } // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { if (isEmpty && !isUndefined) { // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists @@ -83506,73 +84100,55 @@ var ts; writePunctuation(getClosingBracket(format)); } } - function commitPendingSemicolonInternal() { - if (pendingSemicolon) { - writeSemicolonInternal(); - pendingSemicolon = false; - } - } + // Writers function writeLiteral(s) { - commitPendingSemicolon(); writer.writeLiteral(s); } function writeStringLiteral(s) { - commitPendingSemicolon(); writer.writeStringLiteral(s); } function writeBase(s) { - commitPendingSemicolon(); writer.write(s); } function writeSymbol(s, sym) { - commitPendingSemicolon(); writer.writeSymbol(s, sym); } function writePunctuation(s) { - commitPendingSemicolon(); writer.writePunctuation(s); } - function deferWriteSemicolon() { - pendingSemicolon = true; - } - function writeSemicolonInternal() { - writer.writePunctuation(";"); + function writeTrailingSemicolon() { + writer.writeTrailingSemicolon(";"); } function writeKeyword(s) { - commitPendingSemicolon(); writer.writeKeyword(s); } function writeOperator(s) { - commitPendingSemicolon(); writer.writeOperator(s); } function writeParameter(s) { - commitPendingSemicolon(); writer.writeParameter(s); } + function writeComment(s) { + writer.writeComment(s); + } function writeSpace() { - commitPendingSemicolon(); writer.writeSpace(" "); } function writeProperty(s) { - commitPendingSemicolon(); writer.writeProperty(s); } function writeLine() { - commitPendingSemicolon(); writer.writeLine(); } function increaseIndent() { - commitPendingSemicolon(); writer.increaseIndent(); } function decreaseIndent() { - commitPendingSemicolon(); writer.decreaseIndent(); } function writeToken(token, pos, writer, contextNode) { - return onEmitSourceMapOfToken - ? onEmitSourceMapOfToken(contextNode, token, writer, pos, writeTokenText) + return !sourceMapsDisabled + ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText) : writeTokenText(token, writer, pos); } function writeTokenNode(node, writer) { @@ -83600,23 +84176,23 @@ var ts; function writeLines(text) { var lines = text.split(/\r\n?|\n/g); var indentation = ts.guessIndentation(lines); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var lineText = lines_2[_a]; + for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) { + var lineText = lines_3[_a]; var line = indentation ? lineText.slice(indentation) : lineText; if (line.length) { writeLine(); write(line); - writeLine(); + writer.rawWrite(newLine); } } } - function increaseIndentIf(value, valueToWriteWhenNotIndenting) { + function increaseIndentIf(value, writeSpaceIfNotIndenting) { if (value) { increaseIndent(); writeLine(); } - else if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); + else if (writeSpaceIfNotIndenting) { + writeSpace(); } } // Helper function to decrease the indent if we previously indented. Allows multiple @@ -83636,7 +84212,7 @@ var ts; return true; } if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var firstChild = children[0]; @@ -83675,10 +84251,10 @@ var ts; } function shouldWriteClosingLineTerminator(parentNode, children, format) { if (format & 1 /* MultiLine */) { - return (format & 65536 /* NoTrailingNewLine */) === 0; + return (format & 131072 /* NoTrailingNewLine */) === 0; } else if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var lastChild = ts.lastOrUndefined(children); @@ -83700,11 +84276,11 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { parent = skipSynthesizedParentheses(parent); @@ -83724,7 +84300,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -83736,7 +84312,7 @@ var ts; else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { return ts.idText(node); } - else if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { @@ -83745,7 +84321,7 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape) { - if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode)) { return neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? @@ -83789,81 +84365,81 @@ var ts; if (!node) return; switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: ts.forEach(node.statements, generateNames); break; - case 231 /* LabeledStatement */: - case 229 /* WithStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 233 /* LabeledStatement */: + case 231 /* WithStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: generateNames(node.statement); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: generateNames(node.declarationList); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: generateNames(node.importClause); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -83872,12 +84448,12 @@ var ts; if (!node) return; switch (node.kind) { - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -84057,23 +84633,23 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 254 /* ExportAssignment */: return generateNameForExportDefault(); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return generateNameForClassExpression(); - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -84114,21 +84690,396 @@ var ts; // otherwise, return the original node for the source; return node; } + // Comments + function pipelineEmitWithComments(hint, node) { + enterComment(); + hasWrittenComment = false; + var emitFlags = ts.getEmitFlags(node); + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + // 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 */; + // Save current container state on the stack. + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + 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); + } + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* 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)) { + // 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 === 238 /* VariableDeclarationList */) { + declarationListContainerEnd = end; + } + } + } + ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); + exitComment(); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, node); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + pipelinePhase(hint, node); + commentsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + enterComment(); + ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); + if ((pos > 0 || end > 0) && pos !== end) { + // Restore previous container state. + containerPos = savedContainerPos; + containerEnd = savedContainerEnd; + 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 && isEmittedNode) { + emitTrailingComments(end); + } + } + exitComment(); + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 /* MultiLineCommentTrivia */ + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { + 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; + if (!skipLeadingComments) { + emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); + } + exitComment(); + if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + commentsDisabled = true; + emitCallback(node); + commentsDisabled = false; + } + else { + emitCallback(node); + } + enterComment(); + if (!skipTrailingComments) { + emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); + if (hasWrittenComment && !writer.isAtStartOfLine()) { + writer.writeLine(); + } + } + exitComment(); + } + function emitLeadingComments(pos, isEmittedNode) { + hasWrittenComment = false; + if (isEmittedNode) { + forEachLeadingCommentToEmit(pos, emitLeadingComment); + } + else if (pos === 0) { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted + forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); + } + } + function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (isTripleSlashComment(commentPos, commentEnd)) { + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + } + } + function shouldWriteComment(text, pos) { + if (printerOptions.onlyPrintJsDocStyle) { + return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); + } + return true; + } + function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + if (!hasWrittenComment) { + ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); + hasWrittenComment = true; + } + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + else if (kind === 3 /* MultiLineCommentTrivia */) { + writer.writeSpace(" "); + } + } + function emitLeadingCommentsOfPosition(pos) { + if (commentsDisabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } + function emitTrailingComments(pos) { + forEachTrailingCommentToEmit(pos, emitTrailingComment); + } + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + } + function emitTrailingCommentsOfPosition(pos, prefixSpace) { + if (commentsDisabled) { + return; + } + enterComment(); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); + exitComment(); + } + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + // 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 (hasTrailingNewLine) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function forEachLeadingCommentToEmit(pos, cb) { + // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) { + if (hasDetachedComments(pos)) { + forEachLeadingCommentWithoutDetachedComments(cb); + } + else { + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + } + } + function forEachTrailingCommentToEmit(end, cb) { + // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) { + ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; + } + function forEachLeadingCommentWithoutDetachedComments(cb) { + // get the leading comments from detachedPos + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + function emitDetachedCommentsAndUpdateCommentsInfo(range) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + emitPos(commentPos); + ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + */ + function isTripleSlashComment(commentPos, commentEnd) { + return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + } + // Source Maps + function pipelineEmitWithSourceMap(hint, node) { + var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); + if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { + var parsed = ts.tryParseRawSourceMap(node.sourceMapText); + if (parsed) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + } + pipelinePhase(hint, node); + } + else { + var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; + var emitFlags = ts.getEmitFlags(node); + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + && pos >= 0) { + emitSourcePos(source, skipSourceTrivia(source, pos)); + } + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = true; + pipelinePhase(hint, node); + sourceMapsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + && end >= 0) { + emitSourcePos(source, end); + } + } + } + /** + * Skips trivia such as comments and white-space that can optionally overriden by the source map source + */ + function skipSourceTrivia(source, pos) { + return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(sourceMapSource.text, pos); + } + /** + * Emits a mapping. + * + * If the position is synthetic (undefined or a negative value), no mapping will be + * created. + * + * @param pos The position. + */ + function emitPos(pos) { + if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) { + return; + } + var _a = ts.getLineAndCharacterOfPosition(currentSourceFile, pos), sourceLine = _a.line, sourceCharacter = _a.character; + sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, + /*nameIndex*/ undefined); + } + function emitSourcePos(source, pos) { + if (source !== sourceMapSource) { + var savedSourceMapSource = sourceMapSource; + setSourceMapSource(source); + emitPos(pos); + setSourceMapSource(savedSourceMapSource); + } + else { + emitPos(pos); + } + } + /** + * Emits a token of a node with possible leading and trailing source maps. + * + * @param node The node containing the token. + * @param token The token to emit. + * @param tokenStartPos The start pos of the token. + * @param emitCallback The callback used to emit the token. + */ + function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { + if (sourceMapsDisabled || node && ts.isInJsonFile(node)) { + return emitCallback(token, writer, tokenPos); + } + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags || 0 /* 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) { + emitSourcePos(source, tokenPos); + } + tokenPos = emitCallback(token, writer, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + emitSourcePos(source, tokenPos); + } + return tokenPos; + } + function setSourceMapSource(source) { + if (sourceMapsDisabled) { + return; + } + sourceMapSource = source; + if (isJsonSourceMapSource(source)) { + return; + } + sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName); + if (printerOptions.inlineSources) { + sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text); + } + } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* Braces */] = ["{", "}"]; + brackets[2048 /* Parenthesis */] = ["(", ")"]; + brackets[4096 /* AngleBrackets */] = ["<", ">"]; + brackets[8192 /* SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; + return brackets[format & 15360 /* BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; + return brackets[format & 15360 /* BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -84823,7 +85774,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function loadWithLocalCache(names, containingFile, loader) { + function loadWithLocalCache(names, containingFile, redirectedReference, loader) { if (names.length === 0) { return []; } @@ -84836,7 +85787,7 @@ var ts; result = cache.get(name); } else { - cache.set(name, result = loader(name, containingFile)); + cache.set(name, result = loader(name, containingFile, redirectedReference)); } resolutions.push(result); } @@ -84855,6 +85806,7 @@ var ts; if (program.getRootFileNames().length !== rootFileNames.length) { return false; } + var seenResolvedRefs; // If project references dont match if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { return false; @@ -84880,7 +85832,7 @@ var ts; return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || - hasInvalidatedResolution(sourceFile.resolvedPath); + hasInvalidatedResolution(sourceFile.path); } function sourceFileVersionUptoDate(sourceFile) { return sourceFile.version === getSourceVersion(sourceFile.resolvedPath); @@ -84889,10 +85841,24 @@ var ts; if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { return false; } - var oldResolvedRef = program.getResolvedProjectReferences()[index]; + return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + } + function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { + if (ts.contains(seenResolvedRefs, oldResolvedRef)) { + // Assume true + return true; + } // If sourceFile for the oldResolvedRef existed, check the version for uptodate - return sourceFileVersionUptoDate(oldResolvedRef.sourceFile); + if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + return false; + } + // Add to seen before checking the referenced paths of this config file + (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); + // If child project references are upto date, this project reference is uptodate + return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) { + return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]); + }); } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. @@ -84939,7 +85905,7 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; - var modifiedFilePaths; + var ambientModuleNameToUnmodifiedFileName = ts.createMap(); var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -84971,12 +85937,11 @@ var ts; // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createMap(); var _compilerOptionsObjectLiteralSyntax; - var _referencesArrayLiteralSyntax; var moduleResolutionCache; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -84988,16 +85953,16 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 - resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; + var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 + resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, 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). @@ -85013,7 +85978,7 @@ var ts; // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; // A parallel array to projectReferences storing the results of reading in the referenced tsconfig files - var resolvedProjectReferences = projectReferences ? [] : undefined; + var resolvedProjectReferences; var projectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -85021,23 +85986,25 @@ var ts; processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { - for (var _i = 0, projectReferences_1 = projectReferences; _i < projectReferences_1.length; _i++) { - var ref = projectReferences_1[_i]; - var parsedRef = parseProjectReferenceConfigFile(ref); - resolvedProjectReferences.push(parsedRef); - if (parsedRef) { - var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - var dtsOutfile = ts.changeExtension(out, ".d.ts"); - processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (!resolvedProjectReferences) { + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + } + if (rootNames.length) { + for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { + var parsedRef = resolvedProjectReferences_1[_i]; + if (parsedRef) { + var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; + if (out) { + var dtsOutfile = ts.changeExtension(out, ".d.ts"); + processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } - addProjectReferenceRedirects(parsedRef.commandLine); } } } ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false); }); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); @@ -85051,7 +86018,7 @@ var ts; // - The '--noLib' flag is used. // - A 'no-default-lib' reference comment is encountered in // processing the root files. - if (!skipDefaultLib) { + if (rootNames.length && !skipDefaultLib) { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file var defaultLibraryFileName = getDefaultLibraryFileName(); @@ -85076,10 +86043,18 @@ var ts; var oldSourceFiles = oldProgram.getSourceFiles(); for (var _a = 0, oldSourceFiles_1 = oldSourceFiles; _a < oldSourceFiles_1.length; _a++) { var oldSourceFile = oldSourceFiles_1[_a]; - if (!getSourceFile(oldSourceFile.path) || shouldCreateNewSourceFile) { - host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions()); + var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); + if (shouldCreateNewSourceFile || !newFile || + // old file wasnt redirect but new file is + (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { + host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; @@ -85120,7 +86095,10 @@ var ts; getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, getProjectReferences: getProjectReferences, getResolvedProjectReferences: getResolvedProjectReferences, - getProjectReferenceRedirect: getProjectReferenceRedirect + getProjectReferenceRedirect: getProjectReferenceRedirect, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, + forEachResolvedProjectReference: forEachResolvedProjectReference }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -85183,13 +86161,13 @@ var ts; } return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) { if (structuralIsReused === 0 /* 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, containingFile); + return resolveModuleNamesWorker(moduleNames, containingFile, /*reusedNames*/ undefined, getResolvedProjectReferenceToRedirect(file.originalFileName)); } - var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile); + var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); if (oldSourceFile !== file && file.resolvedModules) { // `file` was created for the new program. // @@ -85252,7 +86230,7 @@ var ts; } } else { - resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName); } if (resolvesToAmbientModuleInNonModifiedFile) { (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; @@ -85263,7 +86241,7 @@ var ts; } } var resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames) + ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName)) : ts.emptyArray; // Combine results of resolutions and predicted results if (!result) { @@ -85289,12 +86267,9 @@ var ts; return result; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. - function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - if (!oldProgramState.program) { - return false; - } - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 - var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) { + var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName); + var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same // place as we expected to find an actual module file. @@ -85303,16 +86278,34 @@ var ts; return false; } // at least one of declarations should come from non-modified source file - var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); }); - if (!firstUnmodifiedFile) { + var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName); + if (!unmodifiedFile) { return false; } if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile); } return true; } } + function canReuseProjectReferences() { + return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) { + var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var newResolvedRef = parseProjectReferenceConfigFile(newRef); + if (oldResolvedRef) { + // Resolved project reference has gone missing or changed + return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + } + else { + // A previously-unresolved reference may be resolved now + return newResolvedRef !== undefined; + } + }, function (oldProjectReferences, parent) { + // If array of references is changed, we cant resue old program + var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences; + return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo); + }); + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return 0 /* Not */; @@ -85333,40 +86326,14 @@ var ts; return oldProgram.structureIsReused = 0 /* Not */; } // Check if any referenced project tsconfig files are different - // If array of references is changed, we cant resue old program - var oldProjectReferences = oldProgram.getProjectReferences(); - if (!ts.arrayIsEqualTo(oldProjectReferences, projectReferences, ts.projectReferenceIsEqualTo)) { + if (!canReuseProjectReferences()) { return oldProgram.structureIsReused = 0 /* Not */; } - // Check the json files for the project references - var oldRefs = oldProgram.getResolvedProjectReferences(); if (projectReferences) { - // Resolved project referenced should be array if projectReferences provided are array - ts.Debug.assert(!!oldRefs); - for (var i = 0; i < projectReferences.length; i++) { - var oldRef = oldRefs[i]; - var newRef = parseProjectReferenceConfigFile(projectReferences[i]); - if (oldRef) { - if (!newRef || newRef.sourceFile !== oldRef.sourceFile) { - // Resolved project reference has gone missing or changed - return oldProgram.structureIsReused = 0 /* Not */; - } - } - else { - // A previously-unresolved reference may be resolved now - if (newRef !== undefined) { - return oldProgram.structureIsReused = 0 /* Not */; - } - } - } - } - else { - // Resolved project referenced should be undefined if projectReferences is undefined - ts.Debug.assert(!oldRefs); + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2 /* Completely */; // If the missing file paths are now present, it can change the progam structure, @@ -85417,7 +86384,6 @@ var ts; newSourceFile.originalFileName = oldSourceFile.originalFileName; newSourceFile.resolvedPath = oldSourceFile.resolvedPath; newSourceFile.fileName = oldSourceFile.fileName; - filePaths.push(newSourceFile.path); 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, @@ -85478,15 +86444,23 @@ var ts; if (oldProgram.structureIsReused !== 2 /* Completely */) { return oldProgram.structureIsReused; } - modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); + for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) { + var oldFile = oldSourceFiles_3[_a]; + if (!ts.contains(modifiedFiles, oldFile)) { + for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) { + var moduleName = _c[_b]; + ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); + } + } + } // try to verify results of module resolution - for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { - var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; + for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { + var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = getModuleNames(newSourceFile); - var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { @@ -85500,7 +86474,7 @@ var ts; if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); if (resolutionsChanged) { @@ -85520,28 +86494,22 @@ var ts; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping - for (var i = 0; i < newSourceFiles.length; i++) { - filesByName.set(filePaths[i], newSourceFiles[i]); + for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { + var newSourceFile = newSourceFiles_1[_f]; + var filePath = newSourceFile.path; + addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); // Set the file as found during node modules search if it was found that way in old progra, - if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) { - sourceFilesFoundSearchingNodeModules.set(filePaths[i], true); + if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePath))) { + sourceFilesFoundSearchingNodeModules.set(filePath, true); } } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) { - var modifiedFile = modifiedSourceFiles_2[_c]; + for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) { + var modifiedFile = modifiedSourceFiles_2[_g]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - resolvedProjectReferences = oldProgram.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - resolvedProjectReferences.forEach(function (ref) { - if (ref) { - addProjectReferenceRedirects(ref.commandLine); - } - }); - } sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; return oldProgram.structureIsReused = 2 /* Completely */; @@ -85804,22 +86772,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 149 /* Parameter */: - case 152 /* PropertyDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 235 /* VariableDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 237 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -85827,41 +86795,41 @@ var ts; } } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 108 /* ImplementsKeyword */) { + if (heritageClause.token === 109 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -85874,51 +86842,51 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 240 /* ClassDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 219 /* VariableStatement */); } break; - case 152 /* PropertyDeclaration */: + case 154 /* 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 !== 115 /* StaticKeyword */) { + if (modifier.kind !== 116 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -85935,24 +86903,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 124 /* DeclareKeyword */: - case 117 /* AbstractKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 125 /* DeclareKeyword */: + case 118 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 115 /* StaticKeyword */: - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 116 /* StaticKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: } } } @@ -86000,10 +86968,22 @@ var ts; return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } function getOptionsDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), options.configFile ? programDiagnostics.getDiagnostics(options.configFile.fileName) : []))); + return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile()))); + } + function getOptionsDiagnosticsOfConfigFile() { + if (!options.configFile) { + return ts.emptyArray; + } + var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); + } + }); + return diagnostics; } function getGlobalDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); + return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray; } function getConfigFileParsingDiagnostics() { return configFileParsingDiagnostics || ts.emptyArray; @@ -86015,9 +86995,9 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 71 /* Identifier */ - ? b.kind === 71 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 9 /* StringLiteral */ && a.text === b.text; + return a.kind === 72 /* Identifier */ + ? b.kind === 72 /* Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -86045,12 +87025,9 @@ var ts; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(node); - } } if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(file.endOfFileToken); + collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; file.moduleAugmentations = moduleAugmentations || ts.emptyArray; @@ -86098,24 +87075,37 @@ var ts; } } } - function collectDynamicImportOrRequireCalls(node) { - if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { - imports = ts.append(imports, node.arguments[0]); - } - // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. - else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { - imports = ts.append(imports, node.arguments[0]); - } - else if (ts.isLiteralImportTypeNode(node)) { - imports = ts.append(imports, node.argument.literal); - } - collectDynamicImportOrRequireCallsForEachChild(node); - if (ts.hasJSDocNodes(node)) { - ts.forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild); + function collectDynamicImportOrRequireCalls(file) { + var r = /import|require/g; + while (r.exec(file.text) !== null) { + var node = getNodeAtPosition(file, r.lastIndex); + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { + imports = ts.append(imports, node.arguments[0]); + } + // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. + else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { + imports = ts.append(imports, node.arguments[0]); + } + else if (ts.isLiteralImportTypeNode(node)) { + imports = ts.append(imports, node.argument.literal); + } } } - function collectDynamicImportOrRequireCallsForEachChild(node) { - ts.forEachChild(node, collectDynamicImportOrRequireCalls); + /** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */ + 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 */)))) { + return child; + } + }; + while (true) { + var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild); + if (!child) { + return current; + } + current = child; + } } } function getLibFileFromReference(ref) { @@ -86277,7 +87267,7 @@ var ts; // Instead of creating a duplicate, just redirect to the existing one. var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 redirectTargetsMap.add(fileFromPackageId.path, fileName); - filesByName.set(path, dupFile); + addFileToFilesByName(dupFile, path, redirectedPath); sourceFileToPackageName.set(path, packageId.name); processingOtherFiles.push(dupFile); return dupFile; @@ -86288,10 +87278,7 @@ var ts; sourceFileToPackageName.set(path, packageId.name); } } - filesByName.set(path, file); - if (redirectedPath) { - filesByName.set(redirectedPath, file); - } + addFileToFilesByName(file, path, redirectedPath); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; @@ -86325,24 +87312,82 @@ var ts; } return file; } + function addFileToFilesByName(file, path, redirectedPath) { + filesByName.set(path, file); + if (redirectedPath) { + filesByName.set(redirectedPath, file); + } + } function getProjectReferenceRedirect(fileName) { // Ignore dts or any of the non ts files - if (!projectReferenceRedirects || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to // look in the output folder of the referenced project rather than the input - return ts.forEach(projectReferenceRedirects, function (referencedProject) { + var referencedProject = getResolvedProjectReferenceToRedirect(fileName); + if (!referencedProject) { + return undefined; + } + var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out; + return out ? + ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine); + } + /** + * Get the referenced project if the file is input file from that reference project + */ + function getResolvedProjectReferenceToRedirect(fileName) { + return forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) { // not input file from the referenced project, ignore - if (!ts.contains(referencedProject.fileNames, fileName, isSameFile)) { + if (!referencedProject || + toPath(options.configFilePath) === referenceProjectPath || + !ts.contains(referencedProject.commandLine.fileNames, fileName, isSameFile)) { return undefined; } - var out = referencedProject.options.outFile || referencedProject.options.out; - return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : - ts.getOutputDeclarationFileName(fileName, referencedProject); + return referencedProject; }); } + function forEachResolvedProjectReference(cb) { + return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var resolvedRefPath = toPath(resolveProjectReferencePath(ref)); + return cb(resolvedRef, resolvedRefPath); + }); + } + function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { + var seenResolvedRefs; + return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); + function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) { + // Visit project references first + if (cbRef) { + var result = cbRef(projectReferences, parent); + if (result) { + return result; + } + } + return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { + if (ts.contains(seenResolvedRefs, resolvedRef)) { + // ignore recursives + return undefined; + } + var result = cbResolvedRef(resolvedRef, index, parent); + if (result) { + return result; + } + if (!resolvedRef) + return undefined; + (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef); + return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef); + }); + } + } + function getResolvedProjectReferenceByPath(projectReferencePath) { + if (!projectReferenceRedirects) { + return undefined; + } + return projectReferenceRedirects.get(projectReferencePath) || undefined; + } function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); @@ -86355,7 +87400,7 @@ var ts; if (!typeDirectives) { return; } - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName)); for (var i = 0; i < typeDirectives.length; i++) { var ref = file.typeReferenceDirectives[i]; var resolvedTypeReferenceDirective = resolutions[i]; @@ -86373,6 +87418,8 @@ var ts; } var saveResolution = true; if (resolvedTypeReferenceDirective) { + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 @@ -86397,6 +87444,8 @@ var ts; processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth--; } else { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 @@ -86441,8 +87490,7 @@ var ts; if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); - var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file); ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; @@ -86510,20 +87558,34 @@ var ts; return allFilesBelongToPath; } function parseProjectReferenceConfigFile(ref) { + if (!projectReferenceRedirects) { + projectReferenceRedirects = ts.createMap(); + } // The actual filename (i.e. add "/tsconfig.json" if necessary) var refPath = resolveProjectReferencePath(ref); + var sourceFilePath = toPath(refPath); + var fromCache = projectReferenceRedirects.get(sourceFilePath); + if (fromCache !== undefined) { + return fromCache || undefined; + } // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); return undefined; } - sourceFile.path = toPath(refPath); + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; var commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); - return { commandLine: commandLine, sourceFile: sourceFile }; - } - function addProjectReferenceRedirects(referencedProject) { - (projectReferenceRedirects || (projectReferenceRedirects = [])).push(referencedProject); + var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile }; + projectReferenceRedirects.set(sourceFilePath, resolvedRef); + if (commandLine.projectReferences) { + resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile); + } + return resolvedRef; } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { @@ -86559,30 +87621,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } } - if (projectReferences) { - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i] && resolvedProjectReferences[i].commandLine.options; - if (resolvedRefOpts === undefined) { - createDiagnosticForReference(i, ts.Diagnostics.File_0_does_not_exist, ref.path); - continue; - } - if (!resolvedRefOpts.composite) { - createDiagnosticForReference(i, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); - } - if (ref.prepend) { - var out = resolvedRefOpts.outFile || resolvedRefOpts.out; - if (out) { - if (!host.fileExists(out)) { - createDiagnosticForReference(i, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); - } - } - else { - createDiagnosticForReference(i, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); - } - } - } - } + verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); @@ -86661,12 +87700,12 @@ var ts; } var languageVersion = options.target || 0 /* ES3 */; var outFile = options.outFile || options.out; - var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + 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 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } - var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); @@ -86704,7 +87743,7 @@ var ts; // Precalculate and cache the common source directory var dir = getCommonSourceDirectory(); // If we failed to find a good common directory, but outDir is specified and at least one of our files is on a windows drive/URL/other resource, add a failure - if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { + if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) { createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } @@ -86774,6 +87813,35 @@ var ts; } } } + function verifyProjectReferences() { + forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var parentFile = parent && parent.sourceFile; + if (!resolvedRef) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path); + return; + } + var options = resolvedRef.commandLine.options; + if (!options.composite) { + // ok to not have composite if the current program is container only + var inputs = parent ? parent.commandLine.fileNames : rootNames; + if (inputs.length) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); + } + } + if (ref.prepend) { + var out = options.outFile || options.out; + if (out) { + if (!host.fileExists(out)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); + } + } + else { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); + } + } + }); + } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { var needCompilerDiagnostic = true; var pathsSyntax = getOptionPathsSyntax(); @@ -86824,10 +87892,10 @@ var ts; function createOptionValueDiagnostic(option1, message, arg0) { createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0); } - function createDiagnosticForReference(index, message, arg0, arg1) { - var referencesSyntax = getProjectReferencesSyntax(); + function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) { + var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; }); if (referencesSyntax && referencesSyntax.elements.length > index) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); } else { programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1)); @@ -86841,22 +87909,6 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2)); } } - function getProjectReferencesSyntax() { - if (_referencesArrayLiteralSyntax === undefined) { - _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword - if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 - for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { - var prop = _a[_i]; - if (ts.isArrayLiteralExpression(prop.initializer)) { - _referencesArrayLiteralSyntax = prop.initializer; - break; - } - } - } - } - return _referencesArrayLiteralSyntax; - } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword @@ -86931,7 +87983,8 @@ var ts; readFile: function (f) { return host.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: function () { return undefined; } + onUnRecoverableConfigFileDiagnostic: function () { return undefined; }, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost; @@ -86981,7 +88034,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 === 9 /* StringLiteral */) { + if (aug.kind === 10 /* StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -87206,6 +88259,11 @@ var ts; var latestSignature; if (sourceFile.isDeclarationFile) { latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.path) : undefined; + exportedModulesMapCache.set(sourceFile.path, references || false); + } } else { var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); @@ -87271,7 +88329,7 @@ var ts; return getAllFileNames(state, programOfThisState); } // If this is non module emit, or its a global file, it depends on all the source files - if (!state.referencedMap || (!ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile))) { + if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) { return getAllFileNames(state, programOfThisState); } // Get the references, traversing deep from the referenceMap @@ -87330,6 +88388,20 @@ var ts; } return true; } + /** + * Return true if file contains anything that augments to global scope we need to build them as if + * they are global files as well as module + */ + function containsGlobalScopeAugmentation(sourceFile) { + return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); }); + } + /** + * Return true if the file will invalidate all files because it affectes global scope + */ + function isFileAffectingGlobalScope(sourceFile) { + return containsGlobalScopeAugmentation(sourceFile) || + !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + } /** * Gets all files of the program excluding the default library file */ @@ -87370,7 +88442,7 @@ var ts; * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { - if (!ts.isExternalModule(sourceFileWithUpdatedShape) && !containsOnlyAmbientModules(sourceFileWithUpdatedShape)) { + if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } var compilerOptions = programOfThisState.getCompilerOptions(); @@ -87420,8 +88492,9 @@ var ts; } state.changedFilesSet = ts.createMap(); var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); + var oldCompilerOptions = useOldState ? oldState.program.getCompilerOptions() : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && - !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldState.program.getCompilerOptions()); + !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions); if (useOldState) { // Verify the sanity of old state if (!oldState.currentChangedFilePath) { @@ -87436,6 +88509,8 @@ var ts; // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; + var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck; + var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -87453,6 +88528,13 @@ var ts; state.changedFilesSet.set(sourceFilePath, true); } else if (canCopySemanticDiagnostics) { + var sourceFile = state.program.getSourceFileByPath(sourceFilePath); + if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { + return; + } + if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { + return; + } // Unchanged file copy diagnostics var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath); if (diagnostics) { @@ -87536,18 +88618,31 @@ var ts; // If there are no more diagnostics from old cache, done return; } + // Clean lib file diagnostics if its all files excluding default files to emit + if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles && !state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var options_2 = state.program.getCompilerOptions(); + if (ts.forEach(state.program.getSourceFiles(), function (f) { + return state.program.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2) && + removeSemanticDiagnosticsOf(state, f.path); + })) { + return; + } + } // If there was change in signature for the changed file, // then delete the semantic diagnostics for files that are affected by using exports of this module if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { return; } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); + var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { return exportedModules && exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); })) { return; } @@ -87555,16 +88650,44 @@ var ts; ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** * removes the semantic diagnostics of files referencing referencedPath and * returns true if there are no more semantic diagnostics from old state */ - function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath) { + function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile) { return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) { - return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOf(state, filePath); + return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile); + }); + } + /** + * Removes semantic diagnostics of file and anything that exports this file + */ + function removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile) { + if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) { + return false; + } + if (removeSemanticDiagnosticsOf(state, filePath)) { + // If there are no more diagnostics from old cache, done + return true; + } + 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 + if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { + return exportedModules && + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); + })) { + return true; + } + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + return !!ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { + return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** @@ -87573,7 +88696,7 @@ var ts; */ function removeSemanticDiagnosticsOf(state, path) { if (!state.semanticDiagnosticsFromOldState) { - return false; + return true; } state.semanticDiagnosticsFromOldState.delete(path); state.semanticDiagnosticsPerFile.delete(path); @@ -87846,6 +88969,10 @@ var ts; /*@internal*/ var ts; (function (ts) { + function isPathInNodeModulesStartingWithDot(path) { + return ts.stringContains(path, "/node_modules/."); + } + ts.isPathInNodeModulesStartingWithDot = isPathInNodeModulesStartingWithDot; ts.maxNumberOfFilesToIterateForInvalidation = 256; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; @@ -87859,11 +88986,11 @@ var ts; // The key in the map is source file's path. // The values are Map of resolutions with key being name lookedup. var resolvedModuleNames = ts.createMap(); - var perDirectoryResolvedModuleNames = ts.createMap(); - var nonRelaticeModuleNameCache = ts.createMap(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelaticeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); + var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); + var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); var resolvedTypeReferenceDirectives = ts.createMap(); - var perDirectoryResolvedTypeReferenceDirectives = ts.createMap(); + var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -87887,6 +89014,7 @@ var ts; resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives: resolveTypeReferenceDirectives, + removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects, removeResolutionsOfFile: removeResolutionsOfFile, invalidateResolutionOfFile: invalidateResolutionOfFile, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, @@ -87948,7 +89076,7 @@ var ts; } function clearPerDirectoryResolutions() { perDirectoryResolvedModuleNames.clear(); - nonRelaticeModuleNameCache.clear(); + nonRelativeModuleNameCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); @@ -87964,8 +89092,8 @@ var ts; } }); } - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache); + function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference); // 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; @@ -87983,10 +89111,11 @@ var ts; // Default return the result from the first pass return primaryResult; } - function resolveNamesWithLocalCache(names, containingFile, cache, perDirectoryCache, loader, getResolutionWithResolvedFileName, reusedNames, logChanges) { + function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) { var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); + var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); var perDirectoryResolution = perDirectoryCache.get(dirPath); if (!perDirectoryResolution) { perDirectoryResolution = ts.createMap(); @@ -87995,22 +89124,28 @@ var ts; var resolvedModules = []; var compilerOptions = resolutionHost.getCompilationSettings(); var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path); + // All the resolutions in this file are invalidated if this file wasnt resolved using same redirect + var program = resolutionHost.getCurrentProgram(); + var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile); + var unmatchedRedirects = oldRedirect ? + !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : + !!redirectedReference; var seenNamesInFile = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { var name = names_2[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && - allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated || + allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate - (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && !getResolutionWithResolvedFileName(resolution))) { + (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; } else { - resolution = loader(name, containingFile, compilerOptions, resolutionHost); + resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -88026,7 +89161,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -88054,12 +89189,14 @@ var ts; return oldResult.resolvedFileName === newResult.resolvedFileName; } } - function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile) { - return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) { + return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + /*shouldRetryResolution*/ function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, /*reusedNames*/ undefined, /*logChanges*/ false); } - function resolveModuleNames(moduleNames, containingFile, reusedNames) { - return resolveNamesWithLocalCache(moduleNames, containingFile, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, reusedNames, logChangesWhenResolvingModule); + function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { + return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, + /*shouldRetryResolution*/ function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule); } function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); @@ -88102,12 +89239,6 @@ var ts; } return true; } - function filterFSRootDirectoriesToWatch(watchPath, dirPath) { - if (!canWatchDirectory(dirPath)) { - watchPath.ignore = true; - } - return watchPath; - } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path @@ -88127,13 +89258,13 @@ var ts; } function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) { // If directory path contains node module, get the most parent node_modules directory for watching - while (ts.stringContains(dirPath, ts.nodeModulesPathPart)) { + while (ts.pathContainsNodeModules(dirPath)) { dir = ts.getDirectoryPath(dir); dirPath = ts.getDirectoryPath(dirPath); } // If the directory is node_modules use it to watch, always watch it recursively if (isNodeModulesDirectory(dirPath)) { - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); + return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -88151,7 +89282,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive }, dirPath); + return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -88180,8 +89311,9 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, nonRecursive = _a.nonRecursive, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive; // If the failed lookup location path is not one of the supported extensions, // store it in the custom path if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { @@ -88234,8 +89366,9 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dirPath = toWatch.dirPath; var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { if (refCount === 1) { @@ -88283,6 +89416,22 @@ var ts; cache.delete(filePath); } } + function removeResolutionsFromProjectReferenceRedirects(filePath) { + if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) { + return; + } + var program = resolutionHost.getCurrentProgram(); + if (!program) { + return; + } + // If this file is input file for the referenced project, get it + var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath); + if (!resolvedProjectReference) { + return; + } + // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution + resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); + } function removeResolutionsOfFile(filePath) { removeResolutionsOfFileFromCache(resolvedModuleNames, filePath); removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath); @@ -88344,6 +89493,9 @@ var ts; isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); }; } else { + // If something to do with folder/file starting with "." in node_modules folder, skip it + if (isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return false; // Some file or directory in the watching directory is created // Return early if it does not have any of the watching extension or not the custom failed lookup path var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); @@ -88384,8 +89536,8 @@ var ts; if (isInDirectoryPath(rootPath, typeRootPath)) { return rootPath; } - var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; + var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath); + return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -88873,7 +90025,6 @@ var ts; } return false; } - /** @internal */ ts.screenStartingMessageCodes = [ ts.Diagnostics.Starting_compilation_in_watch_mode.code, ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code, @@ -88914,6 +90065,23 @@ var ts; return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; + function getErrorCountForSummary(diagnostics) { + return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + ts.getErrorCountForSummary = getErrorCountForSummary; + function getWatchErrorSummaryDiagnosticMessage(errorCount) { + return errorCount === 1 ? + ts.Diagnostics.Found_1_error_Watching_for_file_changes : + ts.Diagnostics.Found_0_errors_Watching_for_file_changes; + } + ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage; + function getErrorSummaryText(errorCount, newLine) { + if (errorCount === 0) + return ""; + var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount); + return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine; + } + ts.getErrorSummaryText = getErrorSummaryText; /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ @@ -88952,7 +90120,7 @@ var ts; } } if (reportSummary) { - reportSummary(diagnostics.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length); + reportSummary(getErrorCountForSummary(diagnostics)); } if (emitSkipped && diagnostics.length > 0) { // If the emitter didn't emit anything, then pass that value along. @@ -89031,15 +90199,7 @@ var ts; function emitFilesAndReportErrorUsingBuilder(builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - var reportSummary = function (errorCount) { - if (errorCount === 1) { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_1_error_Watching_for_file_changes, errorCount), newLine, compilerOptions); - } - else { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_0_errors_Watching_for_file_changes, errorCount, errorCount), newLine, compilerOptions); - } - }; - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, reportSummary); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); } } /** @@ -89115,7 +90275,8 @@ var ts; fileExists: function (path) { return host.fileExists(path); }, readFile: readFile, getCurrentDirectory: getCurrentDirectory, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; // From tsc we want to get already parsed result and hence check for rootFileNames var newLine = updateNewLine(); @@ -89183,11 +90344,11 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }) : - (function (moduleNames, containingFile, reusedNames) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); }); + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }) : - (function (typeDirectiveNames, containingFile) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }); + (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; synchronizeProgram(); // Update the wild card directory watch @@ -89361,8 +90522,8 @@ var ts; var hostSourceFile = sourceFilesCache.get(path); return !hostSourceFile || isFileMissingOnHost(hostSourceFile) ? undefined : hostSourceFile.version.toString(); } - function onReleaseOldSourceFile(oldSourceFile, _oldOptions) { - var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.path); + function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { + var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); // If this is the source file thats in the cache and new program doesnt need it, // remove the cached entry. // Note we arent deleting entry if file became missing in new program or @@ -89376,8 +90537,10 @@ var ts; if (hostSourceFileInfo.fileWatcher) { hostSourceFileInfo.fileWatcher.close(); } - sourceFilesCache.delete(oldSourceFile.path); - resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + sourceFilesCache.delete(oldSourceFile.resolvedPath); + if (!hasSourceFileByPath) { + resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + } } } } @@ -89457,6 +90620,7 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.get(path)) { resolutionCache.invalidateResolutionOfFile(path); } + resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -89497,6 +90661,8 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } nextSourceFileVersion(fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) { @@ -89699,7 +90865,7 @@ var ts; }; } ts.createBuilderStatusReporter = createBuilderStatusReporter; - function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus) { + function createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) { if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker({}, /*setParentNodes*/ undefined, system); host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; @@ -89709,10 +90875,15 @@ var ts; host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; } + function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { + if (system === void 0) { system = ts.sys; } + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); + host.reportErrorSummary = reportErrorSummary; + return host; + } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { - if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); host.onWatchStatusChange = watchHost.onWatchStatusChange; host.watchFile = watchHost.watchFile; @@ -89729,12 +90900,6 @@ var ts; }); return result; } - /** - * A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but - * can dynamically add/remove other projects based on changes on the rootNames' references - * TODO: use SolutionBuilderWithWatchHost => watchedSolution - * use SolutionBuilderHost => Solution - */ function createSolutionBuilder(host, rootNames, defaultOptions) { var hostWithWatch = host; var currentDirectory = host.getCurrentDirectory(); @@ -90093,9 +91258,7 @@ var ts; globalDependencyGraph = undefined; } projectStatus.removeKey(resolved); - if (options.watch) { - diagnostics.removeKey(resolved); - } + diagnostics.removeKey(resolved); addProjToQueue(resolved, reloadLevel); } /** @@ -90157,7 +91320,7 @@ var ts; } } function reportErrorSummary() { - if (options.watch) { + if (options.watch || host.reportErrorSummary) { // Report errors from the other projects getGlobalDependencyGraph().buildQueue.forEach(function (project) { if (!projectErrorsReported.hasKey(project)) { @@ -90165,8 +91328,13 @@ var ts; } }); var totalErrors_1 = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += singleProjectErrors.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length; }); - reportWatchStatus(totalErrors_1 === 1 ? ts.Diagnostics.Found_1_error_Watching_for_file_changes : ts.Diagnostics.Found_0_errors_Watching_for_file_changes, totalErrors_1); + diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += ts.getErrorCountForSummary(singleProjectErrors); }); + if (options.watch) { + reportWatchStatus(ts.getWatchErrorSummaryDiagnosticMessage(totalErrors_1), totalErrors_1); + } + else { + host.reportErrorSummary(totalErrors_1); + } } } function buildSingleInvalidatedProject(resolved, reloadLevel) { @@ -90330,9 +91498,7 @@ var ts; type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime }; - if (options.watch) { - diagnostics.removeKey(proj); - } + diagnostics.removeKey(proj); projectStatus.setValue(proj, status); return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { @@ -90458,10 +91624,8 @@ var ts; } function reportAndStoreErrors(proj, errors) { reportErrors(errors); - if (options.watch) { - projectErrorsReported.setValue(proj, true); - diagnostics.setValue(proj, errors); - } + projectErrorsReported.setValue(proj, true); + diagnostics.setValue(proj, errors); } function reportErrors(errors) { errors.forEach(function (err) { return host.reportDiagnostic(err); }); @@ -90583,10 +91747,12 @@ var ts; if (builtin !== undefined) return builtin; var entries = getEntriesOfObject(value); - return { kind: 3 /* Object */, name: name, members: ts.flatMap(entries, function (_a) { - var key = _a.key, value = _a.value; - return getValueInfo(key, value, recurser); - }) }; + var hasNontrivialPrototype = Object.getPrototypeOf(value) !== Object.prototype; + var members = ts.flatMap(entries, function (_a) { + var key = _a.key, value = _a.value; + return getValueInfo(key, value, recurser); + }); + return { kind: 3 /* Object */, name: name, hasNontrivialPrototype: hasNontrivialPrototype, members: members }; } return { kind: 0 /* Const */, name: name, typeName: isNullOrUndefined(value) ? "any" : typeof value }; }, function (isCircularReference, keyStack) { return anyValue(name, " " + (isCircularReference ? "Circular reference" : "Too-deep object hierarchy") + " from " + keyStack.join(".")); }); @@ -90696,7 +91862,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -90752,30 +91918,32 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + function getDefaultFormatCodeSettings(newLineCharacter) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: newLineCharacter || "\n", + convertTabsToSpaces: true, + indentStyle: IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; /* @internal */ - ts.testFormatSettings = { - baseIndentSize: 0, - indentSize: 4, - tabSize: 4, - newLineCharacter: "\n", - convertTabsToSpaces: true, - indentStyle: IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterConstructor: false, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - insertSpaceAfterTypeAssertion: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - insertSpaceBeforeTypeAnnotation: false - }; + ts.testFormatSettings = getDefaultFormatCodeSettings("\n"); var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; @@ -90837,8 +92005,9 @@ var ts; TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + TokenClass[TokenClass["BigIntLiteral"] = 7] = "BigIntLiteral"; + TokenClass[TokenClass["StringLiteral"] = 8] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 9] = "RegExpLiteral"; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { @@ -90921,6 +92090,12 @@ var ts; ScriptElementKindModifier["staticModifier"] = "static"; ScriptElementKindModifier["abstractModifier"] = "abstract"; ScriptElementKindModifier["optionalModifier"] = "optional"; + ScriptElementKindModifier["dtsModifier"] = ".d.ts"; + ScriptElementKindModifier["tsModifier"] = ".ts"; + ScriptElementKindModifier["tsxModifier"] = ".tsx"; + ScriptElementKindModifier["jsModifier"] = ".js"; + ScriptElementKindModifier["jsxModifier"] = ".jsx"; + ScriptElementKindModifier["jsonModifier"] = ".json"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames; (function (ClassificationTypeNames) { @@ -90928,6 +92103,7 @@ var ts; ClassificationTypeNames["identifier"] = "identifier"; ClassificationTypeNames["keyword"] = "keyword"; ClassificationTypeNames["numericLiteral"] = "number"; + ClassificationTypeNames["bigintLiteral"] = "bigint"; ClassificationTypeNames["operator"] = "operator"; ClassificationTypeNames["stringLiteral"] = "string"; ClassificationTypeNames["whiteSpace"] = "whitespace"; @@ -90974,6 +92150,7 @@ var ts; ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + ClassificationType[ClassificationType["bigintLiteral"] = 25] = "bigintLiteral"; })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); // These utilities are common to multiple language service features. @@ -90991,37 +92168,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 272 /* CatchClause */: - case 265 /* JsxAttribute */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 274 /* CatchClause */: + case 267 /* JsxAttribute */: return 1 /* Value */; - case 148 /* TypeParameter */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 166 /* TypeLiteral */: + case 150 /* TypeParameter */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 168 /* TypeLiteral */: return 2 /* Type */; - case 302 /* JSDocTypedefTag */: + case 304 /* 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 276 /* EnumMember */: - case 238 /* ClassDeclaration */: + case 278 /* EnumMember */: + case 240 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -91031,26 +92208,26 @@ var ts; else { return 4 /* Namespace */; } - case 241 /* EnumDeclaration */: - case 250 /* NamedImports */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 243 /* EnumDeclaration */: + case 252 /* NamedImports */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 252 /* ExportAssignment */ || node.parent.kind === 257 /* ExternalModuleReference */) { + else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -91082,11 +92259,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 148 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 248 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -91098,27 +92275,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 146 /* QualifiedName */) { - while (root.parent && root.parent.kind === 146 /* QualifiedName */) { + if (root.parent.kind === 148 /* QualifiedName */) { + while (root.parent && root.parent.kind === 148 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 162 /* TypeReference */ && !isLastClause; + return root.parent.kind === 164 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 187 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { + if (root.parent.kind === 189 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 189 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 211 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 273 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 240 /* ClassDeclaration */ && root.parent.parent.token === 109 /* ImplementsKeyword */) || + (decl.kind === 241 /* InterfaceDeclaration */ && root.parent.parent.token === 86 /* ExtendsKeyword */); } return false; } @@ -91127,17 +92304,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return true; } switch (node.parent.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return true; - case 181 /* ImportType */: + case 183 /* ImportType */: return !node.parent.isTypeOf; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -91164,7 +92341,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 233 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -91180,11 +92357,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 71 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 71 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -91192,40 +92369,40 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 244 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 71 /* Identifier */ && + return node.kind === 72 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 276 /* EnumMember */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 242 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 278 /* EnumMember */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 244 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return true; - case 180 /* LiteralType */: - return node.parent.parent.kind === 178 /* IndexedAccessType */; + case 182 /* LiteralType */: + return node.parent.parent.kind === 180 /* IndexedAccessType */; default: return false; } @@ -91249,17 +92426,17 @@ var ts; return undefined; } switch (node.kind) { - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return node; } } @@ -91267,51 +92444,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return "class" /* classElement */; - case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 240 /* TypeAliasDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 242 /* TypeAliasDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 241 /* EnumDeclaration */: return "enum" /* enumElement */; - case 235 /* VariableDeclaration */: + case 243 /* EnumDeclaration */: return "enum" /* enumElement */; + case 237 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return "function" /* functionElement */; - case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 158 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 159 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return "property" /* memberVariableElement */; - case 160 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 159 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 158 /* CallSignature */: return "call" /* callSignatureElement */; - case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 276 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: - case 249 /* NamespaceImport */: + case 162 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 161 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 160 /* CallSignature */: return "call" /* callSignatureElement */; + case 157 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 150 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 278 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 151 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: + case 251 /* NamespaceImport */: return "alias" /* alias */; - case 202 /* BinaryExpression */: + case 204 /* 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 */: @@ -91332,7 +92512,7 @@ var ts; return "" /* unknown */; } } - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -91348,12 +92528,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 149 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 151 /* Parameter */; default: return false; } @@ -91418,42 +92598,42 @@ var ts; return false; } switch (n.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 182 /* ObjectBindingPattern */: - case 166 /* TypeLiteral */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 244 /* CaseBlock */: - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 272 /* CatchClause */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 168 /* TypeLiteral */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 246 /* CaseBlock */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); + case 274 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 190 /* NewExpression */: + case 192 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 189 /* CallExpression */: - case 193 /* ParenthesizedExpression */: - case 175 /* ParenthesizedType */: - return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 191 /* CallExpression */: + case 195 /* ParenthesizedExpression */: + case 177 /* ParenthesizedType */: + return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 197 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -91462,66 +92642,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 242 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); + case 244 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 220 /* IfStatement */: + case 222 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 185 /* ArrayLiteralExpression */: - case 183 /* ArrayBindingPattern */: - case 188 /* ElementAccessExpression */: - case 147 /* ComputedPropertyName */: - case 168 /* TupleType */: - return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); - case 160 /* IndexSignature */: + hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); + case 187 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 190 /* ElementAccessExpression */: + case 149 /* ComputedPropertyName */: + case 170 /* TupleType */: + return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); + case 162 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 107 /* WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 197 /* TypeOfExpression */: - case 196 /* DeleteExpression */: - case 198 /* VoidExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: + case 199 /* TypeOfExpression */: + case 198 /* DeleteExpression */: + case 200 /* VoidExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -91538,7 +92718,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 25 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -91700,7 +92880,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 277 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* 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. @@ -91762,25 +92942,25 @@ var ts; if (!token) { return false; } - if (token.kind === 10 /* JsxText */) { + if (token.kind === 11 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 263 /* JsxClosingElement */) { return true; } return false; @@ -91794,6 +92974,20 @@ var ts; return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; + function isInJSXText(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + if (ts.isJsxText(token)) { + return true; + } + if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + return false; + } + ts.isInJSXText = isInJSXText; function findPrecedingMatchingToken(token, matchingTokenKind, sourceFile) { var tokenKind = token.kind; var remainingMatchingTokens = 0; @@ -91840,7 +93034,7 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); if (!token || !ts.isIdentifier(token)) @@ -91850,53 +93044,54 @@ var ts; } remainingLessThanTokens--; break; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: remainingLessThanTokens++; break; - case 18 /* CloseBraceToken */: + case 19 /* 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, 17 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 20 /* CloseParenToken */: + case 21 /* 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, 19 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 22 /* CloseBracketToken */: + case 23 /* 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, 21 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 26 /* CommaToken */: + case 27 /* CommaToken */: nTypeArguments++; break; - case 36 /* EqualsGreaterThanToken */: - case 71 /* Identifier */: - case 9 /* StringLiteral */: + case 37 /* EqualsGreaterThanToken */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 103 /* TypeOfKeyword */: - case 85 /* ExtendsKeyword */: - case 128 /* KeyOfKeyword */: - case 23 /* DotToken */: - case 49 /* BarToken */: - case 55 /* QuestionToken */: - case 56 /* ColonToken */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 104 /* TypeOfKeyword */: + case 86 /* ExtendsKeyword */: + case 129 /* KeyOfKeyword */: + case 24 /* DotToken */: + case 50 /* BarToken */: + case 56 /* QuestionToken */: + case 57 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -91951,10 +93146,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { + if (node.kind === 164 /* TypeReference */ || node.kind === 191 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 240 /* ClassDeclaration */ || node.kind === 241 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -91965,8 +93160,8 @@ var ts; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 /* StringLiteral */ - || kind === 12 /* RegularExpressionLiteral */ + if (kind === 10 /* StringLiteral */ + || kind === 13 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -91974,7 +93169,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 71 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -91984,9 +93179,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: return true; } return false; @@ -91999,18 +93194,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 185 /* ArrayLiteralExpression */ || - node.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 187 /* ArrayLiteralExpression */ || + node.kind === 188 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 202 /* BinaryExpression */ && + if (node.parent.kind === 204 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 58 /* EqualsToken */) { + node.parent.operatorToken.kind === 59 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 225 /* ForOfStatement */ && + if (node.parent.kind === 227 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -92018,7 +93213,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 275 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -92062,21 +93257,21 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 119 /* AnyKeyword */, - 122 /* BooleanKeyword */, - 86 /* FalseKeyword */, - 128 /* KeyOfKeyword */, - 131 /* NeverKeyword */, - 95 /* NullKeyword */, - 134 /* NumberKeyword */, - 135 /* ObjectKeyword */, - 137 /* StringKeyword */, - 138 /* SymbolKeyword */, - 101 /* TrueKeyword */, - 105 /* VoidKeyword */, - 140 /* UndefinedKeyword */, - 141 /* UniqueKeyword */, - 142 /* UnknownKeyword */, + 120 /* AnyKeyword */, + 123 /* BooleanKeyword */, + 87 /* FalseKeyword */, + 129 /* KeyOfKeyword */, + 132 /* NeverKeyword */, + 96 /* NullKeyword */, + 135 /* NumberKeyword */, + 136 /* ObjectKeyword */, + 138 /* StringKeyword */, + 139 /* SymbolKeyword */, + 102 /* TrueKeyword */, + 106 /* VoidKeyword */, + 141 /* UndefinedKeyword */, + 142 /* UniqueKeyword */, + 143 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -92112,7 +93307,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 147 /* ComputedPropertyName */ + return name.kind === 149 /* 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.getTextOfIdentifierOrLiteral(name); @@ -92188,7 +93383,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 71 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 72 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -92201,13 +93396,7 @@ var ts; ts.isObjectBindingElementWithoutPropertyName = isObjectBindingElementWithoutPropertyName; function getPropertySymbolFromBindingElement(checker, bindingElement) { var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); - var propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - if (propSymbol && propSymbol.flags & 98304 /* Accessor */) { - // See GH#16922 - ts.Debug.assert(!!(propSymbol.flags & 33554432 /* Transient */)); - return propSymbol.target; - } - return propSymbol; + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; /** @@ -92260,7 +93449,6 @@ var ts; return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); } ts.findModifier = findModifier; - /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); if (lastImportDeclaration) { @@ -92284,7 +93472,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 151 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -92310,6 +93498,7 @@ var ts; writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeTrailingSemicolon: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, @@ -92318,7 +93507,7 @@ var ts; writeSymbol: writeSymbol, writeLine: writeLine, write: unknownWrite, - writeTextOfNode: unknownWrite, + writeComment: unknownWrite, getText: function () { return ""; }, getTextPos: function () { return 0; }, getColumn: function () { return 0; }, @@ -92469,7 +93658,6 @@ var ts; return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } ts.lineBreakPart = lineBreakPart; - /* @internal */ function mapToDisplayParts(writeDisplayParts) { try { writeDisplayParts(displayPartWriter); @@ -92504,7 +93692,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && + (location.parent.kind === 253 /* ImportSpecifier */ || location.parent.kind === 257 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -92551,6 +93739,13 @@ var ts; return position; } ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getPrecedingNonSpaceCharacterPosition(text, position) { + while (position > -1 && ts.isWhiteSpaceSingleLine(text.charCodeAt(position))) { + position -= 1; + } + return position + 1; + } + ts.getPrecedingNonSpaceCharacterPosition = getPrecedingNonSpaceCharacterPosition; /** * Creates a deep, memberwise clone of a node with no source map location. * @@ -92617,7 +93812,6 @@ var ts; /** * Sets EmitFlags to suppress leading and trailing trivia on the node. */ - /* @internal */ function suppressLeadingAndTrailingTrivia(node) { suppressLeadingTrivia(node); suppressTrailingTrivia(node); @@ -92626,7 +93820,6 @@ var ts; /** * Sets EmitFlags to suppress leading trivia on the node. */ - /* @internal */ function suppressLeadingTrivia(node) { addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); } @@ -92634,7 +93827,6 @@ var ts; /** * Sets EmitFlags to suppress trailing trivia on the node. */ - /* @internal */ function suppressTrailingTrivia(node) { addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); } @@ -92648,7 +93840,6 @@ var ts; function getFirstChild(node) { return node.forEachChild(function (child) { return child; }); } - /* @internal */ function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { @@ -92662,7 +93853,6 @@ var ts; * to be on the reference, rather than the declaration, because it's closer to where the * user was before extracting it. */ - /* @internal */ function getRenameLocation(edits, renameFilename, name, preferLastLocation) { var delta = 0; var lastPos = -1; @@ -92716,6 +93906,72 @@ var ts; idx = change.indexOf('"' + name); return idx === -1 ? -1 : idx + 1; } + function getContextualTypeFromParent(node, checker) { + var parent = node.parent; + switch (parent.kind) { + case 192 /* NewExpression */: + return checker.getContextualType(parent); + case 204 /* 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 271 /* CaseClause */: + return parent.expression === node ? getSwitchedType(parent, checker) : undefined; + default: + return checker.getContextualType(node); + } + } + ts.getContextualTypeFromParent = getContextualTypeFromParent; + function quote(text, preferences) { + if (/^\d+$/.test(text)) { + return text; + } + var quoted = JSON.stringify(text); + switch (preferences.quotePreference) { + case undefined: + case "double": + return quoted; + case "single": + return "'" + stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; + default: + return ts.Debug.assertNever(preferences.quotePreference); + } + } + ts.quote = quote; + function isEqualityOperatorKind(kind) { + switch (kind) { + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + return true; + default: + return false; + } + } + ts.isEqualityOperatorKind = isEqualityOperatorKind; + function isStringLiteralOrTemplate(node) { + switch (node.kind) { + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + return true; + default: + return false; + } + } + ts.isStringLiteralOrTemplate = isStringLiteralOrTemplate; + function hasIndexSignature(type) { + return !!type.getStringIndexType() || !!type.getNumberIndexType(); + } + ts.hasIndexSignature = hasIndexSignature; + function getSwitchedType(caseClause, checker) { + return checker.getTypeAtLocation(caseClause.parent.parent.expression); + } + ts.getSwitchedType = getSwitchedType; })(ts || (ts = {})); var ts; (function (ts) { @@ -92754,7 +94010,7 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(14 /* TemplateHead */); + templateStack.push(15 /* TemplateHead */); } scanner.setText(text); var endOfLineState = 0 /* None */; @@ -92796,65 +94052,65 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 12 /* RegularExpressionLiteral */) { - token = 12 /* RegularExpressionLiteral */; + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + token = 13 /* RegularExpressionLiteral */; } break; - case 27 /* LessThanToken */: - if (lastNonTriviaToken === 71 /* Identifier */) { + case 28 /* LessThanToken */: + if (lastNonTriviaToken === 72 /* 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 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 119 /* AnyKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: + case 120 /* AnyKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: templateStack.push(token); break; - case 17 /* OpenBraceToken */: + case 18 /* 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 18 /* CloseBraceToken */: + case 19 /* 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 === 14 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 16 /* TemplateTail */) { + if (token === 17 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 15 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 17 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -92863,15 +94119,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 23 /* DotToken */) { - token = 71 /* Identifier */; + if (lastNonTriviaToken === 24 /* DotToken */) { + token = 72 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } } } @@ -92885,22 +94141,23 @@ 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([ - 71 /* Identifier */, - 9 /* StringLiteral */, + 72 /* Identifier */, + 10 /* StringLiteral */, 8 /* NumericLiteral */, - 12 /* RegularExpressionLiteral */, - 99 /* ThisKeyword */, - 43 /* PlusPlusToken */, - 44 /* MinusMinusToken */, - 20 /* CloseParenToken */, - 22 /* CloseBracketToken */, - 18 /* CloseBraceToken */, - 101 /* TrueKeyword */, - 86 /* FalseKeyword */, + 9 /* BigIntLiteral */, + 13 /* RegularExpressionLiteral */, + 100 /* ThisKeyword */, + 44 /* PlusPlusToken */, + 45 /* MinusMinusToken */, + 21 /* CloseParenToken */, + 23 /* CloseBracketToken */, + 19 /* CloseBraceToken */, + 102 /* TrueKeyword */, + 87 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; @@ -92924,15 +94181,15 @@ var ts; return undefined; } switch (token) { - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return 5 /* InTemplateMiddleOrTail */; - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 14 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { @@ -92981,6 +94238,7 @@ var ts; 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; @@ -93007,10 +94265,10 @@ var ts; return true; } switch (keyword2) { - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 123 /* ConstructorKeyword */: - case 115 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 124 /* ConstructorKeyword */: + case 116 /* 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. @@ -93043,43 +94301,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 48 /* AmpersandToken */: - case 50 /* CaretToken */: - case 49 /* BarToken */: - case 53 /* AmpersandAmpersandToken */: - case 54 /* BarBarToken */: - case 69 /* BarEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 49 /* AmpersandToken */: + case 51 /* CaretToken */: + case 50 /* BarToken */: + case 54 /* AmpersandAmpersandToken */: + case 55 /* BarBarToken */: + case 70 /* BarEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return true; default: return false; @@ -93087,12 +94345,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: return true; default: return false; @@ -93105,15 +94363,17 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 17 /* FirstPunctuation */ && token <= 70 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 71 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + return 25 /* bigintLiteral */; + case 10 /* StringLiteral */: return 6 /* stringLiteral */; - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -93122,7 +94382,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 71 /* Identifier */: + case 72 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -93147,10 +94407,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -93225,6 +94485,7 @@ var ts; 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 */; @@ -93358,22 +94619,22 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); // "@" + pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -93444,10 +94705,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -93460,22 +94721,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -93492,7 +94753,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 27 /* LessThanToken */ || tokenKind === 29 /* GreaterThanToken */) { + if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* 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)) { @@ -93502,19 +94763,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 58 /* EqualsToken */) { + if (tokenKind === 59 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 235 /* VariableDeclaration */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 149 /* Parameter */ || - parent.kind === 265 /* JsxAttribute */) { + if (parent.kind === 237 /* VariableDeclaration */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 151 /* Parameter */ || + parent.kind === 267 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 202 /* BinaryExpression */ || - parent.kind === 200 /* PrefixUnaryExpression */ || - parent.kind === 201 /* PostfixUnaryExpression */ || - parent.kind === 203 /* ConditionalExpression */) { + if (parent.kind === 204 /* BinaryExpression */ || + parent.kind === 202 /* PrefixUnaryExpression */ || + parent.kind === 203 /* PostfixUnaryExpression */ || + parent.kind === 205 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -93523,11 +94784,14 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 9 /* BigIntLiteral */) { + return 25 /* bigintLiteral */; } - else if (tokenKind === 12 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* StringLiteral */) { + // TODO: GH#18217 + return token.parent.kind === 267 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + } + else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -93535,38 +94799,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 10 /* JsxText */) { + else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 71 /* Identifier */) { + else if (tokenKind === 72 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 149 /* Parameter */: + case 151 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -93600,37 +94864,245 @@ var ts; (function (ts) { var Completions; (function (Completions) { - var PathCompletions; - (function (PathCompletions) { - function nameAndKind(name, kind) { - return { name: name, kind: kind }; + var StringCompletions; + (function (StringCompletions) { + function getStringLiteralCompletions(sourceFile, position, contextToken, checker, options, host, log, preferences) { + if (ts.isInReferenceComment(sourceFile, position)) { + var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); + return entries && convertPathCompletions(entries); + } + if (ts.isInString(sourceFile, position, contextToken)) { + return !contextToken || !ts.isStringLiteralLike(contextToken) + ? undefined + : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host), sourceFile, checker, log, preferences); + } + } + StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; + function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { + if (completion === undefined) { + return undefined; + } + switch (completion.kind) { + case 0 /* Paths */: + return convertPathCompletions(completion.paths); + case 1 /* Properties */: { + var entries = []; + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; + } + case 2 /* Types */: { + var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; + } + default: + return ts.Debug.assertNever(completion); + } + } + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + if (!contextToken || !ts.isStringLiteralLike(contextToken)) + return undefined; + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); + } + StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; + function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { + switch (completion.kind) { + case 0 /* 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 */: { + 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; + default: + return ts.Debug.assertNever(completion); + } + } + function convertPathCompletions(pathCompletions) { + var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. + var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. + var entries = pathCompletions.map(function (_a) { + var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension; + return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span }); + }); + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + } + 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 undefined: return "" /* none */; + default: + return ts.Debug.assertNever(extension); + } + } + var StringLiteralCompletionKind; + (function (StringLiteralCompletionKind) { + StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; + })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + var parent = node.parent; + switch (parent.kind) { + case 182 /* LiteralType */: + switch (parent.parent.kind) { + case 164 /* TypeReference */: + return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; + case 180 /* IndexedAccessType */: + // Get all apparent property names + // i.e. interface Foo { + // foo: string; + // bar: string; + // } + // let x: Foo["/*completion position*/"] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); + case 183 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; + case 173 /* UnionType */: { + if (!ts.isTypeReferenceNode(parent.parent.parent)) + return undefined; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + } + default: + return undefined; + } + case 275 /* PropertyAssignment */: + if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); + } + return fromContextualType(); + case 190 /* ElementAccessExpression */: { + var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; + if (node === argumentExpression) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); + } + return undefined; + } + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); + } + // falls through (is `require("")` or `import("")`) + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 259 /* 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) }; + 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 }; + } + } + function getAlreadyUsedTypesInStringLiteralUnion(union, current) { + return ts.mapDefined(union.types, function (type) { + return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; + }); + } + function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { + var isNewIdentifier = false; + var uniques = ts.createMap(); + var candidates = []; + checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); + var types = ts.flatMap(candidates, function (candidate) { + if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + return; + var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + return getStringLiteralTypes(type, uniques); + }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + } + function stringLiteralCompletionsFromProperties(type) { + return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: ts.hasIndexSignature(type) }; + } + function getStringLiteralTypes(type, uniques) { + if (uniques === void 0) { uniques = ts.createMap(); } + if (!type) + 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; + } + function nameAndKind(name, kind, extension) { + return { name: name, kind: kind, extension: extension }; + } + function directoryResult(name) { + return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); return names.map(function (_a) { - var name = _a.name, kind = _a.kind; - return ({ name: name, kind: kind, span: span }); + var name = _a.name, kind = _a.kind, extension = _a.extension; + return ({ name: name, kind: kind, extension: extension, span: span }); }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } - PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); - if (compilerOptions.rootDirs) { - return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, compilerOptions, host, scriptPath); - } - else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, host, scriptPath); - } + return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + } + function getExtensionOptions(compilerOptions, includeExtensions) { + if (includeExtensions === void 0) { includeExtensions = false; } + return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; + } + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { + var extensionOptions = getExtensionOptions(compilerOptions); + if (compilerOptions.rootDirs) { + return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); } } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -93653,21 +95125,22 @@ var ts; // Now find a path for each potential directory that is to be merged with the one containing the script return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, compilerOptions, host, exclude) { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); var result = []; for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, host, exclude, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude, result); } return result; } /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, host, exclude, result) { + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { + var extensions = _a.extensions, includeExtensions = _a.includeExtensions; if (result === void 0) { result = []; } if (fragment === undefined) { fragment = ""; @@ -93688,55 +95161,53 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_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 */) { - continue; - } - var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles.has(foundFileName)) { - foundFiles.set(foundFileName, true); - } + if (!tryDirectoryExists(host, baseDirectory)) + return result; + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); // maps file to its extension + 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 */) { + continue; } - ts.forEachKey(foundFiles, function (foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */)); - }); + var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { - var directory = directories_1[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - if (directoryName !== "@types") { - result.push(nameAndKind(directoryName, "directory" /* directory */)); - } + foundFiles.forEach(function (ext, foundFile) { + result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { + var directory = directories_1[_b]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + if (directoryName !== "@types") { + result.push(directoryResult(directoryName)); } } - // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); - if (packageJsonPath) { - var packageJson = ts.readJson(packageJsonPath, host); - var typesVersions = packageJson.typesVersions; - if (typeof typesVersions === "object") { - var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); - var versionPaths = versionResult && versionResult.paths; - var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); - if (versionPaths) { - addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); - } + } + // check for a version redirect + var packageJsonPath = findPackageJson(baseDirectory, host); + if (packageJsonPath) { + var packageJson = ts.readJson(packageJsonPath, host); + var typesVersions = packageJson.typesVersions; + if (typeof typesVersions === "object") { + var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); + var versionPaths = versionResult && versionResult.paths; + var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); + if (versionPaths) { + addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); } } } @@ -93748,15 +95219,15 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_1 = function (name, kind) { + var _loop_1 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { - result.push(nameAndKind(name, kind)); + result.push(nameAndKind(name, kind, extension)); } }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { - var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_1(name, kind); + var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; + _loop_1(name, kind, extension); } } } @@ -93771,21 +95242,21 @@ var ts; function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; var result = []; - var fileExtensions = getSupportedExtensionsForModuleResolution(compilerOptions); + var extensionOptions = getExtensionOptions(compilerOptions); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); - getCompletionEntriesForDirectoryFragment(fragment, absolute, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, fileExtensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); } } - var fragmentDirectory = containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + 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 */)); + result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, result); + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) { // 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.) @@ -93794,7 +95265,7 @@ var ts; var _loop_2 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); + result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -93806,13 +95277,16 @@ var ts; ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); if (tryDirectoryExists(host, nodeModules)) { - getCompletionEntriesForDirectoryFragment(fragment, nodeModules, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); } } return result; } + function getFragmentDirectory(fragment) { + return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + } function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. @@ -93824,7 +95298,7 @@ var ts; return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; + return ts.startsWith(name, fragment) ? [directoryResult(name)] : ts.emptyArray; } } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { @@ -93852,15 +95326,20 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]).map(function (name) { return ({ name: name, kind: "script" /* scriptElement */ }); }); - var directories = tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }).map(function (name) { return ({ name: name, kind: "directory" /* directory */ }); }); - // Trim away prefix and suffix - return ts.mapDefined(ts.concatenate(matches, directories), function (_a) { - var name = _a.name, kind = _a.kind; - var normalizedMatch = ts.normalizePath(name); - var inner = withoutStartAndEnd(normalizedMatch, completePrefix, normalizedSuffix); - return inner !== undefined ? { name: removeLeadingDirectorySeparator(ts.removeFileExtension(inner)), kind: kind } : undefined; + var matches = ts.mapDefined(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); }); + var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var name = trimPrefixAndSuffix(dir); + return name === undefined ? undefined : directoryResult(name); + }); + return matches.concat(directories); + function trimPrefixAndSuffix(path) { + var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); + return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); + } } function withoutStartAndEnd(s, start, end) { return ts.startsWith(s, start) && ts.endsWith(s, end) ? s.slice(start.length, s.length - end.length) : undefined; @@ -93895,62 +95374,48 @@ 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, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, host, sourceFile.path) - : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath) - : undefined; - return names && addReplacementSpans(toComplete, range.pos + prefix.length, names); + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, /*includeExtensions*/ true), host, sourceFile.path) + : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) + : ts.Debug.fail(); + return addReplacementSpans(toComplete, range.pos + prefix.length, names); } - PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; - function getCompletionEntriesFromTypings(host, options, scriptPath, result) { + function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var typesName = _a[_i]; - var moduleName = ts.unmangleScopedPackageName(typesName); - pushResult(moduleName); - } + var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + getCompletionEntriesFromDirectories(root); } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch ( /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */_b) { /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */ } - if (typeRoots) { - for (var _c = 0, typeRoots_1 = typeRoots; _c < typeRoots_1.length; _c++) { - var root = typeRoots_1[_c]; - getCompletionEntriesFromDirectories(root); - } - } - // Also get all @types typings installed in visible node_modules directories - for (var _d = 0, _e = findPackageJsons(scriptPath, host); _d < _e.length; _d++) { - var packageJson = _e[_d]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(typesDir); - } + // Also get all @types typings installed in visible node_modules directories + for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + var packageJson = _b[_a]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - ts.Debug.assert(!!host.getDirectories); - if (tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_2 = directories; _i < directories_2.length; _i++) { - var typeDirectory = directories_2[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - var directoryName = ts.getBaseFileName(typeDirectory); - var moduleName = ts.unmangleScopedPackageName(directoryName); - pushResult(moduleName); + if (!tryDirectoryExists(host, directory)) + return; + for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + var typeDirectoryName = _a[_i]; + var packageName = ts.unmangleScopedPackageName(typeDirectoryName); + if (options.types && !ts.contains(options.types, packageName)) + continue; + if (fragmentDirectory === undefined) { + if (!seen.has(packageName)) { + result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + seen.set(packageName, true); + } + } + else { + var baseDirectory = ts.combinePaths(directory, typeDirectoryName); + var remainingFragment = ts.tryRemoveDirectoryPrefix(fragmentDirectory, packageName, ts.hostGetCanonicalFileName(host)); + if (remainingFragment !== undefined) { + getCompletionEntriesForDirectoryFragment(remainingFragment, baseDirectory, extensionOptions, host, /*exclude*/ undefined, result); } } - } - } - function pushResult(moduleName) { - if (!seen.has(moduleName)) { - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); - seen.set(moduleName, true); } } } @@ -94040,27 +95505,27 @@ var ts; return tryIOAndConsumeErrors(host, host.fileExists, path); } function tryDirectoryExists(host, path) { - try { - return ts.directoryProbablyExists(path, host); - } - catch ( /*ignore*/_a) { /*ignore*/ } - return false; + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + function tryAndIgnoreErrors(cb) { try { - return toApply && toApply.apply(host, args); + return cb(); + } + catch (_a) { + return undefined; } - catch ( /*ignore*/_a) { /*ignore*/ } - return undefined; } function containsSlash(fragment) { return ts.stringContains(fragment, ts.directorySeparator); } - })(PathCompletions = Completions.PathCompletions || (Completions.PathCompletions = {})); + })(StringCompletions = Completions.StringCompletions || (Completions.StringCompletions = {})); })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -94100,20 +95565,15 @@ var ts; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); - if (ts.isInReferenceComment(sourceFile, position)) { - var entries = Completions.PathCompletions.getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); - return entries && convertPathCompletions(entries); - } var contextToken = ts.findPrecedingToken(position, sourceFile); if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) return undefined; - if (ts.isInString(sourceFile, position, contextToken)) { - return !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host), sourceFile, typeChecker, log, preferences); + var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); + if (stringCompletions) { + return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 72 /* BreakKeyword */ || contextToken.kind === 77 /* ContinueKeyword */ || contextToken.kind === 71 /* Identifier */)) { + && (contextToken.kind === 73 /* BreakKeyword */ || contextToken.kind === 78 /* ContinueKeyword */ || contextToken.kind === 72 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); @@ -94136,35 +95596,6 @@ var ts; } } Completions.getCompletionsAtPosition = getCompletionsAtPosition; - function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { - if (completion === undefined) { - return undefined; - } - switch (completion.kind) { - case 0 /* Paths */: - return convertPathCompletions(completion.paths); - case 1 /* Properties */: { - var entries = []; - getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; - } - case 2 /* Types */: { - var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; - } - default: - return ts.Debug.assertNever(completion); - } - } - function convertPathCompletions(pathCompletions) { - var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. - var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. - var entries = pathCompletions.map(function (_a) { - var name = _a.name, kind = _a.kind, span = _a.span; - return ({ name: name, kind: kind, kindModifiers: "" /* none */, sortText: "0", replacementSpan: span }); - }); - return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - } function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } @@ -94178,7 +95609,7 @@ var ts; // The completion list at "1" will contain "div>" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 29 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -94243,7 +95674,9 @@ var ts; } }); } - var completionNameForLiteral = JSON.stringify; + var completionNameForLiteral = function (literal) { + return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal); + }; function createCompletionEntryForLiteral(literal) { return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" }; } @@ -94256,13 +95689,13 @@ var ts; var insertText; var replacementSpan; if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + quote(name, preferences) + "]" : "this." + name; + insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 23 /* DotToken */, sourceFile); + insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -94297,21 +95730,6 @@ var ts; replacementSpan: replacementSpan, }; } - function quote(text, preferences) { - if (/^\d+$/.test(text)) { - return text; - } - var quoted = JSON.stringify(text); - switch (preferences.quotePreference) { - case undefined: - case "double": - return quoted; - case "single": - return "'" + ts.stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; - default: - return ts.Debug.assertNever(preferences.quotePreference); - } - } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; @@ -94349,6 +95767,7 @@ var ts; log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); return uniques; } + Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { var entries = getLabelStatementCompletions(node); if (entries.length) { @@ -94379,131 +95798,6 @@ var ts; } return entries; } - var StringLiteralCompletionKind; - (function (StringLiteralCompletionKind) { - StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; - })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { - var parent = node.parent; - switch (parent.kind) { - case 180 /* LiteralType */: - switch (parent.parent.kind) { - case 162 /* TypeReference */: - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 178 /* IndexedAccessType */: - // Get all apparent property names - // i.e. interface Foo { - // foo: string; - // bar: string; - // } - // let x: Foo["/*completion position*/"] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 181 /* ImportType */: - return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 171 /* UnionType */: { - if (!ts.isTypeReferenceNode(parent.parent.parent)) - return undefined; - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; - } - default: - return undefined; - } - case 273 /* PropertyAssignment */: - if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); - } - return fromContextualType(); - case 188 /* ElementAccessExpression */: { - var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; - if (node === argumentExpression) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); - } - return undefined; - } - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); - } - // falls through (is `require("")` or `import("")`) - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 257 /* 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: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - 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(getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; - } - } - function getAlreadyUsedTypesInStringLiteralUnion(union, current) { - return ts.mapDefined(union.types, function (type) { - return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; - }); - } - function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { - var isNewIdentifier = false; - var uniques = ts.createMap(); - var candidates = []; - checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); - var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) - return; - var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); - return getStringLiteralTypes(type, uniques); - }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; - } - function stringLiteralCompletionsFromProperties(type) { - return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: hasIndexSignature(type) }; - } - function getStringLiteralTypes(type, uniques) { - if (uniques === void 0) { uniques = ts.createMap(); } - if (!type) - return ts.emptyArray; - type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 512 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; - } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); @@ -94542,10 +95836,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - var stringLiteralCompletions = !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host); - return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); // TODO: GH#18217 + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); @@ -94589,25 +95880,11 @@ var ts; }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } - function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { - switch (completion.kind) { - case 0 /* Paths */: { - var match = ts.find(completion.paths, function (p) { return p.name === name; }); - return match && createCompletionDetails(name, "" /* none */, match.kind, [ts.textPart(name)]); - } - case 1 /* Properties */: { - var match = ts.find(completion.symbols, function (s) { return s.name === name; }); - return match && createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); - } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; - default: - return ts.Debug.assertNever(completion); - } - } + Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } + Completions.createCompletionDetails = createCompletionDetails; function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { @@ -94638,7 +95915,7 @@ var ts; CompletionKind[CompletionKind["MemberLike"] = 3] = "MemberLike"; CompletionKind[CompletionKind["String"] = 4] = "String"; CompletionKind[CompletionKind["None"] = 5] = "None"; - })(CompletionKind || (CompletionKind = {})); + })(CompletionKind = Completions.CompletionKind || (Completions.CompletionKind = {})); function getRecommendedCompletion(previousToken, contextualType, checker) { // For a union, return the first one with a recommended completion. return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { @@ -94652,56 +95929,36 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 71 /* Identifier */: - return getContextualTypeFromParent(previousToken, checker); - case 58 /* EqualsToken */: + case 72 /* Identifier */: + return ts.getContextualTypeFromParent(previousToken, checker); + case 59 /* EqualsToken */: switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return checker.getContextualType(parent); - case 73 /* CaseKeyword */: - return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); - case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + case 74 /* CaseKeyword */: + return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); + case 18 /* OpenBraceToken */: + return ts.isJsxExpression(parent) && parent.parent.kind !== 260 /* JsxElement */ ? 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 === 26 /* CommaToken */ ? 1 : 0)) - : isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind) + ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* 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) : checker.getContextualType(previousToken); } } - function getContextualTypeFromParent(node, checker) { - var parent = node.parent; - switch (parent.kind) { - case 190 /* NewExpression */: - return checker.getContextualType(parent); - case 202 /* 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 269 /* CaseClause */: - return parent.expression === node ? getSwitchedType(parent, checker) : undefined; - default: - return checker.getContextualType(node); - } - } - function getSwitchedType(caseClause, checker) { - return checker.getTypeAtLocation(caseClause.parent.parent.expression); - } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) @@ -94709,7 +95966,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -94760,11 +96017,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 303 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -94811,21 +96068,21 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 23 /* DotToken */) { + if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: node = parent.left; break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: node = parent.name; break; - case 181 /* ImportType */: - case 212 /* MetaProperty */: + case 183 /* ImportType */: + case 214 /* MetaProperty */: node = parent; break; default: @@ -94838,56 +96095,56 @@ var ts; // // 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 === 187 /* PropertyAccessExpression */) { + if (parent && parent.kind === 189 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { + case 30 /* GreaterThanToken */: + if (currentToken.parent.kind === 260 /* JsxElement */ || currentToken.parent.kind === 262 /* JsxOpeningElement */) { location = currentToken; } break; - case 41 /* SlashToken */: - if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { + case 42 /* SlashToken */: + if (currentToken.parent.kind === 261 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 261 /* JsxClosingElement */: - if (contextToken.kind === 41 /* SlashToken */) { + case 263 /* JsxClosingElement */: + if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: - case 260 /* JsxOpeningElement */: - if (contextToken.kind === 27 /* LessThanToken */) { + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: + case 262 /* JsxOpeningElement */: + if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: switch (previousToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: isJsxInitializer = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: // For `
` 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, 58 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 59 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -94935,11 +96192,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: - case 298 /* JSDocReturnTag */: - case 300 /* JSDocTypeTag */: - case 302 /* JSDocTypedefTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 304 /* JSDocTypedefTag */: return true; default: return false; @@ -94979,15 +96236,15 @@ 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.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 94 /* NewKeyword */ || node.keywordToken === 91 /* ImportKeyword */)) { - var completion = (node.keywordToken === 94 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 95 /* NewKeyword */ || node.keywordToken === 92 /* ImportKeyword */)) { + var completion = (node.keywordToken === 95 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -95008,7 +96265,7 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 183 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -95062,10 +96319,10 @@ var ts; function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element - var attrsType = jsxContainer && typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); + var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) return 0 /* Continue */; - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); + symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -95111,7 +96368,7 @@ var ts; var symbolMeanings = 67897832 /* Type */ | 67220415 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -95147,10 +96404,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 277 /* SourceFile */: - case 204 /* TemplateExpression */: - case 268 /* JsxExpression */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 206 /* TemplateExpression */: + case 270 /* JsxExpression */: + case 218 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -95186,41 +96443,35 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 103 /* TypeOfKeyword */ && - (contextToken.parent.kind === 165 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 104 /* TypeOfKeyword */ && + (contextToken.parent.kind === 167 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 56 /* ColonToken */: - return parentKind === 152 /* PropertyDeclaration */ || - parentKind === 151 /* PropertySignature */ || - parentKind === 149 /* Parameter */ || - parentKind === 235 /* VariableDeclaration */ || + case 57 /* ColonToken */: + return parentKind === 154 /* PropertyDeclaration */ || + parentKind === 153 /* PropertySignature */ || + parentKind === 151 /* Parameter */ || + parentKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 58 /* EqualsToken */: - return parentKind === 240 /* TypeAliasDeclaration */; - case 118 /* AsKeyword */: - return parentKind === 210 /* AsExpression */; + case 59 /* EqualsToken */: + return parentKind === 242 /* TypeAliasDeclaration */; + case 119 /* AsKeyword */: + return parentKind === 212 /* AsExpression */; } } return false; } - function symbolCanBeReferencedAtTypeLocation(symbol) { - symbol = symbol.exportSymbol || symbol; - // This is an alias, follow what it aliases - symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & 67897832 /* Type */) { - return true; - } - if (symbol.flags & 1536 /* Module */) { - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - // If the exported symbols contains type, - // symbol can be referenced at locations where type is allowed - return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); - } - return false; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { + if (seenModules === void 0) { seenModules = ts.createMap(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); + return !!(sym.flags & 67897832 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); @@ -95248,13 +96499,16 @@ var ts; // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. // This is just to avoid adding duplicate completion entries. // - // If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. - // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { + || ts.some(symbol.declarations, function (d) { + // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); + })) { continue; } - var isDefaultExport = symbol.name === "default" /* Default */; + var isDefaultExport = symbol.escapedName === "default" /* Default */; if (isDefaultExport) { symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; } @@ -95308,15 +96562,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 10 /* JsxText */) { + if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { + if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 262 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; + if (contextToken.parent.kind === 263 /* JsxClosingElement */ || contextToken.parent.kind === 261 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 260 /* JsxElement */; } } return false; @@ -95326,41 +96580,41 @@ var ts; var containingNodeKind = previousToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { - case 26 /* CommaToken */: - return containingNodeKind === 189 /* CallExpression */ // func( a, | - || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 190 /* NewExpression */ // new C(a, | - || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| - case 19 /* OpenParenToken */: - return containingNodeKind === 189 /* CallExpression */ // func( | - || containingNodeKind === 155 /* Constructor */ // constructor( | - || containingNodeKind === 190 /* NewExpression */ // new C(a| - || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 21 /* OpenBracketToken */: - return containingNodeKind === 185 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 129 /* ModuleKeyword */: // module | - case 130 /* NamespaceKeyword */: // namespace | + case 27 /* CommaToken */: + return containingNodeKind === 191 /* CallExpression */ // func( a, | + || containingNodeKind === 157 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 192 /* NewExpression */ // new C(a, | + || containingNodeKind === 187 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 204 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 165 /* FunctionType */; // var x: (s: string, list| + case 20 /* OpenParenToken */: + return containingNodeKind === 191 /* CallExpression */ // func( | + || containingNodeKind === 157 /* Constructor */ // constructor( | + || containingNodeKind === 192 /* NewExpression */ // new C(a| + || containingNodeKind === 195 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 177 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* OpenBracketToken */: + return containingNodeKind === 187 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 162 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 149 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 130 /* ModuleKeyword */: // module | + case 131 /* NamespaceKeyword */: // namespace | return true; - case 23 /* DotToken */: - return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| - case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | - case 58 /* EqualsToken */: - return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 202 /* BinaryExpression */; // x = a| - case 14 /* TemplateHead */: - return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| - case 15 /* TemplateMiddle */: - return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */; // class A{ public | + case 24 /* DotToken */: + return containingNodeKind === 244 /* ModuleDeclaration */; // module A.| + case 18 /* OpenBraceToken */: + return containingNodeKind === 240 /* ClassDeclaration */; // class A{ | + case 59 /* EqualsToken */: + return containingNodeKind === 237 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 204 /* BinaryExpression */; // x = a| + case 15 /* TemplateHead */: + return containingNodeKind === 206 /* TemplateExpression */; // `aa ${| + case 16 /* TemplateMiddle */: + return containingNodeKind === 216 /* TemplateSpan */; // `aa ${10} dd ${| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -95387,16 +96641,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 188 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; - isNewIdentifierLocation = hasIndexSignature(typeForObject); + isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 184 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -95407,12 +96661,12 @@ 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 === 225 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 227 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 151 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 154 /* MethodDeclaration */ || rootDeclaration.parent.kind === 157 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 156 /* MethodDeclaration */ || rootDeclaration.parent.kind === 159 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -95448,13 +96702,13 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { // `import { |` or `import { a as 0, | }` - var namedImportsOrExports = contextToken && (contextToken.kind === 17 /* OpenBraceToken */ || contextToken.kind === 26 /* CommaToken */) + var namedImportsOrExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 252 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -95477,7 +96731,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 39 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* 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)) @@ -95485,7 +96739,7 @@ var ts; var classElement = contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 71 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 72 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -95514,15 +96768,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 17 /* OpenBraceToken */: // const x = { | - case 26 /* CommaToken */: // const x = { a: 0, | + case 18 /* OpenBraceToken */: // const x = { | + case 27 /* CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 71 /* Identifier */: + case 72 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -95541,8 +96795,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 19 /* OpenParenToken */: - case 26 /* CommaToken */: + case 20 /* OpenParenToken */: + case 27 /* CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -95572,17 +96826,17 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 28 /* LessThanSlashToken */: - case 41 /* SlashToken */: - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 266 /* JsxAttributes */: - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { + case 29 /* LessThanSlashToken */: + case 42 /* SlashToken */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 268 /* JsxAttributes */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 261 /* JsxSelfClosingElement */ || parent.kind === 262 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 265 /* JsxAttribute */) { + else if (parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95593,8 +96847,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 9 /* StringLiteral */: - if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { + case 10 /* StringLiteral */: + if (parent && ((parent.kind === 267 /* JsxAttribute */) || (parent.kind === 269 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95602,10 +96856,10 @@ var ts; return parent.parent.parent; } break; - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: if (parent && - parent.kind === 268 /* JsxExpression */ && - parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { + parent.kind === 270 /* JsxExpression */ && + parent.parent && parent.parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95613,7 +96867,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 269 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95632,65 +96886,65 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 26 /* CommaToken */: - return containingNodeKind === 235 /* VariableDeclaration */ || - containingNodeKind === 236 /* VariableDeclarationList */ || - containingNodeKind === 217 /* VariableStatement */ || - containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | + case 27 /* CommaToken */: + return containingNodeKind === 237 /* VariableDeclaration */ || + containingNodeKind === 238 /* VariableDeclarationList */ || + containingNodeKind === 219 /* VariableStatement */ || + containingNodeKind === 243 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 23 /* DotToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| - case 56 /* ColonToken */: - return containingNodeKind === 184 /* BindingElement */; // var {x :html| - case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| - case 19 /* OpenParenToken */: - return containingNodeKind === 272 /* CatchClause */ || + case 24 /* DotToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [.| + case 57 /* ColonToken */: + return containingNodeKind === 186 /* BindingElement */; // var {x :html| + case 22 /* OpenBracketToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [x| + case 20 /* OpenParenToken */: + return containingNodeKind === 274 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 17 /* OpenBraceToken */: - return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | - case 27 /* LessThanToken */: - return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | - containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | + case 18 /* OpenBraceToken */: + return containingNodeKind === 243 /* EnumDeclaration */; // enum a { | + case 28 /* LessThanToken */: + return containingNodeKind === 240 /* ClassDeclaration */ || // class A< | + containingNodeKind === 209 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 241 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 242 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 115 /* StaticKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 24 /* DotDotDotToken */: - return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 118 /* AsKeyword */: - return containingNodeKind === 251 /* ImportSpecifier */ || - containingNodeKind === 255 /* ExportSpecifier */ || - containingNodeKind === 249 /* NamespaceImport */; - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* DotDotDotToken */: + return containingNodeKind === 151 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 185 /* ArrayBindingPattern */); // var [...z| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 151 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 119 /* AsKeyword */: + return containingNodeKind === 253 /* ImportSpecifier */ || + containingNodeKind === 257 /* ExportSpecifier */ || + containingNodeKind === 251 /* NamespaceImport */; + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 109 /* InterfaceKeyword */: - case 89 /* FunctionKeyword */: - case 104 /* VarKeyword */: - case 91 /* ImportKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 116 /* YieldKeyword */: - case 139 /* TypeKeyword */: // type htm| + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 110 /* InterfaceKeyword */: + case 90 /* FunctionKeyword */: + case 105 /* VarKeyword */: + case 92 /* ImportKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 117 /* YieldKeyword */: + case 140 /* TypeKeyword */: // type htm| return true; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -95711,22 +96965,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 117 /* AbstractKeyword */: - case 75 /* ClassKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 83 /* EnumKeyword */: - case 89 /* FunctionKeyword */: - case 109 /* InterfaceKeyword */: - case 110 /* LetKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 115 /* StaticKeyword */: - case 104 /* VarKeyword */: - case 116 /* YieldKeyword */: + case 118 /* AbstractKeyword */: + case 76 /* ClassKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 84 /* EnumKeyword */: + case 90 /* FunctionKeyword */: + case 110 /* InterfaceKeyword */: + case 111 /* LetKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 116 /* StaticKeyword */: + case 105 /* VarKeyword */: + case 117 /* YieldKeyword */: return true; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -95736,7 +96990,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 155 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 157 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -95759,12 +97013,12 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 273 /* PropertyAssignment */ && - m.kind !== 274 /* ShorthandPropertyAssignment */ && - m.kind !== 184 /* BindingElement */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 275 /* PropertyAssignment */ && + m.kind !== 276 /* ShorthandPropertyAssignment */ && + m.kind !== 186 /* BindingElement */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -95774,7 +97028,7 @@ var ts; var existingName = void 0; if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 71 /* Identifier */) { + if (m.propertyName.kind === 72 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -95799,10 +97053,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 !== 152 /* PropertyDeclaration */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 154 /* PropertyDeclaration */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -95842,7 +97096,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 265 /* JsxAttribute */) { + if (attr.kind === 267 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -95886,7 +97140,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72 /* FirstKeyword */; i <= 145 /* LastKeyword */; i++) { + for (var i = 73 /* FirstKeyword */; i <= 147 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -95903,8 +97157,8 @@ var ts; case 0 /* None */: return false; case 1 /* All */: - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 124 /* DeclareKeyword */ || kind === 129 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 140 /* UndefinedKeyword */; + return kind === 121 /* AsyncKeyword */ || 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 125 /* DeclareKeyword */ || kind === 130 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 141 /* UndefinedKeyword */; case 2 /* ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); case 3 /* InterfaceElementKeywords */: @@ -95921,37 +97175,26 @@ var ts; })); } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 132 /* ReadonlyKeyword */; + return kind === 133 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 117 /* AbstractKeyword */: - case 123 /* ConstructorKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 120 /* AsyncKeyword */: + case 118 /* AbstractKeyword */: + case 124 /* ConstructorKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 121 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; } - function isEqualityOperatorKind(kind) { - switch (kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - return true; - default: - return false; - } - } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { var jsdoc = ts.findAncestor(node, ts.isJSDoc); @@ -95961,7 +97204,7 @@ var ts; return contextualType.isUnion() ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - return !(memberType.flags & 32764 /* Primitive */ || + return !(memberType.flags & 131068 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); @@ -95984,31 +97227,31 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 304 /* SyntaxList */: + case 306 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { return cls; } } if (!contextToken) return undefined; switch (contextToken.kind) { - case 25 /* SemicolonToken */: // class c {getValue(): number; | } - case 18 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SemicolonToken */: // class c {getValue(): number; | } + case 19 /* CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 17 /* OpenBraceToken */: // class c { | - case 26 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* OpenBraceToken */: // class c { | + case 27 /* CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) return undefined; var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 39 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -96016,9 +97259,6 @@ var ts; function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); } - function hasIndexSignature(type) { - return !!type.getStringIndexType() || !!type.getNumberIndexType(); - } function isValidTrigger(sourceFile, triggerCharacter, contextToken, position) { switch (triggerCharacter) { case ".": @@ -96028,14 +97268,14 @@ var ts; case "'": case "`": // Only automatically bring up completions if this is an opening quote. - return !!contextToken && isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; + return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 41 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -96044,17 +97284,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function isStringLiteralOrTemplate(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - return true; - default: - return false; - } - } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -96107,40 +97336,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 90 /* IfKeyword */: - case 82 /* ElseKeyword */: + case 91 /* IfKeyword */: + case 83 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 96 /* ReturnKeyword */: + case 97 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 102 /* TryKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: - var tryStatement = node.kind === 74 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 103 /* TryKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: + var tryStatement = node.kind === 75 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 73 /* CaseKeyword */: - case 79 /* DefaultKeyword */: + case 74 /* CaseKeyword */: + case 80 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 72 /* BreakKeyword */: - case 77 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 78 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 88 /* ForKeyword */: - case 106 /* WhileKeyword */: - case 81 /* DoKeyword */: + case 89 /* ForKeyword */: + case 107 /* WhileKeyword */: + case 82 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 123 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [123 /* ConstructorKeyword */]); - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [125 /* GetKeyword */, 136 /* SetKeyword */]); - case 121 /* AwaitKeyword */: + case 124 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [124 /* ConstructorKeyword */]); + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [126 /* GetKeyword */, 137 /* SetKeyword */]); + case 122 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 116 /* YieldKeyword */: + case 117 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -96183,7 +97412,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -96215,16 +97444,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 230 /* SwitchStatement */: - if (statement.kind === 226 /* ContinueStatement */) { + case 232 /* SwitchStatement */: + if (statement.kind === 228 /* ContinueStatement */) { return false; } // falls through - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -96240,11 +97469,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 216 /* Block */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 218 /* Block */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -96252,12 +97481,12 @@ var ts; else { return container.statements; } - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: 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. @@ -96288,12 +97517,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 89 /* ForKeyword */, 107 /* WhileKeyword */, 82 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 221 /* DoStatement */) { + if (loopNode.kind === 223 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 107 /* WhileKeyword */)) { break; } } @@ -96301,7 +97530,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */, 77 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */, 78 /* ContinueKeyword */); } }); return keywords; @@ -96310,13 +97539,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -96324,13 +97553,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 98 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 99 /* 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(), 73 /* CaseKeyword */, 79 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 74 /* CaseKeyword */, 80 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */); } }); }); @@ -96338,13 +97567,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 102 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 103 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 75 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 87 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 88 /* FinallyKeyword */); } return keywords; } @@ -96355,13 +97584,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* 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, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -96373,11 +97602,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* 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, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -96389,13 +97618,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 120 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 121 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 122 /* AwaitKeyword */); } }); }); @@ -96410,7 +97639,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 116 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 117 /* YieldKeyword */); } }); }); @@ -96429,7 +97658,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 === 82 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 83 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -96464,10 +97693,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], 90 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 91 /* 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], 82 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 83 /* ElseKeyword */)) { break; } } @@ -96500,13 +97729,6 @@ var ts; // for those settings. var buckets = ts.createMap(); var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets.get(key); - if (!bucket && createIfMissing) { - buckets.set(key, bucket = ts.createMap()); - } - return bucket; // TODO: GH#18217 - } function reportStats() { var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { var entries = buckets.get(name); @@ -96542,7 +97764,7 @@ var ts; return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); + var bucket = ts.getOrUpdate(buckets, key, ts.createMap); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; if (!entry && externalCache) { @@ -96596,8 +97818,7 @@ var ts; return releaseDocumentWithKey(path, key); } function releaseDocumentWithKey(path, key) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ false); - ts.Debug.assert(bucket !== undefined); + var bucket = ts.Debug.assertDefined(buckets.get(key)); var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); @@ -96691,12 +97912,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 237 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { directImports.push(name); break; } @@ -96705,22 +97926,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 71 /* Identifier */: // for 'const x = require("y"); + case 72 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 251 /* 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 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -96730,7 +97951,7 @@ var ts; directImports.push(direct); } break; - case 181 /* ImportType */: + case 183 /* ImportType */: directImports.push(direct); break; default: @@ -96747,7 +97968,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -96802,17 +98023,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 246 /* ImportEqualsDeclaration */) { + if (decl.kind === 248 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 71 /* Identifier */) { + if (decl.kind === 72 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 181 /* ImportType */) { + if (decl.kind === 183 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -96824,20 +98045,20 @@ var ts; return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 253 /* ExportDeclaration */) { + if (decl.kind === 255 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -96887,7 +98108,7 @@ var ts; } } else { - var localSymbol = element.kind === 255 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 257 /* 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); @@ -96916,7 +98137,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.kind === 277 /* SourceFile */) { + if (searchSourceFile.kind === 279 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -96964,7 +98185,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 === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -96979,15 +98200,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: { + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -97011,7 +98232,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 187 /* PropertyAccessExpression */) { + if (parent.kind === 189 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -97133,10 +98354,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 235 /* VariableDeclaration */) { + if (parent.kind === 237 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 274 /* CatchClause */ ? undefined : p.parent.parent.kind === 219 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -97145,15 +98366,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -97186,21 +98407,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 277 /* SourceFile */) { + if (parent.kind === 279 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 244 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 259 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -97252,18 +98473,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* 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 === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 97 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 98 /* 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); @@ -97325,7 +98546,7 @@ var ts; } function getDefinitionKindAndDisplayParts(symbol, checker, node) { var meaning = FindAllReferences.Core.getIntersectingMeaningFromDeclarations(node, symbol); - var enclosingDeclaration = ts.firstOrUndefined(symbol.declarations) || node; + var enclosingDeclaration = symbol.declarations && ts.firstOrUndefined(symbol.declarations) || node; var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, enclosingDeclaration.getSourceFile(), enclosingDeclaration, enclosingDeclaration, meaning), displayParts = _a.displayParts, symbolKind = _a.symbolKind; return { displayParts: displayParts, kind: symbolKind }; } @@ -97343,7 +98564,7 @@ var ts; textSpan: textSpan, fileName: fileName, isWriteAccess: isWriteAccessForReference(node), - isDefinition: node.kind === 79 /* DefaultKeyword */ + isDefinition: node.kind === 80 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined, @@ -97398,16 +98619,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 207 /* ClassExpression */) { + else if (node.kind === 209 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] }; } else { @@ -97433,7 +98654,7 @@ var ts; function getTextSpan(node, sourceFile) { var start = node.getStart(sourceFile); var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { start += 1; end -= 1; } @@ -97442,7 +98663,7 @@ var ts; /** 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 === 79 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 80 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -97453,46 +98674,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 202 /* BinaryExpression */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 79 /* DefaultKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 255 /* ExportSpecifier */: - case 248 /* ImportClause */: // default import - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 239 /* InterfaceDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 265 /* JsxAttribute */: - case 242 /* ModuleDeclaration */: - case 245 /* NamespaceExportDeclaration */: - case 249 /* NamespaceImport */: - case 149 /* Parameter */: - case 274 /* ShorthandPropertyAssignment */: - case 240 /* TypeAliasDeclaration */: - case 148 /* TypeParameter */: + case 204 /* BinaryExpression */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 80 /* DefaultKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 257 /* ExportSpecifier */: + case 250 /* ImportClause */: // default import + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 241 /* InterfaceDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 267 /* JsxAttribute */: + case 244 /* ModuleDeclaration */: + case 247 /* NamespaceExportDeclaration */: + case 251 /* NamespaceImport */: + case 151 /* Parameter */: + case 276 /* ShorthandPropertyAssignment */: + case 242 /* TypeAliasDeclaration */: + case 150 /* TypeParameter */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return !!decl.body; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 153 /* MethodSignature */: - case 151 /* PropertySignature */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 155 /* MethodSignature */: + case 153 /* PropertySignature */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -97529,6 +98750,9 @@ var ts; // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. return !options.implementations && ts.isStringLiteral(node) ? getReferencesForStringLiteral(node, sourceFiles, cancellationToken) : undefined; } + if (symbol.escapedName === "export=" /* ExportEquals */) { + return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); + } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); var referencedNode = node; @@ -97573,10 +98797,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 277 /* SourceFile */: + case 279 /* 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -97586,6 +98810,22 @@ var ts; ts.Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } + var exported = symbol.exports.get("export=" /* ExportEquals */); + if (exported) { + for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { + var decl = _c[_b]; + var sourceFile = decl.getSourceFile(); + 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.assertDefined(ts.findChildOfKind(decl, 85 /* ExportKeyword */, sourceFile)) + : ts.getNameOfDeclaration(decl) || decl; + references.push(FindAllReferences.nodeEntry(node)); + } + } + } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** getReferencedSymbols for special node kinds. */ @@ -97607,7 +98847,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -97619,7 +98859,7 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - if (node && node.kind === 79 /* DefaultKeyword */) { + if (node && node.kind === 80 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -97644,9 +98884,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: return 1 /* Constructor */; - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -97878,7 +99118,7 @@ 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 === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 196 /* FunctionExpression */ || valueDeclaration.kind === 209 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -97888,7 +99128,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 240 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -97917,7 +99157,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 279 /* 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; @@ -97938,7 +99178,9 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = checker.getSymbolAtLocation(definition); + var symbol = ts.isParameterPropertyDeclaration(definition.parent) + ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) + : checker.getSymbolAtLocation(definition); if (!symbol) return undefined; for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { @@ -98023,16 +99265,16 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.text.length === searchSymbolName.length; - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { var str = node; - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(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 */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 79 /* DefaultKeyword */: + case 80 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -98096,7 +99338,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 71 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 72 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -98151,7 +99393,7 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!(referenceLocation === propertyName && state.options.isForRename)) { - var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; + var exportKind = referenceLocation.originalKeywordKind === 80 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); if (!exportInfo) return ts.Debug.fail(); @@ -98231,7 +99473,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 80 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -98257,7 +99499,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -98274,16 +99516,16 @@ var ts; function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { for (var _i = 0, _a = classSymbol.members.get("__constructor" /* Constructor */).declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 155 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 124 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 157 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 154 /* MethodDeclaration */) { + if (decl && decl.kind === 156 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 100 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -98300,10 +99542,10 @@ var ts; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 155 /* Constructor */); + ts.Debug.assert(decl.kind === 157 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 98 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -98317,10 +99559,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 71 /* Identifier */) { + if (refNode.kind !== 72 /* Identifier */) { return; } - if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 276 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -98340,7 +99582,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 216 /* Block */) { + if (body.kind === 218 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -98368,13 +99610,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 185 /* ArrayLiteralExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 187 /* ArrayLiteralExpression */: return true; default: return false; @@ -98427,13 +99669,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -98442,7 +99684,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 97 /* SuperKeyword */) { + if (node.kind !== 98 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -98458,34 +99700,34 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -98493,19 +99735,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 277 /* SourceFile */: - return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); + case 279 /* SourceFile */: + return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -98702,7 +99944,7 @@ var ts; var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); } @@ -98711,7 +99953,7 @@ var ts; function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var originalPath = sourceMapper && sourceMapper.tryGetOriginalLocation({ fileName: path, position: 0 }); + var originalPath = sourceMapper && sourceMapper.tryGetSourcePosition({ fileName: path, pos: 0 }); var updatedPath = getUpdatedPath(originalPath ? originalPath.fileName : path); return originalPath ? updatedPath === undefined ? undefined : makeCorrespondingRelativeChange(originalPath.fileName, updatedPath, path, getCanonicalFileName) @@ -98730,7 +99972,7 @@ var ts; var rel = ts.getRelativePathFromFile(a0, b0, getCanonicalFileName); return combinePathsSafe(ts.getDirectoryPath(a1), rel); } - function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + function updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) return; @@ -98748,7 +99990,8 @@ var ts; var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); // If there isn't some include for this, add a new one. - if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + if (ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && + !ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); } } @@ -98941,7 +100184,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 97 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 98 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -98949,7 +100192,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -99102,18 +100345,18 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 71 /* Identifier */) { + if (node.kind !== 72 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 248 /* ImportClause */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: return true; - case 251 /* ImportSpecifier */: - return declaration.parent.kind === 250 /* NamedImports */; + case 253 /* ImportSpecifier */: + return declaration.parent.kind === 252 /* NamedImports */; default: return false; } @@ -99123,7 +100366,7 @@ var ts; 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 */ && (ts.isNewExpressionTarget(node) || node.kind === 123 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 124 /* ConstructorKeyword */)) { var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -99197,9 +100440,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return true; default: return false; @@ -99317,11 +100560,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: return [declaration]; - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -99342,16 +100585,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return withNode(tag.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -99528,7 +100771,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 === 71 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 72 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -99538,23 +100781,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 155 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 151 /* PropertySignature */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 153 /* PropertySignature */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 242 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -99562,14 +100805,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 277 /* SourceFile */: + case 279 /* SourceFile */: return "quit"; - case 242 /* ModuleDeclaration */: + case 244 /* 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 === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 202 /* BinaryExpression */: { + return commentOwner.parent.kind === 244 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 204 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -99588,14 +100831,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 195 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return rightHandSide.parameters; - case 207 /* ClassExpression */: { + case 209 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -99657,9 +100900,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 248 /* ImportClause */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -99669,7 +100912,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 147 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 149 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -99686,7 +100929,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 === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 149 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -99855,7 +101098,7 @@ var ts; return; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* 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); @@ -99867,21 +101110,21 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 155 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -99893,7 +101136,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -99904,8 +101147,8 @@ var ts; } } break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -99926,12 +101169,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -99941,9 +101184,9 @@ var ts; } endNode(); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -99951,18 +101194,18 @@ var ts; } endNode(); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 255 /* ExportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 160 /* IndexSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 240 /* TypeAliasDeclaration */: + case 257 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 162 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 242 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -99974,6 +101217,9 @@ var ts; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -100041,12 +101287,12 @@ var ts; return false; } switch (a.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -100062,7 +101308,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 244 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -100092,7 +101338,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -100100,16 +101346,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -100119,16 +101365,16 @@ var ts; } } switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -100136,13 +101382,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return "new()"; - case 158 /* CallSignature */: + case 160 /* CallSignature */: return "()"; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "[]"; default: return ""; @@ -100166,25 +101412,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 277 /* SourceFile */: - case 240 /* TypeAliasDeclaration */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 242 /* TypeAliasDeclaration */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return true; - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 235 /* VariableDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 237 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -100194,10 +101440,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -100206,7 +101452,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; + return childKind !== 237 /* VariableDeclaration */ && childKind !== 186 /* BindingElement */; }); } } @@ -100263,7 +101509,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -100277,13 +101523,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 147 /* ComputedPropertyName */; + return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -100298,7 +101544,7 @@ var ts; return ts.declarationNameToString(parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -100336,9 +101582,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: return true; default: return false; @@ -100465,7 +101711,7 @@ var ts; ? specifier.text : undefined; } - /* @internal */ // Internal for testing + // Internal for testing /** * @param importGroup a list of ImportDeclarations, all with the same module name. */ @@ -100564,7 +101810,7 @@ var ts; } } OrganizeImports.coalesceImports = coalesceImports; - /* @internal */ // Internal for testing + // Internal for testing /** * @param exportGroup a list of ExportDeclarations, all with the same module name. */ @@ -100667,7 +101913,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 91 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 92 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -100774,31 +102020,31 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 197 /* ArrowFunction */); } // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 221 /* DoStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 272 /* CatchClause */: + case 223 /* DoStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 274 /* CatchClause */: return spanForNode(n.parent); - case 233 /* TryStatement */: + case 235 /* 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) { - return spanForNode(ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -100806,21 +102052,21 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanForNode(n.parent); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 244 /* CaseBlock */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 246 /* CaseBlock */: return spanForNode(n); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 185 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); - case 258 /* JsxElement */: + case 187 /* ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); + case 260 /* JsxElement */: return spanForJSXElement(n); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -100836,7 +102082,7 @@ var ts; return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -100845,9 +102091,9 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); - var close = open === 17 /* OpenBraceToken */ ? 18 /* CloseBraceToken */ : 22 /* CloseBracketToken */; + var close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; var closeToken = ts.findChildOfKind(n, close, sourceFile); if (!openToken || !closeToken) { return undefined; @@ -101206,11 +102452,11 @@ var ts; characterSpans: breakIntoCharacterSpans(text) }; } - /* @internal */ function breakIntoCharacterSpans(identifier) { + function breakIntoCharacterSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - /* @internal */ function breakIntoWordSpans(identifier) { + function breakIntoWordSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; @@ -101350,10 +102596,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 17 /* OpenBraceToken */) { + if (currentToken === 18 /* OpenBraceToken */) { braceNesting++; } - else if (currentToken === 18 /* CloseBraceToken */) { + else if (currentToken === 19 /* CloseBraceToken */) { braceNesting--; } return currentToken; @@ -101383,12 +102629,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 124 /* DeclareKeyword */) { + if (token === 125 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 129 /* ModuleKeyword */) { + if (token === 130 /* ModuleKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); } } @@ -101400,42 +102646,42 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 23 /* DotToken */) { + if (lastToken === 24 /* DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 91 /* ImportKeyword */) { + if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 9 /* StringLiteral */) { + else if (token === 10 /* StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 58 /* EqualsToken */) { + else if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 26 /* CommaToken */) { + else if (token === 27 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -101444,18 +102690,18 @@ var ts; return true; } } - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -101463,15 +102709,15 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 118 /* AsKeyword */) { + if (token === 119 /* AsKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -101487,21 +102733,21 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 84 /* ExportKeyword */) { + if (token === 85 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -101509,21 +102755,21 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 91 /* ImportKeyword */) { + else if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 58 /* EqualsToken */) { + if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -101536,11 +102782,11 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 133 /* RequireKeyword */) { + if (token === 134 /* RequireKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // require("mod"); recordModuleName(); } @@ -101551,16 +102797,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 71 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 72 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 19 /* OpenParenToken */) { + if (token !== 20 /* OpenParenToken */) { return true; } token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 26 /* CommaToken */) { + if (token === 27 /* CommaToken */) { token = nextToken(); } else { @@ -101569,15 +102815,15 @@ var ts; } } // should be start of dependency list - if (token !== 21 /* OpenBracketToken */) { + if (token !== 22 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordModuleName(); } token = nextToken(); @@ -101685,14 +102931,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 === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 80 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return getRenameInfoForModule(node, sourceFile, symbol); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 147 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 149 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -101739,7 +102985,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { // Exclude the quotes start += 1; width -= 2; @@ -101748,9 +102994,9 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -101843,13 +103089,13 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 26 /* CommaToken */: { + case 27 /* CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -101895,7 +103141,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 27 /* LessThanToken */ || node.kind === 19 /* OpenParenToken */) { + if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* 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 }; @@ -101948,10 +103194,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 193 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 206 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -102014,24 +103260,24 @@ var ts; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) { - if (startingToken.kind !== 19 /* OpenParenToken */ && startingToken.kind !== 26 /* CommaToken */) + if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 195 /* ParenthesizedExpression */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 19 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* 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) }; } @@ -102063,7 +103309,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 26 /* CommaToken */) { + if (child.kind !== 27 /* CommaToken */) { argumentIndex++; } } @@ -102082,8 +103328,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 !== 26 /* CommaToken */; }); - if (listChildren.length > 0 && ts.last(listChildren).kind === 26 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); + if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -102152,7 +103398,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 === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -102217,10 +103463,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(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(27 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(29 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(26 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; var prefixDisplayParts = callTargetDisplayParts.concat(prefix); @@ -102249,9 +103495,9 @@ var ts; var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(27 /* LessThanToken */)], suffix: [ts.punctuationPart(29 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = candidateSignature.hasRestParameter; @@ -102259,11 +103505,11 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration); })); - printer.writeList(26896 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); } }); var parameters = candidateSignature.parameters.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(19 /* OpenParenToken */)]), suffix: [ts.punctuationPart(20 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -102285,53 +103531,46 @@ var ts; /* @internal */ var ts; (function (ts) { - // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; - var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; - function getSourceMapper(getCanonicalFileName, currentDirectory, log, host, getProgram) { + function getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, getProgram) { + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var sourcemappedFileCache; - return { tryGetOriginalLocation: tryGetOriginalLocation, tryGetGeneratedLocation: tryGetGeneratedLocation, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + return { tryGetSourcePosition: tryGetSourcePosition, tryGetGeneratedPosition: tryGetGeneratedPosition, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + function toPath(fileName) { + return ts.toPath(fileName, currentDirectory, getCanonicalFileName); + } function scanForSourcemapURL(fileName) { - var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var mappedFile = sourcemappedFileCache.get(toPath(fileName)); if (!mappedFile) { return; } - var starts = ts.getLineStarts(mappedFile); - for (var index = starts.length - 1; index >= 0; index--) { - var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); - var comment = sourceMapCommentRegExp.exec(lineText); - if (comment) { - return comment[1]; - } - // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file - else if (!lineText.match(whitespaceOrMapCommentRegExp)) { - break; - } - } + return ts.tryGetSourceMappingURL(mappedFile.text, ts.getLineStarts(mappedFile)); } function convertDocumentToSourceMapper(file, contents, mapFileName) { - var maps; - try { - maps = JSON.parse(contents); - } - catch (_a) { - // swallow error - } - if (!maps || !maps.sources || !maps.file || !maps.mappings) { + var map = ts.tryParseRawSourceMap(contents); + if (!map || !map.sources || !map.file || !map.mappings) { // obviously invalid map - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - return file.sourceMapper = ts.sourcemaps.decode({ - readFile: function (s) { return host.readFile(s); }, - fileExists: function (s) { return host.fileExists(s); }, + var program = getProgram(); + return file.sourceMapper = ts.createDocumentPositionMapper({ + getSourceFileLike: function (s) { + // Lookup file in program, if provided + var file = program && program.getSourceFileByPath(s); + // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file + if (file === undefined || file.resolvedPath !== s) { + // Otherwise check the cache (which may hit disk) + return sourcemappedFileCache.get(s); + } + return file; + }, getCanonicalFileName: getCanonicalFileName, log: log, - }, mapFileName, maps, getProgram(), sourcemappedFileCache); + }, map, mapFileName); } function getSourceMapper(fileName, file) { if (!host.readFile || !host.fileExists) { - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } if (file.sourceMapper) { return file.sourceMapper; @@ -102360,20 +103599,24 @@ var ts; return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217 } } - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - function tryGetOriginalLocation(info) { + function tryGetSourcePosition(info) { if (!ts.isDeclarationFileName(info.fileName)) return undefined; var file = getFile(info.fileName); if (!file) return undefined; - var newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info); - return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc; + var newLoc = getSourceMapper(info.fileName, file).getSourcePosition(info); + return newLoc === info ? undefined : tryGetSourcePosition(newLoc) || newLoc; } - function tryGetGeneratedLocation(info) { + function tryGetGeneratedPosition(info) { var program = getProgram(); - var declarationPath = ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); + var options = program.getCompilerOptions(); + var outPath = options.outFile || options.out; + var declarationPath = outPath ? + ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; var declarationFile = getFile(declarationPath); @@ -102383,18 +103626,45 @@ var ts; return newLoc === info ? undefined : newLoc; } function getFile(fileName) { - return getProgram().getSourceFile(fileName) || sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var path = toPath(fileName); + var file = getProgram().getSourceFileByPath(path); + if (file && file.resolvedPath === path) { + return file; + } + return sourcemappedFileCache.get(path); } function toLineColumnOffset(fileName, position) { - var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217 + var file = getFile(fileName); // TODO: GH#18217 return file.getLineAndCharacterOfPosition(position); } function clearCache() { - sourcemappedFileCache = ts.createSourceFileLikeCache(host); + sourcemappedFileCache = createSourceFileLikeCache(host); } } ts.getSourceMapper = getSourceMapper; + function createSourceFileLikeCache(host) { + var cached = ts.createMap(); + return { + get: function (path) { + if (cached.has(path)) { + return cached.get(path); + } + if (!host.fileExists || !host.readFile || !host.fileExists(path)) + return; + // And failing that, check the disk + var text = host.readFile(path); // TODO: GH#18217 + var file = { + text: text, + lineMap: undefined, + getLineAndCharacterOfPosition: function (pos) { + return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + } + }; + cached.set(path, file); + return file; + } + }; + } })(ts || (ts = {})); /* @internal */ var ts; @@ -102430,7 +103700,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -102440,7 +103710,7 @@ var ts; } } // falls through if no diagnostic was created - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -102473,11 +103743,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -102494,58 +103764,42 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 251 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; default: return undefined; } } function addConvertToAsyncFunctionDiagnostics(node, checker, diags) { - if (ts.isAsyncFunction(node) || !node.body) { - return; + if (!ts.isAsyncFunction(node) && + node.body && + ts.isBlock(node.body) && + hasReturnStatementWithPromiseHandler(node.body) && + returnsPromise(node, checker)) { + diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); } + } + function returnsPromise(node, checker) { var functionType = checker.getTypeAtLocation(node); var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; - if (!returnType || !checker.getPromisedTypeOfPromise(returnType)) { - return; - } - // collect all the return statements - // check that a property access expression exists in there and that it is a handler - var returnStatements = getReturnStatementsWithPromiseHandlers(node); - if (returnStatements.length > 0) { - diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); - } + return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - /** @internal */ - function getReturnStatementsWithPromiseHandlers(node) { - var returnStatements = []; - if (ts.isFunctionLike(node)) { - ts.forEachChild(node, visit); - } - else { - visit(node); - } - function visit(child) { - if (ts.isFunctionLike(child)) { - return; - } - if (ts.isReturnStatement(child) && child.expression && isFixablePromiseHandler(child.expression)) { - returnStatements.push(child); - } - ts.forEachChild(child, visit); - } - return returnStatements; + function hasReturnStatementWithPromiseHandler(body) { + return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); } - ts.getReturnStatementsWithPromiseHandlers = getReturnStatementsWithPromiseHandlers; + function isReturnStatementWithFixablePromiseHandler(node) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + } + ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts function isFixablePromiseHandler(node) { // ensure outermost call exists and is a promise handler @@ -102562,17 +103816,18 @@ var ts; } return true; } + ts.isFixablePromiseHandler = isFixablePromiseHandler; function isPromiseHandler(node) { return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") || ts.hasPropertyAccessExpressionWithName(node, "catch")); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 95 /* NullKeyword */: - case 71 /* Identifier */: // identifier includes undefined - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: // identifier includes undefined + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -102592,7 +103847,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 209 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -102629,7 +103884,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 100 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -102680,11 +103935,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 260 /* JsxOpeningElement */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 265 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + return location.kind === 72 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 267 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -102711,13 +103966,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 100 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 99 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(99 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 100 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(100 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -102727,7 +103982,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 187 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 189 /* 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)) { @@ -102748,7 +104003,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 190 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 192 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 98 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -102766,7 +104021,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -102783,14 +104038,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* 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 */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -102803,29 +104058,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 155 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 124 /* ConstructorKeyword */ && location.parent.kind === 157 /* 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 = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 124 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 155 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 157 /* 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 === 155 /* Constructor */) { + if (functionDeclaration_1.kind === 157 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 160 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -102835,7 +104090,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 209 /* 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 @@ -102843,7 +104098,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(75 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(76 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -102851,45 +104106,45 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(109 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(110 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(77 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(83 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(84 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 244 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 72 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 131 /* NamespaceKeyword */ : 130 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -102900,7 +104155,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 148 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 150 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -102908,21 +104163,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 159 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + if (declaration.kind === 161 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 158 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 160 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 240 /* TypeAliasDeclaration */) { + else if (declaration.kind === 242 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -102934,11 +104189,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 276 /* EnumMember */) { + if (declaration.kind === 278 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -102964,41 +104219,41 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 245 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 247 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(131 /* NamespaceKeyword */)); break; - case 252 /* ExportAssignment */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 254 /* ExportAssignment */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 59 /* EqualsToken */ : 80 /* DefaultKeyword */)); break; - case 255 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 257 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(91 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(92 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 246 /* ImportEqualsDeclaration */) { + if (declaration.kind === 248 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(133 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(134 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -103012,7 +104267,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(99 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(100 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -103023,7 +104278,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -103061,10 +104316,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -103107,7 +104362,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(92 /* InKeyword */)); + displayParts.push(ts.keywordPart(93 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -103117,7 +104372,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(55 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -103140,9 +104395,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); return; } } @@ -103151,12 +104406,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(37 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(38 /* 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(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } var docComment = signature.getDocumentationComment(typeChecker); documentation = docComment.length === 0 ? undefined : docComment; @@ -103165,7 +104420,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration); - getPrinter().writeList(26896 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -103177,16 +104432,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 194 /* FunctionExpression */) { + if (declaration.kind === 196 /* FunctionExpression */) { return true; } - if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* FunctionDeclaration */) { + if (declaration.kind !== 237 /* VariableDeclaration */ && declaration.kind !== 239 /* 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 === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { + if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -103401,8 +104656,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 17 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 18 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -103484,11 +104739,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 31 /* GreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -103496,28 +104751,28 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 265 /* JsxAttribute */: - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 267 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* 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 === 71 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 72 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 12 /* RegularExpressionLiteral */; + return container.kind === 13 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 15 /* TemplateMiddle */ || - container.kind === 16 /* TemplateTail */; + return container.kind === 16 /* TemplateMiddle */ || + container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; + return t === 42 /* SlashToken */ || t === 64 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -103587,7 +104842,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -103603,7 +104858,7 @@ var ts; } break; case 3 /* RescanTemplateToken */: - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { lastScanAction = 3 /* RescanTemplateToken */; return scanner.reScanTemplateToken(); } @@ -103676,7 +104931,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 145 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 147 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -103688,255 +104943,255 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 145 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); - var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 145 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; - var unaryPrefixOperators = [43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]; + var keywords = tokenRangeFromRange(73 /* FirstKeyword */, 147 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 71 /* LastBinaryOperator */); + var binaryKeywordOperators = [93 /* InKeyword */, 94 /* InstanceOfKeyword */, 147 /* OfKeyword */, 119 /* AsKeyword */, 128 /* IsKeyword */]; + var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, - 17 /* OpenBraceToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 72 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostincrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; - var unaryPredecrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostdecrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; + var unaryPreincrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostincrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; + var unaryPredecrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostdecrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [71 /* Identifier */].concat(ts.typeKeywords); + var typeNames = [72 /* Identifier */].concat(ts.typeKeywords); // 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([71 /* Identifier */, 3 /* MultiLineCommentTrivia */, 75 /* ClassKeyword */, 84 /* ExportKeyword */, 91 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([72 /* Identifier */, 3 /* MultiLineCommentTrivia */, 76 /* ClassKeyword */, 85 /* ExportKeyword */, 92 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([20 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 81 /* DoKeyword */, 102 /* TryKeyword */, 87 /* FinallyKeyword */, 82 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 82 /* DoKeyword */, 103 /* TryKeyword */, 88 /* FinallyKeyword */, 83 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 56 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 56 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 55 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), + rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), + rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 23 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 23 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 91 /* ImportKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenImportParenInImportType", 92 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), // 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], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 43 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 44 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 43 /* PlusPlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 37 /* PlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 37 /* PlusToken */, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 44 /* MinusMinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 38 /* MinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 38 /* MinusToken */, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 18 /* CloseBraceToken */, [26 /* CommaToken */, 25 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 18 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 18 /* CloseBraceToken */, anyTokenExcept(20 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 18 /* CloseBraceToken */, 82 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 18 /* CloseBraceToken */, 106 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 83 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 107 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), // 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", 20 /* CloseParenToken */, 21 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 89 /* FunctionKeyword */, 39 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 39 /* AsteriskToken */, [71 /* Identifier */, 19 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 89 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 90 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), + rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, [72 /* Identifier */, 20 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), + rule("SpaceAfterFunctionInFuncDecl", 90 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 17 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), // 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", [125 /* GetKeyword */, 136 /* SetKeyword */], 71 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 116 /* YieldKeyword */, 39 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [116 /* YieldKeyword */, 39 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 96 /* ReturnKeyword */, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [104 /* VarKeyword */, 100 /* ThrowKeyword */, 94 /* NewKeyword */, 80 /* DeleteKeyword */, 96 /* ReturnKeyword */, 103 /* TypeOfKeyword */, 121 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [110 /* LetKeyword */, 76 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [126 /* GetKeyword */, 137 /* SetKeyword */], 72 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBetweenYieldKeywordAndStar", 117 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [117 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), + rule("NoSpaceBetweenReturnAndSemicolon", 97 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterCertainKeywords", [105 /* VarKeyword */, 101 /* ThrowKeyword */, 95 /* NewKeyword */, 81 /* DeleteKeyword */, 97 /* ReturnKeyword */, 104 /* TypeOfKeyword */, 122 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterLetConstInVariableDeclaration", [111 /* LetKeyword */, 77 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), // 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], 2 /* Space */), rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 105 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceAfterVoidOperator", 106 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 120 /* AsyncKeyword */, 19 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 120 /* AsyncKeyword */, 89 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 121 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 121 /* AsyncKeyword */, 90 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [71 /* Identifier */, 20 /* CloseParenToken */], [13 /* NoSubstitutionTemplateLiteral */, 14 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [72 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 71 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 41 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 41 /* SlashToken */, 29 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 58 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 58 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 72 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 59 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterEqualInJsxAttribute", 59 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [129 /* ModuleKeyword */, 133 /* RequireKeyword */], 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [130 /* ModuleKeyword */, 134 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 117 /* AbstractKeyword */, - 75 /* ClassKeyword */, - 124 /* DeclareKeyword */, - 79 /* DefaultKeyword */, - 83 /* EnumKeyword */, - 84 /* ExportKeyword */, - 85 /* ExtendsKeyword */, - 125 /* GetKeyword */, - 108 /* ImplementsKeyword */, - 91 /* ImportKeyword */, - 109 /* InterfaceKeyword */, - 129 /* ModuleKeyword */, - 130 /* NamespaceKeyword */, - 112 /* PrivateKeyword */, - 114 /* PublicKeyword */, - 113 /* ProtectedKeyword */, - 132 /* ReadonlyKeyword */, - 136 /* SetKeyword */, - 115 /* StaticKeyword */, - 139 /* TypeKeyword */, - 143 /* FromKeyword */, - 128 /* KeyOfKeyword */, - 126 /* InferKeyword */, + 118 /* AbstractKeyword */, + 76 /* ClassKeyword */, + 125 /* DeclareKeyword */, + 80 /* DefaultKeyword */, + 84 /* EnumKeyword */, + 85 /* ExportKeyword */, + 86 /* ExtendsKeyword */, + 126 /* GetKeyword */, + 109 /* ImplementsKeyword */, + 92 /* ImportKeyword */, + 110 /* InterfaceKeyword */, + 130 /* ModuleKeyword */, + 131 /* NamespaceKeyword */, + 113 /* PrivateKeyword */, + 115 /* PublicKeyword */, + 114 /* ProtectedKeyword */, + 133 /* ReadonlyKeyword */, + 137 /* SetKeyword */, + 116 /* StaticKeyword */, + 140 /* TypeKeyword */, + 144 /* FromKeyword */, + 129 /* KeyOfKeyword */, + 127 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 143 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [86 /* ExtendsKeyword */, 109 /* ImplementsKeyword */, 144 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 9 /* StringLiteral */, 17 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 36 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 36 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 24 /* DotDotDotToken */, 71 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 55 /* QuestionToken */, [20 /* CloseParenToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 72 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 20 /* CloseParenToken */, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 27 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 29 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 29 /* GreaterThanToken */, [19 /* OpenParenToken */, 21 /* OpenBracketToken */, 29 /* GreaterThanToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), // decorators - rule("SpaceBeforeAt", [20 /* CloseParenToken */, 71 /* Identifier */], 57 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 57 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 72 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 117 /* AbstractKeyword */, - 71 /* Identifier */, - 84 /* ExportKeyword */, - 79 /* DefaultKeyword */, - 75 /* ClassKeyword */, - 115 /* StaticKeyword */, - 114 /* PublicKeyword */, - 112 /* PrivateKeyword */, - 113 /* ProtectedKeyword */, - 125 /* GetKeyword */, - 136 /* SetKeyword */, - 21 /* OpenBracketToken */, - 39 /* AsteriskToken */, + 118 /* AbstractKeyword */, + 72 /* Identifier */, + 85 /* ExportKeyword */, + 80 /* DefaultKeyword */, + 76 /* ClassKeyword */, + 116 /* StaticKeyword */, + 115 /* PublicKeyword */, + 113 /* PrivateKeyword */, + 114 /* ProtectedKeyword */, + 126 /* GetKeyword */, + 137 /* SetKeyword */, + 22 /* OpenBracketToken */, + 40 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 51 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 94 /* NewKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 95 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), ]; // 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", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 19 /* OpenParenToken */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 19 /* OpenParenToken */, 20 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 21 /* OpenBracketToken */, 22 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), // Insert space before and after binary operators rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* 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, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), + rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), + rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), ]; // 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, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 26 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(120 /* AsyncKeyword */, 73 /* CaseKeyword */), 21 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 22 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 25 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(121 /* AsyncKeyword */, 74 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 88 /* ForKeyword */, 121 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 89 /* ForKeyword */, 122 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // 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", [20 /* CloseParenToken */, 81 /* DoKeyword */, 82 /* ElseKeyword */, 73 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 82 /* DoKeyword */, 83 /* ElseKeyword */, 74 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [102 /* TryKeyword */, 87 /* FinallyKeyword */], 17 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [103 /* TryKeyword */, 88 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); } @@ -103980,45 +105235,45 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 223 /* ForStatement */; + return context.contextNode.kind === 225 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 173 /* ConditionalType */: - case 210 /* AsExpression */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 161 /* TypePredicate */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 175 /* ConditionalType */: + case 212 /* AsExpression */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 163 /* TypePredicate */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 184 /* BindingElement */: + case 186 /* BindingElement */: // equals in type X = ... - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: // equal in p = 0; - case 149 /* Parameter */: - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; + case 151 /* Parameter */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + return context.currentTokenSpan.kind === 59 /* EqualsToken */ || context.nextTokenSpan.kind === 59 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 148 /* TypeParameter */: - return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; + case 150 /* TypeParameter */: + return context.currentTokenSpan.kind === 93 /* InKeyword */ || context.nextTokenSpan.kind === 93 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 225 /* ForOfStatement */: - return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; + case 227 /* ForOfStatement */: + return context.currentTokenSpan.kind === 147 /* OfKeyword */ || context.nextTokenSpan.kind === 147 /* OfKeyword */; } return false; } @@ -104030,22 +105285,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 152 /* PropertyDeclaration */ || - contextKind === 151 /* PropertySignature */ || - contextKind === 149 /* Parameter */ || - contextKind === 235 /* VariableDeclaration */ || + return contextKind === 154 /* PropertyDeclaration */ || + contextKind === 153 /* PropertySignature */ || + contextKind === 151 /* Parameter */ || + contextKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 203 /* ConditionalExpression */ || - context.contextNode.kind === 173 /* ConditionalType */; + return context.contextNode.kind === 205 /* ConditionalExpression */ || + context.contextNode.kind === 175 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 182 /* ObjectBindingPattern */ || - context.contextNode.kind === 179 /* MappedType */ || + return context.contextNode.kind === 184 /* ObjectBindingPattern */ || + context.contextNode.kind === 181 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -104071,31 +105326,31 @@ var ts; return true; } switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 186 /* ObjectLiteralExpression */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 188 /* ObjectLiteralExpression */: + case 245 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 158 /* CallSignature */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 197 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 241 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -104104,40 +105359,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; + return context.contextNode.kind === 239 /* FunctionDeclaration */ || context.contextNode.kind === 196 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 166 /* TypeLiteral */: - case 242 /* ModuleDeclaration */: - case 253 /* ExportDeclaration */: - case 254 /* NamedExports */: - case 247 /* ImportDeclaration */: - case 250 /* NamedImports */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 168 /* TypeLiteral */: + case 244 /* ModuleDeclaration */: + case 255 /* ExportDeclaration */: + case 256 /* NamedExports */: + case 249 /* ImportDeclaration */: + case 252 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 272 /* CatchClause */: - case 243 /* ModuleBlock */: - case 230 /* SwitchStatement */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 274 /* CatchClause */: + case 245 /* ModuleBlock */: + case 232 /* SwitchStatement */: return true; - case 216 /* Block */: { + case 218 /* 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 !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 197 /* ArrowFunction */ && blockParent.kind !== 196 /* FunctionExpression */) { return true; } } @@ -104146,64 +105401,64 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 229 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 231 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 272 /* CatchClause */: + case 274 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 186 /* ObjectLiteralExpression */; + return context.contextNode.kind === 188 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 189 /* CallExpression */; + return context.contextNode.kind === 191 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 190 /* NewExpression */; + return context.contextNode.kind === 192 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 26 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 195 /* ArrowFunction */; + return context.contextNode.kind === 197 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 181 /* ImportType */; + return context.contextNode.kind === 183 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; + return context.contextNode.kind !== 260 /* JsxElement */ && context.contextNode.kind !== 264 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; + return context.contextNode.kind === 270 /* JsxExpression */ || context.contextNode.kind === 269 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 265 /* JsxAttribute */; + return context.nextTokenParent.kind === 267 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 265 /* JsxAttribute */; + return context.contextNode.kind === 267 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 259 /* JsxSelfClosingElement */; + return context.contextNode.kind === 261 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -104218,45 +105473,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 238 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 242 /* ModuleDeclaration */; + return context.contextNode.kind === 244 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 168 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 159 /* ConstructSignature */; + return context.contextNode.kind === 161 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { + if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 162 /* TypeReference */: - case 192 /* TypeAssertionExpression */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 194 /* TypeAssertionExpression */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -104267,16 +105522,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 192 /* TypeAssertionExpression */; + return context.contextNode.kind === 194 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; + return context.currentTokenSpan.kind === 106 /* VoidKeyword */ && context.currentTokenParent.kind === 200 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 207 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 211 /* NonNullExpression */; + return context.contextNode.kind === 213 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -104327,12 +105582,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 145 /* LastKeyword */ && column <= 145 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 147 /* LastKeyword */ && column <= 147 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 145 /* LastToken */ + 1; + var mapRowLength = 147 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -104421,12 +105676,12 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 25 /* SemicolonToken */, sourceFile); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 17 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -104452,7 +105707,7 @@ var ts; } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 18 /* CloseBraceToken */, sourceFile); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; @@ -104510,17 +105765,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 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 277 /* SourceFile */: - case 216 /* Block */: - case 243 /* ModuleBlock */: + return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 279 /* SourceFile */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -104633,7 +105888,6 @@ var ts; } return 0; } - /* @internal */ function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: 0, end: sourceFileLike.text.length }; 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 @@ -104663,7 +105917,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine; + var indentationOnLastIndentedLine = -1 /* Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -104677,7 +105931,7 @@ var ts; if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); // TODO: GH#18217 + indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); trimTrailingWhitespacesForRemainingRange(); } } @@ -104722,7 +105976,7 @@ var ts; }; } else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 19 /* OpenParenToken */ && startLine === lastIndentedLine) { + if (node.kind === 20 /* 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) }; @@ -104743,19 +105997,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; - case 156 /* GetAccessor */: return 125 /* GetKeyword */; - case 157 /* SetAccessor */: return 136 /* SetKeyword */; - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: return 76 /* ClassKeyword */; + case 241 /* InterfaceDeclaration */: return 110 /* InterfaceKeyword */; + case 239 /* FunctionDeclaration */: return 90 /* FunctionKeyword */; + case 243 /* EnumDeclaration */: return 243 /* EnumDeclaration */; + case 158 /* GetAccessor */: return 126 /* GetKeyword */; + case 159 /* SetAccessor */: return 137 /* SetKeyword */; + case 156 /* MethodDeclaration */: if (node.asteriskToken) { - return 39 /* AsteriskToken */; + return 40 /* AsteriskToken */; } // falls through - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -104770,15 +106024,25 @@ var ts; // .. { // // comment // } - case 18 /* CloseBraceToken */: - case 22 /* CloseBracketToken */: - case 20 /* CloseParenToken */: + case 19 /* CloseBraceToken */: + case 23 /* CloseBracketToken */: + case 21 /* CloseParenToken */: return indentation + getDelta(container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; }, - getIndentationForToken: function (line, kind, container) { - return shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : 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. + // foo.then + // < + // number, + // string, + // >(); + // vs + // var a = xValue + // > yValue; + getIndentationForToken: function (line, kind, container, suppressDelta) { + return !suppressDelta && shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: getDelta, @@ -104792,26 +106056,25 @@ 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 17 /* OpenBraceToken */: - case 18 /* CloseBraceToken */: - case 19 /* OpenParenToken */: - case 20 /* CloseParenToken */: - case 82 /* ElseKeyword */: - case 106 /* WhileKeyword */: - case 57 /* AtToken */: + case 18 /* OpenBraceToken */: + case 19 /* CloseBraceToken */: + case 21 /* CloseParenToken */: + case 83 /* ElseKeyword */: + case 107 /* WhileKeyword */: + case 58 /* AtToken */: return false; - case 41 /* SlashToken */: - case 29 /* GreaterThanToken */: + case 42 /* SlashToken */: + case 30 /* GreaterThanToken */: switch (container.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: return false; } break; - case 21 /* OpenBracketToken */: - case 22 /* CloseBracketToken */: - if (container.kind !== 179 /* MappedType */) { + case 22 /* OpenBracketToken */: + case 23 /* CloseBracketToken */: + if (container.kind !== 181 /* MappedType */) { return false; } break; @@ -104896,22 +106159,22 @@ var ts; return inheritedIndentation; } // JSX text shouldn't affect indenting - if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { + if (ts.isToken(child) && child.kind !== 11 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 150 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 152 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { var range = { pos: child.getStart(), end: child.getEnd() }; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 187 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -104932,9 +106195,20 @@ var ts; else if (tokenInfo.token.kind === listStartToken) { // consume list start token startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_1 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_1.indentation, indentation_1.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); + var indentationOnListStartToken = void 0; + if (indentationOnLastIndentedLine !== -1 /* 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; + // }: {}; + indentationOnListStartToken = indentationOnLastIndentedLine; + } + else { + var startLinePosition = ts.getLineStartPositionForPosition(tokenInfo.token.pos, sourceFile); + indentationOnListStartToken = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, tokenInfo.token.pos, sourceFile, options); + } + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentationOnListStartToken, options.indentSize); // TODO: GH#18217 } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope @@ -104950,7 +106224,7 @@ var ts; var listEndToken = getCloseTokenForOpenToken(listStartToken); if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 26 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { formattingScanner.advance(); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; } @@ -104960,11 +106234,11 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo && tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent, /*isListEndToken*/ true); } } } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container) { + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container, isListEndToken) { ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); var indentToken = false; @@ -104996,32 +106270,12 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) : + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); - switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: - if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); - } - indentNextTokenOrTrivia = false; - break; - case 2 /* SingleLineCommentTrivia */: - if (indentNextTokenOrTrivia && triviaInRange) { - insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); - } - indentNextTokenOrTrivia = false; - break; - case 4 /* NewLineTrivia */: - indentNextTokenOrTrivia = true; - break; - } - } + 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) { @@ -105034,16 +106288,39 @@ var ts; childContextNode = parent; } } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + function indentTriviaItems(trivia, commentIndentation, indentNextTokenOrTrivia, indentSingleLine) { for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { var triviaItem = trivia_1[_i]; + var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); + switch (triviaItem.kind) { + case 3 /* MultiLineCommentTrivia */: + if (triviaInRange) { + indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + } + indentNextTokenOrTrivia = false; + break; + case 2 /* SingleLineCommentTrivia */: + if (indentNextTokenOrTrivia && triviaInRange) { + indentSingleLine(triviaItem); + } + indentNextTokenOrTrivia = false; + break; + case 4 /* NewLineTrivia */: + indentNextTokenOrTrivia = true; + break; + } + } + return indentNextTokenOrTrivia; + } + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0, trivia_2 = trivia; _i < trivia_2.length; _i++) { + var triviaItem = trivia_2[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); } } } - // TODO: GH#18217 use an enum instead of `boolean | undefined` function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAction = 0 /* None */; @@ -105215,7 +106492,10 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - var startPosition = previousRange ? previousRange.end : originalRange.pos; + if (!previousRange) { + return; + } + var startPosition = previousRange.end; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -105315,41 +106595,46 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 197 /* ArrowFunction */: if (node.typeParameters === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.parameters === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.arguments === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 162 /* TypeReference */: + case 164 /* TypeReference */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } + break; + case 168 /* TypeLiteral */: + return 18 /* OpenBraceToken */; } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 19 /* OpenParenToken */: - return 20 /* CloseParenToken */; - case 27 /* LessThanToken */: - return 29 /* GreaterThanToken */; + case 20 /* OpenParenToken */: + return 21 /* CloseParenToken */; + case 28 /* LessThanToken */: + return 30 /* GreaterThanToken */; + case 18 /* OpenBraceToken */: + return 19 /* CloseBraceToken */; } return 0 /* Unknown */; } @@ -105454,13 +106739,18 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 204 /* 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 */) { 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 + } return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options); } SmartIndenter.getIndentation = getIndentation; @@ -105471,12 +106761,12 @@ var ts; if (previousLine <= commentStartLine) { return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); } - var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); - var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + var startPositionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPositionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; if (column === 0) { return column; } - var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { @@ -105509,14 +106799,13 @@ var ts; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + // do not consider parent-child line sharing yet: + // 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 */) { return actualIndentation; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.indentSize; // TODO: GH#18217 - } previous = current; current = current.parent; } @@ -105543,23 +106832,17 @@ var ts; var start = current.getStart(sourceFile); useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; } - if (useActualIndentation) { - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } var containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); var parentAndChildShareLine = containingListOrParentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { - // try to fetch actual indentation for current node from source text - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + // try to fetch actual indentation for current node from source text + actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } @@ -105610,7 +106893,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -105627,11 +106910,11 @@ var ts; if (!nextToken) { return 0 /* Unknown */; } - if (nextToken.kind === 17 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* OpenBraceToken */) { // open braces are always indented at the parent level return 1 /* OpenBrace */; } - else if (nextToken.kind === 18 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* 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 { @@ -105658,8 +106941,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); + if (parent.kind === 222 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 83 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -105667,103 +106950,87 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getListIfStartEndIsInListRange(list, start, end) { - return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; - } function getContainingList(node, sourceFile) { - if (node.parent) { - var end = node.end; - switch (node.parent.kind) { - case 162 /* TypeReference */: - return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 186 /* ObjectLiteralExpression */: - return node.parent.properties; - case 185 /* ArrayLiteralExpression */: - return node.parent.elements; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || - getListIfStartEndIsInListRange(node.parent.parameters, start, end); - } - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: { - var typeParameters = node.parent.typeParameters; - return getListIfStartEndIsInListRange(typeParameters, node.getStart(sourceFile), end); - } - case 190 /* NewExpression */: - case 189 /* CallExpression */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || - getListIfStartEndIsInListRange(node.parent.arguments, start, end); - } - case 236 /* VariableDeclarationList */: - return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - } - } - return undefined; + return node.parent && getListByRange(node.getStart(sourceFile), node.getEnd(), node.parent, sourceFile); } SmartIndenter.getContainingList = getContainingList; - function getActualIndentationForListItem(node, sourceFile, options) { + function getListByPosition(pos, node, sourceFile) { + return node && getListByRange(pos, pos, node, sourceFile); + } + function getListByRange(start, end, node, sourceFile) { + switch (node.kind) { + case 164 /* TypeReference */: + return getList(node.typeArguments); + case 188 /* ObjectLiteralExpression */: + return getList(node.properties); + case 187 /* ArrayLiteralExpression */: + return getList(node.elements); + case 168 /* TypeLiteral */: + return getList(node.members); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: + return getList(node.typeParameters) || getList(node.parameters); + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + return getList(node.typeParameters); + case 192 /* NewExpression */: + case 191 /* CallExpression */: + return getList(node.typeArguments) || getList(node.arguments); + case 238 /* VariableDeclarationList */: + return getList(node.declarations); + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return getList(node.elements); + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + return getList(node.elements); + } + function getList(list) { + return list && ts.rangeContainsStartEnd(getVisualListRange(node, list, sourceFile), start, end) ? list : undefined; + } + } + function getVisualListRange(node, list, sourceFile) { + var children = node.getChildren(sourceFile); + for (var i = 1; i < children.length - 1; i++) { + if (children[i].pos === list.pos && children[i].end === list.end) { + return { pos: children[i - 1].end, end: children[i + 1].getStart(sourceFile) }; + } + } + return list; + } + function getActualIndentationForListStartLine(list, sourceFile, options) { + if (!list) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); + } + function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { + if (node.parent && node.parent.kind === 238 /* VariableDeclarationList */) { + // VariableDeclarationList has no wrapping tokens + return -1 /* Unknown */; + } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { - return deriveActualIndentationFromList(containingList, index, sourceFile, options); - } - } - return -1 /* Unknown */; - } - function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - // actual indentation should not be used when: - // - node is close parenthesis - this is the end of the expression - if (node.kind === 20 /* CloseParenToken */) { - return -1 /* Unknown */; - } - if (node.parent && ts.isCallOrNewExpression(node.parent) && node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1 /* Unknown */; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); - } - return -1 /* Unknown */; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - node = node.expression; - break; - default: - return node; + var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); + if (result !== -1 /* Unknown */) { + return result; } } + return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } + return -1 /* Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -105772,7 +107039,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 === 26 /* CommaToken */) { + if (list[i].kind === 27 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -105821,83 +107088,83 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 219 /* ExpressionStatement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 185 /* ArrayLiteralExpression */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 179 /* MappedType */: - case 168 /* TupleType */: - case 244 /* CaseBlock */: - case 270 /* DefaultClause */: - case 269 /* CaseClause */: - case 193 /* ParenthesizedExpression */: - case 187 /* PropertyAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 217 /* VariableStatement */: - case 252 /* ExportAssignment */: - case 228 /* ReturnStatement */: - case 203 /* ConditionalExpression */: - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: - case 259 /* JsxSelfClosingElement */: - case 268 /* JsxExpression */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 149 /* Parameter */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 175 /* ParenthesizedType */: - case 191 /* TaggedTemplateExpression */: - case 199 /* AwaitExpression */: - case 254 /* NamedExports */: - case 250 /* NamedImports */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 152 /* PropertyDeclaration */: + case 221 /* ExpressionStatement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 187 /* ArrayLiteralExpression */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 181 /* MappedType */: + case 170 /* TupleType */: + case 246 /* CaseBlock */: + case 272 /* DefaultClause */: + case 271 /* CaseClause */: + case 195 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 219 /* VariableStatement */: + case 254 /* ExportAssignment */: + case 230 /* ReturnStatement */: + case 205 /* ConditionalExpression */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: + case 261 /* JsxSelfClosingElement */: + case 270 /* JsxExpression */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 151 /* Parameter */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 177 /* ParenthesizedType */: + case 193 /* TaggedTemplateExpression */: + case 201 /* AwaitExpression */: + case 256 /* NamedExports */: + case 252 /* NamedImports */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 154 /* PropertyDeclaration */: return true; - case 235 /* VariableDeclaration */: - case 273 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 237 /* VariableDeclaration */: + case 275 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 188 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } return true; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return childKind !== 216 /* Block */; - case 253 /* ExportDeclaration */: - return childKind !== 254 /* NamedExports */; - case 247 /* ImportDeclaration */: - return childKind !== 248 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); - case 258 /* JsxElement */: - return childKind !== 261 /* JsxClosingElement */; - case 262 /* JsxFragment */: - return childKind !== 264 /* JsxClosingFragment */; - case 172 /* IntersectionType */: - case 171 /* UnionType */: - if (childKind === 166 /* TypeLiteral */) { + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return childKind !== 218 /* Block */; + case 255 /* ExportDeclaration */: + return childKind !== 256 /* NamedExports */; + case 249 /* ImportDeclaration */: + return childKind !== 250 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 252 /* NamedImports */); + case 260 /* JsxElement */: + return childKind !== 263 /* JsxClosingElement */; + case 264 /* JsxFragment */: + return childKind !== 266 /* JsxClosingFragment */; + case 174 /* IntersectionType */: + case 173 /* UnionType */: + if (childKind === 168 /* TypeLiteral */) { return false; } // falls through @@ -105908,11 +107175,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: - return parent.kind !== 216 /* Block */; + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: + return parent.kind !== 218 /* Block */; default: return false; } @@ -106040,7 +107307,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 === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 188 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -106112,13 +107379,16 @@ var ts; if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, options), newNodes, options); }; + ChangeTracker.prototype.replaceNodeWithText = function (sourceFile, oldNode, text) { + this.replaceRangeWithText(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, textChanges_3.useNonAdjustedPositions), text); + }; ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 26 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -106168,10 +107438,20 @@ var ts; var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); }; - ChangeTracker.prototype.insertCommentThenNewline = function (sourceFile, character, position, commentText) { - var token = ts.getTouchingToken(sourceFile, position); - var text = "/**" + commentText + "*/" + this.newLineCharacter + ts.repeatString(" ", character); - this.insertText(sourceFile, token.getStart(sourceFile), text); + ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { + var fnStart = node.getStart(sourceFile); + if (node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsdoc = _a[_i]; + this.deleteRange(sourceFile, { + pos: ts.getLineStartPositionForPosition(jsdoc.getStart(sourceFile), sourceFile), + end: getAdjustedEndPosition(sourceFile, jsdoc, /*options*/ {}) + }); + } + } + 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 }); }; ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) { this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text }); @@ -106179,28 +107459,11 @@ var ts; ChangeTracker.prototype.insertText = function (sourceFile, pos, text) { this.replaceRangeWithText(sourceFile, ts.createRange(pos), text); }; - ChangeTracker.prototype.tryInsertJSDocParameters = function (sourceFile, parameters) { - if (parameters.length === 0) { - return; - } - var parent = parameters[0].declaration.parent; - var indent = ts.getLineAndCharacterOfPosition(sourceFile, parent.getStart()).character; - var commentText = "\n"; - for (var _i = 0, parameters_3 = parameters; _i < parameters_3.length; _i++) { - var _a = parameters_3[_i], declaration = _a.declaration, typeNode = _a.typeNode, isOptional = _a.isOptional; - if (ts.isIdentifier(declaration.name)) { - var printed = changesToText.getNonformattedText(typeNode, sourceFile, this.newLineCharacter).text; - commentText += this.printJSDocParameter(indent, printed, declaration.name, isOptional); - } - } - commentText += ts.repeatString(" ", indent + 1); - this.insertCommentThenNewline(sourceFile, indent, parent.getStart(), commentText); - }; /** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */ ChangeTracker.prototype.tryInsertTypeAnnotation = function (sourceFile, node, type) { var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 20 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return; // Function missing parentheses, give up @@ -106209,32 +107472,13 @@ var ts; } } else { - endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 237 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; - ChangeTracker.prototype.tryInsertJSDocType = function (sourceFile, node, type) { - var printed = changesToText.getNonformattedText(type, sourceFile, this.newLineCharacter).text; - var commentText; - if (ts.isGetAccessorDeclaration(node)) { - commentText = " @return {" + printed + "} "; - } - else { - commentText = " @type {" + printed + "} "; - node = node.parent; - } - this.insertCommentThenNewline(sourceFile, ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile)).character, node.getStart(sourceFile), commentText); - }; - ChangeTracker.prototype.printJSDocParameter = function (indent, printed, name, isOptionalParameter) { - var printName = ts.unescapeLeadingUnderscores(name.escapedText); - if (isOptionalParameter) { - printName = "[" + printName + "]"; - } - return ts.repeatString(" ", indent) + (" * @param {" + printed + "} " + printName + "\n"); - }; 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, 19 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, doubleNewlines) { @@ -106328,7 +107572,7 @@ var ts; // 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.createToken(25 /* SemicolonToken */)); + this.replaceRange(sourceFile, ts.createRange(after.end), ts.createToken(26 /* SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -106340,18 +107584,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 235 /* VariableDeclaration */: - case 9 /* StringLiteral */: - case 71 /* Identifier */: + case 237 /* VariableDeclaration */: + case 10 /* StringLiteral */: + case 72 /* Identifier */: return { prefix: ", " }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: return { prefix: " " }; - case 149 /* Parameter */: + case 151 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -106360,28 +107604,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 195 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); + if (node.kind === 197 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(90 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 216 /* Block */) { + if (node.body.kind !== 218 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(97 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 196 /* FunctionExpression */ ? 90 /* FunctionKeyword */ : 76 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -106469,12 +107713,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 = 26 /* CommaToken */; + separator = 27 /* 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 : 26 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* 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; @@ -106514,7 +107758,7 @@ var ts; }; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var deletedNodesInLists = new ts.NodeSet(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. var _loop_8 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { @@ -106568,7 +107812,7 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - return [ts.findChildOfKind(cls, 17 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile).end]; + return [ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile).end]; } function getMembersOrProperties(cls) { return ts.isObjectLiteralExpression(cls) ? cls.properties : cls.members; @@ -106611,7 +107855,7 @@ var ts; var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 6 /* ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); - return applyChanges(nonFormattedText, changes); + return applyChanges(nonFormattedText, changes) + newLineCharacter; } changesToText.newFileChangesWorker = newFileChangesWorker; function computeNewText(change, sourceFile, newLineCharacter, formatContext, validate) { @@ -106736,6 +107980,9 @@ var ts; this.writer.write(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeComment = function (s) { + this.writer.writeComment(s); + }; Writer.prototype.writeKeyword = function (s) { this.writer.writeKeyword(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -106748,6 +107995,10 @@ var ts; this.writer.writePunctuation(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeTrailingSemicolon = function (s) { + this.writer.writeTrailingSemicolon(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; Writer.prototype.writeParameter = function (s) { this.writer.writeParameter(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -106768,9 +108019,6 @@ var ts; this.writer.writeSymbol(s, sym); this.setLastNonTriviaPosition(s, /*force*/ false); }; - Writer.prototype.writeTextOfNode = function (text, node) { - this.writer.writeTextOfNode(text, node); - }; Writer.prototype.writeLine = function () { this.writer.writeLine(); }; @@ -106812,10 +108060,25 @@ var ts; }; return Writer; }()); - function getInsertionPositionAtSourceFileTop(_a) { - var text = _a.text; - var shebang = ts.getShebang(text); + function getInsertionPositionAtSourceFileTop(sourceFile) { + var lastPrologue; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + if (ts.isPrologueDirective(node)) { + lastPrologue = node; + } + else { + break; + } + } var position = 0; + var text = sourceFile.text; + if (lastPrologue) { + position = lastPrologue.end; + advancePastLineBreak(); + return position; + } + var shebang = ts.getShebang(text); if (shebang !== undefined) { position = shebang.length; advancePastLineBreak(); @@ -106831,8 +108094,8 @@ var ts; ranges = ranges.slice(1); } // As well as any triple slash references - for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { - var range = ranges_1[_i]; + for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { + var range = ranges_1[_b]; if (range.kind === 2 /* SingleLineCommentTrivia */ && ts.isRecognizedTripleSlashComment(text, range.pos, range.end)) { position = range.end; advancePastLineBreak(); @@ -106854,45 +108117,40 @@ var ts; } } function isValidLocationToAddComment(sourceFile, position) { - return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position); + return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position) && !ts.isInJSXText(sourceFile, position); } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 149 /* 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 149 /* Parameter */: { + case 151 /* Parameter */: { var oldFunction = node.parent; - if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { + if (ts.isArrowFunction(oldFunction) && + oldFunction.parameters.length === 1 && + !ts.findChildOfKind(oldFunction, 20 /* 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`). - var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, // TODO: GH#18217 - oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); - // Drop leading and trailing trivia of the new function because we're only going - // to replace the span (vs the full span) of the old function - the old leading - // and trailing trivia will remain. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); + changes.replaceNodeWithText(sourceFile, node, "()"); } else { deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; } - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 185 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -106900,13 +108158,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -106915,7 +108173,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -106926,7 +108184,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } else { - deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + deleteNode(changes, sourceFile, node, node.kind === 26 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); } } } @@ -106940,7 +108198,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 === 26 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* 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 }); @@ -106962,15 +108220,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 249 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 272 /* CatchClause */) { + if (parent.kind === 274 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -106979,14 +108237,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -107131,6 +108389,32 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addConvertToUnknownForNonOverlappingTypes"; + var errorCodes = [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.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, + }); + function makeChange(changeTracker, sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var replacement = ts.isAsExpression(assertion) + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(143 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(143 /* UnknownKeyword */), assertion.expression); + changeTracker.replaceNode(sourceFile, assertion.expression, replacement); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107198,9 +108482,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(19 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -107210,7 +108494,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(20 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(21 /* CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -107225,26 +108509,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 235 /* VariableDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 237 /* VariableDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 154 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -107266,9 +108550,9 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 288 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -107306,8 +108590,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -107317,6 +108601,754 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "inferFromUsage"; + var errorCodes = [ + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, + ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, + //// Suggestions + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code, + ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var token = ts.getTokenAtPosition(sourceFile, start); + var declaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var markSeen = ts.nodeSeenTracker(); + return codefix.codeFixAll(context, errorCodes, function (changes, err) { + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + }); + }, + }); + function getDiagnostic(errorCode, token) { + switch (errorCode) { + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Infer_parameter_types_from_usage; + default: + return ts.Diagnostics.Infer_type_of_0_from_usage; + } + } + /** Map suggestion code to error code */ + function mapSuggestionDiagnostic(errorCode) { + switch (errorCode) { + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code; + case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code; + case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code; + } + return errorCode; + } + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 72 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 100 /* ThisKeyword */) { + return undefined; + } + var parent = token.parent; + errorCode = mapSuggestionDiagnostic(errorCode); + switch (errorCode) { + // Variable and Property declarations + case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: + if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + return parent; + } + if (ts.isPropertyAccessExpression(parent)) { + var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); + var typeNode = getTypeNodeIfAccessible(type, parent, program, host); + if (typeNode) { + // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags + var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ ""); + addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); + } + return parent; + } + return undefined; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { + var symbol = program.getTypeChecker().getSymbolAtLocation(token); + if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + return symbol.valueDeclaration; + } + return undefined; + } + } + var containingFunction = ts.getContainingFunction(token); + if (containingFunction === undefined) { + return undefined; + } + switch (errorCode) { + // Parameter declarations + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + // falls through + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + if (markSeen(containingFunction)) { + var param = ts.cast(parent, ts.isParameter); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + return param; + } + return undefined; + // Get Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: + case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: + if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + return containingFunction; + } + return undefined; + // Set Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + return undefined; + default: + return ts.Debug.fail(String(errorCode)); + } + } + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + if (ts.isIdentifier(declaration.name)) { + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + } + } + function isApplicableFunctionForInference(declaration) { + switch (declaration.kind) { + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + return true; + case 196 /* FunctionExpression */: + var parent = declaration.parent; + return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; + } + return false; + } + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + return; + } + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || + containingFunction.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + if (ts.isInJSFile(containingFunction)) { + annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); + } + else { + 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) { + annotate(changes, sourceFile, declaration, type, program, host); + } + } + } + } + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); + if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { + var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); + if (type === program.getTypeChecker().getAnyType()) { + type = inferTypeForVariableFromUsage(param.name, program, cancellationToken); + } + if (ts.isInJSFile(setAccessorDeclaration)) { + annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); + } + else { + annotate(changes, sourceFile, param, type, program, host); + } + } + } + function annotate(changes, sourceFile, declaration, type, program, host) { + var typeNode = getTypeNodeIfAccessible(type, declaration, program, host); + if (typeNode) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 153 /* PropertySignature */) { + var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; + if (!parent) { + return; + } + var typeExpression = ts.createJSDocTypeExpression(typeNode); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); + addJSDocTags(changes, sourceFile, parent, [typeTag]); + } + else { + changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); + } + } + } + function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { + var signature = parameterInferences.length && parameterInferences[0].declaration.parent; + if (!signature) { + return; + } + var paramTags = ts.mapDefined(parameterInferences, function (inference) { + var param = inference.declaration; + // only infer parameters that have (1) no type and (2) an accessible inferred type + if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name)) + return; + var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); + var name = ts.getSynthesizedClone(param.name); + ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), ""); + }); + addJSDocTags(changes, sourceFile, signature, paramTags); + } + function addJSDocTags(changes, sourceFile, parent, newTags) { + var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); + var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { + var merged = tryMergeJsdocTags(tag, newTag); + if (merged) + oldTags[i] = merged; + return !!merged; + }); }); + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); + changes.insertJsdocCommentBefore(sourceFile, parent, tag); + } + function tryMergeJsdocTags(oldTag, newTag) { + if (oldTag.kind !== newTag.kind) { + return undefined; + } + switch (oldTag.kind) { + case 299 /* JSDocParameterTag */: { + var oldParam = oldTag; + var newParam = newTag; + return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText + ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) + : undefined; + } + case 300 /* JSDocReturnTag */: + return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); + } + } + function getTypeNodeIfAccessible(type, enclosingScope, program, host) { + var checker = program.getTypeChecker(); + var typeIsAccessible = true; + var notAccessible = function () { typeIsAccessible = false; }; + var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { + trackSymbol: function (symbol, declaration, meaning) { + // TODO: GH#18217 + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + }, + reportInaccessibleThisError: notAccessible, + reportPrivateInBaseOfClassExpression: notAccessible, + reportInaccessibleUniqueSymbolError: notAccessible, + moduleResolverHost: { + readFile: host.readFile, + fileExists: host.fileExists, + directoryExists: host.directoryExists, + getSourceFiles: program.getSourceFiles, + getCurrentDirectory: program.getCurrentDirectory, + getCommonSourceDirectory: program.getCommonSourceDirectory, + } + }); + return typeIsAccessible ? res : undefined; + } + 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; + }); + } + function inferTypeForVariableFromUsage(token, program, cancellationToken) { + var references = getReferences(token, program, cancellationToken); + var checker = program.getTypeChecker(); + var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); + return InferFromReference.unifyFromContext(types, checker); + } + function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { + var searchToken; + switch (containingFunction.kind) { + case 157 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); + break; + case 196 /* FunctionExpression */: + var parent = containingFunction.parent; + searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? + parent.name : + containingFunction.name; + break; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + searchToken = containingFunction.name; + break; + } + if (searchToken) { + return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program, cancellationToken); + } + } + var InferFromReference; + (function (InferFromReference) { + function inferTypesFromReferences(references, checker, cancellationToken) { + var usageContext = {}; + for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { + var reference = references_1[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + return inferFromContext(usageContext, checker); + } + InferFromReference.inferTypesFromReferences = inferTypesFromReferences; + function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { + var checker = program.getTypeChecker(); + if (references.length === 0) { + return undefined; + } + if (!declaration.parameters) { + return undefined; + } + var usageContext = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + var isConstructor = declaration.kind === 157 /* Constructor */; + var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; + return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { + var types = []; + var isRest = ts.isRestParameter(parameter); + var isOptional = false; + for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { + var callContext = callContexts_1[_i]; + if (callContext.argumentTypes.length <= parameterIndex) { + isOptional = ts.isInJSFile(declaration); + types.push(checker.getUndefinedType()); + } + else if (isRest) { + for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + } + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + if (ts.isIdentifier(parameter.name)) { + types.push.apply(types, inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken)); + } + var type = unifyFromContext(types, checker); + return { + type: isRest ? checker.createArrayType(type) : type, + isOptional: isOptional && !isRest, + declaration: parameter + }; + }); + } + InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; + function inferTypeFromContext(node, checker, usageContext) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + switch (node.parent.kind) { + case 203 /* PostfixUnaryExpression */: + usageContext.isNumber = true; + break; + case 202 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + break; + case 204 /* BinaryExpression */: + inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + break; + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + break; + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (node.parent.expression === node) { + inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + } + else { + inferTypeFromContextualType(node, checker, usageContext); + } + break; + case 189 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + break; + case 190 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + break; + case 237 /* 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. + addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + } + break; + } + } + // falls through + default: + return inferTypeFromContextualType(node, checker, usageContext); + } + } + function inferTypeFromContextualType(node, checker, usageContext) { + if (ts.isExpressionNode(node)) { + addCandidateType(usageContext, checker.getContextualType(node)); + } + } + function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + switch (node.operator) { + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + usageContext.isNumber = true; + break; + case 38 /* PlusToken */: + usageContext.isNumber = true; + usageContext.isString = true; + break; + // case SyntaxKind.ExclamationToken: + // no inferences here; + } + } + function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + switch (parent.operatorToken.kind) { + // ExponentiationOperator + case 41 /* AsteriskAsteriskToken */: + // MultiplicativeOperator + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + // ShiftOperator + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // BitwiseOperator + case 49 /* AmpersandToken */: + case 50 /* BarToken */: + case 51 /* CaretToken */: + // CompoundAssignmentOperator + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 70 /* BarEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + // AdditiveOperator + case 39 /* MinusToken */: + // RelationalOperator + case 28 /* LessThanToken */: + case 31 /* LessThanEqualsToken */: + case 30 /* GreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (operandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, operandType); + } + else { + usageContext.isNumber = true; + } + break; + case 60 /* PlusEqualsToken */: + case 38 /* PlusToken */: + var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (otherOperandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, otherOperandType); + } + else if (otherOperandType.flags & 296 /* NumberLike */) { + usageContext.isNumber = true; + } + else if (otherOperandType.flags & 132 /* StringLike */) { + usageContext.isString = true; + } + else { + usageContext.isNumber = true; + usageContext.isString = true; + } + break; + // AssignmentOperators + case 59 /* EqualsToken */: + case 33 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + break; + case 93 /* InKeyword */: + if (node === parent.left) { + usageContext.isString = true; + } + break; + // LogicalOperator + case 55 /* BarBarToken */: + if (node === parent.left && + (node.parent.parent.kind === 237 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + // var x = x || {}; + // TODO: use getFalsyflagsOfType + addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + } + break; + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: + case 94 /* InstanceOfKeyword */: + // nothing to infer here + break; + } + } + function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { + addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + } + function inferTypeFromCallExpressionContext(parent, checker, usageContext) { + var callContext = { + argumentTypes: [], + returnType: {} + }; + if (parent.arguments) { + for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + } + } + inferTypeFromContext(parent, checker, callContext.returnType); + if (parent.kind === 191 /* CallExpression */) { + (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + } + else { + (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + } + } + function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + var name = ts.escapeLeadingUnderscores(parent.name.text); + if (!usageContext.properties) { + usageContext.properties = ts.createUnderscoreEscapedMap(); + } + var propertyUsageContext = usageContext.properties.get(name) || {}; + inferTypeFromContext(parent, checker, propertyUsageContext); + usageContext.properties.set(name, propertyUsageContext); + } + function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + if (node === parent.argumentExpression) { + usageContext.isNumber = true; + usageContext.isString = true; + return; + } + else { + var indexType = checker.getTypeAtLocation(parent.argumentExpression); + var indexUsageContext = {}; + inferTypeFromContext(parent, checker, indexUsageContext); + if (indexType.flags & 296 /* NumberLike */) { + usageContext.numberIndexContext = indexUsageContext; + } + else { + usageContext.stringIndexContext = indexUsageContext; + } + } + } + function unifyFromContext(inferences, checker, fallback) { + if (fallback === void 0) { fallback = checker.getAnyType(); } + if (!inferences.length) + return fallback; + var hasNonVacuousType = inferences.some(function (i) { return !(i.flags & (1 /* Any */ | 16384 /* Void */)); }); + var hasNonVacuousNonAnonymousType = inferences.some(function (i) { return !(i.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); + var anons = inferences.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); + var good = []; + if (!hasNonVacuousNonAnonymousType && anons.length) { + good.push(unifyAnonymousTypes(anons, checker)); + } + good.push.apply(good, inferences.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */) && !(hasNonVacuousType && i.flags & (1 /* Any */ | 16384 /* Void */)); })); + return checker.getWidenedType(checker.getUnionType(good)); + } + InferFromReference.unifyFromContext = unifyFromContext; + function unifyAnonymousTypes(anons, checker) { + if (anons.length === 1) { + return anons[0]; + } + var calls = []; + var constructs = []; + var stringIndices = []; + var numberIndices = []; + var stringIndexReadonly = false; + var numberIndexReadonly = false; + var props = ts.createMultiMap(); + for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) { + var anon = anons_1[_i]; + for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { + var p = _b[_a]; + props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + } + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); + if (anon.stringIndexInfo) { + stringIndices.push(anon.stringIndexInfo.type); + stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly; + } + if (anon.numberIndexInfo) { + numberIndices.push(anon.numberIndexInfo.type); + numberIndexReadonly = numberIndexReadonly || anon.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); + s.type = checker.getUnionType(types); + return [name, s]; + }); + return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); + } + function inferFromContext(usageContext, checker) { + var types = []; + if (usageContext.isNumber) { + types.push(checker.getNumberType()); + } + if (usageContext.isString) { + types.push(checker.getStringType()); + } + types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { + var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 + var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); + } + else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + } + if (usageContext.numberIndexContext) { + return [checker.createArrayType(recur(usageContext.numberIndexContext))]; + } + else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + var members_1 = ts.createUnderscoreEscapedMap(); + var callSignatures = []; + var constructSignatures = []; + var stringIndexInfo = void 0; + if (usageContext.properties) { + usageContext.properties.forEach(function (context, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = recur(context); + members_1.set(name, symbol); + }); + } + if (usageContext.callContexts) { + for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { + var callContext = _a[_i]; + callSignatures.push(getSignatureFromCallContext(callContext, checker)); + } + } + if (usageContext.constructContexts) { + for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { + var constructContext = _c[_b]; + constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + } + } + if (usageContext.stringIndexContext) { + stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + } + types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + } + return types; + function recur(innerContext) { + return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + } + function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + var types = []; + if (callContexts) { + for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { + var callContext = callContexts_2[_i]; + if (callContext.argumentTypes.length > parameterIndex) { + if (isRestParameter) { + types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + } + } + if (types.length) { + var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); + return isRestParameter ? checker.createArrayType(type) : type; + } + return undefined; + } + function getSignatureFromCallContext(callContext, checker) { + var parameters = []; + for (var i = 0; i < callContext.argumentTypes.length; i++) { + var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + parameters.push(symbol); + } + var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + // TODO: GH#18217 + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + } + function addCandidateType(context, type) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + (context.candidateTypes || (context.candidateTypes = [])).push(type); + } + } + function hasCallContext(usageContext) { + return !!usageContext && !!usageContext.callContexts; + } + })(InferFromReference || (InferFromReference = {})); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107341,12 +109373,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -107378,7 +109410,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(116 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -107401,7 +109433,7 @@ var ts; 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 === 219 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 221 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -107409,27 +109441,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 195 /* ArrowFunction */: { + case 197 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 216 /* Block */) { + if (arrowFunctionBody.kind === 218 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyComments(assignmentBinaryExpression, method, sourceFile); @@ -107450,17 +109482,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 196 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 71 /* Identifier */) { + if (node.name.kind !== 72 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107471,7 +109503,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107523,13 +109555,13 @@ var ts; var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context, setOfExpressionsToReturn, originalTypeMap, allVarNames); var constIdentifiers = getConstIdentifiers(synthNamesMap); - var returnStatements = ts.getReturnStatementsWithPromiseHandlers(functionToConvertRenamed); + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, allVarNames: allVarNames, setOfExpressionsToReturn: setOfExpressionsToReturn, constIdentifiers: constIdentifiers, originalTypeMap: originalTypeMap, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 120 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 121 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); @@ -107549,6 +109581,14 @@ var ts; _loop_10(statement); } } + function getReturnStatementsWithPromiseHandlers(body) { + var res = []; + ts.forEachReturnStatement(body, function (ret) { + if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + res.push(ret); + }); + return res; + } // Returns the identifiers that are never reassigned in the refactor function getConstIdentifiers(synthNamesMap) { var constIdentifiers = []; @@ -107810,10 +109850,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 71 /* Identifier */: // identifier includes undefined + case 72 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -107835,8 +109875,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -107847,7 +109887,7 @@ var ts; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; } - if (ts.getReturnStatementsWithPromiseHandlers(statement).length) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -107858,7 +109898,7 @@ var ts; removeReturns(refactoredStmts, prevArgName === undefined ? undefined : prevArgName.identifier, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.getReturnStatementsWithPromiseHandlers(ts.createReturn(funcBody)); + var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.createReturn(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -108001,10 +110041,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -108050,29 +110090,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 59 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 189 /* CallExpression */: { + case 191 /* 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 59 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -108112,8 +110152,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: { + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -108121,7 +110161,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: @@ -108164,16 +110204,16 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 274 /* ShorthandPropertyAssignment */: - case 275 /* SpreadAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 277 /* SpreadAssignment */: return undefined; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 154 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); + case 156 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(85 /* ExportKeyword */)], prop); default: ts.Debug.assertNever(prop); } @@ -108222,23 +110262,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.createToken(84 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(85 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* 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, 23 /* DotToken */, sourceFile), [ts.createToken(84 /* ExportKeyword */), ts.createToken(76 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(85 /* ExportKeyword */), ts.createToken(77 /* 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) { - var modifiers = [ts.createToken(84 /* ExportKeyword */)]; + var modifiers = [ts.createToken(85 /* ExportKeyword */)]; switch (exported.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -108246,10 +110286,10 @@ var ts; } } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -108267,7 +110307,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: { + case 184 /* 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 @@ -108278,7 +110318,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 183 /* ArrayBindingPattern */: { + case 185 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -108289,7 +110329,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name); @@ -108361,11 +110401,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node; - case 184 /* BindingElement */: + case 186 /* BindingElement */: return parent.propertyName !== node; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -108704,21 +110744,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 247 /* ImportDeclaration */) + if (declaration.kind !== 249 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 252 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 247 /* ImportDeclaration */) { + if (declaration.kind === 249 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 251 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -108729,7 +110769,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) + return (i.kind === 249 /* ImportDeclaration */ || i.kind === 248 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -108744,7 +110784,7 @@ var ts; }); }); // Sort to keep the shortest paths first - return choicesForEachExportingModule.sort(function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -108752,9 +110792,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 247 /* ImportDeclaration */ + var expression = declaration.kind === 249 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 259 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -109082,12 +111122,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -109142,6 +111182,9 @@ var ts; var errorCodes = [ ts.Diagnostics.Property_0_does_not_exist_on_type_1.code, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code, + ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more.code ]; var fixId = "addMissingMember"; codefix.registerCodeFix({ @@ -109275,7 +111318,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 207 /* ClassExpression */) { + if (classDeclaration.kind === 209 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -109301,13 +111344,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 202 /* BinaryExpression */) { + if (token.parent.parent.kind === 204 /* 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); } - return typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); + else { + var contextualType = checker.getContextualType(token.parent); + typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; + } + return typeNode || ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -109316,7 +111363,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -109340,7 +111387,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(137 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(138 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -109360,7 +111407,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, !ts.isInterfaceDeclaration(typeDecl)); - var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 156 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -109376,7 +111423,7 @@ var ts; */ var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 68 /* StringLike */); + return !!(type && type.flags & 132 /* StringLike */); }); var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); @@ -109625,7 +111672,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 99 /* ThisKeyword */) + if (token.kind !== 100 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -109664,7 +111711,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 124 /* ConstructorKeyword */); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -109702,17 +111749,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 86 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(109 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 85 /* ExtendsKeyword */ && - heritageClauses[1].token === 108 /* ImplementsKeyword */) { + heritageClauses[0].token === 86 /* ExtendsKeyword */ && + heritageClauses[1].token === 109 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(26 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* 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; @@ -109796,7 +111843,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 === 27 /* LessThanToken */) { + if (token.kind === 28 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -109816,7 +111863,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* 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)); @@ -109848,7 +111895,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 126 /* InferKeyword */) + if (token.kind === 127 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -109857,7 +111904,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 27 /* LessThanToken */) { + else if (token.kind === 28 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -109867,7 +111914,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -109878,7 +111925,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(142 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(143 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -109888,13 +111935,13 @@ var ts; } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 92 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { - if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) + if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 149 /* Parameter */) { + if (decl.kind === 151 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -109905,7 +111952,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -109914,7 +111961,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 === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -109923,14 +111970,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 149 /* Parameter */: - case 148 /* TypeParameter */: + case 151 /* Parameter */: + case 150 /* TypeParameter */: return true; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: return true; } } @@ -109944,9 +111991,9 @@ var ts; } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 187 /* PropertyAccessExpression */) + if (ts.isPropertyAccessExpression(ref.parent) && ref.parent.name === ref) ref = ref.parent; - if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + if (ts.isBinaryExpression(ref.parent) && ts.isExpressionStatement(ref.parent.parent) && ref.parent.left === ref) { changes.delete(sourceFile, ref.parent.parent); } }); @@ -109962,33 +112009,41 @@ var ts; } function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { if (mayDeleteParameter(p, checker, isFixAll)) { - changes.delete(sourceFile, p); - deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + if (p.modifiers && p.modifiers.length > 0 + && (!ts.isIdentifier(p.name) || ts.FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) { + p.modifiers.forEach(function (modifier) { + changes.deleteModifier(sourceFile, modifier); + }); + } + else { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + } } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: return true; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 72 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -110028,7 +112083,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 220 /* IfStatement */: + case 222 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -110039,8 +112094,8 @@ var ts; return; } // falls through - case 222 /* WhileStatement */: - case 223 /* ForStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -110089,7 +112144,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, 56 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -110113,10 +112168,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 === 284 /* JSDocNullableType */) { + if (typeNode.kind === 286 /* 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, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -110133,7 +112188,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -110150,22 +112205,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 210 /* AsExpression */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 237 /* FunctionDeclaration */: - case 156 /* GetAccessor */: - case 160 /* IndexSignature */: - case 179 /* MappedType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 192 /* TypeAssertionExpression */: - case 235 /* VariableDeclaration */: + case 212 /* AsExpression */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 239 /* FunctionDeclaration */: + case 158 /* GetAccessor */: + case 162 /* IndexSignature */: + case 181 /* MappedType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 194 /* TypeAssertionExpression */: + case 237 /* VariableDeclaration */: return true; default: return false; @@ -110219,15 +112274,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 90 /* FunctionKeyword */, sourceFile); break; - case 195 /* ArrowFunction */: - insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); + case 197 /* ArrowFunction */: + insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: return; @@ -110241,11 +112296,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 71 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 72 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 120 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 121 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -110335,17 +112390,17 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); switch (declaration.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 151 /* PropertySignature */: - case 152 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 153 /* PropertySignature */: + case 154 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 153 /* MethodSignature */: - case 154 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 156 /* 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 @@ -110385,14 +112440,14 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 156 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(55 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -110408,11 +112463,11 @@ var ts; ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); - var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(119 /* AnyKeyword */); + var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(120 /* AnyKeyword */); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(39 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -110429,8 +112484,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(120 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -110458,11 +112513,11 @@ 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.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(120 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyArrayType, + /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -110473,7 +112528,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -110482,10 +112537,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(114 /* PublicKeyword */); + return ts.createToken(115 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(113 /* ProtectedKeyword */); + return ts.createToken(114 /* ProtectedKeyword */); } return undefined; } @@ -110493,608 +112548,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - var codefix; - (function (codefix) { - var fixId = "inferFromUsage"; - var errorCodes = [ - // Variable declarations - ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, - // Variable uses - ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, - // Parameter declarations - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, - // Get Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, - ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, - // Set Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, - // Property declarations - ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, - ]; - codefix.registerCodeFix({ - errorCodes: errorCodes, - getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; - var token = ts.getTokenAtPosition(sourceFile, start); - var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); - var name = declaration && ts.getNameOfDeclaration(declaration); - return !name || changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; - }, - fixIds: [fixId], - getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; - var markSeen = ts.nodeSeenTracker(); - return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); - }); - }, - }); - function getDiagnostic(errorCode, token) { - switch (errorCode) { - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - return ts.Diagnostics.Infer_parameter_types_from_usage; - default: - return ts.Diagnostics.Infer_type_of_0_from_usage; - } - } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 71 /* Identifier */ && token.kind !== 24 /* DotDotDotToken */ && token.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var parent = token.parent; - switch (errorCode) { - // Variable and Property declarations - case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: - case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: - if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); - return parent; - } - if (ts.isPropertyAccessExpression(parent)) { - var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); - var typeNode = type && getTypeNodeIfAccessible(type, parent, program, host); - if (typeNode) { - changes.tryInsertJSDocType(sourceFile, parent, typeNode); - } - return parent; - } - return undefined; - case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { - var symbol = program.getTypeChecker().getSymbolAtLocation(token); - if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); - return symbol.valueDeclaration; - } - return undefined; - } - } - var containingFunction = ts.getContainingFunction(token); - if (containingFunction === undefined) { - return undefined; - } - switch (errorCode) { - // Parameter declarations - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - // falls through - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - if (markSeen(containingFunction)) { - var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, param, containingFunction, sourceFile, program, host, cancellationToken); - return param; - } - return undefined; - // Get Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: - case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: - if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); - return containingFunction; - } - return undefined; - // Set Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - return undefined; - default: - return ts.Debug.fail(String(errorCode)); - } - } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { - if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); - } - } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - return true; - case 194 /* FunctionExpression */: - return !!declaration.name; - } - return false; - } - function annotateParameters(changes, parameterDeclaration, containingFunction, sourceFile, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { - return; - } - var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : undefined - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); - if (ts.isInJSFile(containingFunction)) { - annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); - } - else { - 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) { - annotate(changes, sourceFile, declaration, type, program, host); - } - } - } - } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { - var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); - if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { - var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken) || - inferTypeForVariableFromUsage(param.name, program, cancellationToken); - if (ts.isInJSFile(setAccessorDeclaration)) { - annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); - } - else { - annotate(changes, sourceFile, param, type, program, host); - } - } - } - function annotate(changes, sourceFile, declaration, type, program, host) { - var typeNode = type && getTypeNodeIfAccessible(type, declaration, program, host); - if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 151 /* PropertySignature */) { - changes.tryInsertJSDocType(sourceFile, declaration, typeNode); - } - else { - changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); - } - } - } - function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { - var result = ts.mapDefined(parameterInferences, function (inference) { - var param = inference.declaration; - var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); - return typeNode && !param.initializer && !ts.getJSDocType(param) ? __assign({}, inference, { typeNode: typeNode }) : undefined; - }); - changes.tryInsertJSDocParameters(sourceFile, result); - } - function getTypeNodeIfAccessible(type, enclosingScope, program, host) { - var checker = program.getTypeChecker(); - var typeIsAccessible = true; - var notAccessible = function () { typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { - trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; - }, - reportInaccessibleThisError: notAccessible, - reportPrivateInBaseOfClassExpression: notAccessible, - reportInaccessibleUniqueSymbolError: notAccessible, - moduleResolverHost: { - readFile: host.readFile, - fileExists: host.fileExists, - directoryExists: host.directoryExists, - getSourceFiles: program.getSourceFiles, - getCurrentDirectory: program.getCurrentDirectory, - getCommonSourceDirectory: program.getCommonSourceDirectory, - } - }); - return typeIsAccessible ? res : undefined; - } - 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; - }); - } - function inferTypeForVariableFromUsage(token, program, cancellationToken) { - return InferFromReference.inferTypeFromReferences(getReferences(token, program, cancellationToken), program.getTypeChecker(), cancellationToken); - } - function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { - switch (containingFunction.kind) { - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - var isConstructor = containingFunction.kind === 155 /* Constructor */; - var searchToken = isConstructor ? - ts.findChildOfKind(containingFunction, 123 /* ConstructorKeyword */, sourceFile) : - containingFunction.name; - if (searchToken) { - return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program.getTypeChecker(), cancellationToken); - } - } - } - var InferFromReference; - (function (InferFromReference) { - function inferTypeFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { - var reference = references_1[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return getTypeFromUsageContext(usageContext, checker); - } - InferFromReference.inferTypeFromReferences = inferTypeFromReferences; - function inferTypeForParametersFromReferences(references, declaration, checker, cancellationToken) { - if (references.length === 0) { - return undefined; - } - if (!declaration.parameters) { - return undefined; - } - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - var isConstructor = declaration.kind === 155 /* Constructor */; - var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; - return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { - var types = []; - var isRest = ts.isRestParameter(parameter); - var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { - isOptional = ts.isInJSFile(declaration); - continue; - } - if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - } - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - if (!types.length) { - return { declaration: parameter }; - } - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return { - type: isRest ? checker.createArrayType(type) : type, - isOptional: isOptional && !isRest, - declaration: parameter - }; - }); - } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeFromContext(node, checker, usageContext) { - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - switch (node.parent.kind) { - case 201 /* PostfixUnaryExpression */: - usageContext.isNumber = true; - break; - case 200 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); - break; - case 202 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); - break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); - break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); - } - else { - inferTypeFromContextualType(node, checker, usageContext); - } - break; - case 187 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); - break; - case 188 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); - break; - case 235 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); - } - break; - } - } - // falls through - default: - return inferTypeFromContextualType(node, checker, usageContext); - } - } - function inferTypeFromContextualType(node, checker, usageContext) { - if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); - } - } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { - switch (node.operator) { - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - usageContext.isNumber = true; - break; - case 37 /* PlusToken */: - usageContext.isNumberOrString = true; - break; - // case SyntaxKind.ExclamationToken: - // no inferences here; - } - } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { - switch (parent.operatorToken.kind) { - // ExponentiationOperator - case 40 /* AsteriskAsteriskToken */: - // MultiplicativeOperator - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - // ShiftOperator - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - // BitwiseOperator - case 48 /* AmpersandToken */: - case 49 /* BarToken */: - case 50 /* CaretToken */: - // CompoundAssignmentOperator - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 69 /* BarEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - // AdditiveOperator - case 38 /* MinusToken */: - // RelationalOperator - case 27 /* LessThanToken */: - case 30 /* LessThanEqualsToken */: - case 29 /* GreaterThanToken */: - case 31 /* GreaterThanEqualsToken */: - var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, operandType); - } - else { - usageContext.isNumber = true; - } - break; - case 59 /* PlusEqualsToken */: - case 37 /* PlusToken */: - var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); - } - else if (otherOperandType.flags & 168 /* NumberLike */) { - usageContext.isNumber = true; - } - else if (otherOperandType.flags & 68 /* StringLike */) { - usageContext.isString = true; - } - else { - usageContext.isNumberOrString = true; - } - break; - // AssignmentOperators - case 58 /* EqualsToken */: - case 32 /* EqualsEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); - break; - case 92 /* InKeyword */: - if (node === parent.left) { - usageContext.isString = true; - } - break; - // LogicalOperator - case 54 /* BarBarToken */: - if (node === parent.left && - (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { - // var x = x || {}; - // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); - } - break; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: - case 93 /* InstanceOfKeyword */: - // nothing to infer here - break; - } - } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); - } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { - argumentTypes: [], - returnType: {} - }; - if (parent.arguments) { - for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); - } - } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 189 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); - } - else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); - } - } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { - var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); - } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); - } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { - if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; - return; - } - else { - var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 168 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; - } - else { - usageContext.stringIndexContext = indexUsageContext; - } - } - } - function getTypeFromUsageContext(usageContext, checker) { - if (usageContext.isNumberOrString && !usageContext.isNumber && !usageContext.isString) { - return checker.getUnionType([checker.getNumberType(), checker.getStringType()]); - } - else if (usageContext.isNumber) { - return checker.getNumberType(); - } - else if (usageContext.isString) { - return checker.getStringType(); - } - else if (usageContext.candidateTypes) { - return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(function (t) { return checker.getBaseTypeOfLiteralType(t); }), 2 /* Subtype */)); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - return checker.createPromiseType(types.length ? checker.getUnionType(types, 2 /* Subtype */) : checker.getAnyType()); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - return checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker)); - } - else if (usageContext.numberIndexContext) { - return checker.createArrayType(recur(usageContext.numberIndexContext)); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_1 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_1.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - return checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 - } - else { - return undefined; - } - function recur(innerContext) { - return getTypeFromUsageContext(innerContext, checker) || checker.getAnyType(); - } - } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { - var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - } - } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; - } - return undefined; - } - function getSignatureFromCallContext(callContext, checker) { - var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - parameters.push(symbol); - } - var returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType(); - // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - } - function addCandidateType(context, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 32768 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); - } - } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); - })(codefix = ts.codefix || (ts.codefix = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var codefix; (function (codefix) { @@ -111127,7 +112580,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 191 /* CallExpression */ : 192 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; @@ -111238,7 +112691,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(51 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -111246,7 +112699,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(141 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -111267,7 +112720,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 512 /* BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.createFalse() : ts.createTrue(); } else if (type.isLiteral()) { @@ -111292,15 +112745,23 @@ var ts; } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/* @internal */ var ts; (function (ts) { function generateTypesForModule(name, moduleValue, formatSettings) { - return valueInfoToDeclarationFileText(ts.inspectValue(name, moduleValue), formatSettings); + return generateTypesForModuleOrGlobal(name, moduleValue, formatSettings, 0 /* ExportEquals */); } ts.generateTypesForModule = generateTypesForModule; - function valueInfoToDeclarationFileText(valueInfo, formatSettings) { - return ts.textChanges.getNewFileText(toStatements(valueInfo, 0 /* ExportEquals */), 3 /* TS */, "\n", ts.formatting.getFormatContext(formatSettings)); + function generateTypesForGlobal(name, globalValue, formatSettings) { + return generateTypesForModuleOrGlobal(name, globalValue, formatSettings, 3 /* Global */); + } + ts.generateTypesForGlobal = generateTypesForGlobal; + function generateTypesForModuleOrGlobal(name, globalValue, formatSettings, outputKind) { + return valueInfoToDeclarationFileText(ts.inspectValue(name, globalValue), formatSettings, outputKind); + } + /* @internal */ + function valueInfoToDeclarationFileText(valueInfo, formatSettings, outputKind) { + if (outputKind === void 0) { outputKind = 0 /* ExportEquals */; } + return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; var OutputKind; @@ -111308,6 +112769,7 @@ var ts; OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; OutputKind[OutputKind["NamedExport"] = 1] = "NamedExport"; OutputKind[OutputKind["NamespaceMember"] = 2] = "NamespaceMember"; + OutputKind[OutputKind["Global"] = 3] = "Global"; })(OutputKind || (OutputKind = {})); function toNamespaceMemberStatements(info) { return toStatements(info, 2 /* NamespaceMember */); @@ -111317,9 +112779,9 @@ var ts; var name = isDefault ? "_default" : info.name; if (!isValidIdentifier(name) || isDefault && kind !== 1 /* NamedExport */) return ts.emptyArray; - var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(84 /* ExportKeyword */), ts.createModifier(79 /* DefaultKeyword */)] - : kind === 0 /* ExportEquals */ ? [ts.createModifier(124 /* DeclareKeyword */)] - : kind === 1 /* NamedExport */ ? [ts.createModifier(84 /* ExportKeyword */)] + var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(85 /* ExportKeyword */), ts.createModifier(80 /* DefaultKeyword */)] + : kind === 3 /* Global */ || kind === 0 /* ExportEquals */ ? [ts.createModifier(125 /* DeclareKeyword */)] + : kind === 1 /* NamedExport */ ? [ts.createModifier(85 /* ExportKeyword */)] : undefined; var exportEquals = function () { return kind === 0 /* ExportEquals */ ? [exportEqualsOrDefault(info.name, /*isExportEquals*/ true)] : ts.emptyArray; }; var exportDefault = function () { return isDefault ? [exportEqualsOrDefault("_default", /*isExportEquals*/ false)] : ts.emptyArray; }; @@ -111327,13 +112789,15 @@ var ts; case 2 /* FunctionOrClass */: return exportEquals().concat(functionOrClassToStatements(modifiers, name, info)); case 3 /* Object */: - var members = info.members; - if (kind === 0 /* ExportEquals */) { - return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); - } - if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { - // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. - return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + var members = info.members, hasNontrivialPrototype = info.hasNontrivialPrototype; + if (!hasNontrivialPrototype) { + if (kind === 0 /* ExportEquals */) { + return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); + } + if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { + // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. + return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + } } // falls through case 0 /* Const */: @@ -111353,8 +112817,20 @@ var ts; var source = _a.source, prototypeMembers = _a.prototypeMembers, namespaceMembers = _a.namespaceMembers; var fnAst = parseClassOrFunctionBody(source); var _b = fnAst === undefined ? { parameters: ts.emptyArray, returnType: anyType() } : getParametersAndReturnType(fnAst), parameters = _b.parameters, returnType = _b.returnType; - var instanceProperties = typeof fnAst === "object" ? getConstructorFunctionInstanceProperties(fnAst) : ts.emptyArray; - var classStaticMembers = instanceProperties.length !== 0 || prototypeMembers.length !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */ ? [] : undefined; + var protoOrInstanceMembers = ts.createMap(); + if (typeof fnAst === "object") + getConstructorFunctionInstanceProperties(fnAst, protoOrInstanceMembers); + for (var _i = 0, prototypeMembers_1 = prototypeMembers; _i < prototypeMembers_1.length; _i++) { + var p = prototypeMembers_1[_i]; + // ignore non-functions on the prototype + if (p.kind === 2 /* FunctionOrClass */) { + var m = tryGetMethod(p); + if (m) { + protoOrInstanceMembers.set(p.name, m); + } + } + } + var classStaticMembers = protoOrInstanceMembers.size !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */ ? [] : undefined; var namespaceStatements = ts.flatMap(namespaceMembers, function (info) { if (!isValidIdentifier(info.name)) return undefined; @@ -111367,16 +112843,19 @@ var ts; // falls through case 1 /* Array */: case 0 /* Const */: - classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(115 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); + classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(116 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); return undefined; case 2 /* FunctionOrClass */: if (!info.namespaceMembers.length) { // Else, can't merge a static method with a namespace. Must make it a function on the namespace. - var sig = tryGetMethod(info, [ts.createModifier(115 /* StaticKeyword */)]); + var sig = tryGetMethod(info, [ts.createModifier(116 /* StaticKeyword */)]); if (sig) { classStaticMembers.push(sig); return undefined; } } + break; + default: + ts.Debug.assertNever(info); } } return toStatements(info, 2 /* NamespaceMember */); @@ -111385,7 +112864,7 @@ var ts; ? ts.createClassDeclaration( /*decorators*/ undefined, modifiers, name, /*typeParameters*/ undefined, - /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), instanceProperties, ts.mapDefined(prototypeMembers, function (info) { return info.kind === 2 /* FunctionOrClass */ ? tryGetMethod(info) : undefined; }))) + /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), ts.arrayFrom(protoOrInstanceMembers.values()))) : ts.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, name, /*typeParameters*/ undefined, parameters, returnType, /*body*/ undefined); return [decl].concat((namespaceStatements.length === 0 ? ts.emptyArray : [createNamespace(modifiers && modifiers.map(function (m) { return ts.getSynthesizedDeepClone(m); }), name, namespaceStatements)])); } @@ -111394,7 +112873,7 @@ var ts; if (!isValidIdentifier(name)) return undefined; var fnAst = parseClassOrFunctionBody(source); - if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */)) + if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */)) return undefined; var sig = getParametersAndReturnType(fnAst); return sig && ts.createMethod( @@ -111413,23 +112892,25 @@ var ts; case 2 /* FunctionOrClass */: return ts.createTypeReferenceNode("Function", /*typeArguments*/ undefined); // Normally we create a FunctionDeclaration, but this can happen for a function in an array. case 3 /* Object */: - return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, m.name, /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); + return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, toPropertyName(m.name), /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); default: return ts.Debug.assertNever(info); } } + function toPropertyName(name) { + return ts.isIdentifierText(name, 6 /* ESNext */) ? ts.createIdentifier(name) : ts.createStringLiteral(name); + } // Parses assignments to "this.x" in the constructor into class property declarations - function getConstructorFunctionInstanceProperties(fnAst) { - var members = []; + function getConstructorFunctionInstanceProperties(fnAst, members) { forEachOwnNodeOfFunction(fnAst, function (node) { if (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && - ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 99 /* ThisKeyword */) { - var name = node.left.name.text; - if (!ts.isJsPrivate(name)) - members.push(ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined)); + ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 100 /* ThisKeyword */) { + var name_4 = node.left.name.text; + if (!ts.isJsPrivate(name_4)) { + ts.getOrUpdate(members, name_4, function () { return ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name_4, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined); }); + } } }); - return members; } function getParametersAndReturnType(fnAst) { if (typeof fnAst === "number") { @@ -111438,16 +112919,16 @@ var ts; var usedArguments = false, hasReturn = false; forEachOwnNodeOfFunction(fnAst, function (node) { usedArguments = usedArguments || ts.isIdentifier(node) && node.text === "arguments"; - hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 198 /* VoidExpression */; + hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 200 /* VoidExpression */; }); var parameters = fnAst.parameters.map(function (p) { return makeParameter("" + p.name.getText(), inferParameterType(fnAst, p)); }).concat((usedArguments ? [makeRestParameter()] : ts.emptyArray)); - return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(105 /* VoidKeyword */) }; + return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(106 /* VoidKeyword */) }; } function makeParameter(name, type) { return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name, /*questionToken*/ undefined, type); } function makeRestParameter() { - return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); + return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); } /** Returns 'undefined' for class with no declared constructor */ function parseClassOrFunctionBody(source) { @@ -111486,7 +112967,7 @@ var ts; return node; } function anyType() { - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createNamespace(modifiers, name, statements) { return ts.createModuleDeclaration(/*decorators*/ undefined, modifiers, ts.createIdentifier(name), ts.createModuleBlock(statements), 16 /* Namespace */); @@ -111588,8 +113069,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 181 /* ImportType */); + ts.Debug.assert(token.kind === 92 /* ImportKeyword */); + ts.Debug.assert(token.parent.kind === 183 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -111641,7 +113122,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(133 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -111661,7 +113142,7 @@ var ts; getAvailableActions: function (context) { var info = getInfo(context); if (!info) - return undefined; + return ts.emptyArray; var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; @@ -111688,16 +113169,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: { + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -111720,17 +113201,17 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 80 /* DefaultKeyword */))); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 85 /* ExportKeyword */)); switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(80 /* DefaultKeyword */)); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. @@ -111738,9 +113219,9 @@ var ts; break; } // falls through - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); @@ -111767,18 +113248,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { + case 253 /* ImportSpecifier */: + case 257 /* 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 248 /* ImportClause */: { + case 250 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref); var spec = makeImportSpecifier(exportName, ref.text); @@ -111787,7 +113268,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 249 /* NamespaceImport */) { + else if (namedBindings.kind === 251 /* 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 */; @@ -111808,36 +113289,33 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { - var spec = parent; - if (spec.kind === 251 /* ImportSpecifier */) { - // `import { foo } from "./a";` --> `import foo from "./a";` - // `import { foo as bar } from "./a";` --> `import bar from "./a";` - var defaultImport = ts.createIdentifier(spec.name.text); - if (spec.parent.elements.length === 1) { - changes.replaceNode(importingSourceFile, spec.parent, defaultImport); - } - else { - changes.delete(importingSourceFile, spec); - changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); - } + case 253 /* ImportSpecifier */: { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(parent.name.text); + if (parent.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, parent.parent, defaultImport); } else { - // `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";` - // (Because `export foo from "./a";` isn't valid syntax.) - changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + changes.delete(importingSourceFile, parent); + changes.insertNodeBefore(importingSourceFile, parent.parent, defaultImport); } break; } + case 257 /* 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";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, parent, makeExportSpecifier("default", parent.name.text)); + break; + } default: - ts.Debug.failBadSyntaxKind(parent); + ts.Debug.assertNever(parent); } } function makeImportSpecifier(propertyName, name) { @@ -111860,9 +113338,9 @@ var ts; getAvailableActions: function (context) { var i = getImportToConvert(context); if (!i) - return undefined; - var description = i.kind === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 249 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return ts.emptyArray; + var description = i.kind === 251 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 251 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { @@ -111884,7 +113362,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 249 /* NamespaceImport */) { + if (toConvert.kind === 251 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -111992,12 +113470,12 @@ var ts; var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context)); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { - return undefined; + return ts.emptyArray; } var extractions = getPossibleExtractions(targetRange, context); if (extractions === undefined) { // No extractions possible - return undefined; + return ts.emptyArray; } var functionActions = []; var usedFunctionNames = ts.createMap(); @@ -112053,7 +113531,7 @@ var ts; actions: constantActions }); } - return infos.length ? infos : undefined; + return infos.length ? infos : ts.emptyArray; } extractSymbol.getAvailableActions = getAvailableActions; /* Exported for tests */ @@ -112227,20 +113705,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 152 /* PropertyDeclaration */) { + if (current.kind === 154 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 149 /* Parameter */) { + else if (current.kind === 151 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 155 /* Constructor */) { + if (ctorOrMethod.kind === 157 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 154 /* MethodDeclaration */) { + else if (current.kind === 156 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -112283,7 +113761,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 235 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 237 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* 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`! @@ -112295,13 +113773,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 97 /* SuperKeyword */: + case 98 /* 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 === 189 /* CallExpression */) { + if (node.parent.kind === 191 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -112316,8 +113794,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -112329,20 +113807,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 220 /* IfStatement */: + case 222 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 216 /* Block */: - if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { + case 218 /* Block */: + if (node.parent && node.parent.kind === 235 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -112354,11 +113832,11 @@ var ts; break; } switch (node.kind) { - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -112366,8 +113844,8 @@ var ts; seenLabels.pop(); break; } - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: { var label = node.label; if (label) { @@ -112377,20 +113855,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 229 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -112444,7 +113922,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 === 149 /* Parameter */) { + if (current.kind === 151 /* 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; } @@ -112455,7 +113933,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 277 /* SourceFile */) { + if (current.kind === 279 /* SourceFile */) { return scopes; } } @@ -112545,32 +114023,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return "arrow function"; - case 154 /* MethodDeclaration */: - return "method '" + scope.name.getText(); - case 156 /* GetAccessor */: + case 156 /* MethodDeclaration */: + return "method '" + scope.name.getText() + "'"; + case 158 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 238 /* ClassDeclaration */ + return scope.kind === 240 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 243 /* ModuleBlock */ + return scope.kind === 245 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -112636,20 +114114,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(112 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(113 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(120 /* AsyncKeyword */)); + modifiers.push(ts.createToken(121 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(121 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* 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; @@ -112666,7 +114144,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -112790,9 +114268,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 140 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 141 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(140 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(141 /* UndefinedKeyword */)]); } } /** @@ -112815,11 +114293,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(112 /* PrivateKeyword */)); + modifiers.push(ts.createToken(113 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } - modifiers.push(ts.createToken(132 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(133 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -112848,7 +114326,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 219 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 221 /* 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.createVariableStatement( @@ -112867,7 +114345,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 219 /* ExpressionStatement */) { + if (node.parent.kind === 221 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -112954,7 +114432,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 230 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -113124,7 +114602,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (4096 /* Void */ | 32768 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -113132,7 +114610,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 239 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -113448,30 +114926,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 276 /* EnumMember */: + case 278 /* EnumMember */: return false; } switch (node.kind) { - case 9 /* StringLiteral */: - return parent.kind !== 247 /* ImportDeclaration */ && - parent.kind !== 251 /* ImportSpecifier */; - case 206 /* SpreadElement */: - case 182 /* ObjectBindingPattern */: - case 184 /* BindingElement */: + case 10 /* StringLiteral */: + return parent.kind !== 249 /* ImportDeclaration */ && + parent.kind !== 253 /* ImportSpecifier */; + case 208 /* SpreadElement */: + case 184 /* ObjectBindingPattern */: + case 186 /* BindingElement */: return false; - case 71 /* Identifier */: - return parent.kind !== 184 /* BindingElement */ && - parent.kind !== 251 /* ImportSpecifier */ && - parent.kind !== 255 /* ExportSpecifier */; + case 72 /* Identifier */: + return parent.kind !== 186 /* BindingElement */ && + parent.kind !== 253 /* ImportSpecifier */ && + parent.kind !== 257 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 216 /* Block */: - case 277 /* SourceFile */: - case 243 /* ModuleBlock */: - case 269 /* CaseClause */: + case 218 /* Block */: + case 279 /* SourceFile */: + case 245 /* ModuleBlock */: + case 271 /* CaseClause */: return true; default: return false; @@ -113492,7 +114970,7 @@ var ts; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { if (!getConvertibleFieldAtPosition(context)) - return undefined; + return ts.emptyArray; return [{ name: actionName, description: actionDescription, @@ -113520,10 +114998,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 114 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 115 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 112 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 113 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -113561,7 +115039,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(115 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(116 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -113584,7 +115062,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 149 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 151 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -113666,7 +115144,7 @@ var ts; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) - return undefined; + return ts.emptyArray; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, @@ -113728,11 +115206,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return true; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -113820,12 +115298,12 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? + case 249 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 251 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -113856,20 +115334,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 249 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 248 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -113939,15 +115417,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -113960,7 +115438,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 251 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -113972,7 +115450,7 @@ var ts; if (namedBindingsUnused) { changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 250 /* NamedImports */) { + else if (namedBindings.kind === 252 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -113985,14 +115463,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: break; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); } @@ -114097,13 +115575,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: return true; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -114115,7 +115593,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -114125,9 +115603,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -114136,7 +115614,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -114146,11 +115624,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return keep(name) ? name : undefined; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return name; - case 182 /* ObjectBindingPattern */: { + case 184 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -114207,13 +115685,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -114221,17 +115699,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return cb(statement); - case 217 /* VariableStatement */: - return ts.forEach(statement.declarationList.declarations, cb); - case 219 /* ExpressionStatement */: { + case 219 /* VariableStatement */: + return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); + case 221 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -114239,11 +115717,29 @@ var ts; } } } + function forEachTopLevelDeclarationInBindingName(name, cb) { + switch (name.kind) { + case 72 /* Identifier */: + return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); + default: + return ts.Debug.assertNever(name); + } + } function nameOfTopLevelDeclaration(d) { - return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return ts.isExpressionStatement(d) ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { - return ts.isVariableDeclaration(d) ? d.parent.parent : d; + switch (d.kind) { + case 237 /* VariableDeclaration */: + return d.parent.parent; + case 186 /* BindingElement */: + return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); + default: + return d; + } } function addExportToChanges(sourceFile, decl, changes, useEs6Exports) { if (isExported(sourceFile, decl, useEs6Exports)) @@ -114270,25 +115766,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(85 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -114299,18 +115795,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -114318,7 +115814,7 @@ var ts; } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 58 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 59 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -114340,7 +115836,7 @@ var ts; var file = context.file, startPosition = context.startPosition; var info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) - return undefined; + return ts.emptyArray; return [{ name: refactorName, description: refactorDescription, @@ -114382,7 +115878,7 @@ var ts; return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { var node = ts.getTokenAtPosition(file, startPosition); @@ -114418,7 +115914,7 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 71 /* Identifier */ ? new IdentifierObject(71 /* Identifier */, pos, end) : + kind === 72 /* Identifier */ ? new IdentifierObject(72 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 12679168 /* ContextFlags */; @@ -114491,8 +115987,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 303 /* LastJSDocNode */; }); - return child.kind < 146 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -114503,7 +115999,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 146 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 148 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -114549,7 +116045,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 71 /* Identifier */) { + if (token === 72 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -114561,7 +116057,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(304 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -114693,7 +116189,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 71 /* Identifier */; + IdentifierObject.prototype.kind = 72 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -114739,25 +116235,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 262144 /* Union */); + return !!(this.flags & 1048576 /* Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 524288 /* Intersection */); + return !!(this.flags & 2097152 /* Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 786432 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 192 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 64 /* StringLiteral */); + return !!(this.flags & 128 /* StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 128 /* NumberLiteral */); + return !!(this.flags & 256 /* NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 65536 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); @@ -114894,10 +116390,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -114917,31 +116413,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 166 /* TypeLiteral */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 168 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: { + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -114952,19 +116448,19 @@ var ts; } } // falls through - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: addDeclaration(node); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -114976,7 +116472,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -114985,7 +116481,7 @@ var ts; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -115298,7 +116794,7 @@ var ts; } var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - var sourceMapper = ts.getSourceMapper(getCanonicalFileName, currentDirectory, log, host, function () { return program; }); + var sourceMapper = ts.getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, function () { return program; }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -115379,11 +116875,11 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }; + compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile); + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -115417,7 +116913,7 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -115574,15 +117070,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return !ts.isLabelName(node); - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 97 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 98 /* SuperKeyword */: return true; default: return false; @@ -115620,7 +117116,7 @@ var ts; var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return ts.Debug.assertDefined(program.getSourceFile(f)); }); + var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -115628,7 +117124,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, position); - if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) { var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); @@ -115689,16 +117185,16 @@ var ts; return undefined; } switch (node.kind) { - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: - case 9 /* StringLiteral */: - case 86 /* FalseKeyword */: - case 101 /* TrueKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 71 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: + case 10 /* StringLiteral */: + case 87 /* FalseKeyword */: + case 102 /* TrueKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 72 /* Identifier */: break; // Cant create the text span default: @@ -115714,7 +117210,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 === 242 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 244 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -115776,10 +117272,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = ts.createMapFromTemplate((_a = {}, - _a[17 /* OpenBraceToken */] = 18 /* CloseBraceToken */, - _a[19 /* OpenParenToken */] = 20 /* CloseParenToken */, - _a[21 /* OpenBracketToken */] = 22 /* CloseBracketToken */, - _a[29 /* GreaterThanToken */] = 27 /* LessThanToken */, + _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, + _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, + _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, + _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -115919,7 +117415,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 29 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -116178,7 +117674,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 257 /* ExternalModuleReference */ || + node.parent.kind === 259 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -116193,15 +117689,15 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 147 /* ComputedPropertyName */) { + if (node.parent.kind === 149 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && + (node.parent.parent.kind === 188 /* ObjectLiteralExpression */ || node.parent.parent.kind === 268 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -116243,7 +117739,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 188 /* ElementAccessExpression */ && + node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -116323,144 +117819,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return spanInVariableDeclaration(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return spanInParameterDeclaration(node); - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanInBlock(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInBlock(node.block); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return spanInForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 233 /* TryStatement */: + case 235 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 184 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 186 /* BindingElement */: // span on complete node return textSpan(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 150 /* Decorator */: + case 152 /* Decorator */: return spanInNodeArray(parent.decorators); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return spanInPreviousNode(node); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 22 /* CloseBracketToken */: + case 23 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return spanInOpenParenToken(node); - case 20 /* CloseParenToken */: + case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 56 /* ColonToken */: + case 57 /* ColonToken */: return spanInColonToken(node); - case 29 /* GreaterThanToken */: - case 27 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 28 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return spanInWhileKeyword(node); - case 82 /* ElseKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 83 /* ElseKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return spanInNextNode(node); - case 145 /* OfKeyword */: + case 147 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -116472,14 +117968,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 === 71 /* Identifier */ || - node.kind === 206 /* SpreadElement */ || - node.kind === 273 /* PropertyAssignment */ || - node.kind === 274 /* ShorthandPropertyAssignment */) && + if ((node.kind === 72 /* Identifier */ || + node.kind === 208 /* SpreadElement */ || + node.kind === 275 /* PropertyAssignment */ || + node.kind === 276 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 202 /* BinaryExpression */) { + if (node.kind === 204 /* 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 @@ -116488,35 +117984,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 58 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 59 /* 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 === 26 /* CommaToken */) { + if (operatorToken.kind === 27 /* CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 150 /* Decorator */: + case 152 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: return textSpan(node); - case 202 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 26 /* CommaToken */) { + case 204 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -116525,21 +118021,21 @@ var ts; } } switch (node.parent.kind) { - case 273 /* PropertyAssignment */: + case 275 /* 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 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: { + case 237 /* VariableDeclaration */: + case 151 /* 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)) { @@ -116547,7 +118043,7 @@ var ts; } break; } - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -116577,7 +118073,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 226 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -116589,7 +118085,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 225 /* ForOfStatement */) { + parent.parent.kind === 227 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -116630,7 +118126,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 240 /* ClassDeclaration */ && functionDeclaration.kind !== 157 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -116653,26 +118149,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 224 /* ForInStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 226 /* 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 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* 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 === 236 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 238 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -116697,21 +118193,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 184 /* BindingElement */) { + if (bindingPattern.parent.kind === 186 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); - var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 185 /* ArrayBindingPattern */ && node.kind !== 184 /* ObjectBindingPattern */); + var elements = node.kind === 187 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -116719,18 +118215,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 === 202 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 204 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -116738,25 +118234,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* EnumDeclaration */: - case 238 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -116764,7 +118260,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); @@ -116780,7 +118276,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 183 /* ArrayBindingPattern */: + case 185 /* 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); @@ -116795,12 +118291,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 189 /* CallExpression */ || - node.parent.kind === 190 /* NewExpression */) { + if (node.parent.kind === 223 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 191 /* CallExpression */ || + node.parent.kind === 192 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 193 /* ParenthesizedExpression */) { + if (node.parent.kind === 195 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -116809,21 +118305,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 193 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 195 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -116833,20 +118329,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ || - node.parent.kind === 149 /* Parameter */) { + node.parent.kind === 275 /* PropertyAssignment */ || + node.parent.kind === 151 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 192 /* TypeAssertionExpression */) { + if (node.parent.kind === 194 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 221 /* DoStatement */) { + if (node.parent.kind === 223 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -116854,7 +118350,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.kind === 227 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -116952,7 +118448,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); // TODO: GH#18217 return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; // TODO: GH#18217 + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } @@ -116962,7 +118458,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); }); // TODO: GH#18217 + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); }; } } @@ -117702,7 +119198,6 @@ var ts; : undefined; } server.findArgument = findArgument; - /*@internal*/ function nowString() { // E.g. "12:34:56.789" var d = new Date(); @@ -117716,13 +119211,11 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - /* @internal */ function isTypingUpToDate(cachedTyping, availableTypingVersions) { var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; - /* @internal */ JsTyping.nodeCoreModuleList = [ "assert", "async_hooks", @@ -117761,7 +119254,6 @@ var ts; "vm", "zlib" ]; - /* @internal */ JsTyping.nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); @@ -118027,7 +119519,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -118089,30 +119581,6 @@ var ts; } Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterConstructor: false, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - insertSpaceBeforeFunctionParenthesis: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; function toNormalizedPath(fileName) { return ts.normalizePath(fileName); } @@ -118231,20 +119699,6 @@ var ts; } } server.removeSorted = removeSorted; - function toSortedArray(arr, comparer) { - arr.sort(comparer); - return arr; - } - server.toSortedArray = toSortedArray; - function toDeduplicatedSortedArray(arr) { - arr.sort(); - ts.filterMutate(arr, isNonDuplicateInSortedArray); - return arr; - } - server.toDeduplicatedSortedArray = toDeduplicatedSortedArray; - function isNonDuplicateInSortedArray(value, index, array) { - return index === 0 || value !== array[index - 1]; - } var indentStr = "\n "; function indent(str) { return indentStr + str.replace(/\n/g, indentStr); @@ -118352,6 +119806,7 @@ var ts; CommandTypes["OrganizeImportsFull"] = "organizeImports-full"; CommandTypes["GetEditsForFileRename"] = "getEditsForFileRename"; CommandTypes["GetEditsForFileRenameFull"] = "getEditsForFileRename-full"; + CommandTypes["ConfigurePlugin"] = "configurePlugin"; })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {})); var IndentStyle; (function (IndentStyle) { @@ -118697,7 +120152,7 @@ var ts; ScriptInfo.prototype.setOptions = function (formatSettings, preferences) { if (formatSettings) { if (!this.formatSettings) { - this.formatSettings = server.getDefaultFormatCodeSettings(this.host); + this.formatSettings = ts.getDefaultFormatCodeSettings(this.host.newLine); ts.assign(this.formatSettings, formatSettings); } else { @@ -118861,7 +120316,7 @@ var ts; } }; TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { - var typings = server.toSortedArray(newTypings); + var typings = ts.sort(newTypings); this.perProjectCache.set(projectName, { compilerOptions: compilerOptions, typeAcquisition: typeAcquisition, @@ -119040,7 +120495,7 @@ var ts; return this.projectStateVersion.toString(); }; Project.prototype.getProjectReferences = function () { - return server.emptyArray; + return undefined; }; Project.prototype.getScriptFileNames = function () { var _this = this; @@ -119107,14 +120562,14 @@ var ts; var path = this.toPath(file); return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file); }; - Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames) { - return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); + Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { + return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile) { return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile); }; - Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); + Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference) { + return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }; Project.prototype.directoryExists = function (path) { return this.directoryStructureHost.directoryExists(path); @@ -119231,11 +120686,11 @@ var ts; }; Project.prototype.getExternalFiles = function () { var _this = this; - return server.toSortedArray(ts.flatMap(this.plugins, function (plugin) { - if (typeof plugin.getExternalFiles !== "function") + return ts.sort(ts.flatMap(this.plugins, function (plugin) { + if (typeof plugin.module.getExternalFiles !== "function") return; try { - return plugin.getExternalFiles(_this); + return plugin.module.getExternalFiles(_this); } catch (e) { _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); @@ -119262,19 +120717,15 @@ var ts; var f = _a[_i]; this.detachScriptInfoIfNotRoot(f.fileName); } - var projectReferences = this.program.getResolvedProjectReferences(); - if (projectReferences) { - for (var _b = 0, projectReferences_1 = projectReferences; _b < projectReferences_1.length; _b++) { - var ref = projectReferences_1[_b]; - if (ref) { - this.detachScriptInfoFromProject(ref.sourceFile.fileName); - } + this.program.forEachResolvedProjectReference(function (ref) { + if (ref) { + _this.detachScriptInfoFromProject(ref.sourceFile.fileName); } - } + }); } ts.forEach(this.externalFiles, function (externalFile) { return _this.detachScriptInfoIfNotRoot(externalFile); }); - for (var _c = 0, _d = this.rootFiles; _c < _d.length; _c++) { - var root = _d[_c]; + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; root.detachFromProject(this); } this.projectService.pendingEnsureProjectForOpenFiles = true; @@ -119437,38 +120888,10 @@ var ts; this.dirty = true; } }; - Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, ambientModules) { - var cached = this.cachedUnresolvedImportsPerFile.get(file.path); - if (cached) { - return cached; - } - var unresolvedImports; - if (file.resolvedModules) { - file.resolvedModules.forEach(function (resolvedModule, name) { - if (!resolvedModule && !ts.isExternalModuleNameRelative(name) && !isAmbientlyDeclaredModule(name)) { - var trimmed = name.trim(); - var i = trimmed.indexOf("/"); - if (i !== -1 && trimmed.charCodeAt(0) === 64) { - i = trimmed.indexOf("/", i + 1); - } - if (i !== -1) { - trimmed = trimmed.substr(0, i); - } - (unresolvedImports || (unresolvedImports = [])).push(trimmed); - } - }); - } - this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); - return unresolvedImports || server.emptyArray; - function isAmbientlyDeclaredModule(name) { - return ambientModules.some(function (m) { return m === name; }); - } - }; Project.prototype.onFileAddedOrRemoved = function () { this.hasAddedorRemovedFiles = true; }; Project.prototype.updateGraph = function () { - var _a; this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; @@ -119480,16 +120903,7 @@ var ts; } if (this.languageServiceEnabled) { if (hasNewProgram || changedFiles.length) { - var result = void 0; - var ambientModules = this.program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); - for (var _b = 0, _c = this.program.getSourceFiles(); _b < _c.length; _b++) { - var sourceFile = _c[_b]; - var unResolved = this.extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules); - if (unResolved !== server.emptyArray) { - (_a = (result || (result = []))).push.apply(_a, unResolved); - } - } - this.lastCachedUnresolvedImportsList = result ? server.toDeduplicatedSortedArray(result) : server.emptyArray; + this.lastCachedUnresolvedImportsList = getUnresolvedImports(this.program, this.cachedUnresolvedImportsPerFile); } this.projectService.typingsCache.enqueueInstallTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasAddedorRemovedFiles); } @@ -119532,11 +120946,16 @@ var ts; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var f = _a[_i]; - if (this.program.getSourceFileByPath(f.path)) { - continue; + var newFile = this.program.getSourceFileByPath(f.resolvedPath); + if (!newFile || (f.resolvedPath === f.path && newFile.resolvedPath !== f.path)) { + this.detachScriptInfoFromProject(f.fileName, !!this.program.getSourceFileByPath(f.path)); } - this.detachScriptInfoFromProject(f.fileName); } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !_this.program.getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + _this.detachScriptInfoFromProject(resolvedProjectReference.sourceFile.fileName); + } + }); } ts.updateMissingFilePathsWatch(this.program, this.missingFilesMap || (this.missingFilesMap = ts.createMap()), function (missingFilePath) { return _this.addMissingFileWatcher(missingFilePath); }); if (this.languageServiceEnabled) { @@ -119553,11 +120972,13 @@ var ts; this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + " Elapsed: " + elapsed + "ms"); return hasNewProgram; }; - Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName) { + Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { scriptInfoToDetach.detachFromProject(this); - this.resolutionCache.removeResolutionsOfFile(scriptInfoToDetach.path); + if (!noRemoveResolution) { + this.resolutionCache.removeResolutionsOfFile(scriptInfoToDetach.path); + } } }; Project.prototype.addMissingFileWatcher = function (missingFilePath) { @@ -119601,6 +121022,11 @@ var ts; } return strBuilder; }; + Project.prototype.print = function (counter) { + this.writeLog("Project '" + this.projectName + "' (" + ProjectKind[this.projectKind] + ") " + (counter === undefined ? "" : counter)); + this.writeLog(this.filesToString(this.projectService.logger.hasLevel(server.LogLevel.verbose))); + this.writeLog("-----------------------------------------------"); + }; Project.prototype.setCompilerOptions = function (compilerOptions) { if (compilerOptions) { compilerOptions.allowNonTsExtensions = true; @@ -119666,7 +121092,7 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; - Project.prototype.enableGlobalPlugins = function (options) { + Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -119680,7 +121106,7 @@ var ts; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; this_1.projectService.logger.info("Loading global plugin " + globalPluginName); - this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths); + this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_1 = this; for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { @@ -119689,7 +121115,7 @@ var ts; } } }; - Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { + Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); var log = function (message) { @@ -119699,15 +121125,18 @@ var ts; return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log); }); if (resolvedModule) { + var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); + if (configurationOverride) { + var pluginName = pluginConfigEntry.name; + pluginConfigEntry = configurationOverride; + pluginConfigEntry.name = pluginName; + } this.enableProxy(resolvedModule, pluginConfigEntry); } else { this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); } }; - Project.prototype.refreshDiagnostics = function () { - this.projectService.sendProjectsUpdatedInBackgroundEvent(); - }; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { @@ -119732,25 +121161,56 @@ var ts; } this.projectService.logger.info("Plugin validation succeded"); this.languageService = newLS; - this.plugins.push(pluginModule); + this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { this.projectService.logger.info("Plugin activation failed: " + e); } }; + Project.prototype.onPluginConfigurationChanged = function (pluginName, configuration) { + this.plugins.filter(function (plugin) { return plugin.name === pluginName; }).forEach(function (plugin) { + if (plugin.module.onConfigurationChanged) { + plugin.module.onConfigurationChanged(configuration); + } + }); + }; + Project.prototype.refreshDiagnostics = function () { + this.projectService.sendProjectsUpdatedInBackgroundEvent(); + }; return Project; }()); server.Project = Project; + function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) { + var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); + return ts.sortAndDeduplicate(ts.flatMap(program.getSourceFiles(), function (sourceFile) { + return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile); + })); + } + function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) { + return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () { + if (!file.resolvedModules) + return server.emptyArray; + var unresolvedImports; + file.resolvedModules.forEach(function (resolvedModule, name) { + if ((!resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) && + !ts.isExternalModuleNameRelative(name) && + !ambientModules.some(function (m) { return m === name; })) { + unresolvedImports = ts.append(unresolvedImports, ts.parsePackageName(name).packageName); + } + }); + return unresolvedImports || server.emptyArray; + }); + } var InferredProject = (function (_super) { __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory) { + function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory, pluginConfigOverrides) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, undefined, compilerOptions, false, projectService.host, currentDirectory) || this; _this._isJsInferredProject = false; _this.projectRootPath = projectRootPath && projectService.toCanonicalFileName(projectRootPath); if (!projectRootPath && !projectService.useSingleInferredProject) { _this.canonicalCurrentDirectory = projectService.toCanonicalFileName(_this.currentDirectory); } - _this.enableGlobalPlugins(_this.getCompilerOptions()); + _this.enableGlobalPlugins(_this.getCompilerOptions(), pluginConfigOverrides); return _this; } InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { @@ -119760,10 +121220,10 @@ var ts; } }; InferredProject.prototype.setCompilerOptions = function (options) { - var newOptions = options ? ts.cloneCompilerOptions(options) : this.getCompilationSettings(); - if (!newOptions) { + if (!options && !this.getCompilationSettings()) { return; } + var newOptions = ts.cloneCompilerOptions(options || this.getCompilationSettings()); if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { newOptions.maxNodeModuleJsDepth = 2; } @@ -119860,19 +121320,16 @@ var ts; return server.asNormalizedPath(this.getProjectName()); }; ConfiguredProject.prototype.getProjectReferences = function () { - return this.projectReferences || server.emptyArray; + return this.projectReferences; }; ConfiguredProject.prototype.updateReferences = function (refs) { this.projectReferences = refs; }; - ConfiguredProject.prototype.getResolvedProjectReferences = function () { + ConfiguredProject.prototype.forEachResolvedProjectReference = function (cb) { var program = this.getCurrentProgram(); - return program && program.getResolvedProjectReferences(); + return program && program.forEachResolvedProjectReference(cb); }; - ConfiguredProject.prototype.enablePlugins = function () { - this.enablePluginsWithOptions(this.getCompilerOptions()); - }; - ConfiguredProject.prototype.enablePluginsWithOptions = function (options) { + ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -119887,10 +121344,10 @@ var ts; if (options.plugins) { for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { var pluginConfigEntry = _a[_i]; - this.enablePlugin(pluginConfigEntry, searchPaths); + this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides); } } - this.enableGlobalPlugins(options); + this.enableGlobalPlugins(options, pluginConfigOverrides); }; ConfiguredProject.prototype.getGlobalProjectErrors = function () { return ts.filter(this.projectErrors, function (diagnostic) { return !diagnostic.file; }) || server.emptyArray; @@ -120220,7 +121677,7 @@ var ts; this.typingsInstaller.attach(this); this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { - formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + formatCodeOptions: ts.getDefaultFormatCodeSettings(this.host.newLine), preferences: ts.emptyOptions, hostInfo: "Unknown host", extraFileExtensions: [] @@ -120431,9 +121888,9 @@ var ts; return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); }; ProjectService.prototype.forEachProject = function (cb) { - this.inferredProjects.forEach(cb); - this.configuredProjects.forEach(cb); this.externalProjects.forEach(cb); + this.configuredProjects.forEach(cb); + this.inferredProjects.forEach(cb); }; ProjectService.prototype.forEachEnabledProject = function (cb) { this.forEachProject(function (project) { @@ -120455,7 +121912,7 @@ var ts; ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) { this.ensureProjectStructuresUptoDate(); var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - return scriptInfo ? scriptInfo.getDefaultProject() : server.Errors.ThrowNoProject(); + return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), server.Errors.ThrowNoProject()); }; ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) { this.ensureProjectStructuresUptoDate(); @@ -120493,12 +121950,17 @@ var ts; if (!info) { this.logger.msg("Error: got watch notification for unknown file: " + fileName); } - else if (eventKind === ts.FileWatcherEventKind.Deleted) { - this.handleDeletedFile(info); - } - else if (!info.isScriptOpen()) { - info.delayReloadNonMixedContentFile(); - this.delayUpdateProjectGraphs(info.containingProjects); + else { + if (info.containingProjects) { + info.containingProjects.forEach(function (project) { return project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(info.path); }); + } + if (eventKind === ts.FileWatcherEventKind.Deleted) { + this.handleDeletedFile(info); + } + else if (!info.isScriptOpen()) { + info.delayReloadNonMixedContentFile(); + this.delayUpdateProjectGraphs(info.containingProjects); + } } }; ProjectService.prototype.handleDeletedFile = function (info) { @@ -120515,6 +121977,8 @@ var ts; return this.watchFactory.watchDirectory(this.host, directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; var configFilename = project.getConfigFilePath(); if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, project.getCompilationSettings(), _this.hostConfiguration.extraFileExtensions)) { _this.logger.info("Project: " + configFilename + " Detected file add/remove of non supported extension: " + fileOrDirectory); @@ -120553,10 +122017,12 @@ var ts; this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, false); }; ProjectService.prototype.removeProject = function (project) { - this.logger.info("remove project: " + project.getRootFiles().toString()); + var _this = this; + this.logger.info("`remove Project::"); + project.print(); project.close(); if (ts.Debug.shouldAssert(1)) { - this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project)); }); + this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return project.projectName + ": ScriptInfos still attached: " + JSON.stringify(ts.mapDefined(ts.arrayFrom(_this.filenameToScriptInfo.values()), function (info) { return info.isAttached(project) ? info : undefined; })); }); }); } this.pendingProjectUpdates.delete(project.getProjectName()); switch (project.projectKind) { @@ -120845,20 +122311,9 @@ var ts; } var writeProjectFileNames = this.logger.hasLevel(server.LogLevel.verbose); this.logger.startGroup(); - var counter = 0; - var printProjects = function (projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; - _this.logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - _this.logger.info(project.filesToString(writeProjectFileNames)); - _this.logger.info("-----------------------------------------------"); - counter++; - } - return counter; - }; - counter = printProjects(this.externalProjects, counter); - counter = printProjects(ts.arrayFrom(this.configuredProjects.values()), counter); - printProjects(this.inferredProjects, counter); + var counter = printProjectsWithCounter(this.externalProjects, 0); + counter = printProjectsWithCounter(ts.arrayFrom(this.configuredProjects.values()), counter); + printProjectsWithCounter(this.inferredProjects, counter); this.logger.info("Open files: "); this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); @@ -121042,7 +122497,7 @@ var ts; project.enableLanguageService(); project.watchWildcards(ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories)); } - project.enablePluginsWithOptions(compilerOptions); + project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; @@ -121179,7 +122634,7 @@ var ts; }; ProjectService.prototype.createInferredProject = function (currentDirectory, isSingleInferredProject, projectRootPath) { var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; - var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory); + var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory, this.currentPluginConfigOverrides); if (isSingleInferredProject) { this.inferredProjects.unshift(project); } @@ -121202,6 +122657,13 @@ var ts; var configProject = this.configuredProjects.get(uncheckedFileName); return configProject && configProject.getCompilerOptions().configFile; }; + ProjectService.prototype.logErrorForScriptInfoNotFound = function (fileName) { + var names = ts.arrayFrom(this.filenameToScriptInfo.entries()).map(function (_a) { + var path = _a[0], scriptInfo = _a[1]; + return ({ path: path, fileName: scriptInfo.fileName }); + }); + this.logger.msg("Could not find file " + JSON.stringify(fileName) + ".\nAll files are: " + JSON.stringify(names), server.Msg.Err); + }; ProjectService.prototype.getSymlinkedProjects = function (info) { var projects; if (this.realpathToScriptInfos) { @@ -121261,6 +122723,8 @@ var ts; var watchDir = dir + "/node_modules"; var watcher = this.watchFactory.watchDirectory(this.host, watchDir, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; ts.Debug.assert(result.refCount > 0); if (watchDir === fileOrDirectoryPath) { _this.refreshScriptInfosInDirectory(watchDir); @@ -121319,7 +122783,14 @@ var ts; } }; ProjectService.prototype.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath = function (fileName, currentDirectory, scriptKind, hasMixedContent, hostToQueryFileExistsOn) { - return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, false, undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); + if (ts.isRootedDiskPath(fileName) || server.isDynamicFileName(fileName)) { + return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, false, undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); + } + var info = this.openFilesWithNonRootedDiskPath.get(this.toCanonicalFileName(fileName)); + if (info) { + return info; + } + return undefined; }; ProjectService.prototype.getOrCreateScriptInfoOpenedByClientForNormalizedPath = function (fileName, currentDirectory, fileContent, scriptKind, hasMixedContent) { return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, true, fileContent, scriptKind, hasMixedContent); @@ -121334,7 +122805,7 @@ var ts; var info = this.getScriptInfoForPath(path); if (!info) { var isDynamic = server.isDynamicFileName(fileName); - ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info"; }); + ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; }); ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; }); ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always have current directory context since containing external project name will always match the script info name."; }); if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { @@ -121346,7 +122817,7 @@ var ts; if (!openedByClient) { this.watchClosedScriptInfo(info); } - else if (!ts.isRootedDiskPath(fileName) && currentDirectory !== this.currentDirectory) { + else if (!ts.isRootedDiskPath(fileName) && !isDynamic) { this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info); } } @@ -121479,7 +122950,7 @@ var ts; return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind, false, projectRootPath ? server.toNormalizedPath(projectRootPath) : undefined); }; ProjectService.prototype.getOriginalLocationEnsuringConfiguredProject = function (project, location) { - var originalLocation = project.getSourceMapper().tryGetOriginalLocation(location); + var originalLocation = project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) return undefined; var fileName = originalLocation.fileName; @@ -121577,18 +123048,14 @@ var ts; markOriginalProjectsAsUsed(project); } else { - var resolvedProjectReferences = project.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { - var ref = resolvedProjectReferences_1[_i]; - if (ref) { - var refProject = _this.configuredProjects.get(ref.sourceFile.path); - if (refProject && refProject.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); - } + project.forEachResolvedProjectReference(function (ref) { + if (ref) { + var refProject = _this.configuredProjects.get(ref.sourceFile.path); + if (refProject && refProject.hasOpenRef()) { + toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); } } - } + }); } }); toRemoveConfiguredProjects.forEach(function (project) { return _this.removeProject(project); }); @@ -121693,8 +123160,8 @@ var ts; ts.forEachKey(this.externalProjectToConfiguredProjectMap, function (externalProjectName) { projectsToClose.set(externalProjectName, true); }); - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var externalProject = projects_4[_i]; + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var externalProject = projects_3[_i]; this.openExternalProject(externalProject); projectsToClose.delete(externalProject.projectFileName); } @@ -121923,6 +123390,11 @@ var ts; } return false; }; + ProjectService.prototype.configurePlugin = function (args) { + this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); }); + this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || ts.createMap(); + this.currentPluginConfigOverrides.set(args.pluginName, args.configuration); + }; ProjectService.filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g; return ProjectService; }()); @@ -121931,6 +123403,14 @@ var ts; return config.kind !== undefined; } server.isConfigFile = isConfigFile; + function printProjectsWithCounter(projects, counter) { + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var project = projects_4[_i]; + project.print(counter); + counter++; + } + return counter; + } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; @@ -122105,7 +123585,7 @@ var ts; } server.toEvent = toEvent; function combineProjectOutput(defaultValue, getValue, projects, action) { - var outputs = ts.flatMap(ts.isArray(projects) ? projects : projects.projects, function (project) { return action(project, defaultValue); }); + var outputs = ts.flatMapToMutable(ts.isArray(projects) ? projects : projects.projects, function (project) { return action(project, defaultValue); }); if (!ts.isArray(projects) && projects.symLinkedProjects) { projects.symLinkedProjects.forEach(function (projects, path) { var value = getValue(path); @@ -122122,9 +123602,9 @@ var ts; }); return outputs; } - function combineProjectOutputWhileOpeningReferencedProjects(projects, defaultProject, projectService, action, getLocation, resultsEqual) { + function combineProjectOutputWhileOpeningReferencedProjects(projects, defaultProject, action, getLocation, resultsEqual) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, undefined, projectService, function (_a, tryAddToTodo) { + combineProjectOutputWorker(projects, defaultProject, undefined, function (_a, tryAddToTodo) { var project = _a.project; for (var _i = 0, _b = action(project); _i < _b.length; _i++) { var output = _b[_i]; @@ -122135,11 +123615,11 @@ var ts; }, undefined); return outputs; } - function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, projectService, findInStrings, findInComments) { + function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, findInStrings, findInComments) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, function (_a, tryAddToTodo) { + combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, tryAddToTodo) { var project = _a.project, location = _a.location; - for (var _i = 0, _b = project.getLanguageService().findRenameLocations(location.fileName, location.position, findInStrings, findInComments) || server.emptyArray; _i < _b.length; _i++) { + for (var _i = 0, _b = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments) || server.emptyArray; _i < _b.length; _i++) { var output = _b[_i]; if (!ts.contains(outputs, output, ts.documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) { outputs.push(output); @@ -122149,17 +123629,17 @@ var ts; return outputs; } function getDefinitionLocation(defaultProject, initialLocation) { - var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.position); + var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos); var info = infos && ts.firstOrUndefined(infos); - return info && { fileName: info.fileName, position: info.textSpan.start }; + return info && { fileName: info.fileName, pos: info.textSpan.start }; } - function combineProjectOutputForReferences(projects, defaultProject, initialLocation, projectService) { + function combineProjectOutputForReferences(projects, defaultProject, initialLocation) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, function (_a, getMappedLocation) { + combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, getMappedLocation) { var project = _a.project, location = _a.location; var _loop_8 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); - var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.position, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName }); + var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName }); var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); }); if (!symbolToAddTo) { symbolToAddTo = { definition: definition, references: [] }; @@ -122172,7 +123652,7 @@ var ts; } } }; - for (var _i = 0, _b = project.getLanguageService().findReferences(location.fileName, location.position) || server.emptyArray; _i < _b.length; _i++) { + for (var _i = 0, _b = project.getLanguageService().findReferences(location.fileName, location.pos) || server.emptyArray; _i < _b.length; _i++) { var outputReferencedSymbol = _b[_i]; _loop_8(outputReferencedSymbol); } @@ -122193,11 +123673,12 @@ var ts; }); } } - function combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, cb, getDefinition) { + function combineProjectOutputWorker(projects, defaultProject, initialLocation, cb, getDefinition) { + var projectService = defaultProject.projectService; var toDo; var seenProjects = ts.createMap(); forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, function (project, path) { - var location = (initialLocation ? { fileName: path, position: initialLocation.position } : undefined); + var location = (initialLocation ? { fileName: path, pos: initialLocation.pos } : undefined); toDo = callbackProjectAndLocation({ project: project, location: location }, projectService, toDo, seenProjects, cb); }); if (getDefinition) { @@ -122218,7 +123699,7 @@ var ts; function getDefinitionInProject(definition, definingProject, project) { if (!definition || project.containsFile(server.toNormalizedPath(definition.fileName))) return definition; - var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedLocation(definition); + var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); return mappedDefinition && project.containsFile(server.toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; } function callbackProjectAndLocation(projectAndLocation, projectService, toDo, seenProjects, cb) { @@ -122254,10 +123735,10 @@ var ts; } function documentSpanLocation(_a) { var fileName = _a.fileName, textSpan = _a.textSpan; - return { fileName: fileName, position: textSpan.start }; + return { fileName: fileName, pos: textSpan.start }; } function getMappedLocation(location, projectService, project) { - var mapsTo = project.getSourceMapper().tryGetOriginalLocation(location); + var mapsTo = project.getSourceMapper().tryGetSourcePosition(location); return mapsTo && projectService.fileExists(server.toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined; } var Session = (function () { @@ -122563,6 +124044,10 @@ var ts; _a[server.CommandNames.GetEditsForFileRenameFull] = function (request) { return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, false)); }, + _a[server.CommandNames.ConfigurePlugin] = function (request) { + _this.configurePlugin(request.arguments); + return _this.notRequired(); + }, _a)); this.host = opts.host; this.cancellationToken = opts.cancellationToken; @@ -122620,7 +124105,7 @@ var ts; break; case server.ProjectLoadingFinishEvent: var finishProject = event.data.project; - this.event({ projectName: finishProject.getProjectName() }, server.ProjectLoadingStartEvent); + this.event({ projectName: finishProject.getProjectName() }, server.ProjectLoadingFinishEvent); break; case server.LargeFileReferencedEvent: var _b = event.data, file = _b.file, fileSize = _b.fileSize, maxFileSize_1 = _b.maxFileSize; @@ -122718,7 +124203,27 @@ var ts; success: success, }; if (success) { - res.body = info; + var metadata = void 0; + if (ts.isArray(info)) { + res.body = info; + metadata = info.metadata; + delete info.metadata; + } + else if (typeof info === "object") { + if (info.metadata) { + var _a = info, infoMetadata = _a.metadata, body = __rest(_a, ["metadata"]); + res.body = body; + metadata = infoMetadata; + } + else { + res.body = info; + } + } + else { + res.body = info; + } + if (metadata) + res.metadata = metadata; } else { ts.Debug.assert(info === undefined); @@ -122896,7 +124401,7 @@ var ts; kind: info.kind, name: info.name, textSpan: { - start: newLoc.position, + start: newLoc.pos, length: info.textSpan.length }, originalFileName: info.fileName, @@ -122968,7 +124473,7 @@ var ts; kind: info.kind, displayParts: info.displayParts, textSpan: { - start: newLoc.position, + start: newLoc.pos, length: info.textSpan.length }, originalFileName: info.fileName, @@ -123101,13 +124606,17 @@ var ts; this.projectService.getScriptInfoEnsuringProjectsUptoDate(args.file) : this.projectService.getScriptInfo(args.file); if (!scriptInfo) { - return ignoreNoProjectError ? server.emptyArray : server.Errors.ThrowNoProject(); + if (ignoreNoProjectError) + return server.emptyArray; + this.projectService.logErrorForScriptInfoNotFound(args.file); + return server.Errors.ThrowNoProject(); } projects = scriptInfo.containingProjects; symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo); } projects = ts.filter(projects, function (p) { return p.languageServiceEnabled && !p.isOrphan(); }); if (!ignoreNoProjectError && (!projects || !projects.length) && !symLinkedProjects) { + this.projectService.logErrorForScriptInfoNotFound(args.file); return server.Errors.ThrowNoProject(); } return symLinkedProjects ? { projects: projects, symLinkedProjects: symLinkedProjects } : projects; @@ -123126,7 +124635,7 @@ var ts; var file = server.toNormalizedPath(args.file); var position = this.getPositionInFile(args, file); var projects = this.getProjects(args); - var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, position: position }, this.projectService, !!args.findInStrings, !!args.findInComments); + var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments); if (!simplifiedResult) return locations; var defaultProject = this.getDefaultProject(args); @@ -123160,7 +124669,7 @@ var ts; var file = server.toNormalizedPath(args.file); var projects = this.getProjects(args); var position = this.getPositionInFile(args, file); - var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, position: position }, this.projectService); + var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }); if (simplifiedResult) { var defaultProject = this.getDefaultProject(args); var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); @@ -123382,8 +124891,11 @@ var ts; return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended }; } }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); - if (kind === "completions") + if (kind === "completions") { + if (completions.metadata) + entries.metadata = completions.metadata; return entries; + } var res = __assign({}, completions, { entries: entries }); return res; }; @@ -123591,7 +125103,7 @@ var ts; return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file); } else { - return combineProjectOutputWhileOpeningReferencedProjects(this.getProjects(args), this.getDefaultProject(args), this.projectService, function (project) { + return combineProjectOutputWhileOpeningReferencedProjects(this.getProjects(args), this.getDefaultProject(args), function (project) { return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, undefined, project.isNonTsProject()); }, documentSpanLocation, navigateToItemIsEqualTo); } @@ -123744,8 +125256,17 @@ var ts; var _this = this; return textChanges.map(function (change) { return _this.mapTextChangeToCodeEdit(change); }); }; - Session.prototype.mapTextChangeToCodeEdit = function (change) { - return mapTextChangesToCodeEdits(change, this.projectService.getScriptInfoOrConfig(change.fileName)); + Session.prototype.mapTextChangeToCodeEdit = function (textChanges) { + var scriptInfo = this.projectService.getScriptInfoOrConfig(textChanges.fileName); + if (!!textChanges.isNewFile === !!scriptInfo) { + if (!scriptInfo) { + this.projectService.logErrorForScriptInfoNotFound(textChanges.fileName); + } + ts.Debug.fail("Expected isNewFile for (only) new files. " + JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo })); + } + return scriptInfo + ? { fileName: textChanges.fileName, textChanges: textChanges.textChanges.map(function (textChange) { return convertTextChangeToCodeEdit(textChange, scriptInfo); }) } + : convertNewFileTextChangeToCodeEdit(textChanges); }; Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { return { @@ -123808,6 +125329,9 @@ var ts; var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); this.updateErrorCheck(next, checkList, delay, false); }; + Session.prototype.configurePlugin = function (args) { + this.projectService.configurePlugin(args); + }; Session.prototype.getCanonicalFileName = function (fileName) { var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); return ts.normalizePath(name); @@ -123913,12 +125437,6 @@ var ts; function toFileSpan(fileName, textSpan, scriptInfo) { return { file: fileName, start: scriptInfo.positionToLineOffset(textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)) }; } - function mapTextChangesToCodeEdits(textChanges, scriptInfo) { - ts.Debug.assert(!!textChanges.isNewFile === !scriptInfo, "Expected isNewFile for (only) new files", function () { return JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo }); }); - return scriptInfo - ? { fileName: textChanges.fileName, textChanges: textChanges.textChanges.map(function (textChange) { return convertTextChangeToCodeEdit(textChange, scriptInfo); }) } - : convertNewFileTextChangeToCodeEdit(textChanges); - } function convertTextChangeToCodeEdit(change, scriptInfo) { return { start: positionToLineOffset(scriptInfo, change.span.start), end: positionToLineOffset(scriptInfo, ts.textSpanEnd(change.span)), newText: change.newText }; } diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index d8306559986..ac36533a094 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -27,6 +27,9 @@ declare namespace ts { interface MapLike { [index: string]: T; } + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedArrayBrand": any; + } interface SortedArray extends Array { " __sortedArrayBrand": any; } @@ -70,7 +73,7 @@ declare namespace ts { end: number; } type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -82,337 +85,339 @@ declare namespace ts { ShebangTrivia = 6, ConflictMarkerTrivia = 7, NumericLiteral = 8, - StringLiteral = 9, - JsxText = 10, - JsxTextAllWhiteSpaces = 11, - RegularExpressionLiteral = 12, - NoSubstitutionTemplateLiteral = 13, - TemplateHead = 14, - TemplateMiddle = 15, - TemplateTail = 16, - OpenBraceToken = 17, - CloseBraceToken = 18, - OpenParenToken = 19, - CloseParenToken = 20, - OpenBracketToken = 21, - CloseBracketToken = 22, - DotToken = 23, - DotDotDotToken = 24, - SemicolonToken = 25, - CommaToken = 26, - LessThanToken = 27, - LessThanSlashToken = 28, - GreaterThanToken = 29, - LessThanEqualsToken = 30, - GreaterThanEqualsToken = 31, - EqualsEqualsToken = 32, - ExclamationEqualsToken = 33, - EqualsEqualsEqualsToken = 34, - ExclamationEqualsEqualsToken = 35, - EqualsGreaterThanToken = 36, - PlusToken = 37, - MinusToken = 38, - AsteriskToken = 39, - AsteriskAsteriskToken = 40, - SlashToken = 41, - PercentToken = 42, - PlusPlusToken = 43, - MinusMinusToken = 44, - LessThanLessThanToken = 45, - GreaterThanGreaterThanToken = 46, - GreaterThanGreaterThanGreaterThanToken = 47, - AmpersandToken = 48, - BarToken = 49, - CaretToken = 50, - ExclamationToken = 51, - TildeToken = 52, - AmpersandAmpersandToken = 53, - BarBarToken = 54, - QuestionToken = 55, - ColonToken = 56, - AtToken = 57, - EqualsToken = 58, - PlusEqualsToken = 59, - MinusEqualsToken = 60, - AsteriskEqualsToken = 61, - AsteriskAsteriskEqualsToken = 62, - SlashEqualsToken = 63, - PercentEqualsToken = 64, - LessThanLessThanEqualsToken = 65, - GreaterThanGreaterThanEqualsToken = 66, - GreaterThanGreaterThanGreaterThanEqualsToken = 67, - AmpersandEqualsToken = 68, - BarEqualsToken = 69, - CaretEqualsToken = 70, - Identifier = 71, - BreakKeyword = 72, - CaseKeyword = 73, - CatchKeyword = 74, - ClassKeyword = 75, - ConstKeyword = 76, - ContinueKeyword = 77, - DebuggerKeyword = 78, - DefaultKeyword = 79, - DeleteKeyword = 80, - DoKeyword = 81, - ElseKeyword = 82, - EnumKeyword = 83, - ExportKeyword = 84, - ExtendsKeyword = 85, - FalseKeyword = 86, - FinallyKeyword = 87, - ForKeyword = 88, - FunctionKeyword = 89, - IfKeyword = 90, - ImportKeyword = 91, - InKeyword = 92, - InstanceOfKeyword = 93, - NewKeyword = 94, - NullKeyword = 95, - ReturnKeyword = 96, - SuperKeyword = 97, - SwitchKeyword = 98, - ThisKeyword = 99, - ThrowKeyword = 100, - TrueKeyword = 101, - TryKeyword = 102, - TypeOfKeyword = 103, - VarKeyword = 104, - VoidKeyword = 105, - WhileKeyword = 106, - WithKeyword = 107, - ImplementsKeyword = 108, - InterfaceKeyword = 109, - LetKeyword = 110, - PackageKeyword = 111, - PrivateKeyword = 112, - ProtectedKeyword = 113, - PublicKeyword = 114, - StaticKeyword = 115, - YieldKeyword = 116, - AbstractKeyword = 117, - AsKeyword = 118, - AnyKeyword = 119, - AsyncKeyword = 120, - AwaitKeyword = 121, - BooleanKeyword = 122, - ConstructorKeyword = 123, - DeclareKeyword = 124, - GetKeyword = 125, - InferKeyword = 126, - IsKeyword = 127, - KeyOfKeyword = 128, - ModuleKeyword = 129, - NamespaceKeyword = 130, - NeverKeyword = 131, - ReadonlyKeyword = 132, - RequireKeyword = 133, - NumberKeyword = 134, - ObjectKeyword = 135, - SetKeyword = 136, - StringKeyword = 137, - SymbolKeyword = 138, - TypeKeyword = 139, - UndefinedKeyword = 140, - UniqueKeyword = 141, - UnknownKeyword = 142, - FromKeyword = 143, - GlobalKeyword = 144, - OfKeyword = 145, - QualifiedName = 146, - ComputedPropertyName = 147, - TypeParameter = 148, - Parameter = 149, - Decorator = 150, - PropertySignature = 151, - PropertyDeclaration = 152, - MethodSignature = 153, - MethodDeclaration = 154, - Constructor = 155, - GetAccessor = 156, - SetAccessor = 157, - CallSignature = 158, - ConstructSignature = 159, - IndexSignature = 160, - TypePredicate = 161, - TypeReference = 162, - FunctionType = 163, - ConstructorType = 164, - TypeQuery = 165, - TypeLiteral = 166, - ArrayType = 167, - TupleType = 168, - OptionalType = 169, - RestType = 170, - UnionType = 171, - IntersectionType = 172, - ConditionalType = 173, - InferType = 174, - ParenthesizedType = 175, - ThisType = 176, - TypeOperator = 177, - IndexedAccessType = 178, - MappedType = 179, - LiteralType = 180, - ImportType = 181, - ObjectBindingPattern = 182, - ArrayBindingPattern = 183, - BindingElement = 184, - ArrayLiteralExpression = 185, - ObjectLiteralExpression = 186, - PropertyAccessExpression = 187, - ElementAccessExpression = 188, - CallExpression = 189, - NewExpression = 190, - TaggedTemplateExpression = 191, - TypeAssertionExpression = 192, - ParenthesizedExpression = 193, - FunctionExpression = 194, - ArrowFunction = 195, - DeleteExpression = 196, - TypeOfExpression = 197, - VoidExpression = 198, - AwaitExpression = 199, - PrefixUnaryExpression = 200, - PostfixUnaryExpression = 201, - BinaryExpression = 202, - ConditionalExpression = 203, - TemplateExpression = 204, - YieldExpression = 205, - SpreadElement = 206, - ClassExpression = 207, - OmittedExpression = 208, - ExpressionWithTypeArguments = 209, - AsExpression = 210, - NonNullExpression = 211, - MetaProperty = 212, - SyntheticExpression = 213, - TemplateSpan = 214, - SemicolonClassElement = 215, - Block = 216, - VariableStatement = 217, - EmptyStatement = 218, - ExpressionStatement = 219, - IfStatement = 220, - DoStatement = 221, - WhileStatement = 222, - ForStatement = 223, - ForInStatement = 224, - ForOfStatement = 225, - ContinueStatement = 226, - BreakStatement = 227, - ReturnStatement = 228, - WithStatement = 229, - SwitchStatement = 230, - LabeledStatement = 231, - ThrowStatement = 232, - TryStatement = 233, - DebuggerStatement = 234, - VariableDeclaration = 235, - VariableDeclarationList = 236, - FunctionDeclaration = 237, - ClassDeclaration = 238, - InterfaceDeclaration = 239, - TypeAliasDeclaration = 240, - EnumDeclaration = 241, - ModuleDeclaration = 242, - ModuleBlock = 243, - CaseBlock = 244, - NamespaceExportDeclaration = 245, - ImportEqualsDeclaration = 246, - ImportDeclaration = 247, - ImportClause = 248, - NamespaceImport = 249, - NamedImports = 250, - ImportSpecifier = 251, - ExportAssignment = 252, - ExportDeclaration = 253, - NamedExports = 254, - ExportSpecifier = 255, - MissingDeclaration = 256, - ExternalModuleReference = 257, - JsxElement = 258, - JsxSelfClosingElement = 259, - JsxOpeningElement = 260, - JsxClosingElement = 261, - JsxFragment = 262, - JsxOpeningFragment = 263, - JsxClosingFragment = 264, - JsxAttribute = 265, - JsxAttributes = 266, - JsxSpreadAttribute = 267, - JsxExpression = 268, - CaseClause = 269, - DefaultClause = 270, - HeritageClause = 271, - CatchClause = 272, - PropertyAssignment = 273, - ShorthandPropertyAssignment = 274, - SpreadAssignment = 275, - EnumMember = 276, - SourceFile = 277, - Bundle = 278, - UnparsedSource = 279, - InputFiles = 280, - JSDocTypeExpression = 281, - JSDocAllType = 282, - JSDocUnknownType = 283, - JSDocNullableType = 284, - JSDocNonNullableType = 285, - JSDocOptionalType = 286, - JSDocFunctionType = 287, - JSDocVariadicType = 288, - JSDocComment = 289, - JSDocTypeLiteral = 290, - JSDocSignature = 291, - JSDocTag = 292, - JSDocAugmentsTag = 293, - JSDocClassTag = 294, - JSDocCallbackTag = 295, - JSDocEnumTag = 296, - JSDocParameterTag = 297, - JSDocReturnTag = 298, - JSDocThisTag = 299, - JSDocTypeTag = 300, - JSDocTemplateTag = 301, - JSDocTypedefTag = 302, - JSDocPropertyTag = 303, - SyntaxList = 304, - NotEmittedStatement = 305, - PartiallyEmittedExpression = 306, - CommaListExpression = 307, - MergeDeclarationMarker = 308, - EndOfDeclarationMarker = 309, - Count = 310, - FirstAssignment = 58, - LastAssignment = 70, - FirstCompoundAssignment = 59, - LastCompoundAssignment = 70, - FirstReservedWord = 72, - LastReservedWord = 107, - FirstKeyword = 72, - LastKeyword = 145, - FirstFutureReservedWord = 108, - LastFutureReservedWord = 116, - FirstTypeNode = 161, - LastTypeNode = 181, - FirstPunctuation = 17, - LastPunctuation = 70, + BigIntLiteral = 9, + StringLiteral = 10, + JsxText = 11, + JsxTextAllWhiteSpaces = 12, + RegularExpressionLiteral = 13, + NoSubstitutionTemplateLiteral = 14, + TemplateHead = 15, + TemplateMiddle = 16, + TemplateTail = 17, + OpenBraceToken = 18, + CloseBraceToken = 19, + OpenParenToken = 20, + CloseParenToken = 21, + OpenBracketToken = 22, + CloseBracketToken = 23, + DotToken = 24, + DotDotDotToken = 25, + SemicolonToken = 26, + CommaToken = 27, + LessThanToken = 28, + LessThanSlashToken = 29, + GreaterThanToken = 30, + LessThanEqualsToken = 31, + GreaterThanEqualsToken = 32, + EqualsEqualsToken = 33, + ExclamationEqualsToken = 34, + EqualsEqualsEqualsToken = 35, + ExclamationEqualsEqualsToken = 36, + EqualsGreaterThanToken = 37, + PlusToken = 38, + MinusToken = 39, + AsteriskToken = 40, + AsteriskAsteriskToken = 41, + SlashToken = 42, + PercentToken = 43, + PlusPlusToken = 44, + MinusMinusToken = 45, + LessThanLessThanToken = 46, + GreaterThanGreaterThanToken = 47, + GreaterThanGreaterThanGreaterThanToken = 48, + AmpersandToken = 49, + BarToken = 50, + CaretToken = 51, + ExclamationToken = 52, + TildeToken = 53, + AmpersandAmpersandToken = 54, + BarBarToken = 55, + QuestionToken = 56, + ColonToken = 57, + AtToken = 58, + EqualsToken = 59, + PlusEqualsToken = 60, + MinusEqualsToken = 61, + AsteriskEqualsToken = 62, + AsteriskAsteriskEqualsToken = 63, + SlashEqualsToken = 64, + PercentEqualsToken = 65, + LessThanLessThanEqualsToken = 66, + GreaterThanGreaterThanEqualsToken = 67, + GreaterThanGreaterThanGreaterThanEqualsToken = 68, + AmpersandEqualsToken = 69, + BarEqualsToken = 70, + CaretEqualsToken = 71, + Identifier = 72, + BreakKeyword = 73, + CaseKeyword = 74, + CatchKeyword = 75, + ClassKeyword = 76, + ConstKeyword = 77, + ContinueKeyword = 78, + DebuggerKeyword = 79, + DefaultKeyword = 80, + DeleteKeyword = 81, + DoKeyword = 82, + ElseKeyword = 83, + EnumKeyword = 84, + ExportKeyword = 85, + ExtendsKeyword = 86, + FalseKeyword = 87, + FinallyKeyword = 88, + ForKeyword = 89, + FunctionKeyword = 90, + IfKeyword = 91, + ImportKeyword = 92, + InKeyword = 93, + InstanceOfKeyword = 94, + NewKeyword = 95, + NullKeyword = 96, + ReturnKeyword = 97, + SuperKeyword = 98, + SwitchKeyword = 99, + ThisKeyword = 100, + ThrowKeyword = 101, + TrueKeyword = 102, + TryKeyword = 103, + TypeOfKeyword = 104, + VarKeyword = 105, + VoidKeyword = 106, + WhileKeyword = 107, + WithKeyword = 108, + ImplementsKeyword = 109, + InterfaceKeyword = 110, + LetKeyword = 111, + PackageKeyword = 112, + PrivateKeyword = 113, + ProtectedKeyword = 114, + PublicKeyword = 115, + StaticKeyword = 116, + YieldKeyword = 117, + AbstractKeyword = 118, + AsKeyword = 119, + AnyKeyword = 120, + AsyncKeyword = 121, + AwaitKeyword = 122, + BooleanKeyword = 123, + ConstructorKeyword = 124, + DeclareKeyword = 125, + GetKeyword = 126, + InferKeyword = 127, + IsKeyword = 128, + KeyOfKeyword = 129, + ModuleKeyword = 130, + NamespaceKeyword = 131, + NeverKeyword = 132, + ReadonlyKeyword = 133, + RequireKeyword = 134, + NumberKeyword = 135, + ObjectKeyword = 136, + SetKeyword = 137, + StringKeyword = 138, + SymbolKeyword = 139, + TypeKeyword = 140, + UndefinedKeyword = 141, + UniqueKeyword = 142, + UnknownKeyword = 143, + FromKeyword = 144, + GlobalKeyword = 145, + BigIntKeyword = 146, + OfKeyword = 147, + QualifiedName = 148, + ComputedPropertyName = 149, + TypeParameter = 150, + Parameter = 151, + Decorator = 152, + PropertySignature = 153, + PropertyDeclaration = 154, + MethodSignature = 155, + MethodDeclaration = 156, + Constructor = 157, + GetAccessor = 158, + SetAccessor = 159, + CallSignature = 160, + ConstructSignature = 161, + IndexSignature = 162, + TypePredicate = 163, + TypeReference = 164, + FunctionType = 165, + ConstructorType = 166, + TypeQuery = 167, + TypeLiteral = 168, + ArrayType = 169, + TupleType = 170, + OptionalType = 171, + RestType = 172, + UnionType = 173, + IntersectionType = 174, + ConditionalType = 175, + InferType = 176, + ParenthesizedType = 177, + ThisType = 178, + TypeOperator = 179, + IndexedAccessType = 180, + MappedType = 181, + LiteralType = 182, + ImportType = 183, + ObjectBindingPattern = 184, + ArrayBindingPattern = 185, + BindingElement = 186, + ArrayLiteralExpression = 187, + ObjectLiteralExpression = 188, + PropertyAccessExpression = 189, + ElementAccessExpression = 190, + CallExpression = 191, + NewExpression = 192, + TaggedTemplateExpression = 193, + TypeAssertionExpression = 194, + ParenthesizedExpression = 195, + FunctionExpression = 196, + ArrowFunction = 197, + DeleteExpression = 198, + TypeOfExpression = 199, + VoidExpression = 200, + AwaitExpression = 201, + PrefixUnaryExpression = 202, + PostfixUnaryExpression = 203, + BinaryExpression = 204, + ConditionalExpression = 205, + TemplateExpression = 206, + YieldExpression = 207, + SpreadElement = 208, + ClassExpression = 209, + OmittedExpression = 210, + ExpressionWithTypeArguments = 211, + AsExpression = 212, + NonNullExpression = 213, + MetaProperty = 214, + SyntheticExpression = 215, + TemplateSpan = 216, + SemicolonClassElement = 217, + Block = 218, + VariableStatement = 219, + EmptyStatement = 220, + ExpressionStatement = 221, + IfStatement = 222, + DoStatement = 223, + WhileStatement = 224, + ForStatement = 225, + ForInStatement = 226, + ForOfStatement = 227, + ContinueStatement = 228, + BreakStatement = 229, + ReturnStatement = 230, + WithStatement = 231, + SwitchStatement = 232, + LabeledStatement = 233, + ThrowStatement = 234, + TryStatement = 235, + DebuggerStatement = 236, + VariableDeclaration = 237, + VariableDeclarationList = 238, + FunctionDeclaration = 239, + ClassDeclaration = 240, + InterfaceDeclaration = 241, + TypeAliasDeclaration = 242, + EnumDeclaration = 243, + ModuleDeclaration = 244, + ModuleBlock = 245, + CaseBlock = 246, + NamespaceExportDeclaration = 247, + ImportEqualsDeclaration = 248, + ImportDeclaration = 249, + ImportClause = 250, + NamespaceImport = 251, + NamedImports = 252, + ImportSpecifier = 253, + ExportAssignment = 254, + ExportDeclaration = 255, + NamedExports = 256, + ExportSpecifier = 257, + MissingDeclaration = 258, + ExternalModuleReference = 259, + JsxElement = 260, + JsxSelfClosingElement = 261, + JsxOpeningElement = 262, + JsxClosingElement = 263, + JsxFragment = 264, + JsxOpeningFragment = 265, + JsxClosingFragment = 266, + JsxAttribute = 267, + JsxAttributes = 268, + JsxSpreadAttribute = 269, + JsxExpression = 270, + CaseClause = 271, + DefaultClause = 272, + HeritageClause = 273, + CatchClause = 274, + PropertyAssignment = 275, + ShorthandPropertyAssignment = 276, + SpreadAssignment = 277, + EnumMember = 278, + SourceFile = 279, + Bundle = 280, + UnparsedSource = 281, + InputFiles = 282, + JSDocTypeExpression = 283, + JSDocAllType = 284, + JSDocUnknownType = 285, + JSDocNullableType = 286, + JSDocNonNullableType = 287, + JSDocOptionalType = 288, + JSDocFunctionType = 289, + JSDocVariadicType = 290, + JSDocComment = 291, + JSDocTypeLiteral = 292, + JSDocSignature = 293, + JSDocTag = 294, + JSDocAugmentsTag = 295, + JSDocClassTag = 296, + JSDocCallbackTag = 297, + JSDocEnumTag = 298, + JSDocParameterTag = 299, + JSDocReturnTag = 300, + JSDocThisTag = 301, + JSDocTypeTag = 302, + JSDocTemplateTag = 303, + JSDocTypedefTag = 304, + JSDocPropertyTag = 305, + SyntaxList = 306, + NotEmittedStatement = 307, + PartiallyEmittedExpression = 308, + CommaListExpression = 309, + MergeDeclarationMarker = 310, + EndOfDeclarationMarker = 311, + Count = 312, + FirstAssignment = 59, + LastAssignment = 71, + FirstCompoundAssignment = 60, + LastCompoundAssignment = 71, + FirstReservedWord = 73, + LastReservedWord = 108, + FirstKeyword = 73, + LastKeyword = 147, + FirstFutureReservedWord = 109, + LastFutureReservedWord = 117, + FirstTypeNode = 163, + LastTypeNode = 183, + FirstPunctuation = 18, + LastPunctuation = 71, FirstToken = 0, - LastToken = 145, + LastToken = 147, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 13, - FirstTemplateToken = 13, - LastTemplateToken = 16, - FirstBinaryOperator = 27, - LastBinaryOperator = 70, - FirstNode = 146, - FirstJSDocNode = 281, - LastJSDocNode = 303, - FirstJSDocTagNode = 292, - LastJSDocTagNode = 303 + LastLiteralToken = 14, + FirstTemplateToken = 14, + LastTemplateToken = 17, + FirstBinaryOperator = 28, + LastBinaryOperator = 71, + FirstNode = 148, + FirstJSDocNode = 283, + LastJSDocNode = 305, + FirstJSDocTagNode = 294, + LastJSDocTagNode = 305 } enum NodeFlags { None = 0, @@ -499,7 +504,6 @@ declare namespace ts { type AsteriskToken = Token; type EqualsGreaterThanToken = Token; type EndOfFileToken = Token & JSDocContainer; - type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; type PlusToken = Token; @@ -526,7 +530,7 @@ declare namespace ts { } type EntityName = Identifier | QualifiedName; type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern; + type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; interface Declaration extends Node { _declarationBrand: any; } @@ -724,7 +728,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; @@ -996,6 +1000,9 @@ declare namespace ts { interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } + interface BigIntLiteral extends LiteralExpression { + kind: SyntaxKind.BigIntLiteral; + } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; @@ -1543,7 +1550,6 @@ declare namespace ts { } interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; - atToken: AtToken; tagName: Identifier; comment?: string; } @@ -1573,7 +1579,7 @@ declare namespace ts { } interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; - constraint: TypeNode | undefined; + constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } interface JSDocReturnTag extends JSDocTag { @@ -1755,13 +1761,14 @@ declare namespace ts { } interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; + readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. */ fileExists(path: string): boolean; readFile(path: string): string | undefined; + trace?(s: string): void; } /** * Branded string for keeping track of when we've turned an ambiguous path @@ -1813,11 +1820,12 @@ declare namespace ts { isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; + getResolvedProjectReferences(): ReadonlyArray | undefined; } interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; + references?: ReadonlyArray; } interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ @@ -1841,17 +1849,6 @@ declare namespace ts { /** .ts file (index into sources array) associated with this span */ sourceIndex: number; } - interface SourceMapData { - sourceMapFilePath: string; - jsSourceMappingURL: string; - sourceMapFile: string; - sourceMapSourceRoot: string; - sourceMapSources: string[]; - sourceMapSourcesContent?: (string | null)[]; - inputSourceFileNames: string[]; - sourceMapNames?: string[]; - sourceMapMappings: string; - } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { Success = 0, @@ -1923,7 +1920,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): Symbol[]; + getRootSymbols(symbol: Symbol): ReadonlyArray; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -1941,7 +1938,6 @@ declare namespace ts { /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined; getJsxIntrinsicTagNamesAt(location: Node): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; @@ -2160,44 +2156,47 @@ declare namespace ts { Number = 8, Boolean = 16, Enum = 32, - StringLiteral = 64, - NumberLiteral = 128, - BooleanLiteral = 256, - EnumLiteral = 512, - ESSymbol = 1024, - UniqueESSymbol = 2048, - Void = 4096, - Undefined = 8192, - Null = 16384, - Never = 32768, - TypeParameter = 65536, - Object = 131072, - Union = 262144, - Intersection = 524288, - Index = 1048576, - IndexedAccess = 2097152, - Conditional = 4194304, - Substitution = 8388608, - NonPrimitive = 16777216, - Literal = 448, - Unit = 27072, - StringOrNumberLiteral = 192, - PossiblyFalsy = 29148, - StringLike = 68, - NumberLike = 168, - BooleanLike = 272, - EnumLike = 544, - ESSymbolLike = 3072, - VoidLike = 12288, - UnionOrIntersection = 786432, - StructuredType = 917504, - TypeVariable = 2162688, - InstantiableNonPrimitive = 14745600, - InstantiablePrimitive = 1048576, - Instantiable = 15794176, - StructuredOrInstantiable = 16711680, - Narrowable = 33492479, - NotUnionOrUnit = 16909315 + BigInt = 64, + StringLiteral = 128, + NumberLiteral = 256, + BooleanLiteral = 512, + EnumLiteral = 1024, + BigIntLiteral = 2048, + ESSymbol = 4096, + UniqueESSymbol = 8192, + Void = 16384, + Undefined = 32768, + Null = 65536, + Never = 131072, + TypeParameter = 262144, + Object = 524288, + Union = 1048576, + Intersection = 2097152, + Index = 4194304, + IndexedAccess = 8388608, + Conditional = 16777216, + Substitution = 33554432, + NonPrimitive = 67108864, + Literal = 2944, + Unit = 109440, + StringOrNumberLiteral = 384, + PossiblyFalsy = 117724, + StringLike = 132, + NumberLike = 296, + BigIntLike = 2112, + BooleanLike = 528, + EnumLike = 1056, + ESSymbolLike = 12288, + VoidLike = 49152, + UnionOrIntersection = 3145728, + StructuredType = 3670016, + TypeVariable = 8650752, + InstantiableNonPrimitive = 58982400, + InstantiablePrimitive = 4194304, + Instantiable = 63176704, + StructuredOrInstantiable = 66846720, + Narrowable = 133970943, + NotUnionOrUnit = 67637251 } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2208,7 +2207,7 @@ declare namespace ts { aliasTypeArguments?: ReadonlyArray; } interface LiteralType extends Type { - value: string | number; + value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } @@ -2221,6 +2220,9 @@ declare namespace ts { interface NumberLiteralType extends LiteralType { value: number; } + interface BigIntLiteralType extends LiteralType { + value: PseudoBigInt; + } interface EnumType extends Type { } enum ObjectFlags { @@ -2239,6 +2241,7 @@ declare namespace ts { JsxAttributes = 4096, MarkerType = 8192, JSLiteral = 16384, + FreshLiteral = 32768, ClassOrInterface = 3 } interface ObjectType extends Type { @@ -2670,6 +2673,8 @@ declare namespace ts { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; + /** True if `resolvedFileName` comes from `node_modules`. */ + isExternalLibraryImport?: boolean; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; @@ -2688,11 +2693,11 @@ declare namespace ts { useCaseSensitiveFileNames(): boolean; getNewLine(): string; readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; } @@ -2747,7 +2752,8 @@ declare namespace ts { Expression = 1, IdentifierName = 2, MappedTypeParameter = 3, - Unspecified = 4 + Unspecified = 4, + EmbeddedStatement = 5 } interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ @@ -2940,60 +2946,62 @@ declare namespace ts { BarDelimited = 4, AmpersandDelimited = 8, CommaDelimited = 16, - DelimitersMask = 28, - AllowTrailingComma = 32, - Indented = 64, - SpaceBetweenBraces = 128, - SpaceBetweenSiblings = 256, - Braces = 512, - Parenthesis = 1024, - AngleBrackets = 2048, - SquareBrackets = 4096, - BracketsMask = 7680, - OptionalIfUndefined = 8192, - OptionalIfEmpty = 16384, - Optional = 24576, - PreferNewLine = 32768, - NoTrailingNewLine = 65536, - NoInterveningComments = 131072, - NoSpaceIfEmpty = 262144, - SingleElement = 524288, - Modifiers = 131328, - HeritageClauses = 256, - SingleLineTypeLiteralMembers = 384, - MultiLineTypeLiteralMembers = 16449, - TupleTypeElements = 272, - UnionTypeConstituents = 260, - IntersectionTypeConstituents = 264, - ObjectBindingPatternElements = 262576, - ArrayBindingPatternElements = 262448, - ObjectLiteralExpressionProperties = 263122, - ArrayLiteralExpressionElements = 4466, - CommaListElements = 272, - CallExpressionArguments = 1296, - NewExpressionArguments = 9488, - TemplateExpressionSpans = 131072, - SingleLineBlockStatements = 384, - MultiLineBlockStatements = 65, - VariableDeclarationList = 272, - SingleLineFunctionBodyStatements = 384, + AsteriskDelimited = 32, + DelimitersMask = 60, + AllowTrailingComma = 64, + Indented = 128, + SpaceBetweenBraces = 256, + SpaceBetweenSiblings = 512, + Braces = 1024, + Parenthesis = 2048, + AngleBrackets = 4096, + SquareBrackets = 8192, + BracketsMask = 15360, + OptionalIfUndefined = 16384, + OptionalIfEmpty = 32768, + Optional = 49152, + PreferNewLine = 65536, + NoTrailingNewLine = 131072, + NoInterveningComments = 262144, + NoSpaceIfEmpty = 524288, + SingleElement = 1048576, + Modifiers = 262656, + HeritageClauses = 512, + SingleLineTypeLiteralMembers = 768, + MultiLineTypeLiteralMembers = 32897, + TupleTypeElements = 528, + UnionTypeConstituents = 516, + IntersectionTypeConstituents = 520, + ObjectBindingPatternElements = 525136, + ArrayBindingPatternElements = 524880, + ObjectLiteralExpressionProperties = 526226, + ArrayLiteralExpressionElements = 8914, + CommaListElements = 528, + CallExpressionArguments = 2576, + NewExpressionArguments = 18960, + TemplateExpressionSpans = 262144, + SingleLineBlockStatements = 768, + MultiLineBlockStatements = 129, + VariableDeclarationList = 528, + SingleLineFunctionBodyStatements = 768, MultiLineFunctionBodyStatements = 1, ClassHeritageClauses = 0, - ClassMembers = 65, - InterfaceMembers = 65, - EnumMembers = 81, - CaseBlockClauses = 65, - NamedImportsOrExportsElements = 262576, - JsxElementOrFragmentChildren = 131072, - JsxElementAttributes = 131328, - CaseOrDefaultClauseStatements = 81985, - HeritageClauseTypes = 272, - SourceFileStatements = 65537, - Decorators = 24577, - TypeArguments = 26896, - TypeParameters = 26896, - Parameters = 1296, - IndexSignatureParameters = 4432 + ClassMembers = 129, + InterfaceMembers = 129, + EnumMembers = 145, + CaseBlockClauses = 129, + NamedImportsOrExportsElements = 525136, + JsxElementOrFragmentChildren = 262144, + JsxElementAttributes = 262656, + CaseOrDefaultClauseStatements = 163969, + HeritageClauseTypes = 528, + SourceFileStatements = 131073, + Decorators = 49153, + TypeArguments = 53776, + TypeParameters = 53776, + Parameters = 2576, + IndexSignatureParameters = 8848, + JSDocComment = 33 } interface UserPreferences { readonly disableSuggestions?: boolean; @@ -3005,6 +3013,11 @@ declare namespace ts { readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; readonly allowTextChangesInNewFiles?: boolean; } + /** Represents a bigint literal value without requiring bigint support */ + interface PseudoBigInt { + negative: boolean; + base10Value: string; + } } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -3121,7 +3134,7 @@ declare namespace ts { /** Non-internal stuff goes here */ declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): T[]; + function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3287,6 +3300,7 @@ declare namespace ts { } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; + function isBigIntLiteral(node: Node): node is BigIntLiteral; function isStringLiteral(node: Node): node is StringLiteral; function isJsxText(node: Node): node is JsxText; function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral; @@ -3606,7 +3620,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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -3621,14 +3635,14 @@ declare namespace ts { * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string): Map; + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ interface NonRelativeModuleNameResolutionCache { - getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; @@ -3636,18 +3650,19 @@ declare namespace ts { } function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; - function createLiteral(value: number): NumericLiteral; + function createLiteral(value: number | PseudoBigInt): NumericLiteral; function createLiteral(value: boolean): BooleanLiteral; - function createLiteral(value: string | number | boolean): PrimaryExpression; + function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression; function createNumericLiteral(value: string): NumericLiteral; + function createBigIntLiteral(value: string): BigIntLiteral; function createStringLiteral(text: string): StringLiteral; function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; function createIdentifier(text: string): Identifier; @@ -4148,7 +4163,7 @@ declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -4384,9 +4399,9 @@ declare namespace ts { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; } /** * Host to create watch with root files and options @@ -4452,9 +4467,6 @@ declare namespace ts.server { type EventBeginInstallTypes = "event::beginInstallTypes"; type EventEndInstallTypes = "event::endInstallTypes"; type EventInitializationFailed = "event::initializationFailed"; - interface SortedReadonlyArray extends ReadonlyArray { - " __sortedArrayBrand": any; - } interface TypingInstallerResponse { readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | ActionValueInspected | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed; } @@ -4654,9 +4666,9 @@ declare namespace ts { realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4666,6 +4678,9 @@ declare namespace ts { installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; } + type WithMetadata = T & { + metadata?: unknown; + }; interface LanguageService { cleanupSemanticCache(): void; getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; @@ -4683,7 +4698,7 @@ declare namespace ts { getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined; + getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): WithMetadata | undefined; getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; @@ -4691,16 +4706,16 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; - getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; + getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -5040,24 +5055,25 @@ declare namespace ts { insertSpaceBeforeTypeAnnotation?: boolean; } interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterConstructor?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceAfterTypeAssertion?: boolean; - insertSpaceBeforeFunctionParenthesis?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - insertSpaceBeforeTypeAnnotation?: boolean; - indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly insertSpaceAfterCommaDelimiter?: boolean; + readonly insertSpaceAfterSemicolonInForStatements?: boolean; + readonly insertSpaceBeforeAndAfterBinaryOperators?: boolean; + readonly insertSpaceAfterConstructor?: boolean; + readonly insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + readonly insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + readonly insertSpaceAfterTypeAssertion?: boolean; + readonly insertSpaceBeforeFunctionParenthesis?: boolean; + readonly placeOpenBraceOnNewLineForFunctions?: boolean; + readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; + readonly insertSpaceBeforeTypeAnnotation?: boolean; + readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; } + function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { kind: ScriptElementKind; name: string; @@ -5250,8 +5266,9 @@ declare namespace ts { Whitespace = 4, Identifier = 5, NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8 + BigIntLiteral = 7, + StringLiteral = 8, + RegExpLiteral = 9 } interface ClassificationResult { finalLexState: EndOfLineState; @@ -5363,13 +5380,20 @@ declare namespace ts { ambientModifier = "declare", staticModifier = "static", abstractModifier = "abstract", - optionalModifier = "optional" + optionalModifier = "optional", + dtsModifier = ".d.ts", + tsModifier = ".ts", + tsxModifier = ".tsx", + jsModifier = ".js", + jsxModifier = ".jsx", + jsonModifier = ".json" } enum ClassificationTypeNames { comment = "comment", identifier = "identifier", keyword = "keyword", numericLiteral = "number", + bigintLiteral = "bigint", operator = "operator", stringLiteral = "string", whiteSpace = "whitespace", @@ -5414,7 +5438,8 @@ declare namespace ts { jsxSelfClosingTagName = 21, jsxAttribute = 22, jsxText = 23, - jsxAttributeStringLiteralValue = 24 + jsxAttributeStringLiteralValue = 24, + bigintLiteral = 25 } } declare namespace ts { @@ -5506,6 +5531,10 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } +declare namespace ts { + function generateTypesForModule(name: string, moduleValue: unknown, formatSettings: FormatCodeSettings): string; + function generateTypesForGlobal(name: string, globalValue: unknown, formatSettings: FormatCodeSettings): string; +} declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; @@ -5595,7 +5624,6 @@ declare namespace ts.server { function ThrowProjectLanguageServiceDisabled(): never; function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; } - function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; type NormalizedPath = string & { __normalizedPathTag: any; }; @@ -5676,7 +5704,8 @@ declare namespace ts.server.protocol { GetApplicableRefactors = "getApplicableRefactors", GetEditsForRefactor = "getEditsForRefactor", OrganizeImports = "organizeImports", - GetEditsForFileRename = "getEditsForFileRename" + GetEditsForFileRename = "getEditsForFileRename", + ConfigurePlugin = "configurePlugin" } /** * A TypeScript Server message @@ -5751,6 +5780,10 @@ declare namespace ts.server.protocol { * Contains message body if success === true. */ body?: any; + /** + * Contains extra information that plugin can include to be passed on + */ + metadata?: unknown; } /** * Arguments for FileRequest messages. @@ -6396,7 +6429,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReferencesResponseItem[]; + refs: ReadonlyArray; /** * The name of the symbol. */ @@ -6625,6 +6658,14 @@ declare namespace ts.server.protocol { */ interface ConfigureResponse extends Response { } + interface ConfigurePluginRequestArguments { + pluginName: string; + configuration: any; + } + interface ConfigurePluginRequest extends Request { + command: CommandTypes.ConfigurePlugin; + arguments: ConfigurePluginRequestArguments; + } /** * Information found in an "open" request. */ @@ -7462,6 +7503,7 @@ declare namespace ts.server.protocol { */ interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; + event: DiagnosticEventKind; } interface ConfigFileDiagnosticEventBody { /** @@ -8071,6 +8113,11 @@ declare namespace ts.server { interface PluginModule { create(createInfo: PluginCreateInfo): LanguageService; getExternalFiles?(proj: Project): string[]; + onConfigurationChanged?(config: any): void; + } + interface PluginModuleWithName { + name: string; + module: PluginModule; } type PluginModuleFactory = (mod: { typescript: typeof ts; @@ -8135,7 +8182,7 @@ declare namespace ts.server { getCompilerOptions(): CompilerOptions; getNewLine(): string; getProjectVersion(): string; - getProjectReferences(): ReadonlyArray; + getProjectReferences(): ReadonlyArray | undefined; getScriptFileNames(): string[]; private getOrCreateScriptInfoAndAttachToProject; getScriptKind(fileName: string): ScriptKind; @@ -8149,9 +8196,9 @@ declare namespace ts.server { readFile(fileName: string): string | undefined; writeFile(fileName: string, content: string): void; fileExists(file: string): boolean; - resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModuleFull[]; + resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModuleFull | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; directoryExists(path: string): boolean; getDirectories(path: string): string[]; log(s: string): void; @@ -8209,11 +8256,11 @@ declare namespace ts.server { filesToString(writeProjectFileNames: boolean): string; setCompilerOptions(compilerOptions: CompilerOptions): void; protected removeRoot(info: ScriptInfo): void; - protected enableGlobalPlugins(options: CompilerOptions): void; - protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void; + protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map | undefined): void; + protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): void; + private enableProxy; /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ refreshDiagnostics(): void; - private enableProxy; } /** * If a file is opened and no tsconfig (or jsconfig) is found, @@ -8252,9 +8299,8 @@ declare namespace ts.server { */ updateGraph(): boolean; getConfigFilePath(): NormalizedPath; - getProjectReferences(): ReadonlyArray; + getProjectReferences(): ReadonlyArray | undefined; updateReferences(refs: ReadonlyArray | undefined): void; - enablePlugins(): void; /** * Get the errors that dont have any file name associated */ @@ -8514,6 +8560,7 @@ declare namespace ts.server { readonly globalPlugins: ReadonlyArray; readonly pluginProbeLocations: ReadonlyArray; readonly allowLocalPluginLoads: boolean; + private currentPluginConfigOverrides; readonly typesMapLocation: string | undefined; readonly syntaxOnly?: boolean; /** Tracks projects that we have already sent telemetry for. */ @@ -8689,6 +8736,7 @@ declare namespace ts.server { applySafeList(proj: protocol.ExternalProject): NormalizedPath[]; openExternalProject(proj: protocol.ExternalProject): void; hasDeferredExtension(): boolean; + configurePlugin(args: protocol.ConfigurePluginRequestArguments): void; } } declare namespace ts.server { @@ -8861,6 +8909,7 @@ declare namespace ts.server { private convertTextChangeToCodeEdit; private getBraceMatching; private getDiagnosticsForProject; + private configurePlugin; getCanonicalFileName(fileName: string): string; exit(): void; private notRequired; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 53d751f50a5..0767cfedaad 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -487,10 +487,33 @@ var ts; return result; } ts.flatten = flatten; + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ function flatMap(array, mapfn) { var result; if (array) { - result = []; + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || ts.emptyArray; + } + ts.flatMap = flatMap; + function flatMapToMutable(array, mapfn) { + var result = []; + if (array) { for (var i = 0; i < array.length; i++) { var v = mapfn(array[i], i); if (v) { @@ -505,7 +528,7 @@ var ts; } return result; } - ts.flatMap = flatMap; + ts.flatMapToMutable = flatMapToMutable; function flatMapIterator(iter, mapfn) { var first = iter.next(); if (first.done) { @@ -744,7 +767,7 @@ var ts; */ function deduplicateSorted(array, comparer) { if (array.length === 0) - return []; + return ts.emptyArray; var last = array[0]; var deduplicated = [last]; for (var i = 1; i < array.length; i++) { @@ -775,7 +798,7 @@ var ts; } ts.insertSorted = insertSorted; function sortAndDeduplicate(array, comparer, equalityComparer) { - return deduplicateSorted(sort(array, comparer), equalityComparer || comparer); + return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive); } ts.sortAndDeduplicate = sortAndDeduplicate; function arrayIsEqualTo(array1, array2, equalityComparer) { @@ -928,7 +951,7 @@ var ts; * Returns a new sorted array. */ function sort(array, comparer) { - return array.slice().sort(comparer); + return (array.length === 0 ? array : array.slice().sort(comparer)); } ts.sort = sort; function arrayIterator(array) { @@ -1034,12 +1057,25 @@ var ts; * @param offset An offset into `array` at which to start the search. */ function binarySearch(array, value, keySelector, keyComparer, offset) { - if (!array || array.length === 0) { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); + } + ts.binarySearch = binarySearch; + /** + * Performs a binary search, finding the index at which an object with `key` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `key`. + * @param array A sorted array whose first element must be no larger than number + * @param key The key to be searched for in the array. + * @param keySelector A callback used to select the search key from each element of `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + */ + function binarySearchKey(array, key, keySelector, keyComparer, offset) { + if (!some(array)) { return -1; } var low = offset || 0; var high = array.length - 1; - var key = keySelector(value); while (low <= high) { var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle]); @@ -1056,7 +1092,7 @@ var ts; } return ~low; } - ts.binarySearch = binarySearch; + ts.binarySearchKey = binarySearchKey; function reduceLeft(array, f, initial, start, count) { if (array && array.length > 0) { var size = array.length; @@ -1980,6 +2016,33 @@ var ts; var counts; var marks; var measures; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; /** * Marks a performance event. * @@ -2434,368 +2497,370 @@ var ts; SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["BigIntLiteral"] = 9] = "BigIntLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 11] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 12] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 13] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 14] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 15] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 16] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 17] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 18] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 19] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 20] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 21] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 22] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 23] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 24] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 59] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 60] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 61] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 62] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 63] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 64] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 65] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 66] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 69] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 70] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 71] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 72] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 73] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 74] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 75] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 76] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 77] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 78] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 79] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 80] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 81] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 82] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 83] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 84] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 85] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 86] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 87] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 88] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 89] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 90] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 91] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 92] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 93] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 94] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 95] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 96] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 97] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 98] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 99] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 100] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 101] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 102] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 103] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 104] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 105] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 106] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 107] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 108] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 109] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 110] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 111] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 112] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 113] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 114] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 115] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 116] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 117] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 126] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 127] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 128] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 129] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 130] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 131] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 132] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 133] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 134] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 135] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 136] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 137] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 138] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 118] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 119] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 120] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 121] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 122] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 123] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 124] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 125] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 126] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 127] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 128] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 129] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 130] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 131] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 132] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 133] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 134] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 135] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 136] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 137] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 138] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 139] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 140] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 141] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 142] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 143] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 144] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 145] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 146] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 147] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 148] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 149] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 150] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 151] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 152] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 153] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 154] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 155] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 156] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 157] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 158] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 159] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 160] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 161] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 162] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 163] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 164] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 165] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 166] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 167] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 168] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 169] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 170] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 171] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 172] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 173] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 174] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 175] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 176] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 177] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 178] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 179] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 180] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 181] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 182] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 183] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 184] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 185] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 186] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 187] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 188] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 189] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 190] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 191] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 192] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 193] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 194] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 195] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 196] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 197] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 198] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 199] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 200] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 201] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 202] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 203] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 204] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 205] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 206] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 207] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 208] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 209] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 210] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 211] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 212] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 213] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 214] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 215] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 216] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 217] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 218] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 219] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 220] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 221] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 222] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 223] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 224] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 225] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 226] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 227] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 228] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 229] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 230] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 231] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 232] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 233] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 234] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 235] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 236] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 237] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 238] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 239] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 240] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 241] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 242] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 243] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 244] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 245] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 246] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 247] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 248] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 249] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 250] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 251] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 252] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 253] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 254] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 255] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 256] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 257] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 258] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 259] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 260] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 261] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 262] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 263] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 264] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 265] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 266] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 267] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 268] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 269] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 270] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 271] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 272] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 273] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 274] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 275] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 276] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 296] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 297] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 298] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 299] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 300] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 301] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 302] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 303] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 304] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 305] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 306] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 307] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 308] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 309] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 310] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 60] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 71] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 73] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 108] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 73] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 147] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 109] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 117] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 163] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 183] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 71] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 147] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 303] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 303] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3085,14 +3150,15 @@ var ts; // of a type, such as the global `Promise` type in lib.d.ts). TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; // with call signatures. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; (function (SymbolFlags) { @@ -3247,29 +3313,27 @@ var ts; TypeFlags[TypeFlags["Number"] = 8] = "Number"; TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 4096] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 16384] = "Null"; - TypeFlags[TypeFlags["Never"] = 32768] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 131072] = "Object"; - TypeFlags[TypeFlags["Union"] = 262144] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; - TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; - /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; - /* @internal */ - TypeFlags[TypeFlags["UnionOfPrimitiveTypes"] = 67108864] = "UnionOfPrimitiveTypes"; + TypeFlags[TypeFlags["BigInt"] = 64] = "BigInt"; + TypeFlags[TypeFlags["StringLiteral"] = 128] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 256] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 512] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 1024] = "EnumLiteral"; + TypeFlags[TypeFlags["BigIntLiteral"] = 2048] = "BigIntLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 4096] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 8192] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 16384] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32768] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 65536] = "Null"; + TypeFlags[TypeFlags["Never"] = 131072] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 262144] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 524288] = "Object"; + TypeFlags[TypeFlags["Union"] = 1048576] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 2097152] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 4194304] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 8388608] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; /* @internal */ TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ @@ -3279,40 +3343,41 @@ var ts; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 98304] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 2944] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 117724] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 67359327] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 131068] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 132] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 296] = "NumberLike"; + TypeFlags[TypeFlags["BigIntLike"] = 2112] = "BigIntLike"; + TypeFlags[TypeFlags["BooleanLike"] = 528] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 1056] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 16748579] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ @@ -3347,6 +3412,7 @@ var ts; ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ @@ -3358,6 +3424,13 @@ var ts; Variance[Variance["Bivariant"] = 3] = "Bivariant"; Variance[Variance["Independent"] = 4] = "Independent"; })(Variance = ts.Variance || (ts.Variance = {})); + /* @internal */ + var JsxReferenceKind; + (function (JsxReferenceKind) { + JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; + JsxReferenceKind[JsxReferenceKind["Function"] = 1] = "Function"; + JsxReferenceKind[JsxReferenceKind["Mixed"] = 2] = "Mixed"; + })(JsxReferenceKind = ts.JsxReferenceKind || (ts.JsxReferenceKind = {})); var SignatureKind; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; @@ -3418,6 +3491,15 @@ var ts; AssignmentDeclarationKind[AssignmentDeclarationKind["Property"] = 5] = "Property"; // F.prototype = { ... } AssignmentDeclarationKind[AssignmentDeclarationKind["Prototype"] = 6] = "Prototype"; + // Object.defineProperty(x, 'name', { value: any, writable?: boolean (false by default) }); + // Object.defineProperty(x, 'name', { get: Function, set: Function }); + // Object.defineProperty(x, 'name', { get: Function }); + // Object.defineProperty(x, 'name', { set: Function }); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyValue"] = 7] = "ObjectDefinePropertyValue"; + // Object.defineProperty(exports || module.exports, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyExports"] = 8] = "ObjectDefinePropertyExports"; + // Object.defineProperty(Foo.prototype, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePrototypeProperty"] = 9] = "ObjectDefinePrototypeProperty"; })(AssignmentDeclarationKind = ts.AssignmentDeclarationKind || (ts.AssignmentDeclarationKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -3785,6 +3867,7 @@ var ts; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; + EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); var ListFormat; (function (ListFormat) { @@ -3799,64 +3882,66 @@ var ts; ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["AsteriskDelimited"] = 32] = "AsteriskDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 60] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 64] = "AllowTrailingComma"; // Whitespace - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Indented"] = 128] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 256] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 512] = "SpaceBetweenSiblings"; // Brackets/Braces - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["Braces"] = 1024] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 2048] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 4096] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 8192] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 15360] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 16384] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 32768] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 49152] = "Optional"; // Other - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; - ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; + ListFormat[ListFormat["PreferNewLine"] = 65536] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 131072] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 262144] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 524288] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 1048576] = "SingleElement"; // Precomputed Formats - ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 384] = "SingleLineTypeLiteralMembers"; - ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 16449] = "MultiLineTypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 272] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 262576] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 262448] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["Modifiers"] = 262656] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 512] = "HeritageClauses"; + ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 768] = "SingleLineTypeLiteralMembers"; + ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 32897] = "MultiLineTypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 528] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 516] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 520] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 525136] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 524880] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 526226] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 8914] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CommaListElements"] = 528] = "CommaListElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 2576] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 18960] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 262144] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 768] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 129] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 528] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 768] = "SingleLineFunctionBodyStatements"; ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; ListFormat[ListFormat["ClassHeritageClauses"] = 0] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 262576] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 131072] = "JsxElementOrFragmentChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26896] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26896] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1296] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + ListFormat[ListFormat["ClassMembers"] = 129] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 129] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 145] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 129] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 525136] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 262144] = "JsxElementOrFragmentChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 262656] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 163969] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 528] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 131073] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 49153] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 53776] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 53776] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 2576] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 8848] = "IndexSignatureParameters"; + ListFormat[ListFormat["JSDocComment"] = 33] = "JSDocComment"; })(ListFormat = ts.ListFormat || (ts.ListFormat = {})); /* @internal */ var PragmaKindFlags; @@ -5160,6 +5245,7 @@ var ts; use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), 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."), @@ -5216,14 +5302,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number' or an enum type."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), @@ -5430,9 +5516,9 @@ var ts; No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), @@ -5530,6 +5616,13 @@ var ts; Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), It_is_highly_likely_that_you_are_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "It_is_highly_likely_that_you_are_missing_a_semicolon_2734", "It is highly likely that you are missing a semicolon."), + Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), + Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), + BigInt_literals_are_not_available_when_targeting_lower_than_ESNext: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ESNext_2737", "BigInt literals are not available when targeting lower than ESNext."), + An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, ts.DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."), + Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."), 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}'."), @@ -5846,6 +5939,9 @@ var ts; Did_you_mean_to_call_this_expression: diag(6212, ts.DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"), Did_you_mean_to_use_new_with_this_expression: diag(6213, ts.DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"), Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, ts.DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."), + Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."), + Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."), + Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5886,6 +5982,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."), Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."), Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."), + Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, ts.DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."), Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."), Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."), Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."), @@ -5913,6 +6010,14 @@ var ts; If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any_7041", "The containing arrow function captures the global value of 'this' which implicitly has type 'any'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), + Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, ts.DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, ts.DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."), + Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, ts.DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."), + _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."), 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_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -6074,6 +6179,8 @@ var ts; Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), Generate_types_for_0: diag(95067, ts.DiagnosticCategory.Message, "Generate_types_for_0_95067", "Generate types for '{0}'"), Generate_types_for_all_packages_without_types: diag(95068, ts.DiagnosticCategory.Message, "Generate_types_for_all_packages_without_types_95068", "Generate types for all packages without types"), + Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), + Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), }; })(ts || (ts = {})); var ts; @@ -6081,93 +6188,94 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 71 /* Identifier */; + return token >= 72 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 117 /* AbstractKeyword */, - any: 119 /* AnyKeyword */, - as: 118 /* AsKeyword */, - boolean: 122 /* BooleanKeyword */, - break: 72 /* BreakKeyword */, - case: 73 /* CaseKeyword */, - catch: 74 /* CatchKeyword */, - class: 75 /* ClassKeyword */, - continue: 77 /* ContinueKeyword */, - const: 76 /* ConstKeyword */ + abstract: 118 /* AbstractKeyword */, + any: 120 /* AnyKeyword */, + as: 119 /* AsKeyword */, + bigint: 146 /* BigIntKeyword */, + boolean: 123 /* BooleanKeyword */, + break: 73 /* BreakKeyword */, + case: 74 /* CaseKeyword */, + catch: 75 /* CatchKeyword */, + class: 76 /* ClassKeyword */, + continue: 78 /* ContinueKeyword */, + const: 77 /* ConstKeyword */ }, - _a["" + "constructor"] = 123 /* ConstructorKeyword */, - _a.debugger = 78 /* DebuggerKeyword */, - _a.declare = 124 /* DeclareKeyword */, - _a.default = 79 /* DefaultKeyword */, - _a.delete = 80 /* DeleteKeyword */, - _a.do = 81 /* DoKeyword */, - _a.else = 82 /* ElseKeyword */, - _a.enum = 83 /* EnumKeyword */, - _a.export = 84 /* ExportKeyword */, - _a.extends = 85 /* ExtendsKeyword */, - _a.false = 86 /* FalseKeyword */, - _a.finally = 87 /* FinallyKeyword */, - _a.for = 88 /* ForKeyword */, - _a.from = 143 /* FromKeyword */, - _a.function = 89 /* FunctionKeyword */, - _a.get = 125 /* GetKeyword */, - _a.if = 90 /* IfKeyword */, - _a.implements = 108 /* ImplementsKeyword */, - _a.import = 91 /* ImportKeyword */, - _a.in = 92 /* InKeyword */, - _a.infer = 126 /* InferKeyword */, - _a.instanceof = 93 /* InstanceOfKeyword */, - _a.interface = 109 /* InterfaceKeyword */, - _a.is = 127 /* IsKeyword */, - _a.keyof = 128 /* KeyOfKeyword */, - _a.let = 110 /* LetKeyword */, - _a.module = 129 /* ModuleKeyword */, - _a.namespace = 130 /* NamespaceKeyword */, - _a.never = 131 /* NeverKeyword */, - _a.new = 94 /* NewKeyword */, - _a.null = 95 /* NullKeyword */, - _a.number = 134 /* NumberKeyword */, - _a.object = 135 /* ObjectKeyword */, - _a.package = 111 /* PackageKeyword */, - _a.private = 112 /* PrivateKeyword */, - _a.protected = 113 /* ProtectedKeyword */, - _a.public = 114 /* PublicKeyword */, - _a.readonly = 132 /* ReadonlyKeyword */, - _a.require = 133 /* RequireKeyword */, - _a.global = 144 /* GlobalKeyword */, - _a.return = 96 /* ReturnKeyword */, - _a.set = 136 /* SetKeyword */, - _a.static = 115 /* StaticKeyword */, - _a.string = 137 /* StringKeyword */, - _a.super = 97 /* SuperKeyword */, - _a.switch = 98 /* SwitchKeyword */, - _a.symbol = 138 /* SymbolKeyword */, - _a.this = 99 /* ThisKeyword */, - _a.throw = 100 /* ThrowKeyword */, - _a.true = 101 /* TrueKeyword */, - _a.try = 102 /* TryKeyword */, - _a.type = 139 /* TypeKeyword */, - _a.typeof = 103 /* TypeOfKeyword */, - _a.undefined = 140 /* UndefinedKeyword */, - _a.unique = 141 /* UniqueKeyword */, - _a.unknown = 142 /* UnknownKeyword */, - _a.var = 104 /* VarKeyword */, - _a.void = 105 /* VoidKeyword */, - _a.while = 106 /* WhileKeyword */, - _a.with = 107 /* WithKeyword */, - _a.yield = 116 /* YieldKeyword */, - _a.async = 120 /* AsyncKeyword */, - _a.await = 121 /* AwaitKeyword */, - _a.of = 145 /* OfKeyword */, + _a["" + "constructor"] = 124 /* ConstructorKeyword */, + _a.debugger = 79 /* DebuggerKeyword */, + _a.declare = 125 /* DeclareKeyword */, + _a.default = 80 /* DefaultKeyword */, + _a.delete = 81 /* DeleteKeyword */, + _a.do = 82 /* DoKeyword */, + _a.else = 83 /* ElseKeyword */, + _a.enum = 84 /* EnumKeyword */, + _a.export = 85 /* ExportKeyword */, + _a.extends = 86 /* ExtendsKeyword */, + _a.false = 87 /* FalseKeyword */, + _a.finally = 88 /* FinallyKeyword */, + _a.for = 89 /* ForKeyword */, + _a.from = 144 /* FromKeyword */, + _a.function = 90 /* FunctionKeyword */, + _a.get = 126 /* GetKeyword */, + _a.if = 91 /* IfKeyword */, + _a.implements = 109 /* ImplementsKeyword */, + _a.import = 92 /* ImportKeyword */, + _a.in = 93 /* InKeyword */, + _a.infer = 127 /* InferKeyword */, + _a.instanceof = 94 /* InstanceOfKeyword */, + _a.interface = 110 /* InterfaceKeyword */, + _a.is = 128 /* IsKeyword */, + _a.keyof = 129 /* KeyOfKeyword */, + _a.let = 111 /* LetKeyword */, + _a.module = 130 /* ModuleKeyword */, + _a.namespace = 131 /* NamespaceKeyword */, + _a.never = 132 /* NeverKeyword */, + _a.new = 95 /* NewKeyword */, + _a.null = 96 /* NullKeyword */, + _a.number = 135 /* NumberKeyword */, + _a.object = 136 /* ObjectKeyword */, + _a.package = 112 /* PackageKeyword */, + _a.private = 113 /* PrivateKeyword */, + _a.protected = 114 /* ProtectedKeyword */, + _a.public = 115 /* PublicKeyword */, + _a.readonly = 133 /* ReadonlyKeyword */, + _a.require = 134 /* RequireKeyword */, + _a.global = 145 /* GlobalKeyword */, + _a.return = 97 /* ReturnKeyword */, + _a.set = 137 /* SetKeyword */, + _a.static = 116 /* StaticKeyword */, + _a.string = 138 /* StringKeyword */, + _a.super = 98 /* SuperKeyword */, + _a.switch = 99 /* SwitchKeyword */, + _a.symbol = 139 /* SymbolKeyword */, + _a.this = 100 /* ThisKeyword */, + _a.throw = 101 /* ThrowKeyword */, + _a.true = 102 /* TrueKeyword */, + _a.try = 103 /* TryKeyword */, + _a.type = 140 /* TypeKeyword */, + _a.typeof = 104 /* TypeOfKeyword */, + _a.undefined = 141 /* UndefinedKeyword */, + _a.unique = 142 /* UniqueKeyword */, + _a.unknown = 143 /* UnknownKeyword */, + _a.var = 105 /* VarKeyword */, + _a.void = 106 /* VoidKeyword */, + _a.while = 107 /* WhileKeyword */, + _a.with = 108 /* WithKeyword */, + _a.yield = 117 /* YieldKeyword */, + _a.async = 121 /* AsyncKeyword */, + _a.await = 122 /* AwaitKeyword */, + _a.of = 147 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 59 /* EqualsToken */, "+=": 60 /* PlusEqualsToken */, "-=": 61 /* MinusEqualsToken */, "*=": 62 /* AsteriskEqualsToken */, "**=": 63 /* AsteriskAsteriskEqualsToken */, "/=": 64 /* SlashEqualsToken */, "%=": 65 /* PercentEqualsToken */, "<<=": 66 /* LessThanLessThanEqualsToken */, ">>=": 67 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 69 /* AmpersandEqualsToken */, "|=": 70 /* BarEqualsToken */, "^=": 71 /* CaretEqualsToken */, "@": 58 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6756,8 +6864,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; }, + isIdentifier: function () { return token === 72 /* Identifier */ || token > 108 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -6851,18 +6959,29 @@ var ts; end = pos; } } + var result; if (tokenFlags & 512 /* ContainsSeparator */) { - var result = mainFragment; + result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; } if (scientificFragment) { result += scientificFragment; } - return "" + +result; } else { - return "" + +(text.substring(start, end)); // No need to use all the fragments; no _ removal needed + result = text.substring(start, end); // No need to use all the fragments; no _ removal needed + } + if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { + return { + type: 8 /* NumericLiteral */, + value: "" + +result // if value is not an integer, it can be safely coerced to a number + }; + } + else { + tokenValue = result; + var type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint + return { type: type, value: tokenValue }; } } function scanOctalDigits() { @@ -6877,21 +6996,21 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count, canHaveSeparators) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + var valueString = scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + return valueString ? parseInt(valueString, 16) : -1; } /** * Scans as many hexadecimal digits as are available in the text, - * returning -1 if the given number of digits was unavailable. + * returning "" if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count, canHaveSeparators) { return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true, canHaveSeparators); } function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) { - var digits = 0; - var value = 0; + var valueChars = []; var allowSeparator = false; var isPreviousTokenSeparator = false; - while (digits < minCount || scanAsManyAsPossible) { + while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); if (canHaveSeparators && ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; @@ -6909,29 +7028,24 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; + if (ch >= 65 /* A */ && ch <= 70 /* F */) { + ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { + else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || + (ch >= 97 /* a */ && ch <= 102 /* f */))) { break; } + valueChars.push(ch); pos++; - digits++; isPreviousTokenSeparator = false; } - if (digits < minCount) { - value = -1; + if (valueChars.length < minCount) { + valueChars = []; } if (text.charCodeAt(pos - 1) === 95 /* _ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } - return value; + return String.fromCharCode.apply(String, valueChars); } function scanString(jsxAttributeString) { if (jsxAttributeString === void 0) { jsxAttributeString = false; } @@ -6983,7 +7097,7 @@ var ts; contents += text.substring(start, pos); tokenFlags |= 4 /* Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -6991,14 +7105,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; break; } // Escape character @@ -7091,7 +7205,8 @@ var ts; } } function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; var isInvalidExtendedEscape = false; // Validate the value of the digit if (escapedValue < 0) { @@ -7179,14 +7294,12 @@ var ts; } } } - return token = 71 /* Identifier */; + return token = 72 /* Identifier */; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; + var value = ""; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. - var numberOfDigits = 0; var separatorAllowed = false; var isPreviousTokenSeparator = false; while (true) { @@ -7208,27 +7321,42 @@ var ts; continue; } separatorAllowed = true; - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { + if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { break; } - value = value * base + valueOfCh; + value += text[pos]; pos++; - numberOfDigits++; isPreviousTokenSeparator = false; } - // Invalid binaryIntegerLiteral or octalIntegerLiteral - if (numberOfDigits === 0) { - return -1; - } if (text.charCodeAt(pos - 1) === 95 /* _ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); - return value; } return value; } + function checkBigIntSuffix() { + if (text.charCodeAt(pos) === 110 /* n */) { + tokenValue += "n"; + // Use base 10 instead of base 2 or base 8 for shorter literals + if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; + } + pos++; + return 9 /* 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 */ + ? parseInt(tokenValue.slice(2), 2) // skip "0b" + : tokenFlags & 256 /* OctalSpecifier */ + ? parseInt(tokenValue.slice(2), 8) // skip "0o" + : +tokenValue; + tokenValue = "" + numericValue; + return 8 /* NumericLiteral */; + } + } function scan() { + var _a; startPos = pos; tokenFlags = 0; var asteriskSeen = false; @@ -7301,48 +7429,48 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 33 /* ExclamationEqualsToken */; + return pos += 2, token = 34 /* ExclamationEqualsToken */; } pos++; - return token = 51 /* ExclamationToken */; + return token = 52 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PercentEqualsToken */; + return pos += 2, token = 65 /* PercentEqualsToken */; } pos++; - return token = 42 /* PercentToken */; + return token = 43 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 53 /* AmpersandAmpersandToken */; + return pos += 2, token = 54 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* AmpersandEqualsToken */; + return pos += 2, token = 69 /* AmpersandEqualsToken */; } pos++; - return token = 48 /* AmpersandToken */; + return token = 49 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 19 /* OpenParenToken */; + return token = 20 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 20 /* CloseParenToken */; + return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* AsteriskEqualsToken */; + return pos += 2, token = 62 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 63 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 40 /* AsteriskAsteriskToken */; + return pos += 2, token = 41 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7350,38 +7478,38 @@ var ts; asteriskSeen = true; continue; } - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 43 /* PlusPlusToken */; + return pos += 2, token = 44 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PlusEqualsToken */; + return pos += 2, token = 60 /* PlusEqualsToken */; } pos++; - return token = 37 /* PlusToken */; + return token = 38 /* PlusToken */; case 44 /* comma */: pos++; - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 44 /* MinusMinusToken */; + return pos += 2, token = 45 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* MinusEqualsToken */; + return pos += 2, token = 61 /* MinusEqualsToken */; } pos++; - return token = 38 /* MinusToken */; + return token = 39 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); + tokenValue = scanNumber().value; return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 24 /* DotDotDotToken */; + return pos += 3, token = 25 /* DotDotDotToken */; } pos++; - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -7432,43 +7560,43 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* SlashEqualsToken */; + return pos += 2, token = 64 /* SlashEqualsToken */; } pos++; - return token = 41 /* SlashToken */; + return token = 42 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; - var value = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); - if (value < 0) { + tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); + if (!tokenValue) { error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0x" + tokenValue; tokenFlags |= 64 /* HexSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 2); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 2); + if (!tokenValue) { error(ts.Diagnostics.Binary_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0b" + tokenValue; tokenFlags |= 128 /* BinarySpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 8); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 8); + if (!tokenValue) { error(ts.Diagnostics.Octal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0o" + tokenValue; tokenFlags |= 256 /* OctalSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -7489,14 +7617,14 @@ var ts; case 55 /* _7 */: case 56 /* _8 */: case 57 /* _9 */: - tokenValue = scanNumber(); - return token = 8 /* NumericLiteral */; + (_a = scanNumber(), token = _a.type, tokenValue = _a.value); + return token; case 58 /* colon */: pos++; - return token = 56 /* ColonToken */; + return token = 57 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 25 /* SemicolonToken */; + return token = 26 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7509,20 +7637,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 66 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 45 /* LessThanLessThanToken */; + return pos += 2, token = 46 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 30 /* LessThanEqualsToken */; + return pos += 2, token = 31 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 28 /* LessThanSlashToken */; + return pos += 2, token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7535,15 +7663,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 34 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 32 /* EqualsEqualsToken */; + return pos += 2, token = 33 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 36 /* EqualsGreaterThanToken */; + return pos += 2, token = 37 /* EqualsGreaterThanToken */; } pos++; - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7555,25 +7683,25 @@ var ts; } } pos++; - return token = 29 /* GreaterThanToken */; + return token = 30 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 55 /* QuestionToken */; + return token = 56 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* CaretEqualsToken */; + return pos += 2, token = 71 /* CaretEqualsToken */; } pos++; - return token = 50 /* CaretToken */; + return token = 51 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 124 /* bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7585,22 +7713,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 54 /* BarBarToken */; + return pos += 2, token = 55 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* BarEqualsToken */; + return pos += 2, token = 70 /* BarEqualsToken */; } pos++; - return token = 49 /* BarToken */; + return token = 50 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 52 /* TildeToken */; + return token = 53 /* TildeToken */; case 64 /* at */: pos++; - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -7638,29 +7766,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* 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 = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 67 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 46 /* GreaterThanGreaterThanToken */; + return token = 47 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 31 /* GreaterThanEqualsToken */; + return token = 32 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) { + if (token === 42 /* SlashToken */ || token === 64 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -7705,7 +7833,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 12 /* RegularExpressionLiteral */; + token = 13 /* RegularExpressionLiteral */; } return token; } @@ -7713,7 +7841,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -7730,14 +7858,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 28 /* LessThanSlashToken */; + return token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -7769,7 +7897,7 @@ var ts; } pos++; } - return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -7795,7 +7923,7 @@ var ts; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -7819,36 +7947,36 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 123 /* openBrace */: - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 91 /* openBracket */: - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 44 /* comma */: - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 46 /* dot */: - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 96 /* backtick */: while (pos < end && text.charCodeAt(pos) !== 96 /* backtick */) { pos++; } tokenValue = text.substring(tokenPos + 1, pos); pos++; - return token = 13 /* NoSubstitutionTemplateLiteral */; + return token = 14 /* NoSubstitutionTemplateLiteral */; } if (isIdentifierStart(ch, 6 /* Latest */)) { while (isIdentifierPart(text.charCodeAt(pos), 6 /* Latest */) && pos < end) { @@ -8001,7 +8129,6 @@ var ts; getText: function () { return str; }, write: writeText, rawWrite: writeText, - writeTextOfNode: writeText, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -8010,7 +8137,9 @@ var ts; writeLiteral: writeText, writeParameter: writeText, writeProperty: writeText, - writeSymbol: writeText, + writeSymbol: function (s, _) { return writeText(s); }, + writeTrailingSemicolon: writeText, + writeComment: writeText, getTextPos: function () { return str.length; }, getLine: function () { return 0; }, getColumn: function () { return 0; }, @@ -8209,7 +8338,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { + while (node && node.kind !== 279 /* SourceFile */) { node = node.parent; } return node; @@ -8217,11 +8346,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return true; } return false; @@ -8355,7 +8484,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 === 304 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8374,7 +8503,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 281 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8416,32 +8545,34 @@ var ts; function getLiteralText(node, sourceFile, neverAsciiEscape) { // 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 (!nodeIsSynthesized(node) && node.parent && !(ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */)) { + if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) || + ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // 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 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.singleQuote) { return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; } else { return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return "`" + escapeText(node.text, 96 /* backtick */) + "`"; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: // tslint:disable-next-line no-invalid-template-strings return "`" + escapeText(node.text, 96 /* backtick */) + "${"; - case 15 /* TemplateMiddle */: + case 16 /* TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings return "}" + escapeText(node.text, 96 /* backtick */) + "${"; - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: + case 9 /* BigIntLiteral */: + case 13 /* RegularExpressionLiteral */: return node.text; } return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -8464,15 +8595,15 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; + return node.kind === 237 /* VariableDeclaration */ && node.parent.kind === 274 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 9 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -8496,11 +8627,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 277 /* SourceFile */ || - node.kind === 242 /* ModuleDeclaration */ || + return node.kind === 279 /* SourceFile */ || + node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8517,9 +8648,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 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node.parent); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8535,22 +8666,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 272 /* CatchClause */: - case 242 /* ModuleDeclaration */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 274 /* CatchClause */: + case 244 /* ModuleDeclaration */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 216 /* Block */: + case 218 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8560,9 +8691,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 291 /* JSDocSignature */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 293 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8572,25 +8703,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -8600,8 +8731,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8610,15 +8741,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 217 /* VariableStatement */: - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 219 /* VariableStatement */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -8648,12 +8779,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isStringOrNumericLiteralLike(name.expression) ? ts.escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: return ts.Debug.assertNever(name); @@ -8662,11 +8794,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8711,7 +8843,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 216 /* Block */) { + if (node.body && node.body.kind === 218 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8725,7 +8857,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* 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 @@ -8734,25 +8866,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: errorNode = node.name; break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8801,11 +8933,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 98 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 92 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { @@ -8813,20 +8945,20 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 219 /* ExpressionStatement */ - && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 221 /* ExpressionStatement */ + && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 149 /* Parameter */ || - node.kind === 148 /* TypeParameter */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 195 /* ArrowFunction */ || - node.kind === 193 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 151 /* Parameter */ || + node.kind === 150 /* TypeParameter */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 197 /* ArrowFunction */ || + node.kind === 195 /* ParenthesizedExpression */) ? 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 '/**/' @@ -8842,47 +8974,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= node.kind && node.kind <= 183 /* LastTypeNode */) { return true; } switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 134 /* NumberKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: return true; - case 105 /* VoidKeyword */: - return node.parent.kind !== 198 /* VoidExpression */; - case 209 /* ExpressionWithTypeArguments */: + case 106 /* VoidKeyword */: + return node.parent.kind !== 200 /* VoidExpression */; + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 148 /* TypeParameter */: - return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; + case 150 /* TypeParameter */: + return node.parent.kind === 181 /* MappedType */ || node.parent.kind === 176 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 71 /* Identifier */: + case 72 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 189 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */ || node.kind === 189 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 146 /* QualifiedName */: - case 187 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: { + case 148 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 100 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 165 /* TypeQuery */) { + if (parent.kind === 167 /* TypeQuery */) { return false; } - if (parent.kind === 181 /* ImportType */) { + if (parent.kind === 183 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8891,40 +9024,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 (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= parent.kind && parent.kind <= 183 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return node === parent.constraint; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return node === parent.constraint; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return node === parent.type; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node === parent.type; - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return node === parent.type; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return node === parent.type; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8949,23 +9082,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitor(node); - case 244 /* CaseBlock */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 246 /* CaseBlock */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8975,26 +9108,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* 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); @@ -9017,10 +9150,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 167 /* ArrayType */) { + if (node && node.kind === 169 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 162 /* TypeReference */) { + else if (node && node.kind === 164 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9030,12 +9163,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 166 /* TypeLiteral */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 168 /* TypeLiteral */: return node.members; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return node.properties; } } @@ -9043,14 +9176,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 184 /* BindingElement */: - case 276 /* EnumMember */: - case 149 /* Parameter */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 274 /* ShorthandPropertyAssignment */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 278 /* EnumMember */: + case 151 /* Parameter */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 276 /* ShorthandPropertyAssignment */: + case 237 /* VariableDeclaration */: return true; } } @@ -9062,8 +9195,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 236 /* VariableDeclarationList */ - && node.parent.parent.kind === 217 /* VariableStatement */; + return node.parent.kind === 238 /* VariableDeclarationList */ + && node.parent.parent.kind === 219 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9074,13 +9207,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return true; } return false; @@ -9091,7 +9224,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 231 /* LabeledStatement */) { + if (node.statement.kind !== 233 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9099,17 +9232,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 218 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; + return node && node.kind === 156 /* MethodDeclaration */ && node.parent.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 186 /* ObjectLiteralExpression */ || - node.parent.kind === 207 /* ClassExpression */); + return node.kind === 156 /* MethodDeclaration */ && + (node.parent.kind === 188 /* ObjectLiteralExpression */ || + node.parent.kind === 209 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9122,7 +9255,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 273 /* PropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9159,14 +9292,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 277 /* SourceFile */); + ts.Debug.assert(node.kind !== 279 /* 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 147 /* ComputedPropertyName */: + case 149 /* 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 @@ -9181,9 +9314,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9194,26 +9327,26 @@ var ts; node = node.parent; } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 242 /* ModuleDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 241 /* EnumDeclaration */: - case 277 /* SourceFile */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 244 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 243 /* EnumDeclaration */: + case 279 /* SourceFile */: return node; } } @@ -9223,9 +9356,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return container; } } @@ -9247,27 +9380,27 @@ var ts; return node; } switch (node.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: node = node.parent; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9283,14 +9416,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { + if (func.kind === 196 /* FunctionExpression */ || func.kind === 197 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 193 /* ParenthesizedExpression */) { + while (parent.kind === 195 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 191 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9301,8 +9434,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 97 /* SuperKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 98 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9310,20 +9443,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 99 /* ThisKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 100 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: return node; } return undefined; @@ -9331,10 +9464,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return node.tag; - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9343,25 +9476,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // classes are valid targets return true; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 238 /* ClassDeclaration */; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + return parent.kind === 240 /* ClassDeclaration */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* 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 === 238 /* ClassDeclaration */; - case 149 /* Parameter */: + && parent.kind === 240 /* ClassDeclaration */; + case 151 /* 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 === 155 /* Constructor */ - || parent.kind === 154 /* MethodDeclaration */ - || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 238 /* ClassDeclaration */; + && (parent.kind === 157 /* Constructor */ + || parent.kind === 156 /* MethodDeclaration */ + || parent.kind === 159 /* SetAccessor */) + && grandparent.kind === 240 /* ClassDeclaration */; } return false; } @@ -9377,10 +9510,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 154 /* MethodDeclaration */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 159 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -9389,9 +9522,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 260 /* JsxOpeningElement */ || - parent.kind === 259 /* JsxSelfClosingElement */ || - parent.kind === 261 /* JsxClosingElement */) { + if (parent.kind === 262 /* JsxOpeningElement */ || + parent.kind === 261 /* JsxSelfClosingElement */ || + parent.kind === 263 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9399,56 +9532,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 12 /* RegularExpressionLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 210 /* AsExpression */: - case 192 /* TypeAssertionExpression */: - case 211 /* NonNullExpression */: - case 193 /* ParenthesizedExpression */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 206 /* SpreadElement */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 208 /* OmittedExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 205 /* YieldExpression */: - case 199 /* AwaitExpression */: - case 212 /* MetaProperty */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 13 /* RegularExpressionLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 212 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 213 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 208 /* SpreadElement */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 210 /* OmittedExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 207 /* YieldExpression */: + case 201 /* AwaitExpression */: + case 214 /* MetaProperty */: return true; - case 146 /* QualifiedName */: - while (node.parent.kind === 146 /* QualifiedName */) { + case 148 /* QualifiedName */: + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); - case 71 /* Identifier */: - if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node); + case 72 /* Identifier */: + if (node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -9458,49 +9592,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 186 /* BindingElement */: return parent.initializer === node; - case 219 /* ExpressionStatement */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 228 /* ReturnStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 232 /* ThrowStatement */: + case 221 /* ExpressionStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 230 /* ReturnStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 234 /* ThrowStatement */: return parent.expression === node; - case 223 /* ForStatement */: + case 225 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forInStatement.expression === node; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return node === parent.expression; - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return node === parent.expression; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return node === parent.expression; - case 150 /* Decorator */: - case 268 /* JsxExpression */: - case 267 /* JsxSpreadAttribute */: - case 275 /* SpreadAssignment */: + case 152 /* Decorator */: + case 270 /* JsxExpression */: + case 269 /* JsxSpreadAttribute */: + case 277 /* SpreadAssignment */: return true; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -9508,7 +9642,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9517,7 +9651,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 259 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -9545,15 +9679,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 137 /* StringKeyword */ || node.typeArguments[0].kind === 134 /* NumberKeyword */); + (node.typeArguments[0].kind === 138 /* StringKeyword */ || node.typeArguments[0].kind === 135 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 189 /* CallExpression */) { + if (callExpression.kind !== 191 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 71 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 72 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -9584,16 +9718,16 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.right === node) { name = node.parent.left; decl = name; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { name = node.parent.parent.name; decl = node.parent.parent; } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.parent.right === node.parent) { name = node.parent.parent.left; decl = name; } @@ -9608,13 +9742,13 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl); + return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -9627,16 +9761,25 @@ var ts; return init && getExpandoInitializer(init, isPrototypeAccess(node.name)); } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; + function hasExpandoValueProperty(node, isPrototypeAssignment) { + return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); } + if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) { + var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype"); + if (result) { + return result; + } + } } ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer; /** @@ -9652,11 +9795,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 196 /* FunctionExpression */ || e.kind === 197 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 194 /* FunctionExpression */ || - initializer.kind === 207 /* ClassExpression */ || - initializer.kind === 195 /* ArrowFunction */) { + if (initializer.kind === 196 /* FunctionExpression */ || + initializer.kind === 209 /* ClassExpression */ || + initializer.kind === 197 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9673,14 +9816,14 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 54 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -9688,8 +9831,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 === 54 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 58 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 59 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -9712,7 +9855,7 @@ var ts; return name.escapedText === initializer.escapedText; } if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 99 /* ThisKeyword */ || + return (initializer.expression.kind === 100 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -9746,8 +9889,31 @@ var ts; return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; + function isBindableObjectDefinePropertyCall(expr) { + return ts.length(expr.arguments) === 3 && + ts.isPropertyAccessExpression(expr.expression) && + ts.isIdentifier(expr.expression.expression) && + ts.idText(expr.expression.expression) === "Object" && + ts.idText(expr.expression.name) === "defineProperty" && + isStringOrNumericLiteralLike(expr.arguments[1]) && + isEntityNameExpression(expr.arguments[0]); + } + ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; function getAssignmentDeclarationKindWorker(expr) { - if (expr.operatorToken.kind !== 58 /* EqualsToken */ || + if (ts.isCallExpression(expr)) { + if (!isBindableObjectDefinePropertyCall(expr)) { + return 0 /* None */; + } + var entityName = expr.arguments[0]; + if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + return 8 /* ObjectDefinePropertyExports */; + } + if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + return 9 /* ObjectDefinePrototypeProperty */; + } + return 7 /* ObjectDefinePropertyValue */; + } + if (expr.operatorToken.kind !== 59 /* EqualsToken */ || !ts.isPropertyAccessExpression(expr.left)) { return 0 /* None */; } @@ -9759,10 +9925,10 @@ var ts; return getAssignmentDeclarationPropertyAccessKind(lhs); } function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 99 /* ThisKeyword */) { + if (lhs.expression.kind === 100 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (ts.isIdentifier(lhs.expression) && lhs.expression.escapedText === "module" && lhs.name.escapedText === "exports") { + else if (isModuleExportsPropertyAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } @@ -9801,7 +9967,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 221 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9810,7 +9976,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 237 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 239 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -9819,14 +9985,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.parent; - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return node.parent.parent; - case 189 /* CallExpression */: - return node.parent; - case 180 /* LiteralType */: + case 191 /* CallExpression */: + return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; + case 182 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9836,12 +10002,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.moduleSpecifier; - case 246 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 181 /* ImportType */: + case 248 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 259 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 183 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9850,11 +10016,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9862,19 +10028,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 249 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 149 /* Parameter */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 274 /* ShorthandPropertyAssignment */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 151 /* Parameter */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 276 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -9882,14 +10048,13 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 287 /* JSDocFunctionType */ && - node.parameters.length > 0 && - node.parameters[0].name && - node.parameters[0].name.escapedText === "new"; + var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined; + var name = ts.tryCast(param && param.name, ts.isIdentifier); + return !!name && name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 302 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9899,7 +10064,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ + node.expression.operatorToken.kind === 59 /* EqualsToken */ ? node.expression.right : undefined; } @@ -9908,18 +10073,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + node.expression.right.operatorToken.kind === 55 /* BarBarToken */ ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return node.initializer; } } @@ -9929,7 +10094,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 242 /* ModuleDeclaration */ + node.body.kind === 244 /* ModuleDeclaration */ ? node.body : undefined; } @@ -9944,11 +10109,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 148 /* TypeParameter */) { + if (node.kind === 150 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -9959,11 +10124,11 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 273 /* PropertyAssignment */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + if (parent.kind === 275 /* PropertyAssignment */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 221 /* ExpressionStatement */ && node.kind === 189 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 59 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -9974,7 +10139,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -9997,7 +10162,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 71 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 72 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10032,7 +10197,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 === 288 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10045,31 +10210,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 59 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 193 /* ParenthesizedExpression */: - case 185 /* ArrayLiteralExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 187 /* ArrayLiteralExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: node = parent; break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10096,22 +10261,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 216 /* Block */: - case 217 /* VariableStatement */: - case 229 /* WithStatement */: - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 218 /* Block */: + case 219 /* VariableStatement */: + case 231 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return true; } return false; @@ -10128,33 +10293,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 175 /* ParenthesizedType */); + return walkUp(node, 177 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 193 /* ParenthesizedExpression */); + return walkUp(node, 195 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 196 /* DeleteExpression */; + return node && node.kind === 198 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10175,12 +10340,12 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10203,8 +10368,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 147 /* ComputedPropertyName */ && + return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + node.parent.kind === 149 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10212,32 +10377,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 187 /* PropertyAccessExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 189 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 146 /* QualifiedName */) { + while (parent.kind === 148 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; + return parent.kind === 167 /* TypeQuery */ || parent.kind === 164 /* TypeReference */; } return false; - case 184 /* BindingElement */: - case 251 /* ImportSpecifier */: + case 186 /* BindingElement */: + case 253 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 255 /* ExportSpecifier */: - case 265 /* JsxAttribute */: + case 257 /* ExportSpecifier */: + case 267 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10252,15 +10417,16 @@ var ts; // export { x as } from ... // export = // export default + // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 245 /* NamespaceExportDeclaration */ || - node.kind === 248 /* ImportClause */ && !!node.name || - node.kind === 249 /* NamespaceImport */ || - node.kind === 251 /* ImportSpecifier */ || - node.kind === 255 /* ExportSpecifier */ || - node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */; + return node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 247 /* NamespaceExportDeclaration */ || + node.kind === 250 /* ImportClause */ && !!node.name || + node.kind === 251 /* NamespaceImport */ || + node.kind === 253 /* ImportSpecifier */ || + node.kind === 257 /* ExportSpecifier */ || + node.kind === 254 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -10280,12 +10446,12 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 109 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; @@ -10297,7 +10463,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -10331,11 +10497,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; + return 73 /* FirstKeyword */ <= token && token <= 147 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; + return 118 /* FirstContextualKeyword */ <= token && token <= 147 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10347,6 +10513,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isIdentifierANonContextualKeyword(_a) { + var originalKeywordKind = _a.originalKeywordKind; + return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); + } + ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } @@ -10365,14 +10536,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10386,10 +10557,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10414,7 +10585,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 147 /* ComputedPropertyName */ && + return name.kind === 149 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10430,12 +10601,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10451,9 +10622,9 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: return true; default: @@ -10462,11 +10633,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 72 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 72 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -10481,7 +10652,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 72 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -10490,11 +10661,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 149 /* Parameter */; + return root.kind === 151 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 184 /* BindingElement */) { + while (node.kind === 186 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10502,15 +10673,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 194 /* FunctionExpression */ - || kind === 237 /* FunctionDeclaration */ - || kind === 195 /* ArrowFunction */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 242 /* ModuleDeclaration */ - || kind === 277 /* SourceFile */; + return kind === 157 /* Constructor */ + || kind === 196 /* FunctionExpression */ + || kind === 239 /* FunctionDeclaration */ + || kind === 197 /* ArrowFunction */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 244 /* ModuleDeclaration */ + || kind === 279 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10529,38 +10700,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: return 1 /* Right */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operator) { - case 40 /* AsteriskAsteriskToken */: - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 41 /* AsteriskAsteriskToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 1 /* Right */; } } @@ -10569,15 +10740,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 202 /* BinaryExpression */) { + if (expression.kind === 204 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { + else if (expression.kind === 202 /* PrefixUnaryExpression */ || expression.kind === 203 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10587,116 +10758,116 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return 0; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return 1; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return 2; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return 4; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operatorKind) { - case 26 /* CommaToken */: + case 27 /* CommaToken */: return 0; - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: return 16; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return 17; - case 189 /* CallExpression */: + case 191 /* CallExpression */: return 18; - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 19 : 18; - case 191 /* TaggedTemplateExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 193 /* TaggedTemplateExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 19; - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 71 /* Identifier */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 72 /* Identifier */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 193 /* ParenthesizedExpression */: - case 208 /* OmittedExpression */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 195 /* ParenthesizedExpression */: + case 210 /* OmittedExpression */: return 20; default: return -1; } } ts.getOperatorPrecedence = getOperatorPrecedence; - /* @internal */ function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: return 5; - case 53 /* AmpersandAmpersandToken */: + case 54 /* AmpersandAmpersandToken */: return 6; - case 49 /* BarToken */: + case 50 /* BarToken */: return 7; - case 50 /* CaretToken */: + case 51 /* CaretToken */: return 8; - case 48 /* AmpersandToken */: + case 49 /* AmpersandToken */: return 9; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return 10; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: return 11; - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 37 /* PlusToken */: - case 38 /* MinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: return 13; - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: return 14; - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -10764,7 +10935,7 @@ var ts; if (fileName) { return fileDiagnostics.get(fileName) || []; } - var fileDiags = ts.flatMap(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); + var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); if (!nonFileDiagnostics.length) { return fileDiags; } @@ -10822,7 +10993,7 @@ var ts; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || name.indexOf("-") > -1; + return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { @@ -10905,16 +11076,10 @@ var ts; lineStart = true; } } - function writeTextOfNode(text, node) { - var s = getTextOfNodeFromSourceText(text, node); - write(s); - updateLineCountAndPosFor(s); - } reset(); return { write: write, rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, writeLiteral: writeLiteral, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -10937,10 +11102,77 @@ var ts; writePunctuation: write, writeSpace: write, writeStringLiteral: write, - writeSymbol: write + writeSymbol: function (s, _) { return write(s); }, + writeTrailingSemicolon: write, + writeComment: write }; } ts.createTextWriter = createTextWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var pendingTrailingSemicolon = false; + function commitPendingTrailingSemicolon() { + if (pendingTrailingSemicolon) { + writer.writeTrailingSemicolon(";"); + pendingTrailingSemicolon = false; + } + } + return __assign({}, writer, { writeTrailingSemicolon: function () { + pendingTrailingSemicolon = true; + }, + writeLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeLiteral(s); + }, + writeStringLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeStringLiteral(s); + }, + writeSymbol: function (s, sym) { + commitPendingTrailingSemicolon(); + writer.writeSymbol(s, sym); + }, + writePunctuation: function (s) { + commitPendingTrailingSemicolon(); + writer.writePunctuation(s); + }, + writeKeyword: function (s) { + commitPendingTrailingSemicolon(); + writer.writeKeyword(s); + }, + writeOperator: function (s) { + commitPendingTrailingSemicolon(); + writer.writeOperator(s); + }, + writeParameter: function (s) { + commitPendingTrailingSemicolon(); + writer.writeParameter(s); + }, + writeSpace: function (s) { + commitPendingTrailingSemicolon(); + writer.writeSpace(s); + }, + writeProperty: function (s) { + commitPendingTrailingSemicolon(); + writer.writeProperty(s); + }, + writeComment: function (s) { + commitPendingTrailingSemicolon(); + writer.writeComment(s); + }, + writeLine: function () { + commitPendingTrailingSemicolon(); + writer.writeLine(); + }, + increaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.increaseIndent(); + }, + decreaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.decreaseIndent(); + } }); + } + ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11076,11 +11308,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 72 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 99 /* ThisKeyword */; + return id.originalKeywordKind === 100 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11091,10 +11323,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 157 /* SetAccessor */) { + else if (accessor.kind === 159 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11114,10 +11346,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 156 /* GetAccessor */ && !getAccessor) { + if (member.kind === 158 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 157 /* SetAccessor */ && !setAccessor) { + if (member.kind === 159 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11163,7 +11395,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 === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -11197,13 +11429,13 @@ var ts; function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { if (comments && comments.length > 0) { if (leadingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } var emitInterveningSeparator = false; for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var comment = comments_1[_i]; if (emitInterveningSeparator) { - writer.write(" "); + writer.writeSpace(" "); emitInterveningSeparator = false; } writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); @@ -11215,7 +11447,7 @@ var ts; } } if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } } } @@ -11333,7 +11565,7 @@ var ts; } else { // Single line comment of style //.... - writer.write(text.substring(commentPos, commentEnd)); + writer.writeComment(text.substring(commentPos, commentEnd)); } } ts.writeCommentRange = writeCommentRange; @@ -11342,14 +11574,14 @@ var ts; var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text - writer.write(currentLineText); + writer.writeComment(currentLineText); if (end !== commentEnd) { writer.writeLine(); } } else { // Empty string - make sure we write empty line - writer.writeLiteral(newLine); + writer.rawWrite(newLine); } } function calculateIndent(text, pos, end) { @@ -11403,7 +11635,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 72 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -11411,29 +11643,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 115 /* StaticKeyword */: return 32 /* Static */; - case 114 /* PublicKeyword */: return 4 /* Public */; - case 113 /* ProtectedKeyword */: return 16 /* Protected */; - case 112 /* PrivateKeyword */: return 8 /* Private */; - case 117 /* AbstractKeyword */: return 128 /* Abstract */; - case 84 /* ExportKeyword */: return 1 /* Export */; - case 124 /* DeclareKeyword */: return 2 /* Ambient */; - case 76 /* ConstKeyword */: return 2048 /* Const */; - case 79 /* DefaultKeyword */: return 512 /* Default */; - case 120 /* AsyncKeyword */: return 256 /* Async */; - case 132 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 116 /* StaticKeyword */: return 32 /* Static */; + case 115 /* PublicKeyword */: return 4 /* Public */; + case 114 /* ProtectedKeyword */: return 16 /* Protected */; + case 113 /* PrivateKeyword */: return 8 /* Private */; + case 118 /* AbstractKeyword */: return 128 /* Abstract */; + case 85 /* ExportKeyword */: return 1 /* Export */; + case 125 /* DeclareKeyword */: return 2 /* Ambient */; + case 77 /* ConstKeyword */: return 2048 /* Const */; + case 80 /* DefaultKeyword */: return 512 /* Default */; + case 121 /* AsyncKeyword */: return 256 /* Async */; + case 133 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 54 /* BarBarToken */ - || token === 53 /* AmpersandAmpersandToken */ - || token === 51 /* ExclamationToken */; + return token === 55 /* BarBarToken */ + || token === 54 /* AmpersandAmpersandToken */ + || token === 52 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */; + return token >= 59 /* FirstAssignment */ && token <= 71 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -11446,14 +11678,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 108 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 109 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 58 /* EqualsToken */ + ? node.operatorToken.kind === 59 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -11461,8 +11693,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 186 /* ObjectLiteralExpression */ - || kind === 185 /* ArrayLiteralExpression */; + return kind === 188 /* ObjectLiteralExpression */ + || kind === 187 /* ArrayLiteralExpression */; } return false; } @@ -11472,7 +11704,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 71 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 72 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function isPropertyAccessEntityNameExpression(node) { @@ -11484,17 +11716,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 186 /* ObjectLiteralExpression */ && + return expression.kind === 188 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 185 /* ArrayLiteralExpression */ && + return expression.kind === 187 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11859,8 +12091,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11937,35 +12169,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return accessKind(parent); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 202 /* BinaryExpression */: + return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 204 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 58 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 59 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 273 /* PropertyAssignment */: { + case 275 /* 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 274 /* ShorthandPropertyAssignment */: + case 276 /* 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 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 221 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12068,7 +12300,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 131072 /* Object */ ? type.objectFlags : 0; + return type.flags & 524288 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12339,9 +12571,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 148 /* TypeParameter */) { + if (d && d.kind === 150 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 241 /* InterfaceDeclaration */) { return current; } } @@ -12349,7 +12581,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 157 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12379,14 +12611,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 235 /* VariableDeclaration */) { + if (node.kind === 237 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 236 /* VariableDeclarationList */) { + if (node && node.kind === 238 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 217 /* VariableStatement */) { + if (node && node.kind === 219 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12532,27 +12764,27 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return expr.name; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 193 /* ParenthesizedExpression */: { + case 195 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 231 /* LabeledStatement */: { + case 233 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12576,17 +12808,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return declaration; - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: { + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 146 /* QualifiedName */) { + if (name.kind === 148 /* QualifiedName */) { return name.right; } break; } - case 202 /* BinaryExpression */: { + case 191 /* CallExpression */: + case 204 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -12594,13 +12827,17 @@ var ts; case 5 /* Property */: case 3 /* PrototypeProperty */: return expr.left.name; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return expr.arguments[1]; default: return undefined; } } - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 252 /* ExportAssignment */: { + case 254 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -12802,7 +13039,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12836,684 +13073,688 @@ var ts; return node.kind === 8 /* NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; + function isBigIntLiteral(node) { + return node.kind === 9 /* BigIntLiteral */; + } + ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 9 /* StringLiteral */; + return node.kind === 10 /* StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 12 /* RegularExpressionLiteral */; + return node.kind === 13 /* RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 14 /* TemplateHead */; + return node.kind === 15 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 15 /* TemplateMiddle */; + return node.kind === 16 /* TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 16 /* TemplateTail */; + return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 71 /* Identifier */; + return node.kind === 72 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 146 /* QualifiedName */; + return node.kind === 148 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 147 /* ComputedPropertyName */; + return node.kind === 149 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 148 /* TypeParameter */; + return node.kind === 150 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 149 /* Parameter */; + return node.kind === 151 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 151 /* PropertySignature */; + return node.kind === 153 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 152 /* PropertyDeclaration */; + return node.kind === 154 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 153 /* MethodSignature */; + return node.kind === 155 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 155 /* Constructor */; + return node.kind === 157 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 158 /* CallSignature */; + return node.kind === 160 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 159 /* ConstructSignature */; + return node.kind === 161 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 160 /* IndexSignature */; + return node.kind === 162 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; + return node.kind === 159 /* SetAccessor */ || node.kind === 158 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 161 /* TypePredicate */; + return node.kind === 163 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 162 /* TypeReference */; + return node.kind === 164 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 163 /* FunctionType */; + return node.kind === 165 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 164 /* ConstructorType */; + return node.kind === 166 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 165 /* TypeQuery */; + return node.kind === 167 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 166 /* TypeLiteral */; + return node.kind === 168 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 167 /* ArrayType */; + return node.kind === 169 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 168 /* TupleType */; + return node.kind === 170 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 171 /* UnionType */; + return node.kind === 173 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 172 /* IntersectionType */; + return node.kind === 174 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 173 /* ConditionalType */; + return node.kind === 175 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 174 /* InferType */; + return node.kind === 176 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 175 /* ParenthesizedType */; + return node.kind === 177 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 176 /* ThisType */; + return node.kind === 178 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 177 /* TypeOperator */; + return node.kind === 179 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 178 /* IndexedAccessType */; + return node.kind === 180 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 179 /* MappedType */; + return node.kind === 181 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 180 /* LiteralType */; + return node.kind === 182 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 181 /* ImportType */; + return node.kind === 183 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 182 /* ObjectBindingPattern */; + return node.kind === 184 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 183 /* ArrayBindingPattern */; + return node.kind === 185 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 184 /* BindingElement */; + return node.kind === 186 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 185 /* ArrayLiteralExpression */; + return node.kind === 187 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 186 /* ObjectLiteralExpression */; + return node.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 187 /* PropertyAccessExpression */; + return node.kind === 189 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 188 /* ElementAccessExpression */; + return node.kind === 190 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 189 /* CallExpression */; + return node.kind === 191 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 190 /* NewExpression */; + return node.kind === 192 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 191 /* TaggedTemplateExpression */; + return node.kind === 193 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 192 /* TypeAssertionExpression */; + return node.kind === 194 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 193 /* ParenthesizedExpression */; + return node.kind === 195 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 306 /* PartiallyEmittedExpression */) { + while (node.kind === 308 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 194 /* FunctionExpression */; + return node.kind === 196 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 195 /* ArrowFunction */; + return node.kind === 197 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 196 /* DeleteExpression */; + return node.kind === 198 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 197 /* TypeOfExpression */; + return node.kind === 199 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 198 /* VoidExpression */; + return node.kind === 200 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 199 /* AwaitExpression */; + return node.kind === 201 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 200 /* PrefixUnaryExpression */; + return node.kind === 202 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 201 /* PostfixUnaryExpression */; + return node.kind === 203 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 202 /* BinaryExpression */; + return node.kind === 204 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 203 /* ConditionalExpression */; + return node.kind === 205 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 204 /* TemplateExpression */; + return node.kind === 206 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 205 /* YieldExpression */; + return node.kind === 207 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 206 /* SpreadElement */; + return node.kind === 208 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 207 /* ClassExpression */; + return node.kind === 209 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 208 /* OmittedExpression */; + return node.kind === 210 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 210 /* AsExpression */; + return node.kind === 212 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 211 /* NonNullExpression */; + return node.kind === 213 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 212 /* MetaProperty */; + return node.kind === 214 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 214 /* TemplateSpan */; + return node.kind === 216 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 215 /* SemicolonClassElement */; + return node.kind === 217 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 216 /* Block */; + return node.kind === 218 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 217 /* VariableStatement */; + return node.kind === 219 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 218 /* EmptyStatement */; + return node.kind === 220 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 219 /* ExpressionStatement */; + return node.kind === 221 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 220 /* IfStatement */; + return node.kind === 222 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 221 /* DoStatement */; + return node.kind === 223 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 222 /* WhileStatement */; + return node.kind === 224 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 223 /* ForStatement */; + return node.kind === 225 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 224 /* ForInStatement */; + return node.kind === 226 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 225 /* ForOfStatement */; + return node.kind === 227 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 226 /* ContinueStatement */; + return node.kind === 228 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 227 /* BreakStatement */; + return node.kind === 229 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; + return node.kind === 229 /* BreakStatement */ || node.kind === 228 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 228 /* ReturnStatement */; + return node.kind === 230 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 229 /* WithStatement */; + return node.kind === 231 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 230 /* SwitchStatement */; + return node.kind === 232 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 231 /* LabeledStatement */; + return node.kind === 233 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 232 /* ThrowStatement */; + return node.kind === 234 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 233 /* TryStatement */; + return node.kind === 235 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 234 /* DebuggerStatement */; + return node.kind === 236 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 235 /* VariableDeclaration */; + return node.kind === 237 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 236 /* VariableDeclarationList */; + return node.kind === 238 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 237 /* FunctionDeclaration */; + return node.kind === 239 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 238 /* ClassDeclaration */; + return node.kind === 240 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 239 /* InterfaceDeclaration */; + return node.kind === 241 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 240 /* TypeAliasDeclaration */; + return node.kind === 242 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 241 /* EnumDeclaration */; + return node.kind === 243 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */; + return node.kind === 244 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 243 /* ModuleBlock */; + return node.kind === 245 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 244 /* CaseBlock */; + return node.kind === 246 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 245 /* NamespaceExportDeclaration */; + return node.kind === 247 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */; + return node.kind === 248 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 247 /* ImportDeclaration */; + return node.kind === 249 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 248 /* ImportClause */; + return node.kind === 250 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 249 /* NamespaceImport */; + return node.kind === 251 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 250 /* NamedImports */; + return node.kind === 252 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 251 /* ImportSpecifier */; + return node.kind === 253 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 252 /* ExportAssignment */; + return node.kind === 254 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 253 /* ExportDeclaration */; + return node.kind === 255 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 254 /* NamedExports */; + return node.kind === 256 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 255 /* ExportSpecifier */; + return node.kind === 257 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 256 /* MissingDeclaration */; + return node.kind === 258 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 257 /* ExternalModuleReference */; + return node.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 258 /* JsxElement */; + return node.kind === 260 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 259 /* JsxSelfClosingElement */; + return node.kind === 261 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 260 /* JsxOpeningElement */; + return node.kind === 262 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 261 /* JsxClosingElement */; + return node.kind === 263 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 262 /* JsxFragment */; + return node.kind === 264 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 263 /* JsxOpeningFragment */; + return node.kind === 265 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 264 /* JsxClosingFragment */; + return node.kind === 266 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 265 /* JsxAttribute */; + return node.kind === 267 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 266 /* JsxAttributes */; + return node.kind === 268 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 267 /* JsxSpreadAttribute */; + return node.kind === 269 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 268 /* JsxExpression */; + return node.kind === 270 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 269 /* CaseClause */; + return node.kind === 271 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 270 /* DefaultClause */; + return node.kind === 272 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 271 /* HeritageClause */; + return node.kind === 273 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 272 /* CatchClause */; + return node.kind === 274 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 273 /* PropertyAssignment */; + return node.kind === 275 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 274 /* ShorthandPropertyAssignment */; + return node.kind === 276 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 275 /* SpreadAssignment */; + return node.kind === 277 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 277 /* SourceFile */; + return node.kind === 279 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 278 /* Bundle */; + return node.kind === 280 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 279 /* UnparsedSource */; + return node.kind === 281 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 281 /* JSDocTypeExpression */; + return node.kind === 283 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 282 /* JSDocAllType */; + return node.kind === 284 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 283 /* JSDocUnknownType */; + return node.kind === 285 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 284 /* JSDocNullableType */; + return node.kind === 286 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 285 /* JSDocNonNullableType */; + return node.kind === 287 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 286 /* JSDocOptionalType */; + return node.kind === 288 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 287 /* JSDocFunctionType */; + return node.kind === 289 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 288 /* JSDocVariadicType */; + return node.kind === 290 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 289 /* JSDocComment */; + return node.kind === 291 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 293 /* JSDocAugmentsTag */; + return node.kind === 295 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 294 /* JSDocClassTag */; + return node.kind === 296 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 296 /* JSDocEnumTag */; + return node.kind === 298 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 299 /* JSDocThisTag */; + return node.kind === 301 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 297 /* JSDocParameterTag */; + return node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 298 /* JSDocReturnTag */; + return node.kind === 300 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 300 /* JSDocTypeTag */; + return node.kind === 302 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 301 /* JSDocTemplateTag */; + return node.kind === 303 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 302 /* JSDocTypedefTag */; + return node.kind === 304 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 303 /* JSDocPropertyTag */; + return node.kind === 305 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 303 /* JSDocPropertyTag */ || node.kind === 297 /* JSDocParameterTag */; + return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 290 /* JSDocTypeLiteral */; + return node.kind === 292 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 291 /* JSDocSignature */; + return node.kind === 293 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13524,7 +13765,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 304 /* SyntaxList */; + return n.kind === 306 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13534,7 +13775,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 146 /* FirstNode */; + return kind >= 148 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13543,7 +13784,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 147 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13555,7 +13796,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13565,7 +13806,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; + return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13574,12 +13815,12 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 15 /* TemplateMiddle */ - || kind === 16 /* TemplateTail */; + return kind === 16 /* TemplateMiddle */ + || kind === 17 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isStringTextContainingNode(node) { - return node.kind === 9 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers @@ -13592,17 +13833,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 79 /* DefaultKeyword */: - case 84 /* ExportKeyword */: - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 115 /* StaticKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 80 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 116 /* StaticKeyword */: return true; } return false; @@ -13615,7 +13856,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 115 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 116 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13624,23 +13865,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 9 /* StringLiteral */ + return kind === 72 /* Identifier */ + || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 147 /* ComputedPropertyName */; + || kind === 149 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 182 /* ObjectBindingPattern */ - || kind === 183 /* ArrayBindingPattern */; + return kind === 72 /* Identifier */ + || kind === 184 /* ObjectBindingPattern */ + || kind === 185 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13655,13 +13896,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -13670,14 +13911,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 164 /* ConstructorType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 166 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13692,29 +13933,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 152 /* PropertyDeclaration */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 160 /* IndexSignature */ - || kind === 215 /* SemicolonClassElement */; + return kind === 157 /* Constructor */ + || kind === 154 /* PropertyDeclaration */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 162 /* IndexSignature */ + || kind === 217 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); + return node && (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); + return node && (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; default: return false; @@ -13724,11 +13965,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 159 /* ConstructSignature */ - || kind === 158 /* CallSignature */ - || kind === 151 /* PropertySignature */ - || kind === 153 /* MethodSignature */ - || kind === 160 /* IndexSignature */; + return kind === 161 /* ConstructSignature */ + || kind === 160 /* CallSignature */ + || kind === 153 /* PropertySignature */ + || kind === 155 /* MethodSignature */ + || kind === 162 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13737,37 +13978,38 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 273 /* PropertyAssignment */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 275 /* SpreadAssignment */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 275 /* PropertyAssignment */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 277 /* SpreadAssignment */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) - || kind === 119 /* AnyKeyword */ - || kind === 142 /* UnknownKeyword */ - || kind === 134 /* NumberKeyword */ - || kind === 135 /* ObjectKeyword */ - || kind === 122 /* BooleanKeyword */ - || kind === 137 /* StringKeyword */ - || kind === 138 /* SymbolKeyword */ - || kind === 99 /* ThisKeyword */ - || kind === 105 /* VoidKeyword */ - || kind === 140 /* UndefinedKeyword */ - || kind === 95 /* NullKeyword */ - || kind === 131 /* NeverKeyword */ - || kind === 209 /* ExpressionWithTypeArguments */ - || kind === 282 /* JSDocAllType */ - || kind === 283 /* JSDocUnknownType */ - || kind === 284 /* JSDocNullableType */ - || kind === 285 /* JSDocNonNullableType */ - || kind === 286 /* JSDocOptionalType */ - || kind === 287 /* JSDocFunctionType */ - || kind === 288 /* JSDocVariadicType */; + return (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) + || kind === 120 /* AnyKeyword */ + || kind === 143 /* UnknownKeyword */ + || kind === 135 /* NumberKeyword */ + || kind === 146 /* BigIntKeyword */ + || kind === 136 /* ObjectKeyword */ + || kind === 123 /* BooleanKeyword */ + || kind === 138 /* StringKeyword */ + || kind === 139 /* SymbolKeyword */ + || kind === 100 /* ThisKeyword */ + || kind === 106 /* VoidKeyword */ + || kind === 141 /* UndefinedKeyword */ + || kind === 96 /* NullKeyword */ + || kind === 132 /* NeverKeyword */ + || kind === 211 /* ExpressionWithTypeArguments */ + || kind === 284 /* JSDocAllType */ + || kind === 285 /* JSDocUnknownType */ + || kind === 286 /* JSDocNullableType */ + || kind === 287 /* JSDocNonNullableType */ + || kind === 288 /* JSDocOptionalType */ + || kind === 289 /* JSDocFunctionType */ + || kind === 290 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13780,8 +14022,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return true; } return false; @@ -13792,8 +14034,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 183 /* ArrayBindingPattern */ - || kind === 182 /* ObjectBindingPattern */; + return kind === 185 /* ArrayBindingPattern */ + || kind === 184 /* ObjectBindingPattern */; } return false; } @@ -13801,15 +14043,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 185 /* ArrayLiteralExpression */ - || kind === 186 /* ObjectLiteralExpression */; + return kind === 187 /* ArrayLiteralExpression */ + || kind === 188 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 184 /* BindingElement */ - || kind === 208 /* OmittedExpression */; + return kind === 186 /* BindingElement */ + || kind === 210 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13818,9 +14060,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: return true; } return false; @@ -13841,8 +14083,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return true; } return false; @@ -13854,8 +14096,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return true; } return false; @@ -13864,26 +14106,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */ - || kind === 181 /* ImportType */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */ + || kind === 183 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 150 /* Decorator */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 152 /* Decorator */: return true; default: return false; @@ -13891,13 +14133,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; + return node.kind === 191 /* CallExpression */ || node.kind === 192 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 204 /* TemplateExpression */ - || kind === 13 /* NoSubstitutionTemplateLiteral */; + return kind === 206 /* TemplateExpression */ + || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13907,33 +14149,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 190 /* NewExpression */: - case 189 /* CallExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 191 /* TaggedTemplateExpression */: - case 185 /* ArrayLiteralExpression */: - case 193 /* ParenthesizedExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 71 /* Identifier */: - case 12 /* RegularExpressionLiteral */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 192 /* NewExpression */: + case 191 /* CallExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 193 /* TaggedTemplateExpression */: + case 187 /* ArrayLiteralExpression */: + case 195 /* ParenthesizedExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 72 /* Identifier */: + case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 101 /* TrueKeyword */: - case 97 /* SuperKeyword */: - case 211 /* NonNullExpression */: - case 212 /* MetaProperty */: - case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 102 /* TrueKeyword */: + case 98 /* SuperKeyword */: + case 213 /* NonNullExpression */: + case 214 /* MetaProperty */: + case 92 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13946,13 +14189,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 192 /* TypeAssertionExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 194 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13961,11 +14204,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 43 /* PlusPlusToken */ || - expr.operator === 44 /* MinusMinusToken */; + case 202 /* PrefixUnaryExpression */: + return expr.operator === 44 /* PlusPlusToken */ || + expr.operator === 45 /* MinusMinusToken */; default: return false; } @@ -13982,15 +14225,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: - case 195 /* ArrowFunction */: - case 202 /* BinaryExpression */: - case 206 /* SpreadElement */: - case 210 /* AsExpression */: - case 208 /* OmittedExpression */: - case 307 /* CommaListExpression */: - case 306 /* PartiallyEmittedExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: + case 197 /* ArrowFunction */: + case 204 /* BinaryExpression */: + case 208 /* SpreadElement */: + case 212 /* AsExpression */: + case 210 /* OmittedExpression */: + case 309 /* CommaListExpression */: + case 308 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13998,18 +14241,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 192 /* TypeAssertionExpression */ - || kind === 210 /* AsExpression */; + return kind === 194 /* TypeAssertionExpression */ + || kind === 212 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 306 /* PartiallyEmittedExpression */; + return node.kind === 308 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 305 /* NotEmittedStatement */; + return node.kind === 307 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14020,13 +14263,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return true; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14034,7 +14277,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; + return node.kind === 226 /* ForInStatement */ || node.kind === 227 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14058,113 +14301,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */ - || kind === 71 /* Identifier */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */ + || kind === 72 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 242 /* ModuleDeclaration */; + return kind === 72 /* Identifier */ + || kind === 244 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 250 /* NamedImports */ - || kind === 249 /* NamespaceImport */; + return kind === 252 /* NamedImports */ + || kind === 251 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; + return node.kind === 244 /* ModuleDeclaration */ || node.kind === 243 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 195 /* ArrowFunction */ - || kind === 184 /* BindingElement */ - || kind === 238 /* ClassDeclaration */ - || kind === 207 /* ClassExpression */ - || kind === 155 /* Constructor */ - || kind === 241 /* EnumDeclaration */ - || kind === 276 /* EnumMember */ - || kind === 255 /* ExportSpecifier */ - || kind === 237 /* FunctionDeclaration */ - || kind === 194 /* FunctionExpression */ - || kind === 156 /* GetAccessor */ - || kind === 248 /* ImportClause */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 251 /* ImportSpecifier */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 265 /* JsxAttribute */ - || kind === 154 /* MethodDeclaration */ - || kind === 153 /* MethodSignature */ - || kind === 242 /* ModuleDeclaration */ - || kind === 245 /* NamespaceExportDeclaration */ - || kind === 249 /* NamespaceImport */ - || kind === 149 /* Parameter */ - || kind === 273 /* PropertyAssignment */ - || kind === 152 /* PropertyDeclaration */ - || kind === 151 /* PropertySignature */ - || kind === 157 /* SetAccessor */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 148 /* TypeParameter */ - || kind === 235 /* VariableDeclaration */ - || kind === 302 /* JSDocTypedefTag */ - || kind === 295 /* JSDocCallbackTag */ - || kind === 303 /* JSDocPropertyTag */; + return kind === 197 /* ArrowFunction */ + || kind === 186 /* BindingElement */ + || kind === 240 /* ClassDeclaration */ + || kind === 209 /* ClassExpression */ + || kind === 157 /* Constructor */ + || kind === 243 /* EnumDeclaration */ + || kind === 278 /* EnumMember */ + || kind === 257 /* ExportSpecifier */ + || kind === 239 /* FunctionDeclaration */ + || kind === 196 /* FunctionExpression */ + || kind === 158 /* GetAccessor */ + || kind === 250 /* ImportClause */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 253 /* ImportSpecifier */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 267 /* JsxAttribute */ + || kind === 156 /* MethodDeclaration */ + || kind === 155 /* MethodSignature */ + || kind === 244 /* ModuleDeclaration */ + || kind === 247 /* NamespaceExportDeclaration */ + || kind === 251 /* NamespaceImport */ + || kind === 151 /* Parameter */ + || kind === 275 /* PropertyAssignment */ + || kind === 154 /* PropertyDeclaration */ + || kind === 153 /* PropertySignature */ + || kind === 159 /* SetAccessor */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 150 /* TypeParameter */ + || kind === 237 /* VariableDeclaration */ + || kind === 304 /* JSDocTypedefTag */ + || kind === 297 /* JSDocCallbackTag */ + || kind === 305 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 237 /* FunctionDeclaration */ - || kind === 256 /* MissingDeclaration */ - || kind === 238 /* ClassDeclaration */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 241 /* EnumDeclaration */ - || kind === 242 /* ModuleDeclaration */ - || kind === 247 /* ImportDeclaration */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 253 /* ExportDeclaration */ - || kind === 252 /* ExportAssignment */ - || kind === 245 /* NamespaceExportDeclaration */; + return kind === 239 /* FunctionDeclaration */ + || kind === 258 /* MissingDeclaration */ + || kind === 240 /* ClassDeclaration */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 243 /* EnumDeclaration */ + || kind === 244 /* ModuleDeclaration */ + || kind === 249 /* ImportDeclaration */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 255 /* ExportDeclaration */ + || kind === 254 /* ExportAssignment */ + || kind === 247 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 227 /* BreakStatement */ - || kind === 226 /* ContinueStatement */ - || kind === 234 /* DebuggerStatement */ - || kind === 221 /* DoStatement */ - || kind === 219 /* ExpressionStatement */ - || kind === 218 /* EmptyStatement */ - || kind === 224 /* ForInStatement */ - || kind === 225 /* ForOfStatement */ - || kind === 223 /* ForStatement */ - || kind === 220 /* IfStatement */ - || kind === 231 /* LabeledStatement */ - || kind === 228 /* ReturnStatement */ - || kind === 230 /* SwitchStatement */ - || kind === 232 /* ThrowStatement */ - || kind === 233 /* TryStatement */ - || kind === 217 /* VariableStatement */ - || kind === 222 /* WhileStatement */ - || kind === 229 /* WithStatement */ - || kind === 305 /* NotEmittedStatement */ - || kind === 309 /* EndOfDeclarationMarker */ - || kind === 308 /* MergeDeclarationMarker */; + return kind === 229 /* BreakStatement */ + || kind === 228 /* ContinueStatement */ + || kind === 236 /* DebuggerStatement */ + || kind === 223 /* DoStatement */ + || kind === 221 /* ExpressionStatement */ + || kind === 220 /* EmptyStatement */ + || kind === 226 /* ForInStatement */ + || kind === 227 /* ForOfStatement */ + || kind === 225 /* ForStatement */ + || kind === 222 /* IfStatement */ + || kind === 233 /* LabeledStatement */ + || kind === 230 /* ReturnStatement */ + || kind === 232 /* SwitchStatement */ + || kind === 234 /* ThrowStatement */ + || kind === 235 /* TryStatement */ + || kind === 219 /* VariableStatement */ + || kind === 224 /* WhileStatement */ + || kind === 231 /* WithStatement */ + || kind === 307 /* NotEmittedStatement */ + || kind === 311 /* EndOfDeclarationMarker */ + || kind === 310 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 301 /* JSDocTemplateTag */ || ts.isInJSFile(node); + if (node.kind === 150 /* TypeParameter */) { + return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14191,10 +14434,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 216 /* Block */) + if (node.kind !== 218 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { + if (node.parent.kind === 235 /* TryStatement */ || node.parent.kind === 274 /* CatchClause */) { return false; } } @@ -14204,81 +14447,81 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 257 /* ExternalModuleReference */ - || kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 259 /* ExternalModuleReference */ + || kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 99 /* ThisKeyword */ - || kind === 71 /* Identifier */ - || kind === 187 /* PropertyAccessExpression */; + return kind === 100 /* ThisKeyword */ + || kind === 72 /* Identifier */ + || kind === 189 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 258 /* JsxElement */ - || kind === 268 /* JsxExpression */ - || kind === 259 /* JsxSelfClosingElement */ - || kind === 10 /* JsxText */ - || kind === 262 /* JsxFragment */; + return kind === 260 /* JsxElement */ + || kind === 270 /* JsxExpression */ + || kind === 261 /* JsxSelfClosingElement */ + || kind === 11 /* JsxText */ + || kind === 264 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 265 /* JsxAttribute */ - || kind === 267 /* JsxSpreadAttribute */; + return kind === 267 /* JsxAttribute */ + || kind === 269 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ - || kind === 268 /* JsxExpression */; + return kind === 10 /* StringLiteral */ + || kind === 270 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 260 /* JsxOpeningElement */ - || kind === 259 /* JsxSelfClosingElement */; + return kind === 262 /* JsxOpeningElement */ + || kind === 261 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 269 /* CaseClause */ - || kind === 270 /* DefaultClause */; + return kind === 271 /* CaseClause */ + || kind === 272 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 303 /* LastJSDocNode */; + return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 303 /* LastJSDocTagNode */; + return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14308,12 +14551,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 265 /* JsxAttribute */ || node.kind === 267 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 267 /* JsxAttribute */ || node.kind === 269 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 164 /* TypeReference */ || node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14342,15 +14585,14 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 9 /* StringLiteral */ || node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; })(ts || (ts = {})); /* @internal */ (function (ts) { - /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; + return node.kind === 252 /* NamedImports */ || node.kind === 256 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -14395,10 +14637,9 @@ var ts; getSignatureConstructor: function () { return Signature; }, getSourceMapSourceConstructor: function () { return SourceMapSource; }, }; - /* @internal */ function formatStringFromArgs(text, args, baseIndex) { if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return ts.Debug.assertDefined(args[+index + baseIndex]); }); + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; function getLocaleSpecificMessage(message) { @@ -14427,7 +14668,6 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; - /* @internal */ function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -14452,7 +14692,6 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; - /* @internal */ function createCompilerDiagnosticFromMessageChain(chain) { return { file: undefined, @@ -14489,14 +14728,12 @@ var ts; function getDiagnosticFilePath(diagnostic) { return diagnostic.file ? diagnostic.file.path : undefined; } - /* @internal */ function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; - /* @internal */ function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || @@ -14800,7 +15037,6 @@ var ts; return rootLength > 0 && rootLength === path.length; } ts.isDiskPathRoot = isDiskPathRoot; - /* @internal */ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { return !isRootedDiskPath(absoluteOrRelativePath) ? absoluteOrRelativePath @@ -15765,6 +16001,82 @@ var ts; } } ts.getOrUpdate = getOrUpdate; + /** + * Converts a bigint literal string, e.g. `0x1234n`, + * to its decimal string representation, e.g. `4660`. + */ + function parsePseudoBigInt(stringValue) { + var log2Base; + switch (stringValue.charCodeAt(1)) { // "x" in "0x123" + case 98 /* b */: + case 66 /* B */: // 0b or 0B + log2Base = 1; + break; + case 111 /* o */: + case 79 /* O */: // 0o or 0O + log2Base = 3; + break; + case 120 /* x */: + case 88 /* 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 */) { + nonZeroStart++; + } + return stringValue.slice(nonZeroStart, nIndex) || "0"; + } + // Omit leading "0b", "0o", or "0x", and trailing "n" + var startIndex = 2, endIndex = stringValue.length - 1; + var bitsNeeded = (endIndex - startIndex) * log2Base; + // Stores the value specified by the string as a LE array of 16-bit integers + // using Uint16 instead of Uint32 so combining steps can use bitwise operators + var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0)); + // Add the digits, one at a time + for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) { + 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 */ + : 10 + digitChar - + (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + var shiftedDigit = digit << (bitOffset & 15); + segments[segment] |= shiftedDigit; + var residual = shiftedDigit >>> 16; + if (residual) + segments[segment + 1] |= residual; // overflows segment + } + // Repeatedly divide segments by 10 and add remainder to base10Value + var base10Value = ""; + var firstNonzeroSegment = segments.length - 1; + var segmentsRemaining = true; + while (segmentsRemaining) { + var mod10 = 0; + segmentsRemaining = false; + for (var segment = firstNonzeroSegment; segment >= 0; segment--) { + var newSegment = mod10 << 16 | segments[segment]; + var segmentValue = (newSegment / 10) | 0; + segments[segment] = segmentValue; + mod10 = newSegment - segmentValue * 10; + if (segmentValue && !segmentsRemaining) { + firstNonzeroSegment = segment; + segmentsRemaining = true; + } + } + base10Value = mod10 + base10Value; + } + return base10Value; + } + ts.parsePseudoBigInt = parsePseudoBigInt; + function pseudoBigIntToString(_a) { + var negative = _a.negative, base10Value = _a.base10Value; + return (negative && base10Value !== "0" ? "-" : "") + base10Value; + } + ts.pseudoBigIntToString = pseudoBigIntToString; })(ts || (ts = {})); var ts; (function (ts) { @@ -15784,10 +16096,10 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 277 /* SourceFile */) { + if (kind === 279 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 71 /* Identifier */) { + else if (kind === 72 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -15836,19 +16148,19 @@ 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 <= 145 /* LastToken */) { + if (!node || node.kind <= 147 /* LastToken */) { return; } switch (node.kind) { - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15856,9 +16168,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15866,7 +16178,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15874,51 +16186,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertySignature */: + case 153 /* 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 273 /* PropertyAssignment */: + case 275 /* 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 235 /* VariableDeclaration */: + case 237 /* 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 184 /* BindingElement */: + case 186 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15930,302 +16242,302 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 168 /* TupleType */: + case 170 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 174 /* InferType */: + case 176 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 181 /* ImportType */: + case 183 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 175 /* ParenthesizedType */: - case 177 /* TypeOperator */: + case 177 /* ParenthesizedType */: + case 179 /* TypeOperator */: return visitNode(cbNode, node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 179 /* MappedType */: + case 181 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return visitNode(cbNode, node.literal); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitNode(cbNode, node.name); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return visitNode(cbNode, node.label); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 150 /* Decorator */: + case 152 /* Decorator */: return visitNode(cbNode, node.expression); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 239 /* InterfaceDeclaration */: + case 241 /* 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 240 /* TypeAliasDeclaration */: + case 242 /* 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 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 169 /* OptionalType */: - case 170 /* RestType */: - case 281 /* JSDocTypeExpression */: - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 286 /* JSDocOptionalType */: - case 288 /* JSDocVariadicType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 283 /* JSDocTypeExpression */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 288 /* JSDocOptionalType */: + case 290 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 289 /* JSDocComment */: + case 291 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -16234,17 +16546,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 281 /* JSDocTypeExpression */) { + node.typeExpression.kind === 283 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -16252,20 +16564,20 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 295 /* JSDocCallbackTag */: + case 297 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocThisTag */: + case 301 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocEnumTag */: + case 298 /* JSDocEnumTag */: return visitNode(cbNode, node.typeExpression); - case 291 /* JSDocSignature */: + case 293 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 290 /* JSDocTypeLiteral */: + case 292 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -16273,7 +16585,7 @@ var ts; } } return; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -16491,18 +16803,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(219 /* ExpressionStatement */); + var statement = createNode(221 /* ExpressionStatement */); switch (token()) { - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 38 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 56 /* ColonToken */; })) { + case 39 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -16510,8 +16822,8 @@ var ts; } break; case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 56 /* ColonToken */; })) { + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -16647,7 +16959,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16852,20 +17164,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 71 /* Identifier */) { + if (token() === 72 /* 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() === 116 /* YieldKeyword */ && inYieldContext()) { + if (token() === 117 /* 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() === 121 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 122 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 107 /* LastReservedWord */; + return token() > 108 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -16908,29 +17220,29 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(25 /* SemicolonToken */); + return parseExpected(26 /* SemicolonToken */); } } function createNode(kind, pos) { nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 72 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -16972,7 +17284,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 71 /* Identifier */) { + if (kind === 72 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -16993,9 +17305,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(71 /* Identifier */); + var node = createNode(72 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 71 /* Identifier */) { + if (token() !== 72 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -17004,7 +17316,7 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17014,16 +17326,16 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -17035,13 +17347,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(147 /* ComputedPropertyName */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(149 /* ComputedPropertyName */); + parseExpected(22 /* 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. node.expression = allowInAnd(parseExpression); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -17056,20 +17368,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 83 /* EnumKeyword */; - case 84 /* ExportKeyword */: + return nextToken() === 84 /* EnumKeyword */; + case 85 /* ExportKeyword */: nextToken(); - if (token() === 79 /* DefaultKeyword */) { + if (token() === 80 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier(); - case 79 /* DefaultKeyword */: + return token() !== 40 /* AsteriskToken */ && token() !== 119 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 80 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 115 /* StaticKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -17080,18 +17392,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 21 /* OpenBracketToken */ - || token() === 17 /* OpenBraceToken */ - || token() === 39 /* AsteriskToken */ - || token() === 24 /* DotDotDotToken */ + return token() === 22 /* OpenBracketToken */ + || token() === 18 /* OpenBraceToken */ + || token() === 40 /* AsteriskToken */ + || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ || - token() === 109 /* InterfaceKeyword */ || - (token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 76 /* ClassKeyword */ || token() === 90 /* FunctionKeyword */ || + token() === 110 /* InterfaceKeyword */ || + (token() === 118 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 121 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -17109,9 +17421,9 @@ var ts; // 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() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -17119,17 +17431,17 @@ var ts; // 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() === 25 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: switch (token()) { - case 21 /* OpenBracketToken */: - case 39 /* AsteriskToken */: - case 24 /* DotDotDotToken */: - case 23 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* OpenBracketToken */: + case 40 /* 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`) return true; default: return isLiteralPropertyName(); @@ -17137,11 +17449,11 @@ var ts; case 18 /* RestProperties */: return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* 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() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -17156,37 +17468,39 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern(); case 19 /* TypeParameters */: return isIdentifier(); case 15 /* ArrayLiteralMembers */: - if (token() === 26 /* CommaToken */) { - return true; + 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`) + return true; } // falls through case 11 /* ArgumentExpressions */: - return token() === 24 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); case 17 /* JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); case 20 /* TypeArguments */: case 21 /* TupleElementTypes */: - return token() === 26 /* CommaToken */ || isStartOfType(); + return token() === 27 /* CommaToken */ || isStartOfType(); case 22 /* HeritageClauses */: return isHeritageClause(); case 23 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 17 /* OpenBraceToken */); - if (nextToken() === 18 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* OpenBraceToken */); + if (nextToken() === 19 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -17195,7 +17509,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 86 /* ExtendsKeyword */ || next === 109 /* ImplementsKeyword */; } return true; } @@ -17212,8 +17526,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 108 /* ImplementsKeyword */ || - token() === 85 /* ExtendsKeyword */) { + if (token() === 109 /* ImplementsKeyword */ || + token() === 86 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -17241,37 +17555,37 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 23 /* ImportOrExportSpecifiers */: - return token() === 18 /* CloseBraceToken */; + return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */; + return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 21 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 22 /* CloseBracketToken */; + return token() === 23 /* CloseBracketToken */; case 17 /* JSDocParameters */: case 16 /* Parameters */: case 18 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 20 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 26 /* CommaToken */; + return token() !== 27 /* CommaToken */; case 22 /* HeritageClauses */: - return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */; + return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; + return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -17291,7 +17605,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() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -17461,20 +17775,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 155 /* Constructor */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 215 /* SemicolonClassElement */: + case 157 /* Constructor */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 217 /* SemicolonClassElement */: return true; - case 154 /* MethodDeclaration */: + case 156 /* 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 === 71 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 72 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 124 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -17483,8 +17797,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: return true; } } @@ -17493,58 +17807,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 217 /* VariableStatement */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 219 /* ExpressionStatement */: - case 232 /* ThrowStatement */: - case 228 /* ReturnStatement */: - case 230 /* SwitchStatement */: - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 218 /* EmptyStatement */: - case 233 /* TryStatement */: - case 231 /* LabeledStatement */: - case 221 /* DoStatement */: - case 234 /* DebuggerStatement */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 219 /* VariableStatement */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 221 /* ExpressionStatement */: + case 234 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 232 /* SwitchStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 220 /* EmptyStatement */: + case 235 /* TryStatement */: + case 233 /* LabeledStatement */: + case 223 /* DoStatement */: + case 236 /* DebuggerStatement */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 151 /* PropertySignature */: - case 158 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 153 /* PropertySignature */: + case 160 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 235 /* VariableDeclaration */) { + if (node.kind !== 237 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -17565,7 +17879,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 149 /* Parameter */) { + if (node.kind !== 151 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -17622,7 +17936,7 @@ var ts; var startPos = scanner.getStartPos(); list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -17632,13 +17946,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(26 /* CommaToken */); + parseExpected(27 /* CommaToken */); // 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() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -17689,8 +18003,8 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); - while (parseOptional(23 /* DotToken */)) { - if (token() === 27 /* LessThanToken */) { + while (parseOptional(24 /* DotToken */)) { + if (token() === 28 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -17701,7 +18015,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(146 /* QualifiedName */, entity.pos); + var node = createNode(148 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -17732,33 +18046,33 @@ 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(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(204 /* TemplateExpression */); + var template = createNode(206 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 16 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(214 /* TemplateSpan */); + var span = createNode(216 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 18 /* CloseBraceToken */) { + if (token() === 19 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(16 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */)); + literal = parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -17768,18 +18082,17 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind) { var node = createNode(kind); - var text = scanner.getTokenValue(); - node.text = text; + node.text = scanner.getTokenValue(); if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -17801,24 +18114,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 28 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: { + case 165 /* FunctionType */: + case 166 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17826,20 +18139,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(161 /* TypePredicate */, lhs.pos); + var node = createNode(163 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(176 /* ThisType */); + var node = createNode(178 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(282 /* JSDocAllType */); + var result = createNode(284 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(286 /* JSDocOptionalType */, result); + return createPostfixType(288 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17847,7 +18160,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(285 /* JSDocNonNullableType */); + var result = createNode(287 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17865,66 +18178,66 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 26 /* CommaToken */ || - token() === 18 /* CloseBraceToken */ || - token() === 20 /* CloseParenToken */ || - token() === 29 /* GreaterThanToken */ || - token() === 58 /* EqualsToken */ || - token() === 49 /* BarToken */) { - var result = createNode(283 /* JSDocUnknownType */, pos); + if (token() === 27 /* CommaToken */ || + token() === 19 /* CloseBraceToken */ || + token() === 21 /* CloseParenToken */ || + token() === 30 /* GreaterThanToken */ || + token() === 59 /* EqualsToken */ || + token() === 50 /* BarToken */) { + var result = createNode(285 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(284 /* JSDocNullableType */, pos); + var result = createNode(286 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); nextToken(); - fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { + var parameter = createNode(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */ || token() === 95 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); + var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 58 /* EqualsToken */) { - return createPostfixType(286 /* JSDocOptionalType */, type); + if (token() === 59 /* EqualsToken */) { + return createPostfixType(288 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(165 /* TypeQuery */); - parseExpected(103 /* TypeOfKeyword */); + var node = createNode(167 /* TypeQuery */); + parseExpected(104 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(85 /* ExtendsKeyword */)) { + if (parseOptional(86 /* 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 @@ -17943,39 +18256,39 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(58 /* EqualsToken */)) { + if (parseOptional(59 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 27 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (token() === 28 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(56 /* ColonToken */)) { + if (parseOptional(57 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter(isJSDocParameter) { - return token() === 24 /* DotDotDotToken */ || + return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 /* AtToken */ || + token() === 58 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */) { + var node = createNodeWithJSDoc(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -17990,7 +18303,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(55 /* QuestionToken */); + node.questionToken = parseOptionalToken(56 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18012,16 +18325,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 36 /* EqualsGreaterThanToken */) { + if (returnToken === 37 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(56 /* ColonToken */)) { + else if (parseOptional(57 /* ColonToken */)) { return true; } - else if (isType && token() === 36 /* EqualsGreaterThanToken */) { + else if (isType && token() === 37 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); nextToken(); return true; } @@ -18042,7 +18355,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(19 /* OpenParenToken */)) { + if (!parseExpected(20 /* OpenParenToken */)) { signature.parameters = createMissingList(); return false; } @@ -18055,12 +18368,12 @@ var ts; parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - return parseExpected(20 /* CloseParenToken */); + return parseExpected(21 /* CloseParenToken */); } 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(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -18068,15 +18381,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 159 /* ConstructSignature */) { - parseExpected(94 /* NewKeyword */); + if (kind === 161 /* ConstructSignature */) { + parseExpected(95 /* NewKeyword */); } - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - return token() === 21 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -18096,7 +18409,7 @@ var ts; // [] // nextToken(); - if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) { + if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -18115,39 +18428,39 @@ 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* 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() !== 55 /* QuestionToken */) { + if (token() !== 56 /* 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; + return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 160 /* IndexSignature */; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.kind = 162 /* IndexSignature */; + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 153 /* MethodSignature */; + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.kind = 155 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 151 /* PropertySignature */; + node.kind = 153 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { // 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. @@ -18159,7 +18472,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return true; } var idToken = false; @@ -18169,7 +18482,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -18180,21 +18493,21 @@ 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() === 19 /* OpenParenToken */ || - token() === 27 /* LessThanToken */ || - token() === 55 /* QuestionToken */ || - token() === 56 /* ColonToken */ || - token() === 26 /* CommaToken */ || + return token() === 20 /* OpenParenToken */ || + token() === 28 /* LessThanToken */ || + token() === 56 /* QuestionToken */ || + token() === 57 /* ColonToken */ || + token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(158 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + return parseSignatureMember(160 /* CallSignature */); } - if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(159 /* ConstructSignature */); + if (token() === 95 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(161 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -18205,30 +18518,30 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 23 /* DotToken */; + return nextToken() === 24 /* DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 19 /* OpenParenToken */: - case 27 /* LessThanToken */: - case 23 /* DotToken */: + case 20 /* OpenParenToken */: + case 28 /* LessThanToken */: + case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(166 /* TypeLiteral */); + var node = createNode(168 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { members = createMissingList(); @@ -18237,89 +18550,89 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { - return nextToken() === 132 /* ReadonlyKeyword */; + if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + return nextToken() === 133 /* ReadonlyKeyword */; } - if (token() === 132 /* ReadonlyKeyword */) { + if (token() === 133 /* ReadonlyKeyword */) { nextToken(); } - return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 93 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(92 /* InKeyword */); + parseExpected(93 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(179 /* MappedType */); - parseExpected(17 /* OpenBraceToken */); - if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + var node = createNode(181 /* MappedType */); + parseExpected(18 /* OpenBraceToken */); + if (token() === 133 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { - parseExpectedToken(132 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { + parseExpectedToken(133 /* ReadonlyKeyword */); } } - parseExpected(21 /* OpenBracketToken */); + parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); - parseExpected(22 /* CloseBracketToken */); - if (token() === 55 /* QuestionToken */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + parseExpected(23 /* CloseBracketToken */); + if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 55 /* QuestionToken */) { - parseExpectedToken(55 /* QuestionToken */); + if (node.questionToken.kind !== 56 /* QuestionToken */) { + parseExpectedToken(56 /* QuestionToken */); } } node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(24 /* DotDotDotToken */)) { - var node = createNode(170 /* RestType */, pos); + if (parseOptional(25 /* DotDotDotToken */)) { + var node = createNode(172 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 169 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 171 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + var node = createNode(170 /* TupleType */); + node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(175 /* ParenthesizedType */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(177 /* ParenthesizedType */); + parseExpected(20 /* OpenParenToken */); node.type = parseType(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(94 /* NewKeyword */) ? 164 /* ConstructorType */ : 163 /* FunctionType */; + var kind = parseOptional(95 /* NewKeyword */) ? 166 /* ConstructorType */ : 165 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 23 /* DotToken */ ? undefined : node; + return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(180 /* LiteralType */); + var node = createNode(182 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 38 /* MinusToken */; + unaryMinusExpression = createNode(202 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } - var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */ + var expression = token() === 102 /* TrueKeyword */ || token() === 87 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -18332,79 +18645,82 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 91 /* ImportKeyword */; + return token() === 92 /* ImportKeyword */; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(181 /* ImportType */); - if (parseOptional(103 /* TypeOfKeyword */)) { + var node = createNode(183 /* ImportType */); + if (parseOptional(104 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(91 /* ImportKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(92 /* ImportKeyword */); + parseExpected(20 /* OpenParenToken */); node.argument = parseType(); - parseExpected(20 /* CloseParenToken */); - if (parseOptional(23 /* DotToken */)) { + parseExpected(21 /* CloseParenToken */); + if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } node.typeArguments = tryParseTypeArguments(); return finishNode(node); } - function nextTokenIsNumericLiteral() { - return nextToken() === 8 /* NumericLiteral */; + function nextTokenIsNumericOrBigIntLiteral() { + nextToken(); + return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 138 /* SymbolKeyword */: - case 122 /* BooleanKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 139 /* SymbolKeyword */: + case 123 /* BooleanKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 61 /* AsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 51 /* ExclamationToken */: + case 52 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseLiteralTypeNode(); - case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 105 /* VoidKeyword */: - case 95 /* NullKeyword */: + case 39 /* MinusToken */: + return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); + case 106 /* VoidKeyword */: + case 96 /* NullKeyword */: return parseTokenNode(); - case 99 /* ThisKeyword */: { + case 100 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseTupleType(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportType(); default: return parseTypeReference(); @@ -18412,42 +18728,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 141 /* UniqueKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 103 /* TypeOfKeyword */: - case 131 /* NeverKeyword */: - case 17 /* OpenBraceToken */: - case 21 /* OpenBracketToken */: - case 27 /* LessThanToken */: - case 49 /* BarToken */: - case 48 /* AmpersandToken */: - case 94 /* NewKeyword */: - case 9 /* StringLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 142 /* UniqueKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 104 /* TypeOfKeyword */: + case 132 /* NeverKeyword */: + case 18 /* OpenBraceToken */: + case 22 /* OpenBracketToken */: + case 28 /* LessThanToken */: + case 50 /* BarToken */: + case 49 /* AmpersandToken */: + case 95 /* NewKeyword */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 135 /* ObjectKeyword */: - case 39 /* AsteriskToken */: - case 55 /* QuestionToken */: - case 51 /* ExclamationToken */: - case 24 /* DotDotDotToken */: - case 126 /* InferKeyword */: - case 91 /* ImportKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 136 /* ObjectKeyword */: + case 40 /* AsteriskToken */: + case 56 /* QuestionToken */: + case 52 /* ExclamationToken */: + case 25 /* DotDotDotToken */: + case 127 /* InferKeyword */: + case 92 /* ImportKeyword */: return true; - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return !inStartOfParameter; - case 38 /* MinusToken */: - return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); - case 19 /* OpenParenToken */: + case 39 /* MinusToken */: + return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); + case 20 /* 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); @@ -18457,35 +18775,35 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 20 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 51 /* ExclamationToken */: - type = createPostfixType(285 /* JSDocNonNullableType */, type); + case 52 /* ExclamationToken */: + type = createPostfixType(287 /* JSDocNonNullableType */, type); break; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(284 /* JSDocNullableType */, type); + type = createPostfixType(286 /* JSDocNullableType */, type); break; - case 21 /* OpenBracketToken */: - parseExpected(21 /* OpenBracketToken */); + case 22 /* OpenBracketToken */: + parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(178 /* IndexedAccessType */, type.pos); + var node = createNode(180 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(167 /* ArrayType */, type.pos); + var node = createNode(169 /* ArrayType */, type.pos); node.elementType = type; - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } break; @@ -18502,16 +18820,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(177 /* TypeOperator */); + var node = createNode(179 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(174 /* InferType */); - parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(148 /* TypeParameter */); + var node = createNode(176 /* InferType */); + parseExpected(127 /* InferKeyword */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -18519,10 +18837,10 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 128 /* KeyOfKeyword */: - case 141 /* UniqueKeyword */: + case 129 /* KeyOfKeyword */: + case 142 /* UniqueKeyword */: return parseTypeOperator(operator); - case 126 /* InferKeyword */: + case 127 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -18542,27 +18860,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(174 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(173 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { return true; } - return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 99 /* ThisKeyword */) { + if (isIdentifier() || token() === 100 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) { + if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -18572,7 +18890,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) { + if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -18580,17 +18898,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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || - token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 56 /* QuestionToken */ || token() === 59 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 20 /* CloseParenToken */) { + if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -18602,7 +18920,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(163 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -18613,7 +18931,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -18624,49 +18942,50 @@ var ts; return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 94 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 95 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(173 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(86 /* ExtendsKeyword */)) { + var node = createNode(175 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(55 /* QuestionToken */); + parseExpected(56 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(56 /* ColonToken */) ? parseType() : undefined; + return parseOptional(57 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 19 /* OpenParenToken */: - case 21 /* OpenBracketToken */: - case 17 /* OpenBraceToken */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 94 /* NewKeyword */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 71 /* Identifier */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 20 /* OpenParenToken */: + case 22 /* OpenBracketToken */: + case 18 /* OpenBraceToken */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 95 /* NewKeyword */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 72 /* Identifier */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -18677,18 +18996,18 @@ var ts; return true; } switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 27 /* LessThanToken */: - case 121 /* AwaitKeyword */: - case 116 /* YieldKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 28 /* LessThanToken */: + case 122 /* AwaitKeyword */: + case 117 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -18706,10 +19025,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 17 /* OpenBraceToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && - token() !== 57 /* AtToken */ && + return token() !== 18 /* OpenBraceToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && + token() !== 58 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -18723,7 +19042,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -18732,7 +19051,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(58 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(59 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -18777,7 +19096,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -18793,7 +19112,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 116 /* YieldKeyword */) { + if (token() === 117 /* 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()) { @@ -18822,15 +19141,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(205 /* YieldExpression */); + var node = createNode(207 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 39 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -18841,20 +19160,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(195 /* ArrowFunction */, asyncModifier.pos); + node = createNode(197 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(195 /* ArrowFunction */, identifier.pos); + node = createNode(197 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(149 /* Parameter */, identifier.pos); + var parameter = createNode(151 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -18879,8 +19198,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -18890,10 +19209,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 121 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* 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. @@ -18903,28 +19222,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 19 /* OpenParenToken */) { - if (second === 20 /* CloseParenToken */) { + if (first === 20 /* OpenParenToken */) { + if (second === 21 /* 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 36 /* EqualsGreaterThanToken */: - case 56 /* ColonToken */: - case 17 /* OpenBraceToken */: + case 37 /* EqualsGreaterThanToken */: + case 57 /* ColonToken */: + case 18 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -18936,42 +19255,42 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) { + if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 24 /* DotDotDotToken */) { + if (second === 25 /* DotDotDotToken */) { return 1 /* 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 !== 120 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 121 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 99 /* ThisKeyword */) { + if (!isIdentifier() && second !== 100 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 56 /* ColonToken */: + case 57 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 58 /* EqualsToken */ || token() === 20 /* CloseParenToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 59 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; - case 26 /* CommaToken */: - case 58 /* EqualsToken */: - case 20 /* CloseParenToken */: + case 27 /* CommaToken */: + case 59 /* EqualsToken */: + case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; } @@ -18979,7 +19298,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 27 /* LessThanToken */); + ts.Debug.assert(first === 28 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -18989,17 +19308,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 85 /* ExtendsKeyword */) { + if (third === 86 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 58 /* EqualsToken */: - case 29 /* GreaterThanToken */: + case 59 /* EqualsToken */: + case 30 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 26 /* CommaToken */) { + else if (third === 27 /* CommaToken */) { return true; } return false; @@ -19018,7 +19337,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19031,23 +19350,23 @@ 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() === 120 /* AsyncKeyword */) { + if (token() === 121 /* 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() === 36 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(195 /* ArrowFunction */); + var node = createNodeWithJSDoc(197 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19057,7 +19376,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(56 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -19068,19 +19387,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && token() !== 18 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } - if (token() !== 25 /* SemicolonToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && + if (token() !== 26 /* SemicolonToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -19105,20 +19424,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(55 /* QuestionToken */); + var questionToken = parseOptionalToken(56 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(205 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(56 /* ColonToken */); + node.colonToken = parseExpectedToken(57 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + : createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -19126,7 +19445,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; + return t === 93 /* InKeyword */ || t === 147 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -19155,16 +19474,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() === 40 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 92 /* InKeyword */ && inDisallowInContext()) { + if (token() === 93 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -19185,51 +19504,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 92 /* InKeyword */) { + if (inDisallowInContext() && token() === 93 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(202 /* BinaryExpression */, left.pos); + var node = createNode(204 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(210 /* AsExpression */, left.pos); + var node = createNode(212 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(200 /* PrefixUnaryExpression */); + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(196 /* DeleteExpression */); + var node = createNode(198 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(197 /* TypeOfExpression */); + var node = createNode(199 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(198 /* VoidExpression */); + var node = createNode(200 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 121 /* AwaitKeyword */) { + if (token() === 122 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -19239,7 +19558,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(199 /* AwaitExpression */); + var node = createNode(201 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -19263,7 +19582,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 40 /* AsteriskAsteriskToken */ ? + return token() === 41 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -19280,10 +19599,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 40 /* AsteriskAsteriskToken */) { + if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 194 /* 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 { @@ -19308,23 +19627,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 80 /* DeleteKeyword */: + case 81 /* DeleteKeyword */: return parseDeleteExpression(); - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return parseVoidExpression(); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 121 /* AwaitKeyword */: + case 122 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -19347,16 +19666,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 121 /* AwaitKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 122 /* AwaitKeyword */: return false; - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -19379,21 +19698,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(200 /* PrefixUnaryExpression */); + if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(203 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -19434,7 +19753,7 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 91 /* ImportKeyword */) { + if (token() === 92 /* 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: @@ -19449,8 +19768,8 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(212 /* MetaProperty */, fullStart); - node.keywordToken = 91 /* ImportKeyword */; + var node = createNode(214 /* MetaProperty */, fullStart); + node.keywordToken = 92 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; @@ -19460,7 +19779,7 @@ var ts; } } else { - expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 98 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression. As such, we need to consume the rest of it here to be complete. @@ -19519,22 +19838,22 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* 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. - var node = createNode(187 /* PropertyAccessExpression */, expression.pos); + var node = createNode(189 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 260 /* JsxOpeningElement */) { - var node = createNode(258 /* JsxElement */, opening.pos); + if (opening.kind === 262 /* JsxOpeningElement */) { + var node = createNode(260 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -19543,15 +19862,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 263 /* JsxOpeningFragment */) { - var node = createNode(262 /* JsxFragment */, opening.pos); + else if (opening.kind === 265 /* JsxOpeningFragment */) { + var node = createNode(264 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 261 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -19562,15 +19881,15 @@ 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() === 27 /* LessThanToken */) { + if (inExpressionContext && token() === 28 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(202 /* BinaryExpression */, result.pos); + var badNode = createNode(204 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 + badNode.operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -19578,8 +19897,8 @@ var ts; return result; } function parseJsxText() { - var node = createNode(10 /* JsxText */); - node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */; + var node = createNode(11 /* JsxText */); + node.containsOnlyWhiteSpaces = currentToken === 12 /* JsxTextAllWhiteSpaces */; currentToken = scanner.scanJsxToken(); return finishNode(node); } @@ -19595,15 +19914,15 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 28 /* LessThanSlashToken */: + case 29 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; - case 10 /* JsxText */: - case 11 /* JsxTextAllWhiteSpaces */: + case 11 /* JsxText */: + case 12 /* JsxTextAllWhiteSpaces */: return parseJsxText(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -19624,16 +19943,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(266 /* JsxAttributes */); + var jsxAttributes = createNode(268 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(27 /* LessThanToken */); - if (token() === 29 /* GreaterThanToken */) { + parseExpected(28 /* LessThanToken */); + if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(265 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -19641,23 +19960,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 29 /* GreaterThanToken */) { + if (token() === 30 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(260 /* JsxOpeningElement */, fullStart); + node = createNode(262 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(41 /* SlashToken */); + parseExpected(42 /* SlashToken */); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(259 /* JsxSelfClosingElement */, fullStart); + node = createNode(261 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -19671,10 +19990,10 @@ 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() === 99 /* ThisKeyword */ ? + var expression = token() === 100 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(24 /* DotToken */)) { + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -19682,33 +20001,33 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(268 /* JsxExpression */); - if (!parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(270 /* JsxExpression */); + if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } - if (token() !== 18 /* CloseBraceToken */) { - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + if (token() !== 19 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { - parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(265 /* JsxAttribute */); + var node = createNode(267 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { switch (scanJsxAttributeValue()) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: @@ -19719,72 +20038,72 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(267 /* JsxSpreadAttribute */); - parseExpected(17 /* OpenBraceToken */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(269 /* JsxSpreadAttribute */); + parseExpected(18 /* OpenBraceToken */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(261 /* JsxClosingElement */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(263 /* JsxClosingElement */); + parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(264 /* JsxClosingFragment */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(266 /* JsxClosingFragment */); + parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(192 /* TypeAssertionExpression */); - parseExpected(27 /* LessThanToken */); + var node = createNode(194 /* TypeAssertionExpression */); + parseExpected(28 /* LessThanToken */); node.type = parseType(); - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(23 /* DotToken */); + var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(211 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(213 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { + var indexedAccess = createNode(190 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; - if (token() === 22 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -19793,7 +20112,7 @@ var ts; } indexedAccess.argumentExpression = argument; } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } @@ -19805,13 +20124,13 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; + return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(193 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; - tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); return finishNode(tagExpression); @@ -19819,7 +20138,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { // 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 @@ -19832,15 +20151,15 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(189 /* CallExpression */, expression.pos); + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(189 /* CallExpression */, expression.pos); + else if (token() === 20 /* OpenParenToken */) { + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19850,17 +20169,17 @@ var ts; } } function parseArgumentList() { - parseExpected(19 /* OpenParenToken */); + parseExpected(20 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(27 /* LessThanToken */)) { + if (!parseOptional(28 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(29 /* GreaterThanToken */)) { + if (!parseExpected(30 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -19872,34 +20191,34 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 19 /* OpenParenToken */: // foo( - case 13 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 14 /* TemplateHead */: // foo `...${100}...` + case 20 /* OpenParenToken */: // foo( + case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. - case 23 /* DotToken */: // foo. - case 20 /* CloseParenToken */: // foo) - case 22 /* CloseBracketToken */: // foo] - case 56 /* ColonToken */: // foo: - case 25 /* SemicolonToken */: // foo; - case 55 /* QuestionToken */: // foo? - case 32 /* EqualsEqualsToken */: // foo == - case 34 /* EqualsEqualsEqualsToken */: // foo === - case 33 /* ExclamationEqualsToken */: // foo != - case 35 /* ExclamationEqualsEqualsToken */: // foo !== - case 53 /* AmpersandAmpersandToken */: // foo && - case 54 /* BarBarToken */: // foo || - case 50 /* CaretToken */: // foo ^ - case 48 /* AmpersandToken */: // foo & - case 49 /* BarToken */: // foo | - case 18 /* CloseBraceToken */: // foo } + case 24 /* DotToken */: // foo. + case 21 /* CloseParenToken */: // foo) + case 23 /* CloseBracketToken */: // foo] + case 57 /* ColonToken */: // foo: + case 26 /* SemicolonToken */: // foo; + case 56 /* QuestionToken */: // foo? + case 33 /* EqualsEqualsToken */: // foo == + case 35 /* EqualsEqualsEqualsToken */: // foo === + case 34 /* ExclamationEqualsToken */: // foo != + case 36 /* ExclamationEqualsEqualsToken */: // foo !== + case 54 /* AmpersandAmpersandToken */: // foo && + case 55 /* BarBarToken */: // foo || + case 51 /* CaretToken */: // foo ^ + case 49 /* AmpersandToken */: // foo & + case 50 /* BarToken */: // foo | + case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // 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. return true; - case 26 /* CommaToken */: // foo, - case 17 /* OpenBraceToken */: // foo { + case 27 /* CommaToken */: // foo, + case 18 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -19911,22 +20230,23 @@ var ts; function parsePrimaryExpression() { switch (token()) { case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseTokenNode(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedExpression(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 120 /* AsyncKeyword */: + case 121 /* 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. @@ -19934,76 +20254,76 @@ var ts; break; } return parseFunctionExpression(); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassExpression(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionExpression(); - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) { + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); - parseExpected(19 /* OpenParenToken */); + var node = createNodeWithJSDoc(195 /* ParenthesizedExpression */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(206 /* SpreadElement */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(208 /* SpreadElement */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : + return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* CommaToken */ ? createNode(210 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(185 /* ArrayLiteralExpression */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(187 /* ArrayLiteralExpression */); + parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); - if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 275 /* SpreadAssignment */; + if (parseOptionalToken(25 /* DotDotDotToken */)) { + node.kind = 277 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(51 /* ExclamationToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20011,30 +20331,30 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 274 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(58 /* EqualsToken */); + node.kind = 276 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(59 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 273 /* PropertyAssignment */; - parseExpected(56 /* ColonToken */); + node.kind = 275 /* PropertyAssignment */; + parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(186 /* ObjectLiteralExpression */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(188 /* ObjectLiteralExpression */); + parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -20047,10 +20367,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(194 /* FunctionExpression */); + var node = createNodeWithJSDoc(196 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -20058,7 +20378,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -20070,10 +20390,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(94 /* NewKeyword */); - if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(212 /* MetaProperty */, fullStart); - node_2.keywordToken = 94 /* NewKeyword */; + parseExpected(95 /* NewKeyword */); + if (parseOptional(24 /* DotToken */)) { + var node_2 = createNode(214 /* MetaProperty */, fullStart); + node_2.keywordToken = 95 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } @@ -20089,23 +20409,23 @@ var ts; } break; } - var node = createNode(190 /* NewExpression */, fullStart); + var node = createNode(192 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; - if (node.typeArguments || token() === 19 /* OpenParenToken */) { + if (node.typeArguments || token() === 20 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(216 /* Block */); - if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(218 /* Block */); + if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -20132,52 +20452,52 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(218 /* EmptyStatement */); - parseExpected(25 /* SemicolonToken */); + var node = createNode(220 /* EmptyStatement */); + parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(220 /* IfStatement */); - parseExpected(90 /* IfKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(222 /* IfStatement */); + parseExpected(91 /* IfKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(83 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(221 /* DoStatement */); - parseExpected(81 /* DoKeyword */); + var node = createNode(223 /* DoStatement */); + parseExpected(82 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); // 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(25 /* SemicolonToken */); + parseOptional(26 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(222 /* WhileStatement */); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(224 /* WhileStatement */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(88 /* ForKeyword */); - var awaitToken = parseOptionalToken(121 /* AwaitKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(89 /* ForKeyword */); + var awaitToken = parseOptionalToken(122 /* AwaitKeyword */); + parseExpected(20 /* OpenParenToken */); var initializer; - if (token() !== 25 /* SemicolonToken */) { - if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) { + if (token() !== 26 /* SemicolonToken */) { + if (token() === 105 /* VarKeyword */ || token() === 111 /* LetKeyword */ || token() === 77 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -20185,33 +20505,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(225 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(147 /* OfKeyword */) : parseOptional(147 /* OfKeyword */)) { + var forOfStatement = createNode(227 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(224 /* ForInStatement */, pos); + else if (parseOptional(93 /* InKeyword */)) { + var forInStatement = createNode(226 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(223 /* ForStatement */, pos); + var forStatement = createNode(225 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(25 /* SemicolonToken */); - if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(25 /* SemicolonToken */); - if (token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 21 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -20219,7 +20539,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 229 /* BreakStatement */ ? 73 /* BreakKeyword */ : 78 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -20227,8 +20547,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(228 /* ReturnStatement */); - parseExpected(96 /* ReturnKeyword */); + var node = createNode(230 /* ReturnStatement */); + parseExpected(97 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -20236,42 +20556,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(229 /* WithStatement */); - parseExpected(107 /* WithKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(231 /* WithStatement */); + parseExpected(108 /* WithKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(269 /* CaseClause */); - parseExpected(73 /* CaseKeyword */); + var node = createNode(271 /* CaseClause */); + parseExpected(74 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(270 /* DefaultClause */); - parseExpected(79 /* DefaultKeyword */); - parseExpected(56 /* ColonToken */); + var node = createNode(272 /* DefaultClause */); + parseExpected(80 /* DefaultKeyword */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 74 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(230 /* SwitchStatement */); - parseExpected(98 /* SwitchKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(232 /* SwitchStatement */); + parseExpected(99 /* SwitchKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(244 /* CaseBlock */); - parseExpected(17 /* OpenBraceToken */); + parseExpected(21 /* CloseParenToken */); + var caseBlock = createNode(246 /* CaseBlock */); + parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -20283,32 +20603,32 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(232 /* ThrowStatement */); - parseExpected(100 /* ThrowKeyword */); + var node = createNode(234 /* ThrowStatement */); + parseExpected(101 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(233 /* TryStatement */); - parseExpected(102 /* TryKeyword */); + var node = createNode(235 /* TryStatement */); + parseExpected(103 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 75 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 87 /* FinallyKeyword */) { - parseExpected(87 /* FinallyKeyword */); + if (!node.catchClause || token() === 88 /* FinallyKeyword */) { + parseExpected(88 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(272 /* CatchClause */); - parseExpected(74 /* CatchKeyword */); - if (parseOptional(19 /* OpenParenToken */)) { + var result = createNode(274 /* CatchClause */); + parseExpected(75 /* CatchKeyword */); + if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -20318,8 +20638,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(234 /* DebuggerStatement */); - parseExpected(78 /* DebuggerKeyword */); + var node = createNode(236 /* DebuggerStatement */); + parseExpected(79 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -20329,13 +20649,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 231 /* LabeledStatement */; + if (expression.kind === 72 /* Identifier */ && parseOptional(57 /* ColonToken */)) { + node.kind = 233 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 219 /* ExpressionStatement */; + node.kind = 221 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -20347,25 +20667,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 76 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 90 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* 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 @@ -20388,41 +20708,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 132 /* ReadonlyKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 133 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 144 /* GlobalKeyword */: + case 145 /* GlobalKeyword */: nextToken(); - return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; - case 91 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 72 /* Identifier */ || token() === 85 /* ExportKeyword */; + case 92 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 84 /* ExportKeyword */: + return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 85 /* ExportKeyword */: nextToken(); - if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ || - token() === 118 /* AsKeyword */) { + if (token() === 59 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 80 /* DefaultKeyword */ || + token() === 119 /* AsKeyword */) { return true; } continue; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: nextToken(); continue; default: @@ -20435,50 +20755,50 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 57 /* AtToken */: - case 25 /* SemicolonToken */: - case 17 /* OpenBraceToken */: - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 90 /* IfKeyword */: - case 81 /* DoKeyword */: - case 106 /* WhileKeyword */: - case 88 /* ForKeyword */: - case 77 /* ContinueKeyword */: - case 72 /* BreakKeyword */: - case 96 /* ReturnKeyword */: - case 107 /* WithKeyword */: - case 98 /* SwitchKeyword */: - case 100 /* ThrowKeyword */: - case 102 /* TryKeyword */: - case 78 /* DebuggerKeyword */: + case 58 /* AtToken */: + case 26 /* SemicolonToken */: + case 18 /* OpenBraceToken */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 91 /* IfKeyword */: + case 82 /* DoKeyword */: + case 107 /* WhileKeyword */: + case 89 /* ForKeyword */: + case 78 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 97 /* ReturnKeyword */: + case 108 /* WithKeyword */: + case 99 /* SwitchKeyword */: + case 101 /* ThrowKeyword */: + case 103 /* TryKeyword */: + case 79 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 76 /* ConstKeyword */: - case 84 /* ExportKeyword */: + case 77 /* ConstKeyword */: + case 85 /* ExportKeyword */: return isStartOfDeclaration(); - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 109 /* InterfaceKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 139 /* TypeKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 110 /* InterfaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 140 /* TypeKeyword */: + case 145 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 116 /* StaticKeyword */: + case 133 /* 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); @@ -20488,7 +20808,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */; + return isIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -20497,67 +20817,67 @@ var ts; } function parseStatement() { switch (token()) { - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: return parseEmptyStatement(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); - case 110 /* LetKeyword */: + case 105 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); + case 111 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); } break; - case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); - case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); - case 90 /* IfKeyword */: + case 90 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(239 /* FunctionDeclaration */)); + case 76 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(240 /* ClassDeclaration */)); + case 91 /* IfKeyword */: return parseIfStatement(); - case 81 /* DoKeyword */: + case 82 /* DoKeyword */: return parseDoStatement(); - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return parseWhileStatement(); - case 88 /* ForKeyword */: + case 89 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(226 /* ContinueStatement */); - case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(227 /* BreakStatement */); - case 96 /* ReturnKeyword */: + case 78 /* ContinueKeyword */: + return parseBreakOrContinueStatement(228 /* ContinueStatement */); + case 73 /* BreakKeyword */: + return parseBreakOrContinueStatement(229 /* BreakStatement */); + case 97 /* ReturnKeyword */: return parseReturnStatement(); - case 107 /* WithKeyword */: + case 108 /* WithKeyword */: return parseWithStatement(); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return parseSwitchStatement(); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return parseThrowStatement(); - case 102 /* TryKeyword */: + case 103 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return parseTryStatement(); - case 78 /* DebuggerKeyword */: + case 79 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 57 /* AtToken */: + case 58 /* AtToken */: return parseDeclaration(); - case 120 /* AsyncKeyword */: - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 83 /* EnumKeyword */: - case 84 /* ExportKeyword */: - case 91 /* ImportKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 117 /* AbstractKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 84 /* EnumKeyword */: + case 85 /* ExportKeyword */: + case 92 /* ImportKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 118 /* AbstractKeyword */: + case 116 /* StaticKeyword */: + case 133 /* ReadonlyKeyword */: + case 145 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -20566,7 +20886,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 124 /* DeclareKeyword */; + return modifier.kind === 125 /* DeclareKeyword */; } function parseDeclaration() { var node = createNodeWithJSDoc(0 /* Unknown */); @@ -20585,33 +20905,33 @@ var ts; } function parseDeclarationWorker(node) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: return parseVariableStatement(node); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassDeclaration(node); - case 109 /* InterfaceKeyword */: + case 110 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 139 /* TypeKeyword */: + case 140 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 83 /* EnumKeyword */: + case 84 /* EnumKeyword */: return parseEnumDeclaration(node); - case 144 /* GlobalKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 145 /* GlobalKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: nextToken(); switch (token()) { - case 79 /* DefaultKeyword */: - case 58 /* EqualsToken */: + case 80 /* DefaultKeyword */: + case 59 /* EqualsToken */: return parseExportAssignment(node); - case 118 /* AsKeyword */: + case 119 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -20620,7 +20940,7 @@ var ts; if (node.decorators || node.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(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(258 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -20631,10 +20951,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -20642,25 +20962,25 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 26 /* CommaToken */) { - return createNode(208 /* OmittedExpression */); + if (token() === 27 /* CommaToken */) { + return createNode(210 /* OmittedExpression */); } - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 56 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -20668,27 +20988,27 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(182 /* ObjectBindingPattern */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(184 /* ObjectBindingPattern */); + parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(183 /* ArrayBindingPattern */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(185 /* ArrayBindingPattern */); + parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier(); + return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); @@ -20697,10 +21017,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(235 /* VariableDeclaration */); + var node = createNode(237 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 71 /* Identifier */ && - token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 72 /* Identifier */ && + token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20710,14 +21030,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(236 /* VariableDeclarationList */); + var node = createNode(238 /* VariableDeclarationList */); switch (token()) { - case 104 /* VarKeyword */: + case 105 /* VarKeyword */: break; - case 110 /* LetKeyword */: + case 111 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -20733,7 +21053,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 147 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -20745,44 +21065,44 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 217 /* VariableStatement */; + node.kind = 219 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 237 /* FunctionDeclaration */; - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + node.kind = 239 /* FunctionDeclaration */; + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 155 /* Constructor */; - parseExpected(123 /* ConstructorKeyword */); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + node.kind = 157 /* Constructor */; + parseExpected(124 /* ConstructorKeyword */); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 154 /* MethodDeclaration */; + node.kind = 156 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 152 /* PropertyDeclaration */; - if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 154 /* PropertyDeclaration */; + if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20802,12 +21122,12 @@ var ts; return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.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. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -20815,13 +21135,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 57 /* AtToken */) { + if (token() === 58 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -20838,7 +21158,7 @@ var ts; } nextToken(); } - if (token() === 39 /* AsteriskToken */) { + if (token() === 40 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -20848,24 +21168,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* 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 === 136 /* SetKeyword */ || idToken === 125 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 137 /* SetKeyword */ || idToken === 126 /* 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 19 /* OpenParenToken */: // Method declaration - case 27 /* LessThanToken */: // Generic Method declaration - case 51 /* ExclamationToken */: // Non-null assertion on property name - case 56 /* ColonToken */: // Type Annotation for declaration - case 58 /* EqualsToken */: // Initializer for declaration - case 55 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* OpenParenToken */: // Method declaration + case 28 /* LessThanToken */: // Generic Method declaration + case 52 /* ExclamationToken */: // Non-null assertion on property name + case 57 /* ColonToken */: // Type Annotation for declaration + case 59 /* EqualsToken */: // Initializer for declaration + case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -20883,10 +21203,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(57 /* AtToken */)) { + if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(150 /* Decorator */, decoratorStart); + var decorator = createNode(152 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -20906,7 +21226,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 77 /* 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)) { @@ -20925,7 +21245,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -20935,21 +21255,21 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 25 /* SemicolonToken */) { - var result = createNode(215 /* SemicolonClassElement */); + if (token() === 26 /* SemicolonToken */) { + var result = createNode(217 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - if (token() === 123 /* ConstructorKeyword */) { + if (token() === 124 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); } if (isIndexSignature()) { @@ -20958,37 +21278,37 @@ 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() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 39 /* AsteriskToken */ || - token() === 21 /* OpenBracketToken */) { + token() === 40 /* AsteriskToken */ || + token() === 22 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(node); } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // '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(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 209 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 240 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(75 /* ClassKeyword */); + parseExpected(76 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21006,7 +21326,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 109 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21018,33 +21338,33 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(271 /* HeritageClause */); + ts.Debug.assert(tok === 86 /* ExtendsKeyword */ || tok === 109 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(273 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(209 /* ExpressionWithTypeArguments */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 27 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */) + return token() === 28 /* LessThanToken */ + ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 239 /* InterfaceDeclaration */; - parseExpected(109 /* InterfaceKeyword */); + node.kind = 241 /* InterfaceDeclaration */; + parseExpected(110 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21052,11 +21372,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 240 /* TypeAliasDeclaration */; - parseExpected(139 /* TypeKeyword */); + node.kind = 242 /* TypeAliasDeclaration */; + parseExpected(140 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -21066,18 +21386,18 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(276 /* EnumMember */); + var node = createNodeWithJSDoc(278 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 241 /* EnumDeclaration */; - parseExpected(83 /* EnumKeyword */); + node.kind = 243 /* EnumDeclaration */; + parseExpected(84 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21085,10 +21405,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(243 /* ModuleBlock */); - if (parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(245 /* ModuleBlock */); + if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -21096,20 +21416,20 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 242 /* ModuleDeclaration */; + node.kind = 244 /* ModuleDeclaration */; // 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 */; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(23 /* DotToken */) + node.body = parseOptional(24 /* DotToken */) ? parseModuleOrNamespaceDeclaration(createNode(0 /* Unknown */), 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 242 /* ModuleDeclaration */; - if (token() === 144 /* GlobalKeyword */) { + node.kind = 244 /* ModuleDeclaration */; + if (token() === 145 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -21118,7 +21438,7 @@ var ts; node.name = parseLiteralNode(); node.name.text = internIdentifier(node.name.text); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -21128,68 +21448,68 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 144 /* GlobalKeyword */) { + if (token() === 145 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(130 /* NamespaceKeyword */)) { + else if (parseOptional(131 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(129 /* ModuleKeyword */); - if (token() === 9 /* StringLiteral */) { + parseExpected(130 /* ModuleKeyword */); + if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } } return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 133 /* RequireKeyword */ && + return token() === 134 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 19 /* OpenParenToken */; + return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 41 /* SlashToken */; + return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 245 /* NamespaceExportDeclaration */; - parseExpected(118 /* AsKeyword */); - parseExpected(130 /* NamespaceKeyword */); + node.kind = 247 /* NamespaceExportDeclaration */; + parseExpected(119 /* AsKeyword */); + parseExpected(131 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(91 /* ImportKeyword */); + parseExpected(92 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 144 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 247 /* ImportDeclaration */; + node.kind = 249 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 39 /* AsteriskToken */ || // import * - token() === 17 /* OpenBraceToken */) { // import { + token() === 40 /* AsteriskToken */ || // import * + token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(143 /* FromKeyword */); + parseExpected(144 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 246 /* ImportEqualsDeclaration */; + node.kind = 248 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -21201,7 +21521,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(248 /* ImportClause */, fullStart); + var importClause = createNode(250 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -21210,8 +21530,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); + parseOptional(27 /* CommaToken */)) { + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(252 /* NamedImports */); } return finishNode(importClause); } @@ -21221,15 +21541,15 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(257 /* ExternalModuleReference */); - parseExpected(133 /* RequireKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(259 /* ExternalModuleReference */); + parseExpected(134 /* RequireKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { - if (token() === 9 /* StringLiteral */) { + if (token() === 10 /* StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -21244,9 +21564,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(249 /* NamespaceImport */); - parseExpected(39 /* AsteriskToken */); - parseExpected(118 /* AsKeyword */); + var namespaceImport = createNode(251 /* NamespaceImport */); + parseExpected(40 /* AsteriskToken */); + parseExpected(119 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -21259,14 +21579,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 252 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(255 /* ExportSpecifier */); + return parseImportOrExportSpecifier(257 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(251 /* ImportSpecifier */); + return parseImportOrExportSpecifier(253 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -21280,9 +21600,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(118 /* AsKeyword */); + parseExpected(119 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -21291,24 +21611,24 @@ var ts; else { node.name = identifierName; } - if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 253 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 253 /* ExportDeclaration */; - if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(143 /* FromKeyword */); + node.kind = 255 /* ExportDeclaration */; + if (parseOptional(40 /* AsteriskToken */)) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(254 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(256 /* 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() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(143 /* FromKeyword */); + if (token() === 144 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -21316,12 +21636,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 252 /* ExportAssignment */; - if (parseOptional(58 /* EqualsToken */)) { + node.kind = 254 /* ExportAssignment */; + if (parseOptional(59 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(79 /* DefaultKeyword */); + parseExpected(80 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -21336,10 +21656,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ - || node.kind === 247 /* ImportDeclaration */ - || node.kind === 252 /* ExportAssignment */ - || node.kind === 253 /* ExportDeclaration */ + || node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */ + || node.kind === 249 /* ImportDeclaration */ + || node.kind === 254 /* ExportAssignment */ + || node.kind === 255 /* ExportDeclaration */ ? node : undefined; } @@ -21352,7 +21672,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 91 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 92 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -21403,11 +21723,11 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); + var result = createNode(283 /* JSDocTypeExpression */); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } fixupParentReferences(result); return finishNode(result); @@ -21495,7 +21815,7 @@ var ts; } loop: while (true) { switch (token()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -21515,7 +21835,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -21566,7 +21886,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(289 /* JSDocComment */, start); + var result = createNode(291 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -21600,20 +21920,19 @@ var ts; } } var precedingLineBreak = scanner.hasPrecedingLineBreak(); - while ((precedingLineBreak && token() === 39 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; } - else if (token() === 39 /* AsteriskToken */) { + else if (token() === 40 /* AsteriskToken */) { precedingLineBreak = false; } nextJSDocToken(); } } function parseTag(indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getTokenPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); skipWhitespaceOrAsterisk(); @@ -21621,40 +21940,40 @@ var ts; switch (tagName.escapedText) { case "augments": case "extends": - tag = parseAugmentsTag(atToken, tagName); + tag = parseAugmentsTag(start, tagName); break; case "class": case "constructor": - tag = parseClassTag(atToken, tagName); + tag = parseClassTag(start, tagName); break; case "this": - tag = parseThisTag(atToken, tagName); + tag = parseThisTag(start, tagName); break; case "enum": - tag = parseEnumTag(atToken, tagName); + tag = parseEnumTag(start, tagName); break; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent); + return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, indent); case "return": case "returns": - tag = parseReturnTag(atToken, tagName); + tag = parseReturnTag(start, tagName); break; case "template": - tag = parseTemplateTag(atToken, tagName); + tag = parseTemplateTag(start, tagName); break; case "type": - tag = parseTypeTag(atToken, tagName); + tag = parseTypeTag(start, tagName); break; case "typedef": - tag = parseTypedefTag(atToken, tagName, indent); + tag = parseTypedefTag(start, tagName, indent); break; case "callback": - tag = parseCallbackTag(atToken, tagName, indent); + tag = parseCallbackTag(start, tagName, indent); break; default: - tag = parseUnknownTag(atToken, tagName); + tag = parseUnknownTag(start, tagName); break; } if (!tag.comment) { @@ -21684,7 +22003,7 @@ var ts; } indent = 0; break; - case 57 /* AtToken */: + case 58 /* AtToken */: scanner.setTextPos(scanner.getTextPos() - 1); // falls through case 1 /* EndOfFileToken */: @@ -21703,9 +22022,9 @@ var ts; indent += whitespace.length; } break; - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextJSDocToken() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextJSDocToken(); pushComment(scanner.getTokenText()); @@ -21713,7 +22032,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -21733,9 +22052,8 @@ var ts; removeTrailingWhitespace(comments); return comments.length === 0 ? undefined : comments.join(""); } - function parseUnknownTag(atToken, tagName) { - var result = createNode(292 /* JSDocTag */, atToken.pos); - result.atToken = atToken; + function parseUnknownTag(start, tagName) { + var result = createNode(294 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -21754,37 +22072,37 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { - if (token() === 13 /* NoSubstitutionTemplateLiteral */) { + if (token() === 14 /* NoSubstitutionTemplateLiteral */) { // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild return { name: createIdentifier(/*isIdentifier*/ true), isBracketed: false }; } // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptional(21 /* OpenBracketToken */); + var isBracketed = parseOptional(22 /* OpenBracketToken */); var name = parseJSDocEntityName(); if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(58 /* EqualsToken */)) { + if (parseOptionalToken(59 /* EqualsToken */)) { parseExpression(); } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; } } - function parseParameterOrPropertyTag(atToken, tagName, target, indent) { + function parseParameterOrPropertyTag(start, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); @@ -21794,15 +22112,14 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(303 /* JSDocPropertyTag */, atToken.pos) : - createNode(297 /* JSDocParameterTag */, atToken.pos); - var comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); + createNode(305 /* JSDocPropertyTag */, start) : + createNode(299 /* JSDocParameterTag */, start); + var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; result.name = name; @@ -21813,20 +22130,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) { + if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -21834,81 +22151,74 @@ var ts; } } } - function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 298 /* JSDocReturnTag */; })) { + function parseReturnTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(298 /* JSDocReturnTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(300 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } - function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocTypeTag */; })) { + function parseTypeTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocTypeTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(302 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } - function parseAugmentsTag(atToken, tagName) { - var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); - result.atToken = atToken; + function parseAugmentsTag(start, tagName) { + var result = createNode(295 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(209 /* ExpressionWithTypeArguments */); + var usedBrace = parseOptional(18 /* OpenBraceToken */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); if (usedBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var prop = createNode(187 /* PropertyAccessExpression */, node.pos); + while (parseOptional(24 /* DotToken */)) { + var prop = createNode(189 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); } return node; } - function parseClassTag(atToken, tagName) { - var tag = createNode(294 /* JSDocClassTag */, atToken.pos); - tag.atToken = atToken; + function parseClassTag(start, tagName) { + var tag = createNode(296 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } - function parseThisTag(atToken, tagName) { - var tag = createNode(299 /* JSDocThisTag */, atToken.pos); - tag.atToken = atToken; + function parseThisTag(start, tagName) { + var tag = createNode(301 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseEnumTag(atToken, tagName) { - var tag = createNode(296 /* JSDocEnumTag */, atToken.pos); - tag.atToken = atToken; + function parseEnumTag(start, tagName) { + var tag = createNode(298 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseTypedefTag(atToken, tagName, indent) { + function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); - typedefTag.atToken = atToken; + var typedefTag = createNode(304 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -21920,12 +22230,11 @@ var ts; var child = void 0; var jsdocTypeLiteral = void 0; var childTypeTag = void 0; - var start_3 = atToken.pos; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); } - if (child.kind === 300 /* JSDocTypeTag */) { + if (child.kind === 302 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21938,7 +22247,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -21956,8 +22265,8 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); + if (parseOptional(24 /* DotToken */)) { + var jsDocNamespaceNode = createNode(244 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21970,25 +22279,23 @@ var ts; } return typeNameOrNamespaceName; } - function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); - callbackTag.atToken = atToken; + function parseCallbackTag(start, tagName, indent) { + var callbackTag = createNode(297 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var start = scanner.getStartPos(); - var jsdocSignature = createNode(291 /* JSDocSignature */, start); + var jsdocSignature = createNode(293 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(57 /* AtToken */)) { + if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 298 /* JSDocReturnTag */) { + if (tag && tag.kind === 300 /* JSDocReturnTag */) { return tag; } } @@ -22030,10 +22337,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextJSDocToken()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) && + if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22046,13 +22353,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -22061,16 +22368,15 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getStartPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); skipWhitespace(); var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(atToken, tagName); + return target === 1 /* Property */ && parseTypeTag(start, tagName); case "prop": case "property": t = 1 /* Property */; @@ -22086,26 +22392,25 @@ var ts; if (!(target & t)) { return false; } - return parseParameterOrPropertyTag(atToken, tagName, target, indent); + return parseParameterOrPropertyTag(start, tagName, target, indent); } - function parseTemplateTag(atToken, tagName) { + function parseTemplateTag(start, tagName) { // the template tag looks like '@template {Constraint} T,U,V' var constraint; - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(148 /* TypeParameter */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); - } while (parseOptionalJsdoc(26 /* CommaToken */)); - var result = createNode(301 /* JSDocTemplateTag */, atToken.pos); - result.atToken = atToken; + } while (parseOptionalJsdoc(27 /* CommaToken */)); + var result = createNode(303 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22124,16 +22429,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* 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(23 /* DotToken */)) { + while (parseOptional(24 /* DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -22141,11 +22446,11 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(71 /* Identifier */, pos); + var result = createNode(72 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); nextJSDocToken(); @@ -22271,9 +22576,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 71 /* Identifier */: + case 72 /* Identifier */: return true; } return false; @@ -22851,10 +23156,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 71 /* Identifier */) { + if (lhs.kind === 72 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 99 /* ThisKeyword */) { + if (lhs.kind === 100 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -22911,7 +23216,8 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], - ["esnext.intl", "lib.esnext.intl.d.ts"] + ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.bigint", "lib.esnext.bigint.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -22968,6 +23274,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, { name: "traceResolution", type: "boolean", @@ -23018,11 +23331,11 @@ var ts; description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date }, { - name: "pretty", + name: "showConfig", type: "boolean", - showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + isCommandLineOnly: true, + description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, // Basic { @@ -23615,7 +23928,7 @@ var ts; { name: "maxNodeModuleJsDepth", type: "number", - // TODO: GH#27108 affectsModuleResolution: true, + affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, @@ -24071,6 +24384,9 @@ var ts; } var result = ts.parseJsonText(configFileName, configFileText); var cwd = host.getCurrentDirectory(); + result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd)); } ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile; @@ -24210,7 +24526,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 273 /* PropertyAssignment */) { + if (element.kind !== 275 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -24266,16 +24582,16 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 101 /* TrueKeyword */: + case 102 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -24292,13 +24608,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 200 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 202 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -24315,7 +24631,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -24355,6 +24671,115 @@ var ts; } return false; } + /** + * Generate an uncommented, complete tsconfig for use with "--showConfig" + * @param configParseResult options to be generated into tsconfig.json + * @param configFileName name of the parsed config file - output paths will be generated relative to this + * @param host provides current directory and case sensitivity services + */ + /** @internal */ + function convertToTSConfig(configParseResult, configFileName, host) { + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var files = ts.map(ts.filter(configParseResult.fileNames, !configParseResult.configFileSpecs ? function (_) { return false; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), f, getCanonicalFileName); }); + var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); + var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var _a; + return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), + exclude: configParseResult.configFileSpecs.validatedExcludeSpecs + } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + return config; + } + ts.convertToTSConfig = convertToTSConfig; + function filterSameAsDefaultInclude(specs) { + if (!ts.length(specs)) + return undefined; + if (ts.length(specs) !== 1) + return specs; + if (specs[0] === "**/*") + return undefined; + return specs; + } + function matchesSpecs(path, includeSpecs, excludeSpecs) { + if (!includeSpecs) + return function (_) { return false; }; + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + if (includeRe) { + if (excludeRe) { + return function (path) { return includeRe.test(path) && !excludeRe.test(path); }; + } + return function (path) { return includeRe.test(path); }; + } + if (excludeRe) { + return function (path) { return !excludeRe.test(path); }; + } + return function (_) { return false; }; + } + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + // this is of a type CommandLineOptionOfPrimitiveType + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + // There is a typeMap associated with this command-line option so use it to map value back to its name + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options, pathOptions) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); + var _loop_3 = function (name) { + if (ts.hasProperty(options, name)) { + // tsconfig only options cannot be specified via command line, + // so we can assume that only types that can appear here string | number | boolean + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + return "continue"; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap_1) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + if (pathOptions && optionDefinition.isFilePath) { + result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)); + } + else { + result.set(name, value); + } + } + else { + if (optionDefinition.type === "list") { + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 + } + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); + } + } + } + } + }; + for (var name in options) { + _loop_3(name); + } + return result; + } /** * Generate tsconfig configuration when running command line "--init" * @param options commandlineOptions to be generated into tsconfig.json @@ -24365,62 +24790,6 @@ var ts; var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var compilerOptionsMap = serializeCompilerOptions(compilerOptions); return writeConfigurations(); - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - // this is of a type CommandLineOptionOfPrimitiveType - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - // There is a typeMap associated with this command-line option so use it to map value back to its name - return ts.forEachEntry(customTypeMap, function (mapValue, key) { - if (mapValue === value) { - return key; - } - }); - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - var _loop_3 = function (name) { - if (ts.hasProperty(options, name)) { - // tsconfig only options cannot be specified via command line, - // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { - return "continue"; - } - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap_1) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result.set(name, value); - } - else { - if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); - } - } - } - } - }; - for (var name in options) { - _loop_3(name); - } - return result; - } function getDefaultValueForOption(option) { switch (option.type) { case "number": @@ -24809,20 +25178,24 @@ var ts; } function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) { extendedConfig = ts.normalizeSlashes(extendedConfig); - // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../"))) { - errors.push(createDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return undefined; - } - var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return undefined; + 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 */)) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; + } } + return extendedConfigPath; } - return extendedConfigPath; + // If the path isn't a rooted or relative path, resolve like a module + var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, /*cache*/ undefined, /*projectRefs*/ undefined, /*lookupConfig*/ true); + if (resolved.resolvedModule) { + return resolved.resolvedModule.resolvedFileName; + } + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; } function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors) { var _a; @@ -25272,7 +25645,7 @@ var ts; } } /** - * Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed. + * Produces a cleaned version of compiler options with personally identifying info (aka, paths) removed. * Also converts enum values back to strings. */ /* @internal */ @@ -25343,7 +25716,8 @@ var ts; Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; - Extensions[Extensions["DtsOnly"] = 3] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -25389,6 +25763,9 @@ var ts; return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state) || readPackageJsonPathField(jsonContent, "types", baseDirectory, state); } + function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) { + return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state); + } function readPackageJsonMainField(jsonContent, baseDirectory, state) { return readPackageJsonPathField(jsonContent, "main", baseDirectory, state); } @@ -25488,8 +25865,11 @@ var 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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { var traceEnabled = isTraceEnabled(options, host); + if (redirectedReference) { + options = redirectedReference.commandLine.options; + } var failedLookupLocations = []; var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -25510,6 +25890,9 @@ var ts; trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); } } + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var resolved = primaryLookup(); var primary = true; @@ -25519,13 +25902,12 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - if (!options.preserveSymlinks) { - resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); - } + var fileName = resolved.fileName, packageId = resolved.packageId; + var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -25534,7 +25916,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - return ts.forEach(typeRoots, function (typeRoot) { + return ts.firstDefined(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); var directoryExists = ts.directoryProbablyExists(candidateDirectory, host); @@ -25559,13 +25941,14 @@ var ts; } var result = void 0; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { - result = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined); + var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); + result = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = toSearchResult(nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true)); + result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - var resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25625,29 +26008,56 @@ var ts; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { - return createModuleResolutionCacheWithMaps(ts.createMap(), ts.createMap(), currentDirectory, getCanonicalFileName); + return createModuleResolutionCacheWithMaps(createCacheWithRedirects(), createCacheWithRedirects(), currentDirectory, getCanonicalFileName); } ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ + function createCacheWithRedirects() { + var ownMap = ts.createMap(); + var redirectsMap = ts.createMap(); + return { + ownMap: ownMap, + redirectsMap: redirectsMap, + getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, + clear: clear + }; + function getOrCreateMapOfCacheRedirects(redirectedReference) { + if (!redirectedReference) { + return ownMap; + } + var path = redirectedReference.sourceFile.path; + var redirects = redirectsMap.get(path); + if (!redirects) { + redirects = ts.createMap(); + redirectsMap.set(path, redirects); + } + return redirects; + } + function clear() { + ownMap.clear(); + redirectsMap.clear(); + } + } + ts.createCacheWithRedirects = createCacheWithRedirects; + /*@internal*/ function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; - function getOrCreateCacheForDirectory(directoryName) { + function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - var perFolderCache = directoryToModuleNameMap.get(path); - if (!perFolderCache) { - perFolderCache = ts.createMap(); - directoryToModuleNameMap.set(path, perFolderCache); - } - return perFolderCache; + return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap); } - function getOrCreateCacheForModuleName(nonRelativeModuleName) { + function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); - if (!perModuleNameCache) { - perModuleNameCache = createPerModuleNameCache(); - moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); } - return perModuleNameCache; + return result; } function createPerModuleNameCache() { var directoryPathMap = ts.createMap(); @@ -25722,13 +26132,19 @@ var ts; return perFolderCache && perFolderCache.get(moduleName); } ts.resolveModuleNameFromCache = resolveModuleNameFromCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); + if (redirectedReference) { + compilerOptions = redirectedReference.commandLine.options; + } if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var containingDirectory = ts.getDirectoryPath(containingFile); - var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference); var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -25750,10 +26166,10 @@ var ts; } switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); @@ -25762,7 +26178,7 @@ var ts; perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { // put result in per-module name cache - cache.getOrCreateCacheForModuleName(moduleName).set(containingDirectory, result); + cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result); } } } @@ -25838,6 +26254,9 @@ var ts; * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. */ function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) { + var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state); + if (resolved) + return resolved.value; if (!ts.isExternalModuleNameRelative(moduleName)) { return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state); } @@ -25845,6 +26264,16 @@ var ts; return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state); } } + function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { + var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + if (baseUrl && paths && !ts.pathIsRelative(moduleName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); + } + } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { if (!state.compilerOptions.rootDirs) { return undefined; @@ -25914,22 +26343,13 @@ var ts; return undefined; } function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var baseUrl = state.compilerOptions.baseUrl; if (!baseUrl) { return undefined; } if (state.traceEnabled) { trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); } - if (paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - var resolved = tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); - if (resolved) { - return resolved.value; - } - } var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName)); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate); @@ -25956,22 +26376,22 @@ var ts; return resolvedModule && resolvedModule.resolvedFileName; } ts.tryResolveJSModule = tryResolveJSModule; + var jsOnlyExtensions = [Extensions.JavaScript]; + var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; + var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { - return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true); + return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false); + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { + return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, jsOnly) { + function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; - var result = jsOnly ? - tryResolve(Extensions.JavaScript) : - (tryResolve(Extensions.TypeScript) || - tryResolve(Extensions.JavaScript) || - (compilerOptions.resolveJsonModule ? tryResolve(Extensions.Json) : undefined)); + var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); @@ -25981,13 +26401,13 @@ var ts; var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); if (resolved) { - return toSearchResult({ resolved: resolved, isExternalLibraryImport: ts.stringContains(resolved.path, ts.nodeModulesPathPart) }); + return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) }); } if (!ts.isExternalModuleNameRelative(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache); + var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved_1) return undefined; var resolvedValue = resolved_1.value; @@ -26053,6 +26473,11 @@ var ts; } /*@internal*/ ts.nodeModulesPathPart = "/node_modules/"; + /*@internal*/ + function pathContainsNodeModules(path) { + return ts.stringContains(path, ts.nodeModulesPathPart); + } + ts.pathContainsNodeModules = pathContainsNodeModules; /** * This will be called on the successfully resolved path from `loadModuleFromFile`. * (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.) @@ -26103,9 +26528,9 @@ var ts; * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { - if (extensions === Extensions.Json) { + if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, onlyRecordFailures, state); + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); @@ -26139,6 +26564,7 @@ var ts; return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); case Extensions.JavaScript: return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + case Extensions.TSConfig: case Extensions.Json: return tryExtension(".json" /* Json */); } @@ -26223,11 +26649,27 @@ var ts; } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { - var packageFile = jsonContent && (extensions !== Extensions.JavaScript && extensions !== Extensions.Json - ? readPackageJsonTypesFields(jsonContent, candidate, state) || - // When resolving typescript modules, try resolving using main field as well - (extensions === Extensions.TypeScript ? readPackageJsonMainField(jsonContent, candidate, state) : undefined) - : readPackageJsonMainField(jsonContent, candidate, state)); + var packageFile; + if (jsonContent) { + switch (extensions) { + case Extensions.JavaScript: + case Extensions.Json: + packageFile = readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.TypeScript: + // When resolving typescript modules, try resolving using main field as well + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.DtsOnly: + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state); + break; + case Extensions.TSConfig: + packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state); + break; + default: + return ts.Debug.assertNever(extensions); + } + } var loader = function (extensions, candidate, onlyRecordFailures, state) { var fromFile = tryFile(candidate, onlyRecordFailures, state); if (fromFile) { @@ -26246,7 +26688,7 @@ var ts; }; var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined; var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host); - var indexPath = ts.combinePaths(candidate, "index"); + var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index"); if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) { var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, /*ignoreCase*/ false); if (state.traceEnabled) { @@ -26273,6 +26715,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + case Extensions.TSConfig: case Extensions.Json: return extension === ".json" /* Json */; case Extensions.TypeScript: @@ -26290,15 +26733,15 @@ var ts; return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } ts.parsePackageName = parsePackageName; - function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache) { - return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache); + function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) { + return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference); } function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined); + return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined); } - function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state); @@ -26319,7 +26762,7 @@ var ts; if (packageResult) { return packageResult; } - if (extensions !== Extensions.JavaScript && extensions !== Extensions.Json) { + if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) { var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); var nodeModulesAtTypesExists = nodeModulesFolderExists; if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { @@ -26452,7 +26895,7 @@ var ts; return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + 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 }; @@ -26466,7 +26909,7 @@ var ts; return { value: resolvedUsingSettings }; } if (!ts.isExternalModuleNameRelative(moduleName)) { - var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName); + var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); // Climb up parent directories looking for a module. var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); @@ -26532,24 +26975,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 243 /* ModuleBlock */: { + case 245 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -26571,9 +27014,9 @@ var ts; }); return state_1; } - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(node); - case 71 /* Identifier */: + case 72 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -26734,7 +27177,7 @@ var ts; // 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 === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -26743,7 +27186,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -26755,36 +27198,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "__constructor" /* Constructor */; - case 163 /* FunctionType */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: return "__call" /* Call */; - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return "__new" /* New */; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "__index" /* Index */; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 149 /* Parameter */: + case 151 /* 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 === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (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; @@ -26882,7 +27325,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 === 252 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 254 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; } @@ -26909,7 +27352,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 257 /* ExportSpecifier */ || (node.kind === 248 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -26976,7 +27419,7 @@ var ts; // 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 !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -27008,7 +27451,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property intialization checks. - currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 157 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -27021,13 +27464,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -27070,8 +27513,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -27104,78 +27547,78 @@ var ts; return; } switch (node.kind) { - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: bindWhileStatement(node); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: bindDoStatement(node); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: bindForStatement(node); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: bindIfStatement(node); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: bindTryStatement(node); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: bindSwitchStatement(node); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: bindCaseBlock(node); break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: bindCaseClause(node); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: bindLabeledStatement(node); break; - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 277 /* SourceFile */: { + case 279 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -27186,26 +27629,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return hasNarrowableArgument(expr); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 200 /* PrefixUnaryExpression */: - return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 197 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 199 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || + return expr.kind === 72 /* Identifier */ || expr.kind === 100 /* ThisKeyword */ || expr.kind === 98 /* SuperKeyword */ || ts.isPropertyAccessExpression(expr) && isNarrowableReference(expr.expression) || ts.isElementAccessExpression(expr) && expr.argumentExpression && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && @@ -27220,7 +27663,7 @@ var ts; } } } - if (expr.expression.kind === 187 /* PropertyAccessExpression */ && + if (expr.expression.kind === 189 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -27234,32 +27677,32 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableReference(expr.left); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -27294,8 +27737,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 101 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 86 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 102 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 87 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -27333,34 +27776,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return parent.expression === node; - case 223 /* ForStatement */: - case 203 /* ConditionalExpression */: + case 225 /* ForStatement */: + case 205 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 193 /* ParenthesizedExpression */) { + if (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 202 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 54 /* BarBarToken */); + return node.kind === 204 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 193 /* ParenthesizedExpression */ || - node.parent.kind === 200 /* PrefixUnaryExpression */ && - node.parent.operator === 51 /* ExclamationToken */) { + while (node.parent.kind === 195 /* ParenthesizedExpression */ || + node.parent.kind === 202 /* PrefixUnaryExpression */ && + node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -27401,7 +27844,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 233 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -27435,13 +27878,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 225 /* ForOfStatement */) { + if (node.kind === 227 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 236 /* VariableDeclarationList */) { + if (node.initializer.kind !== 238 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -27463,7 +27906,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 228 /* ReturnStatement */) { + if (node.kind === 230 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -27483,7 +27926,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 229 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -27579,7 +28022,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 272 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -27646,14 +28089,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 223 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -27664,10 +28107,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 185 /* ArrayLiteralExpression */) { + else if (node.kind === 187 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 206 /* SpreadElement */) { + if (e.kind === 208 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -27675,16 +28118,16 @@ var ts; } } } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 273 /* PropertyAssignment */) { + if (p.kind === 275 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 274 /* ShorthandPropertyAssignment */) { + else if (p.kind === 276 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 275 /* SpreadAssignment */) { + else if (p.kind === 277 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -27692,7 +28135,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -27703,7 +28146,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 51 /* ExclamationToken */) { + if (node.operator === 52 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -27713,20 +28156,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -27740,7 +28183,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { + if (operator === 59 /* EqualsToken */ && node.left.kind === 190 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27751,7 +28194,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -27798,10 +28241,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 193 /* ParenthesizedExpression */) { + while (expr.kind === 195 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { + if (expr.kind === 196 /* FunctionExpression */ || expr.kind === 197 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -27809,7 +28252,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27818,54 +28261,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 266 /* JsxAttributes */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 268 /* JsxAttributes */: return 1 /* IsContainer */; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 287 /* JSDocFunctionType */: - case 163 /* FunctionType */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 164 /* ConstructorType */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 289 /* JSDocFunctionType */: + case 165 /* FunctionType */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 166 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 272 /* CatchClause */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 244 /* CaseBlock */: + case 274 /* CatchClause */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 246 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 216 /* Block */: + case 218 /* 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 @@ -27898,45 +28341,45 @@ 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 186 /* ObjectLiteralExpression */: - case 239 /* InterfaceDeclaration */: - case 266 /* JsxAttributes */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 188 /* ObjectLiteralExpression */: + case 241 /* InterfaceDeclaration */: + case 268 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 291 /* JSDocSignature */: - case 160 /* IndexSignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 287 /* JSDocFunctionType */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 293 /* JSDocSignature */: + case 162 /* IndexSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 242 /* TypeAliasDeclaration */: + case 181 /* 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 @@ -27957,11 +28400,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 277 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { + var body = node.kind === 279 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { + if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { return true; } } @@ -27989,7 +28432,7 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 9 /* StringLiteral */) { + if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; if (ts.hasZeroOrOneAsteriskCharacter(text)) { pattern = ts.tryParsePattern(text); @@ -28045,7 +28488,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 277 /* SpreadAssignment */ || prop.name.kind !== 72 /* Identifier */) { continue; } var identifier = prop.name; @@ -28057,7 +28500,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 275 /* PropertyAssignment */ || prop.kind === 276 /* ShorthandPropertyAssignment */ || prop.kind === 156 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -28089,10 +28532,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28123,7 +28566,7 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) { + if (!typeAlias.fullName || typeAlias.fullName.kind === 72 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); } @@ -28141,8 +28584,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 108 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 116 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 109 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 117 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !(node.flags & 4194304 /* Ambient */)) { // Report error only if there are no parse errors in file @@ -28178,7 +28621,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 71 /* Identifier */) { + if (inStrictMode && node.expression.kind === 72 /* 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); @@ -28189,7 +28632,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 71 /* Identifier */) { + if (name && name.kind === 72 /* 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 @@ -28230,8 +28673,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 277 /* SourceFile */ && - blockScopeContainer.kind !== 242 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 279 /* SourceFile */ && + blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -28257,7 +28700,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -28326,7 +28769,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 145 /* LastToken */) { + if (node.kind > 147 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -28388,7 +28831,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 71 /* Identifier */: + case 72 /* 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. @@ -28401,13 +28844,13 @@ var ts; break; } // falls through - case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { + case 100 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 276 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -28421,7 +28864,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -28446,142 +28889,155 @@ var ts; // Nothing to do break; default: - ts.Debug.fail("Unknown special property assignment kind"); + ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return checkStrictModeCatchClause(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkStrictModeWithStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 176 /* ThisType */: + case 178 /* ThisType */: seenThisKeyword = true; return; - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: break; // Binding the children will handle everything - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return bindTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return bindParameter(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return bindPropertyWorker(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* 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 */ : 67212223 /* MethodExcludes */); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: + case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 179 /* MappedType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 181 /* MappedType */: return bindAnonymousTypeWorker(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return bindFunctionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: + var assignmentKind = ts.getAssignmentDeclarationKind(node); + switch (assignmentKind) { + case 7 /* ObjectDefinePropertyValue */: + return bindObjectDefinePropertyAssignment(node); + case 8 /* ObjectDefinePropertyExports */: + return bindObjectDefinePropertyExport(node); + case 9 /* ObjectDefinePrototypeProperty */: + return bindObjectDefinePrototypeProperty(node); + case 0 /* None */: + break; // Nothing to do + default: + return ts.Debug.fail("Unknown call expression assignment declaration kind"); + } if (ts.isInJSFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return bindJsxAttributes(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return bindImportClause(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return bindExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 277 /* SourceFile */: + case 279 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 216 /* Block */: + case 218 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 297 /* JSDocParameterTag */: - if (node.parent.kind === 291 /* JSDocSignature */) { + case 299 /* JSDocParameterTag */: + if (node.parent.kind === 293 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { break; } // falls through - case 303 /* JSDocPropertyTag */: + case 305 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -28668,6 +29124,21 @@ var ts; } return true; } + function bindObjectDefinePropertyExport(node) { + if (!setCommonJsModuleIndicator(node)) { + return; + } + var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + } + return symbol; + }); + if (symbol) { + var flags = 4 /* Property */ | 1048576 /* ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + } + } function bindExportsPropertyAssignment(node) { // When we create a property via 'exports.foo = bar', the 'exports.foo' property access // expression is the declaration @@ -28704,17 +29175,17 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 58 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 59 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -28727,18 +29198,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -28747,10 +29218,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 99 /* ThisKeyword */) { + if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -28766,6 +29237,10 @@ var ts; var lhs = node.left; bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); } + function bindObjectDefinePrototypeProperty(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); + } /** * For `x.prototype.y = z`, declare a member `y` on `x` if `x` is a function or class, or not declared. * Note that jsdoc preceding an ExpressionStatement like `x.prototype.y;` is also treated as a declaration. @@ -28781,6 +29256,12 @@ var ts; classPrototype.parent = lhs; bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); } + function bindObjectDefinePropertyAssignment(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); + var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); + } function bindSpecialPropertyAssignment(node) { var lhs = node.left; // Class declarations in Typescript do not allow property declarations @@ -28809,16 +29290,12 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ - : propertyAccess.parent.parent.kind === 277 /* SourceFile */; + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; - namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_1); return symbol; @@ -28830,6 +29307,9 @@ var ts; } }); } + return namespaceSymbol; + } + function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) { return; } @@ -28837,10 +29317,18 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(propertyAccess)); + var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var isToplevel = ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ + : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** * Javascript expando values are: @@ -28857,6 +29345,9 @@ var ts; return true; } var node = symbol.valueDeclaration; + if (ts.isCallExpression(node)) { + return !!ts.getAssignedExpandoInitializer(node); + } var init = !node ? undefined : ts.isVariableDeclaration(node) ? node.initializer : ts.isBinaryExpression(node) ? node.right : @@ -28865,7 +29356,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 === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); } return false; } @@ -28907,7 +29398,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 238 /* ClassDeclaration */) { + if (node.kind === 240 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -28973,7 +29464,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 297 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { + if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -29050,7 +29541,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 174 /* InferType */) { + else if (node.parent.kind === 176 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -29078,11 +29569,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 220 /* EmptyStatement */) || // report error on class declarations - node.kind === 238 /* ClassDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 244 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -29126,18 +29617,17 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; } } - /* @internal */ function isExportsOrModuleExportsOrAlias(sourceFile, node) { return ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node) || @@ -29172,58 +29662,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 149 /* Parameter */: + case 151 /* Parameter */: return computeParameter(node, subtreeFlags); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 155 /* Constructor */: + case 157 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -29247,7 +29737,7 @@ var ts; transformFlags |= 8192 /* ContainsLexicalThis */; } } - if (expression.kind === 91 /* ImportKeyword */) { + if (expression.kind === 92 /* ImportKeyword */) { transformFlags |= 16777216 /* ContainsDynamicImport */; // A dynamic 'import()' call that contains a lexical 'this' will // require a captured 'this' when emitting down-level. @@ -29275,17 +29765,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 188 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 187 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 40 /* AsteriskAsteriskToken */ - || operatorTokenKind === 62 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ + || operatorTokenKind === 63 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 32 /* AssertES2016 */; } @@ -29329,8 +29819,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 210 /* AsExpression */ - || expressionKind === 192 /* TypeAssertionExpression */) { + if (expressionKind === 212 /* AsExpression */ + || expressionKind === 194 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -29387,11 +29877,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 85 /* ExtendsKeyword */: + case 86 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 108 /* ImplementsKeyword */: + case 109 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -29710,59 +30200,59 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 637535553 /* NodeExcludes */; switch (kind) { - case 120 /* AsyncKeyword */: - case 199 /* AwaitExpression */: + case 121 /* AsyncKeyword */: + case 201 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; break; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 211 /* NonNullExpression */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 213 /* NonNullExpression */: + case 133 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: - case 10 /* JsxText */: - case 261 /* JsxClosingElement */: - case 262 /* JsxFragment */: - case 263 /* JsxOpeningFragment */: - case 264 /* JsxClosingFragment */: - case 265 /* JsxAttribute */: - case 266 /* JsxAttributes */: - case 267 /* JsxSpreadAttribute */: - case 268 /* JsxExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 11 /* JsxText */: + case 263 /* JsxClosingElement */: + case 264 /* JsxFragment */: + case 265 /* JsxOpeningFragment */: + case 266 /* JsxClosingFragment */: + case 267 /* JsxAttribute */: + case 268 /* JsxAttributes */: + case 269 /* JsxSpreadAttribute */: + case 270 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - case 274 /* ShorthandPropertyAssignment */: - case 115 /* StaticKeyword */: - case 212 /* MetaProperty */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + case 276 /* ShorthandPropertyAssignment */: + case 116 /* StaticKeyword */: + case 214 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.hasExtendedUnicodeEscape) { transformFlags |= 192 /* AssertES2015 */; } @@ -29772,60 +30262,64 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ForOfStatement */: + case 9 /* BigIntLiteral */: + transformFlags |= 8 /* AssertESNext */; + break; + case 227 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 4194304 /* ContainsYield */; break; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 161 /* TypePredicate */: - case 162 /* TypeReference */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 165 /* TypeQuery */: - case 166 /* TypeLiteral */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 174 /* InferType */: - case 175 /* ParenthesizedType */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: - case 245 /* NamespaceExportDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 163 /* TypePredicate */: + case 164 /* TypeReference */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 167 /* TypeQuery */: + case 168 /* TypeLiteral */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 176 /* InferType */: + case 177 /* ParenthesizedType */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: + case 247 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -29842,43 +30336,43 @@ var ts; transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 131072 /* ContainsRestOrSpread */; break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; break; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 33554432 /* Super */; excludeFlags = 536872257 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 8192 /* ContainsLexicalThis */; break; - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; } excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 131072 /* ContainsRestOrSpread */; } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: excludeFlags = 638358849 /* ObjectLiteralExcludes */; if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -29896,8 +30390,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 185 /* ArrayLiteralExpression */: - case 190 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: + case 192 /* NewExpression */: excludeFlags = 637666625 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -29905,26 +30399,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -29938,68 +30432,68 @@ var ts; * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather * than calling this function. */ - /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { + if (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 185 /* ArrayLiteralExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: return 637666625 /* ArrayLiteralOrCallOrNewExcludes */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return 647001409 /* ModuleExcludes */; - case 149 /* Parameter */: + case 151 /* Parameter */: return 637535553 /* ParameterExcludes */; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return 653604161 /* ArrowFunctionExcludes */; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return 653620545 /* FunctionExcludes */; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return 639894849 /* VariableDeclarationListExcludes */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 638121281 /* ClassExcludes */; - case 155 /* Constructor */: + case 157 /* Constructor */: return 653616449 /* ConstructorExcludes */; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return 653616449 /* MethodOrAccessorExcludes */; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 137 /* StringKeyword */: - case 135 /* ObjectKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 138 /* StringKeyword */: + case 136 /* ObjectKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return 638358849 /* ObjectLiteralExcludes */; - case 272 /* CatchClause */: + case 274 /* CatchClause */: return 637797697 /* CatchClauseExcludes */; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return 637666625 /* BindingPatternExcludes */; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: - case 193 /* ParenthesizedExpression */: - case 97 /* SuperKeyword */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: + case 195 /* ParenthesizedExpression */: + case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 570426689 /* PropertyAccessExcludes */; default: return 637535553 /* NodeExcludes */; @@ -30060,7 +30554,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -30076,16 +30570,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { visitIndexType(type); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -30174,7 +30668,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 === 165 /* TypeQuery */) { + if (d.type && d.type.kind === 167 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -30264,6 +30758,7 @@ var ts; var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); @@ -30439,10 +30934,6 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { - var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); - return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; - }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isParameter); @@ -30475,6 +30966,7 @@ var ts; getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, + getObjectFlags: ts.getObjectFlags, isArrayLikeType: isArrayLikeType, isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, @@ -30482,7 +30974,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentExport: function (node, target) { return getSuggestionForNonexistentExport(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -30560,21 +31052,24 @@ var ts; var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(16384 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(65536 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */ | 134217728 /* ContainsWideningType */, "null"); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); - var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - falseType.flags |= 33554432 /* FreshLiteral */; - trueType.flags |= 33554432 /* FreshLiteral */; + 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"); trueType.regularType = regularTrueType; + trueType.freshType = trueType; + regularTrueType.regularType = regularTrueType; regularTrueType.freshType = trueType; falseType.regularType = regularFalseType; + falseType.freshType = falseType; + regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = createBooleanType([regularFalseType, regularTrueType]); // Also mark all combinations of fresh/regular booleans as "Boolean" so they print as `boolean` instead of `true | false` @@ -30582,15 +31077,18 @@ var ts; createBooleanType([regularFalseType, trueType]); createBooleanType([falseType, regularTrueType]); createBooleanType([falseType, trueType]); - var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(4096 /* Void */, "void"); - var neverType = createIntrinsicType(32768 /* Never */, "never"); - var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); + 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 implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; + var numberOrBigIntType = getUnionType([numberType, bigintType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -30603,16 +31101,15 @@ var ts; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var markerSuperType = createType(65536 /* TypeParameter */); - var markerSubType = createType(65536 /* TypeParameter */); + var markerSuperType = createType(262144 /* TypeParameter */); + var markerSubType = createType(262144 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(65536 /* TypeParameter */); + var markerOtherType = createType(262144 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignaturesArray = [resolvingSignature]; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var globals = ts.createSymbolTable(); /** Key is "/path/to/a.ts|/path/to/b.ts". */ @@ -30659,6 +31156,9 @@ var ts; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; var deferredGlobalExtractSymbol; + var deferredGlobalExcludeSymbol; + var deferredGlobalPickSymbol; + var deferredGlobalBigIntType; var allPotentiallyUnusedIdentifiers = ts.createMap(); // key is file name var flowLoopStart = 0; var flowLoopCount = 0; @@ -30666,6 +31166,7 @@ var ts; var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); + var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -30691,86 +31192,99 @@ var ts; TypeFacts[TypeFacts["None"] = 0] = "None"; TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["All"] = 4194303] = "All"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; // The following members encode facts about particular kinds of types for use in the getTypeFacts function. // The presence of a particular fact means that the given test is true for some (and possibly all) values // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 1972176] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 4184016] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 1970144] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 4181984] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 4079615] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 4194303] = "EmptyObjectFacts"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMapFromTemplate({ string: 1 /* TypeofEQString */, number: 2 /* TypeofEQNumber */, - boolean: 4 /* TypeofEQBoolean */, - symbol: 8 /* TypeofEQSymbol */, - undefined: 16384 /* EQUndefined */, - object: 16 /* TypeofEQObject */, - function: 32 /* TypeofEQFunction */ + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ }); var typeofNEFacts = ts.createMapFromTemplate({ - string: 128 /* TypeofNEString */, - number: 256 /* TypeofNENumber */, - boolean: 512 /* TypeofNEBoolean */, - symbol: 1024 /* TypeofNESymbol */, - undefined: 131072 /* NEUndefined */, - object: 2048 /* TypeofNEObject */, - function: 4096 /* TypeofNEFunction */ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ }); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, + bigint: bigintType, boolean: booleanType, symbol: esSymbolType, undefined: undefinedType @@ -30992,7 +31506,7 @@ var ts; (source.flags | target.flags) & 67108864 /* Assignment */) { ts.Debug.assert(source !== target); if (!(target.flags & 33554432 /* Transient */)) { - target = cloneSymbol(target); + target = cloneSymbol(resolveSymbol(target)); } // 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) { @@ -31023,7 +31537,7 @@ var ts; else if (target.flags & 1024 /* NamespaceModule */) { error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } - else { + else { // error var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); var message = isEitherEnum @@ -31088,7 +31602,8 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); + var targetSymbol = target.get(id); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -31150,7 +31665,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -31208,17 +31723,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 184 /* BindingElement */) { + if (declaration.kind === 186 /* 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, 184 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 186 /* 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, 235 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 237 /* VariableDeclaration */), usage); } - else if (declaration.kind === 235 /* VariableDeclaration */) { + else if (declaration.kind === 237 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -31237,12 +31752,12 @@ 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 === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 257 /* ExportSpecifier */ || (usage.parent.kind === 254 /* 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 === 252 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 254 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -31250,9 +31765,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 217 /* VariableStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 219 /* VariableStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -31273,16 +31788,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 152 /* PropertyDeclaration */ && + current.parent.kind === 154 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 154 /* MethodDeclaration */) { + if (declaration.kind === 156 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -31324,12 +31839,12 @@ 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 & 67897832 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 149 /* Parameter */ || - lastLocation.kind === 148 /* TypeParameter */ + lastLocation.kind === 151 /* Parameter */ || + lastLocation.kind === 150 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -31346,13 +31861,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 151 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 173 /* ConditionalType */) { + else if (location.kind === 175 /* 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; @@ -31366,14 +31881,14 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -31397,7 +31912,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 257 /* ExportSpecifier */)) { break; } } @@ -31411,13 +31926,13 @@ var ts; } } break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -31434,9 +31949,9 @@ var ts; } } break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* 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! @@ -31455,7 +31970,7 @@ var ts; } break loop; } - if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 209 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -31463,9 +31978,9 @@ var ts; } } break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 86 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { if (nameNotFoundMessage) { @@ -31483,9 +31998,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 241 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -31493,19 +32008,19 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -31518,7 +32033,7 @@ var ts; } } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -31527,7 +32042,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 === 149 /* Parameter */) { + if (location.parent && location.parent.kind === 151 /* Parameter */) { location = location.parent; } // @@ -31540,8 +32055,8 @@ var ts; location = location.parent; } break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -31560,7 +32075,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -31633,8 +32148,7 @@ var ts; } // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { - var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { + if (ts.some(result.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -31643,12 +32157,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: // For `namespace N { N; }` + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -31660,7 +32174,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 148 /* TypeParameter */) { + if (decl.kind === 150 /* 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 @@ -31715,10 +32229,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -31785,7 +32299,7 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 243 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -31820,13 +32334,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 248 /* ImportClause */: + case 250 /* ImportClause */: return node.parent; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -31836,7 +32350,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -32028,20 +32542,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 252 /* ExportAssignment */: - case 202 /* BinaryExpression */: + case 254 /* ExportAssignment */: + case 204 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -32102,11 +32616,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 255 /* ExportSpecifier */) { + else if (node.kind === 257 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -32124,17 +32638,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 71 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 72 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* QualifiedName */) { + if (entityName.kind === 72 /* Identifier */ || entityName.parent.kind === 148 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 248 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -32150,7 +32664,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); var symbol; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name).escapedText); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -32158,9 +32672,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { - var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 148 /* QualifiedName */ || name.kind === 189 /* PropertyAccessExpression */) { + var left = name.kind === 148 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 148 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -32243,6 +32757,9 @@ var ts; } function getDeclarationOfJSPrototypeContainer(symbol) { var decl = symbol.parent.valueDeclaration; + if (!decl) { + return undefined; + } var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) : ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) : undefined; @@ -32361,10 +32878,15 @@ var ts; return getPackagesSet().has(ts.getTypesPackageName(packageName)); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; + if (moduleSymbol) { + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + return getMergedSymbol(exported) || moduleSymbol; + } + return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || moduleSymbol.exports.size === 1) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } var merged = cloneSymbol(exported); @@ -32385,7 +32907,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -32453,7 +32975,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -32598,7 +33120,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 157 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -32621,7 +33143,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(131072 /* Object */); + var type = createType(524288 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -32676,12 +33198,12 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -32745,7 +33267,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 255 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -32781,7 +33303,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, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -32796,10 +33318,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: continue; default: return false; @@ -32916,10 +33438,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -32966,14 +33488,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 165 /* TypeQuery */ || + if (entityName.parent.kind === 167 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 147 /* ComputedPropertyName */) { + entityName.parent.kind === 149 /* ComputedPropertyName */) { // Typeof value meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || - entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 148 /* QualifiedName */ || entityName.kind === 189 /* PropertyAccessExpression */ || + entityName.parent.kind === 248 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -33022,15 +33544,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 166 /* ConstructorType */ : 165 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 161 /* ConstructSignature */ : 160 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 return writer; } } @@ -33095,7 +33617,8 @@ var ts; getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) } : undefined }, encounteredError: false, - visitedSymbols: undefined, + visitedTypes: undefined, + symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; @@ -33119,48 +33642,55 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + return ts.createKeywordTypeNode(143 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* StringKeyword */); + return ts.createKeywordTypeNode(138 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(134 /* NumberKeyword */); + return ts.createKeywordTypeNode(135 /* NumberKeyword */); + } + if (type.flags & 64 /* BigInt */) { + context.approximateLength += 6; + return ts.createKeywordTypeNode(146 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(122 /* BooleanKeyword */); + return ts.createKeywordTypeNode(123 /* BooleanKeyword */); } - if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { + if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToName(parentSymbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); + var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type + ? parentName + : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); + return enumLiteralName; } - if (type.flags & 544 /* EnumLike */) { - var name = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + if (type.flags & 1056 /* EnumLike */) { + return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); } - if (type.flags & 64 /* StringLiteral */) { + if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & 128 /* NumberLiteral */) { + if (type.flags & 256 /* NumberLiteral */) { context.approximateLength += (("" + type.value).length); return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 2048 /* BigIntLiteral */) { + context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; + return ts.createLiteralTypeNode((ts.createLiteral(type.value))); + } + if (type.flags & 512 /* BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; @@ -33171,33 +33701,33 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(142 /* UniqueKeyword */, ts.createKeywordTypeNode(139 /* SymbolKeyword */)); } - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(105 /* VoidKeyword */); + return ts.createKeywordTypeNode(106 /* VoidKeyword */); } - if (type.flags & 8192 /* Undefined */) { + if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(141 /* UndefinedKeyword */); } - if (type.flags & 16384 /* Null */) { + if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(95 /* NullKeyword */); + return ts.createKeywordTypeNode(96 /* NullKeyword */); } - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(131 /* NeverKeyword */); + return ts.createKeywordTypeNode(132 /* NeverKeyword */); } - if (type.flags & 1024 /* ESSymbol */) { + if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(138 /* SymbolKeyword */); + return ts.createKeywordTypeNode(139 /* SymbolKeyword */); } - if (type.flags & 16777216 /* NonPrimitive */) { + if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(135 /* ObjectKeyword */); + return ts.createKeywordTypeNode(136 /* ObjectKeyword */); } - if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { + if (type.flags & 262144 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -33211,16 +33741,16 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 65536 /* TypeParameter */ && + type.flags & 262144 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && @@ -33240,14 +33770,14 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); } - if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { - var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { + var types = type.flags & 1048576 /* 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) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 173 /* UnionType */ : 174 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -33258,23 +33788,23 @@ var ts; } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 4194304 /* Conditional */) { + if (type.flags & 16777216 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -33285,12 +33815,12 @@ var ts; context.approximateLength += 15; return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 8388608 /* Substitution */) { + if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -33309,6 +33839,7 @@ var ts; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); } function createAnonymousTypeNode(type) { + var typeId = "" + type.id; var symbol = type.symbol; var id; if (symbol) { @@ -33320,12 +33851,12 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 209 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67220415 /* Value */); } - else if (context.visitedSymbols && context.visitedSymbols.has(id)) { + else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { @@ -33334,18 +33865,34 @@ var ts; } else { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } } else { // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedSymbols) { - context.visitedSymbols = ts.createMap(); + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); } - context.visitedSymbols.set(id, true); + if (!context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + context.approximateLength += 3; + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); + } + context.symbolDepth.set(id, depth + 1); + context.visitedTypes.set(typeId, true); var result = createTypeNodeFromObjectType(type); - context.visitedSymbols.delete(id); + context.visitedTypes.delete(typeId); + context.symbolDepth.set(id, depth); return result; } } @@ -33359,11 +33906,11 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; + return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively + return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } @@ -33380,12 +33927,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 165 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* ConstructorType */, context); return signatureNode; } } @@ -33517,11 +34064,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 160 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -33572,12 +34119,12 @@ var ts; var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(55 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length) { var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 155 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -33590,9 +34137,9 @@ var ts; else { var savedFlags = context.flags; context.flags |= !!(ts.getCheckFlags(propertySymbol) & 2048 /* ReverseMapped */) ? 33554432 /* InReverseMappedType */ : 0; - var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(120 /* AnyKeyword */); context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -33643,7 +34190,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 137 /* StringKeyword */ : 134 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 138 /* StringKeyword */ : 135 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -33656,7 +34203,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -33667,7 +34214,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 157 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -33686,12 +34233,12 @@ var ts; returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 119 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 120 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(119 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(120 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -33720,9 +34267,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 297 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -33731,16 +34278,16 @@ var ts; var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; - var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; + var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 72 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 148 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -33754,7 +34301,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 184 /* BindingElement */) { + if (clone.kind === 186 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -33853,7 +34400,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -34053,10 +34600,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 24576 /* Nullable */)) { - if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { - var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 262144 /* Union */) { + 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 */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -34068,9 +34615,9 @@ var ts; result.push(t); } } - if (flags & 16384 /* Null */) + if (flags & 65536 /* Null */) result.push(nullType); - if (flags & 8192 /* Undefined */) + if (flags & 32768 /* Undefined */) result.push(undefinedType); return result || types; } @@ -34085,8 +34632,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); - if (node.kind === 240 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 177 /* ParenthesizedType */; }); + if (node.kind === 242 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -34094,11 +34641,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 243 /* ModuleBlock */ && + node.parent.kind === 245 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -34121,27 +34668,30 @@ var ts; var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { + if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + return ts.symbolName(symbol); + } return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 237 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 209 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 128 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 8192 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -34158,27 +34708,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: // 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 184 /* BindingElement */: + case 186 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 235 /* VariableDeclaration */: + case 237 /* 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 237 /* FunctionDeclaration */: - case 241 /* EnumDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 243 /* EnumDeclaration */: + case 248 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -34186,53 +34736,53 @@ var ts; 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 !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 155 /* Constructor */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 149 /* Parameter */: - case 243 /* ModuleBlock */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 162 /* TypeReference */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 175 /* ParenthesizedType */: + case 157 /* Constructor */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 151 /* Parameter */: + case 245 /* ModuleBlock */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 164 /* TypeReference */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 177 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: return false; // Type parameters are always visible - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 277 /* SourceFile */: - case 245 /* NamespaceExportDeclaration */: + case 279 /* SourceFile */: + case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return false; default: return false; @@ -34241,10 +34791,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 254 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 255 /* ExportSpecifier */) { + else if (node.parent.kind === 257 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -34340,12 +34890,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 235 /* VariableDeclaration */: - case 236 /* VariableDeclarationList */: - case 251 /* ImportSpecifier */: - case 250 /* NamedImports */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 237 /* VariableDeclaration */: + case 238 /* VariableDeclarationList */: + case 253 /* ImportSpecifier */: + case 252 /* NamedImports */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: return false; default: return true; @@ -34375,28 +34925,36 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 149 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); - if (source.flags & 32768 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); + if (source.flags & 131072 /* Never */) { return emptyObjectType; } - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } - var members = ts.createSymbolTable(); - var names = ts.createUnderscoreEscapedMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; - names.set(ts.getTextOfPropertyName(name), true); + var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); + if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) { + if (omitKeyType.flags & 131072 /* Never */) { + return source; + } + var pickTypeAlias = getGlobalPickSymbol(); + var excludeTypeAlias = getGlobalExcludeSymbol(); + if (!pickTypeAlias || !excludeTypeAlias) { + return errorType; + } + var pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]); + return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]); } - for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { - var prop = _b[_a]; - if (!names.has(prop.escapedName) + var members = ts.createSymbolTable(); + for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), omitKeyType) && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { - members.set(prop.escapedName, getNonReadonlySymbol(prop)); + members.set(prop.escapedName, getSpreadSymbol(prop)); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -34420,8 +34978,12 @@ var ts; if (isTypeAny(parentType)) { return parentType; } + // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation + if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + parentType = getNonNullableType(parentType); + } var type; - if (pattern.kind === 182 /* ObjectBindingPattern */) { + if (pattern.kind === 184 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -34439,51 +35001,9 @@ var ts; else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; - var isLate = isLateBindableName(name); - var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); - if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { - var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); - } - return anyType; - } - var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); - if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { - if (getIndexTypeOfType(parentType, 1 /* Number */)) { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); - } - else { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(parentType)); - } - } - return indexerType || anyType; - } - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - var nameType = isLate ? checkComputedPropertyName(name) : undefined; - var text = isLate ? getLateBoundNameFromType(nameType) : - isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : - ts.getTextOfPropertyName(name); - // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { - parentType = getNonNullableType(parentType); - } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); - } - return anyType; - } - var declaredType = getConstraintForLocation(getTypeOfPropertyOfType(parentType, text), declaration.name); - type = declaredType && getFlowTypeOfReference(declaration, declaredType) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return errorType; - } + var exprType = getLiteralTypeFromPropertyName(name); + var declaredType = checkIndexedAccessIndexType(getIndexedAccessType(parentType, exprType, name), name); + type = getFlowTypeOfReference(declaration, getConstraintForLocation(declaredType, declaration.name)); } } else { @@ -34519,8 +35039,8 @@ var ts; } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 8192 /* Undefined */)) { - type = getTypeWithFacts(type, 131072 /* NEUndefined */); + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */)) { + type = getTypeWithFacts(type, 524288 /* NEUndefined */); } return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkDeclarationInitializer(declaration)], 2 /* Subtype */) : @@ -34535,11 +35055,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 95 /* NullKeyword */ || expr.kind === 71 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 96 /* NullKeyword */ || expr.kind === 72 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 187 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -34549,11 +35069,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 224 /* ForInStatement */) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 226 /* ForInStatement */) { + var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); + return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* 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, @@ -34572,7 +35092,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 237 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* 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 @@ -34586,11 +35106,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); + if (func.kind === 159 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 158 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -34654,7 +35174,7 @@ var ts; var types; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - var expression = ts.isBinaryExpression(declaration) ? declaration : + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { @@ -34669,9 +35189,11 @@ var ts; definedInMethod = true; } } - jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + if (!ts.isCallExpression(expression)) { + jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } if (!jsdocType) { - (types || (types = [])).push(ts.isBinaryExpression(expression) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } var type = jsdocType; @@ -34685,11 +35207,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(98304 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -34730,8 +35252,33 @@ var ts; } /** If we don't have an explicit JSDoc type, get the type from the initializer. */ function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) { + if (ts.isCallExpression(expression)) { + if (resolvedSymbol) { + return getTypeOfSymbol(resolvedSymbol); // This shouldn't happen except under some hopefully forbidden merges of export assignments and object define assignments + } + var objectLitType = checkExpressionCached(expression.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + return valueType; + } + var getFunc = getTypeOfPropertyOfType(objectLitType, "get"); + if (getFunc) { + var getSig = getSingleCallSignature(getFunc); + if (getSig) { + return getReturnTypeOfSignature(getSig); + } + } + var setFunc = getTypeOfPropertyOfType(objectLitType, "set"); + if (setFunc) { + var setSig = getSingleCallSignature(setFunc); + if (setSig) { + return getTypeOfFirstParameterOfSignature(setSig); + } + } + return anyType; + } var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 131072 /* Object */ && + if (type.flags & 524288 /* Object */ && kind === 2 /* ModuleExports */ && symbol.escapedName === "export=" /* ExportEquals */) { var exportedType_1 = resolveStructuredTypeMembers(type); @@ -34765,9 +35312,9 @@ var ts; 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 === 155 /* Constructor */ || - thisContainer.kind === 237 /* FunctionDeclaration */ || - (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 157 /* Constructor */ || + thisContainer.kind === 239 /* FunctionDeclaration */ || + (thisContainer.kind === 196 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -34842,7 +35389,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 186 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -34865,7 +35412,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 182 /* ObjectBindingPattern */ + return pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -34887,7 +35434,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -34904,7 +35451,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 151 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -34944,12 +35491,12 @@ var ts; return emptyObjectType; } var type_1 = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression)); - if (type_1.flags & 131072 /* Object */) { + if (type_1.flags & 524288 /* Object */) { return getRegularTypeOfObjectLiteral(type_1); } return type_1; } - if (declaration.kind === 252 /* ExportAssignment */) { + if (declaration.kind === 254 /* ExportAssignment */) { return widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } // Handle variable, parameter or property @@ -34958,7 +35505,7 @@ var ts; } var type; if (ts.isInJSFile(declaration) && - (ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { type = getWidenedTypeFromAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) @@ -34995,6 +35542,14 @@ var ts; || ts.isBindingElement(declaration)) { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); } + // getTypeOfSymbol dispatches some JS merges incorrectly because their symbol flags are not mutually exclusive. + // Re-dispatch based on valueDeclaration.kind instead. + else if (ts.isEnumDeclaration(declaration)) { + type = getTypeOfFuncClassEnumModule(symbol); + } + else if (ts.isEnumMember(declaration)) { + type = getTypeOfEnumMember(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } @@ -35005,7 +35560,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -35032,8 +35587,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 159 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -35076,7 +35631,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -35084,7 +35639,7 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -35116,8 +35671,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 202 /* BinaryExpression */ || - declaration.kind === 187 /* PropertyAccessExpression */ && declaration.parent.kind === 202 /* BinaryExpression */) { + else if (declaration.kind === 204 /* BinaryExpression */ || + declaration.kind === 189 /* PropertyAccessExpression */ && declaration.parent.kind === 204 /* BinaryExpression */) { return getWidenedTypeFromAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -35229,7 +35784,7 @@ var ts; var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, check); } return false; @@ -35253,35 +35808,35 @@ var ts; return undefined; } switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 179 /* MappedType */: - case 173 /* ConditionalType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 181 /* MappedType */: + case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 179 /* MappedType */) { + if (node.kind === 181 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 173 /* ConditionalType */) { + else if (node.kind === 175 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && + (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */ || node.kind === 241 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -35289,7 +35844,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, 239 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -35298,9 +35853,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 238 /* ClassDeclaration */ || - node.kind === 207 /* ClassExpression */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || + node.kind === 209 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -35327,7 +35882,7 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } @@ -35370,7 +35925,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 & (131072 /* Object */ | 524288 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* 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); @@ -35380,7 +35935,18 @@ var ts; return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + if (baseConstructorType.flags & 262144 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(baseConstructorType); + var ctorReturn = unknownType; + if (constraint) { + var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + if (ctorSig[0]) { + ctorReturn = getReturnTypeOfSignature(ctorSig[0]); + } + } + addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; @@ -35409,7 +35975,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -35476,14 +36042,14 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || - !!(type.flags & 524288 /* Intersection */) && ts.every(type.types, isValidBaseType); + return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 241 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -35519,7 +36085,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */) { + if (declaration.kind === 241 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -35560,7 +36126,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -35577,7 +36143,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 242 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -35601,10 +36167,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 9 /* StringLiteral */) { + if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 202 /* BinaryExpression */) { + else if (expr.kind === 204 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -35615,15 +36181,15 @@ var ts; return !(member.flags & 4194304 /* Ambient */); } switch (expr.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 38 /* MinusToken */ && + case 202 /* PrefixUnaryExpression */: + return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -35637,10 +36203,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { + if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -35652,7 +36218,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -35664,7 +36230,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getFreshTypeOfLiteralType(getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member))); // TODO: GH#18217 @@ -35675,8 +36241,8 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 262144 /* Union */) { - enumType_1.flags |= 512 /* EnumLiteral */; + if (enumType_1.flags & 1048576 /* Union */) { + enumType_1.flags |= 1024 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; @@ -35699,7 +36265,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(65536 /* TypeParameter */); + var type = createType(262144 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -35743,22 +36309,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: - case 180 /* LiteralType */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: + case 182 /* LiteralType */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isThislessType(node.elementType); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -35784,7 +36351,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 157 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -35800,12 +36367,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -35849,7 +36416,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -35892,10 +36459,10 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -36060,7 +36627,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -36189,7 +36756,7 @@ var ts; function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { var s = signatureList_1[_i]; - if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { + if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) { return s; } } @@ -36223,8 +36790,7 @@ var ts; // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional // parameters and may differ in return types. When signatures differ in return types, the resulting return // type is the union of the constituent return types. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + function getUnionSignatures(signatureLists) { var result; for (var i = 0; i < signatureLists.length; i++) { for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { @@ -36270,8 +36836,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(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 0 /* Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -36367,7 +36933,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -36401,7 +36967,7 @@ var ts; var modifiers = getMappedTypeModifiers(type.mappedType); var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; - var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType), readonlyMask && indexInfo.isReadonly); + var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly); var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -36411,6 +36977,7 @@ var ts; inferredProp.nameType = prop.nameType; inferredProp.propertyType = getTypeOfSymbol(prop); inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -36429,12 +36996,12 @@ 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 ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; - addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include)); + addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); } if (modifiersType.flags & 1 /* Any */ || getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); @@ -36444,11 +37011,9 @@ var ts; } } else { - // First, if the constraint type is a type parameter, obtain the base constraint. Then, - // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. - // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + // If the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. + // Then iterate over the constituents of the key type. + var iterationType = constraintType.flags & 4194304 /* Index */ ? getIndexType(getApparentType(constraintType.type)) : constraintType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -36460,7 +37025,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 8576 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -36472,7 +37037,7 @@ var ts; // 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. prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; @@ -36508,8 +37073,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 177 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; + return constraintDeclaration.kind === 179 /* TypeOperator */ && + constraintDeclaration.operator === 129 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -36525,16 +37090,16 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 38 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 38 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -36553,7 +37118,7 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -36570,10 +37135,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 262144 /* Union */) { + else if (type.flags & 1048576 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -36581,7 +37146,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -36590,7 +37155,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -36614,7 +37179,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 - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { break; } } @@ -36624,12 +37189,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 786432 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { - return obj.properties.some(function (property) { + var list = obj.properties; + return list.some(function (property) { var name = property.name && ts.getTextOfPropertyName(property.name); var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && typeIsLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); @@ -36637,7 +37203,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 262144 /* Union */)) { + if (!(unionType.flags & 1048576 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -36656,9 +37222,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -36678,7 +37244,11 @@ var ts; function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = !(rootTrueType.flags & 33554432 /* Substitution */) + ? rootTrueType + : (rootTrueType.substitute).flags & 3 /* AnyOrUnknown */ + ? rootTrueType.typeVariable + : getIntersectionType([rootTrueType.substitute, rootTrueType.typeVariable]); type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -36695,7 +37265,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 32768 /* Never */)) { + if (!(instantiated.flags & 131072 /* Never */)) { return instantiated; } } @@ -36710,23 +37280,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 15794176 /* Instantiable */) { + if (t.flags & 63176704 /* 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 & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 262144 /* Union */)) { + if (!(constraint.flags & 1048576 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 16809468 /* DisjointDomains */) { + else if (t.flags & 67238908 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -36738,7 +37308,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 16809468 /* DisjointDomains */) { + if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -36748,11 +37318,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { + if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 1048576 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -36801,13 +37371,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 65536 /* TypeParameter */) { + if (t.flags & 262144 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 786432 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -36817,24 +37387,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 1048576 /* Index */) { + if (t.flags & 4194304 /* Index */) { return keyofConstraintType; } - if (t.flags & 2097152 /* IndexedAccess */) { + if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType, /*accessNode*/ undefined, errorType) : undefined; return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 4194304 /* Conditional */) { + if (t.flags & 16777216 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 8388608 /* Substitution */) { + if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -36906,21 +37476,22 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + var t = type.flags & 63176704 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 68 /* StringLike */ ? globalStringType : - t.flags & 168 /* NumberLike */ ? globalNumberType : - t.flags & 272 /* BooleanLike */ ? globalBooleanType : - t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : - t.flags & 1048576 /* Index */ ? keyofConstraintType : - t; + t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 132 /* StringLike */ ? globalStringType : + t.flags & 296 /* NumberLike */ ? globalNumberType : + t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 6 /* ESNext */) : + 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; } function createUnionOrIntersectionProperty(containingType, name) { var props; var indexTypes; - var isUnion = containingType.flags & 262144 /* Union */; + var isUnion = containingType.flags & 1048576 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -37033,7 +37604,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -37051,13 +37622,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -37071,7 +37642,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -37127,10 +37698,10 @@ 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 === 286 /* JSDocOptionalType */ + node.type && node.type.kind === 288 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -37164,7 +37735,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -37189,30 +37760,32 @@ var ts; } function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); - if (numTypeParameters) { - var numTypeArguments = ts.length(typeArguments); - if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { - if (!typeArguments) { - typeArguments = []; - } - // Map an unsatisfied type parameter with a default type. - // If a type parameter does not have a default type, or if the default type - // is a forward reference, the empty object type is used. - for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - for (var i = numTypeArguments; i < numTypeParameters; i++) { - var mapper = createTypeMapper(typeParameters, typeArguments); - var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { - defaultType = anyType; - } - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - typeArguments.length = typeParameters.length; - } + if (!numTypeParameters) { + return []; } - return typeArguments; + var numTypeArguments = ts.length(typeArguments); + if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { + var result = typeArguments ? typeArguments.slice() : []; + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + var baseDefaultType_1 = getDefaultTypeArgumentType(isJavaScriptImplicitAny); + var circularityMapper = createTypeMapper(typeParameters, ts.map(typeParameters, function () { return baseDefaultType_1; })); + for (var i = numTypeArguments; i < numTypeParameters; i++) { + result[i] = instantiateType(getConstraintFromTypeParameter(typeParameters[i]) || baseDefaultType_1, circularityMapper); + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, result); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { + defaultType = anyType; + } + result[i] = defaultType ? instantiateType(defaultType, mapper) : baseDefaultType_1; + } + result.length = typeParameters.length; + return result; + } + return typeArguments && typeArguments.slice(); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); @@ -37248,7 +37821,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 180 /* LiteralType */) { + if (type && type.kind === 182 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -37262,16 +37835,16 @@ 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 === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && + if ((declaration.kind === 158 /* GetAccessor */ || declaration.kind === 159 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = declaration.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 155 /* Constructor */ ? + var classType = declaration.kind === 157 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -37329,13 +37902,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return node.name.kind === 147 /* ComputedPropertyName */ + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return node.name.kind === 149 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -37410,7 +37983,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, func) { var parameterName = node.parameterName; var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 71 /* Identifier */) { + if (parameterName.kind === 72 /* Identifier */) { return createIdentifierTypePredicate(parameterName.escapedText, getTypePredicateParameterIndex(func.parameters, parameterName), type); } else { @@ -37420,7 +37993,7 @@ var ts; function getTypePredicateParameterIndex(parameterList, parameter) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 71 /* Identifier */ && param.name.escapedText === parameter.escapedText) { + if (param.name.kind === 72 /* Identifier */ && param.name.escapedText === parameter.escapedText) { return i; } } @@ -37460,7 +38033,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 155 /* Constructor */) { + if (declaration.kind === 157 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -37470,12 +38043,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 158 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 159 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -37553,7 +38126,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 + var isConstructor = signature.declaration.kind === 157 /* Constructor */ || signature.declaration.kind === 161 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -37567,7 +38140,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 134 /* NumberKeyword */ : 137 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 135 /* NumberKeyword */ : 138 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -37594,7 +38167,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 150 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -37602,13 +38175,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 174 /* InferType */) { + if (declaration.parent.kind === 176 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 162 /* TypeReference */) { + if (grandParent.kind === 164 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -37633,7 +38206,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 151 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -37657,7 +38230,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 150 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -37790,9 +38363,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -37836,7 +38409,7 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : + res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { @@ -37893,13 +38466,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(8388608 /* Substitution */); + var result = createType(33554432 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 170 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -37908,9 +38481,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -37921,7 +38494,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 162 /* TypeReference */ || node.kind === 181 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 164 /* TypeReference */ || node.kind === 183 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -37979,7 +38552,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -38022,9 +38595,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return declaration; } } @@ -38033,7 +38606,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 131072 /* Object */)) { + if (!(type.flags & 524288 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -38110,6 +38683,15 @@ var ts; function getGlobalExtractSymbol() { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } + function getGlobalExcludeSymbol() { + return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalPickSymbol() { + return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalBigIntType(reportErrors) { + return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors)) || emptyObjectType; + } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -38158,7 +38740,7 @@ var ts; if (arity) { typeParameters = new Array(arity); for (var i = 0; i < arity; i++) { - var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + var typeParameter = typeParameters[i] = createType(262144 /* TypeParameter */); if (i < maxLength) { var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); property.type = typeParameter; @@ -38180,7 +38762,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -38215,8 +38797,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 172 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 171 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -38263,16 +38845,17 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { + if (t.flags & 109440 /* Unit */ && combined & 109440 /* Unit */) { return true; } combined |= t.flags; - if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || - combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || - combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || - combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || - combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || - combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { + if (combined & 98304 /* Nullable */ && combined & (524288 /* Object */ | 67108864 /* NonPrimitive */) || + combined & 67108864 /* NonPrimitive */ && combined & (67238908 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || + combined & 132 /* StringLike */ && combined & (67238908 /* DisjointDomains */ & ~132 /* StringLike */) || + combined & 296 /* NumberLike */ && combined & (67238908 /* DisjointDomains */ & ~296 /* NumberLike */) || + combined & 2112 /* BigIntLike */ && combined & (67238908 /* DisjointDomains */ & ~2112 /* BigIntLike */) || + combined & 12288 /* ESSymbolLike */ && combined & (67238908 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || + combined & 49152 /* VoidLike */ && combined & (67238908 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return true; } } @@ -38280,20 +38863,18 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Union */) { + if (flags & 1048576 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + if (!(flags & 131072 /* Never */ || flags & 2097152 /* Intersection */ && isEmptyIntersectionType(type))) { includes |= flags & ~939524096 /* ConstructionFlags */; - if (flags & 3 /* AnyOrUnknown */) { - if (type === wildcardType) - includes |= 268435456 /* Wildcard */; - } - else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (type === wildcardType) + includes |= 268435456 /* Wildcard */; + if (!strictNullChecks && flags & 98304 /* Nullable */) { if (!(flags & 134217728 /* ContainsWideningType */)) includes |= 134217728 /* NonWideningType */; } @@ -38329,11 +38910,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 512 /* EnumLiteral */) { + if (first.flags & 1024 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -38358,10 +38939,11 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || - t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || - t.flags & 448 /* Literal */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 128 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || + t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38384,25 +38966,27 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + if (unionReduction !== 0 /* None */) { + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + } + switch (unionReduction) { + case 1 /* Literal */: + if (includes & 8576 /* StringOrNumberLiteralOrUnique */ | 512 /* BooleanLiteral */) { + removeRedundantLiteralTypes(typeSet, includes); + } + break; + case 2 /* Subtype */: + removeSubtypes(typeSet); + break; + } + if (typeSet.length === 0) { + return includes & 65536 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : + neverType; + } } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & 2240 /* StringOrNumberLiteralOrUnique */ | 256 /* BooleanLiteral */) { - removeRedundantLiteralTypes(typeSet, includes); - } - break; - case 2 /* Subtype */: - removeSubtypes(typeSet); - break; - } - if (typeSet.length === 0) { - return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : - includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : - neverType; - } - return getUnionTypeFromSortedList(typeSet, includes & 16748579 /* NotPrimitiveUnion */ ? 0 : 67108864 /* UnionOfPrimitiveTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, !(includes & 66994211 /* NotPrimitiveUnion */), aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -38439,7 +39023,7 @@ var ts; : !ts.isIdentifierTypePredicate(b); } // This function assumes the constituent type list is sorted and deduplicated. - function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) { + function getUnionTypeFromSortedList(types, primitiveTypesOnly, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { return neverType; } @@ -38449,10 +39033,11 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* Union */ | propagatedFlags); unionTypes.set(id, type); type.types = types; + type.primitiveTypesOnly = primitiveTypesOnly; /* Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. @@ -38474,11 +39059,14 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 536870912 /* EmptyObject */; + if (isEmptyAnonymousObjectType(type)) { + if (!(includes & 536870912 /* EmptyObject */)) { + includes |= 536870912 /* EmptyObject */; + typeSet.push(type); + } } else { includes |= flags & ~939524096 /* ConstructionFlags */; @@ -38486,7 +39074,7 @@ var ts; if (type === wildcardType) includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type)) { + else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !ts.contains(typeSet, type)) { typeSet.push(type); } } @@ -38506,9 +39094,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; + 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 */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38521,10 +39110,11 @@ 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 & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - undefined; + var primitive = type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + undefined; if (!primitive || !containsType(u.types, primitive)) { return false; } @@ -38537,13 +39127,16 @@ 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 (t.flags & 67108864 /* UnionOfPrimitiveTypes */) !== 0; }); + var index = ts.findIndex(types, function (t) { return !!(t.flags & 1048576 /* Union */) && t.primitiveTypesOnly; }); + if (index < 0) { + return false; + } var i = index + 1; // Remove all but the first union of primitive types and collect them in // the unionTypes array. while (i < types.length) { var t = types[i]; - if (t.flags & 67108864 /* UnionOfPrimitiveTypes */) { + if (t.flags & 1048576 /* Union */ && t.primitiveTypesOnly) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -38572,7 +39165,7 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 67108864 /* UnionOfPrimitiveTypes */); + types[index] = getUnionTypeFromSortedList(result, /*primitiveTypesOnly*/ true); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -38588,22 +39181,23 @@ var ts; function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 32768 /* Never */) { + if (includes & 131072 /* Never */) { return neverType; } if (includes & 1 /* Any */) { return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 24576 /* Nullable */) { - return includes & 8192 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* Nullable */) { + return includes & 32768 /* Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { + 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 */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { - typeSet.push(emptyObjectType); + if (includes & 536870912 /* EmptyObject */ && includes & 524288 /* Object */) { + ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { return unknownType; @@ -38611,8 +39205,8 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 262144 /* Union */) { - if (includes & 67108864 /* UnionOfPrimitiveTypes */ && intersectUnionsOfPrimitiveTypes(typeSet)) { + if (includes & 1048576 /* 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. @@ -38620,15 +39214,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(524288 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(2097152 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -38645,7 +39239,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(1048576 /* Index */); + var result = createType(4194304 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -38655,14 +39249,22 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } - function getLiteralTypeFromPropertyName(prop, include) { + function getLiteralTypeFromPropertyName(name) { + return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : + getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); + } + function getBigIntLiteralType(node) { + return getLiteralType({ + negative: false, + base10Value: ts.parsePseudoBigInt(node.text) + }); + } + function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : - getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { return type; @@ -38670,8 +39272,8 @@ var ts; } return neverType; } - function getLiteralTypeFromPropertyNames(type, include) { - return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromPropertyName(t, include); })); + function getLiteralTypeFromProperties(type, include) { + return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromProperty(t, include); })); } function getNonEnumNumberIndexInfo(type) { var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); @@ -38679,16 +39281,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromProperties(type, 128 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 /* StringLiteral */ | 8192 /* UniqueESSymbol */)]) : + getLiteralTypeFromProperties(type, 8576 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -38699,17 +39301,17 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 32768 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 128 /* KeyOfKeyword */: + case 129 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 141 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ + case 142 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 139 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; @@ -38718,7 +39320,7 @@ var ts; return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(2097152 /* IndexedAccess */); + var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; @@ -38739,28 +39341,32 @@ var ts; if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { return true; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { return isJSLiteralType(getResolvedBaseConstraint(type)); } return false; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol, missingType) { - var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; - var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - undefined; + var accessExpression = accessNode && accessNode.kind === 190 /* ElementAccessExpression */ ? accessNode : undefined; + var propName = isTypeUsableAsLateBoundName(indexType) + ? getLateBoundNameFromType(indexType) + : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) + ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) + : accessNode && ts.isPropertyName(accessNode) + // late bound names are handled in the first branch, so here we only need to handle normal names + ? ts.getPropertyNameForPropertyNameNode(accessNode) + : undefined; if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 100 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); return missingType; @@ -38776,22 +39382,22 @@ var ts; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; })) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; }); } } - if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 32768 /* Never */)) { + if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { + if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -38799,7 +39405,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 32768 /* Never */) { + if (indexType.flags & 131072 /* Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -38832,8 +39438,8 @@ var ts; return anyType; } if (accessNode) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + var indexNode = getIndexNodeForAccessExpression(accessNode); + if (indexType.flags & (128 /* StringLiteral */ | 256 /* 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 */)) { @@ -38848,14 +39454,33 @@ var ts; } return missingType; } + function getIndexNodeForAccessExpression(accessNode) { + return accessNode.kind === 190 /* ElementAccessExpression */ + ? accessNode.argumentExpression + : accessNode.kind === 180 /* IndexedAccessType */ + ? accessNode.indexType + : accessNode.kind === 149 /* ComputedPropertyName */ + ? accessNode.expression + : accessNode; + } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */); } function getSimplifiedType(type) { - return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + } + function distributeIndexOverObjectType(objectType, indexType) { + // (T | U)[K] -> T[K] | U[K] + if (objectType.flags & 1048576 /* Union */) { + return mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); + } + // (T & U)[K] -> T[K] & U[K] + if (objectType.flags & 2097152 /* Intersection */) { + return getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + } } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -38869,18 +39494,14 @@ var ts; var objectType = getSimplifiedType(type.objectType); var indexType = getSimplifiedType(type.indexType); // T[A | B] -> T[A] | T[B] - if (indexType.flags & 262144 /* Union */) { + if (indexType.flags & 1048576 /* Union */) { return type.simplified = mapType(indexType, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t)); }); } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 15794176 /* Instantiable */)) { - // (T | U)[K] -> T[K] | U[K] - if (objectType.flags & 262144 /* Union */) { - return type.simplified = mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); - } - // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 524288 /* Intersection */) { - return type.simplified = getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + if (!(indexType.flags & 63176704 /* Instantiable */)) { + var simplified = distributeIndexOverObjectType(objectType, indexType); + if (simplified) { + return type.simplified = simplified; } } // So ultimately: @@ -38892,7 +39513,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 65536 /* TypeParameter */) { + if (objectType.flags & 262144 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -38915,7 +39536,7 @@ var ts; // 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 === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 180 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -38931,7 +39552,7 @@ 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 = getApparentType(objectType); - if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { @@ -38962,7 +39583,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -38984,7 +39605,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; + return type.flags & 33554432 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -38995,7 +39616,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 63176704 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -39034,7 +39655,7 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(4194304 /* Conditional */); + var result = createType(16777216 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -39066,7 +39687,7 @@ var ts; return true; } while (node) { - if (node.kind === 173 /* ConditionalType */) { + if (node.kind === 175 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -39089,7 +39710,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -39209,6 +39830,9 @@ var ts; function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } + function isNonGenericObjectType(type) { + return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + } /** * Since the source of spread types are object literals, which are not binary, * this function should be called in a left folding style, with left = previous result of getSpreadType @@ -39221,21 +39845,37 @@ var ts; if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { return unknownType; } - if (left.flags & 32768 /* Never */) { + if (left.flags & 131072 /* Never */) { return right; } - if (right.flags & 32768 /* Never */) { + if (right.flags & 131072 /* Never */) { return left; } - if (left.flags & 262144 /* Union */) { + if (left.flags & 1048576 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 262144 /* Union */) { + if (right.flags & 1048576 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { + if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { return left; } + if (isGenericObjectType(left) || isGenericObjectType(right)) { + if (isEmptyObjectType(left)) { + return right; + } + // 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 */) { + var types = left.types; + var lastLeft = types[types.length - 1]; + if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { + return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, typeFlags, objectFlags)])); + } + } + return getIntersectionType([left, right]); + } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); var stringIndexInfo; @@ -39255,7 +39895,7 @@ var ts; skippedPrivateMembers.set(rightProp.escapedName, true); } else if (isSpreadableProperty(rightProp)) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSpreadSymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -39270,7 +39910,7 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -39279,27 +39919,28 @@ var ts; } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSpreadSymbol(leftProp)); } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; - spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); + spread.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 1024 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */) - ? !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }) - : !(prop.flags & 65536 /* SetAccessor */); // Setter without getter is not spreadable + return !(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }); } - function getNonReadonlySymbol(prop) { - if (!isReadonlySymbol(prop)) { + function getSpreadSymbol(prop) { + var isReadonly = isReadonlySymbol(prop); + var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (!isReadonly && !isSetonlyAccessor) { return prop; } var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); var result = createSymbol(flags, prop.escapedName); - result.type = getTypeOfSymbol(prop); + result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = prop.nameType; result.syntheticOrigin = prop; @@ -39318,10 +39959,11 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 448 /* Literal */ && !(type.flags & 33554432 /* FreshLiteral */)) { - if (!type.freshType) { // NOTE: Safe because all freshable intrinsics always have fresh types already - var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); + if (type.flags & 2944 /* Literal */) { + if (!type.freshType) { + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; + freshType.freshType = freshType; type.freshType = freshType; } return type.freshType; @@ -39329,21 +39971,27 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + return type.flags & 2944 /* Literal */ ? type.regularType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : type; } + function isFreshLiteralType(type) { + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', // where NNN is the text representation of a numeric literal and SSS are the characters // of a string literal. For literal enum members we use 'EEE#NNN' and 'EEE@SSS', where // EEE is a unique id for the containing enum type. - var qualifier = typeof value === "number" ? "#" : "@"; - var key = enumId ? enumId + qualifier + value : qualifier + value; + var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; + var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value); var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 256 /* NumberLiteral */ : + typeof value === "string" ? 128 /* StringLiteral */ : 2048 /* BigIntLiteral */) | + (enumId ? 1024 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); + type.regularType = type; } return type; } @@ -39355,7 +40003,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(2048 /* UniqueESSymbol */); + var type = createType(8192 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -39370,9 +40018,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 241 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 157 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -39388,87 +40036,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 120 /* AnyKeyword */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return anyType; - case 142 /* UnknownKeyword */: + case 143 /* UnknownKeyword */: return unknownType; - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return stringType; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return numberType; - case 122 /* BooleanKeyword */: + case 146 /* BigIntKeyword */: + return bigintType; + case 123 /* BooleanKeyword */: return booleanType; - case 138 /* SymbolKeyword */: + case 139 /* SymbolKeyword */: return esSymbolType; - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return voidType; - case 140 /* UndefinedKeyword */: + case 141 /* UndefinedKeyword */: return undefinedType; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullType; - case 131 /* NeverKeyword */: + case 132 /* NeverKeyword */: return neverType; - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return getTypeFromTypeReference(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return booleanType; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 175 /* ParenthesizedType */: - case 170 /* RestType */: - case 285 /* JSDocNonNullableType */: - case 281 /* JSDocTypeExpression */: + case 177 /* ParenthesizedType */: + case 172 /* RestType */: + case 287 /* JSDocNonNullableType */: + case 283 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 174 /* InferType */: + case 176 /* InferType */: return getTypeFromInferTypeNode(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -39549,10 +40199,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; + return type.flags & 262144 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(65536 /* TypeParameter */); + var result = createType(262144 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -39598,7 +40248,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -39678,8 +40328,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 146 /* QualifiedName */ || - node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 148 /* QualifiedName */ || + node.parent.kind === 164 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -39687,19 +40337,19 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 218 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 176 /* ThisType */: + case 178 /* ThisType */: return !!tp.isThisType; - case 71 /* Identifier */: + case 72 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -39707,9 +40357,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 1048576 /* Index */) { + if (constraintType.flags & 4194304 /* Index */) { var typeVariable = constraintType.type; - if (typeVariable.flags & 65536 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeParameter */) { return typeVariable; } } @@ -39739,7 +40389,7 @@ var ts; } type.instantiating = true; var result = mapType(mappedTypeVariable, function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */) && t !== wildcardType) { + if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType) { var replacementMapper = createReplacementMapper(typeVariable, t, mapper); return isArrayType(t) ? createArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : isReadonlyArrayType(t) ? createReadonlyArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : @@ -39770,7 +40420,7 @@ var ts; var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper) { @@ -39815,7 +40465,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -39838,10 +40488,10 @@ var ts; } function instantiateTypeWorker(type, mapper) { var flags = type.flags; - if (flags & 65536 /* TypeParameter */) { + if (flags & 262144 /* TypeParameter */) { return mapper(type); } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or @@ -39860,32 +40510,32 @@ var ts; } return type; } - if (flags & 262144 /* Union */ && !(flags & 32764 /* Primitive */)) { + if (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 1048576 /* Index */) { + if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } return type; } function getWildcardInstantiation(type) { - return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : + return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -39894,34 +40544,34 @@ 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 !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 202 /* BinaryExpression */: - return node.operatorToken.kind === 54 /* BarBarToken */ && + case 204 /* BinaryExpression */: + return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 266 /* JsxAttributes */: - return ts.some(node.properties, isContextSensitive); - case 265 /* JsxAttribute */: { + case 268 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); + case 267 /* 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 268 /* JsxExpression */: { + case 270 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -39938,7 +40588,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* 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); @@ -39951,14 +40601,14 @@ var ts; function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 216 /* Block */ ? false : isContextSensitive(body); + return body.kind === 218 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -39969,7 +40619,7 @@ var ts; return result; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -39984,6 +40634,9 @@ var ts; function compareTypesAssignable(source, target) { return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; } + function compareTypesSubtypeOf(source, target) { + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); } @@ -39999,11 +40652,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : - target === globalObjectType ? !!(source.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 131072 /* Object */) && isFunctionObjectType(source) : + 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) || emptyObjectType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)); } /** @@ -40041,7 +40694,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 4194304 /* Conditional */ || (type.flags & 524288 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage) { if (!node || isOrHasGenericConditional(target)) @@ -40050,23 +40703,23 @@ var ts; return true; } switch (node.kind) { - case 268 /* JsxExpression */: - case 193 /* ParenthesizedExpression */: + case 270 /* JsxExpression */: + case 195 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage); } break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return elaborateJsxAttributes(node, source, target, relation); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation); } return false; @@ -40078,7 +40731,7 @@ var ts; var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 32768 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = {}; checkTypeAssignableTo(source, target, node, headMessage, /*containingChain*/ undefined, resultObj); @@ -40135,8 +40788,10 @@ var ts; var reportedError = false; 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 sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); var targetPropType = getIndexedAccessType(target, nameType, /*accessNode*/ undefined, errorType); + if (targetPropType === errorType || targetPropType.flags & 8388608 /* IndexedAccess */) + continue; // Don't elaborate on indexes on generic variables + var sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); if (sourcePropType !== errorType && targetPropType !== errorType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined); if (elaborated) { @@ -40158,7 +40813,7 @@ var ts; var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; var issuedElaboration = false; if (!targetProp) { - var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(nameType, 296 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || getIndexInfoOfType(target, 0 /* String */) || undefined; if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) { @@ -40169,7 +40824,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) { - addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + 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))); } } } @@ -40262,17 +40917,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 32768 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 157 /* SetAccessor */: return [3 /*break*/, 2]; - case 156 /* GetAccessor */: return [3 /*break*/, 2]; - case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 159 /* SetAccessor */: return [3 /*break*/, 2]; + case 158 /* GetAccessor */: return [3 /*break*/, 2]; + case 156 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 276 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 275 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -40331,8 +40986,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && - kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 156 /* MethodDeclaration */ && + kind !== 155 /* MethodSignature */ && kind !== 157 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -40366,7 +41021,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : @@ -40458,12 +41113,15 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 16777216 /* NonPrimitive */ ? true : - type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 524288 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* Object */ ? 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) : false; } + function isEmptyAnonymousObjectType(type) { + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && isEmptyObjectType(type); + } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { if (sourceSymbol === targetSymbol) { return true; @@ -40500,43 +41158,45 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) return true; - if (t & 32768 /* Never */) + if (t & 131072 /* Never */) return false; - if (s & 68 /* StringLike */ && t & 4 /* String */) + if (s & 132 /* StringLike */ && t & 4 /* String */) return true; - if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && - t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && + t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 168 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && - t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && + t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true; - if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) + if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + return true; + if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true; if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { - if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { + if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 448 /* Literal */ && t & 448 /* Literal */ && + if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) + if (s & 32768 /* Undefined */ && (!strictNullChecks || t & (32768 /* Undefined */ | 16384 /* Void */))) return true; - if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) + if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */)) return true; - if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) + if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) return true; - if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) + if (s & 8192 /* UniqueESSymbol */ || t & 8192 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -40544,30 +41204,30 @@ var ts; // 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 */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { + if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { + if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -40587,6 +41247,7 @@ var ts; */ function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; + var relatedInfo; var maybeKeys; var sourceStack; var targetStack; @@ -40594,7 +41255,7 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var isIntersectionConstituent = false; + var suppressNextError = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { @@ -40621,15 +41282,27 @@ var ts; } } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (relatedInfo) { + addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + } if (errorOutputContainer) { errorOutputContainer.error = diag; } diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { + function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); + } + function associateRelatedInfo(info) { + ts.Debug.assert(!!errorInfo); + if (!relatedInfo) { + relatedInfo = [info]; + } + else { + relatedInfo.push(info); + } } function reportRelationError(message, source, target) { var sourceType = typeToString(source); @@ -40662,7 +41335,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 786432 /* UnionOrIntersection */)) { + if (!(type.flags & 3145728 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -40670,7 +41343,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 24576 /* Nullable */) { + if (t.flags & 98304 /* Nullable */) { continue; } if (seenNonNullable) { @@ -40686,24 +41359,24 @@ var ts; * * Ternary.Maybe if they are related with assumptions of other relationships, or * * Ternary.False if they are not related. */ - function isRelatedTo(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage, isApparentIntersectionConstituent) { if (reportErrors === void 0) { reportErrors = false; } - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } - if (source.flags & 8388608 /* Substitution */) { + if (source.flags & 33554432 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 8388608 /* Substitution */) { + if (target.flags & 33554432 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8388608 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 2097152 /* IndexedAccess */) { + if (target.flags & 8388608 /* IndexedAccess */) { target = getSimplifiedType(target); } // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. @@ -40715,10 +41388,10 @@ var ts; // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" // when dealing with generics. // * We also don't deal with primitive source types, since we already halt elaboration below. - if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && - target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { - var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); - if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); + if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { target = nullStrippedTarget; } } @@ -40728,11 +41401,12 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { - var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + if (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */) { + var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -40747,11 +41421,11 @@ var ts; source = getRegularTypeOfObjectLiteral(source); } } - if (relation !== comparableRelation && !isIntersectionConstituent && - source.flags & (32764 /* Primitive */ | 131072 /* Object */ | 524288 /* Intersection */) && source !== globalObjectType && - target.flags & (131072 /* Object */ | 524288 /* Intersection */) && isWeakType(target) && + if (relation !== comparableRelation && !isApparentIntersectionConstituent && + source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && + target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target)) { + !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -40767,25 +41441,24 @@ var ts; } var result = 0 /* False */; var saveErrorInfo = errorInfo; - var saveIsIntersectionConstituent = isIntersectionConstituent; - isIntersectionConstituent = false; + var isIntersectionConstituent = !!isApparentIntersectionConstituent; // 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 & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { - if (target.flags & 262144 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); + if (target.flags & 1048576 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); } - else if (target.flags & 524288 /* Intersection */) { - isIntersectionConstituent = true; + else if (target.flags & 2097152 /* Intersection */) { + isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 524288 /* Intersection */) { + else if (source.flags & 2097152 /* Intersection */) { // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually @@ -40801,13 +41474,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { - if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { + if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 524288 /* Intersection */) { + if (!result && source.flags & 2097152 /* Intersection */) { // 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 @@ -40817,22 +41490,23 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { + if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { + var maybeSuppress = suppressNextError; + suppressNextError = false; + if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* 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) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -40842,6 +41516,10 @@ var ts; return result; } } + if (!headMessage && maybeSuppress) { + // Used by, eg, missing property checking to replace the top-level message with a more informative one + return result; + } reportRelationError(headMessage, source, target); } return result; @@ -40849,10 +41527,10 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 131072 /* Object */ || flags & 2097152 /* IndexedAccess */ || flags & 4194304 /* Conditional */ || flags & 1048576 /* Index */ || flags & 8388608 /* Substitution */) { - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); + if (flags & 524288 /* Object */ || flags & 8388608 /* IndexedAccess */ || flags & 16777216 /* Conditional */ || flags & 4194304 /* Index */ || flags & 33554432 /* Substitution */) { + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); } - if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { + if (flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -40865,7 +41543,7 @@ var ts; if (!noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 524288 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -40876,16 +41554,17 @@ var ts; return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } var _loop_6 = function (prop) { - if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. if (!errorNode) return { value: ts.Debug.fail() }; - if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. + // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -40921,8 +41600,8 @@ var ts; } return false; } - function isPropertyFromSpread(prop, container) { - return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + function shouldCheckAsExcessProperty(prop, container) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration; } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; @@ -40939,7 +41618,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -40960,9 +41639,9 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 131072 /* Object */) { + if (target.flags & 524288 /* Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); if (overlapObjFlags & 4 /* Reference */) { return source.target === target.target; @@ -40990,11 +41669,13 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - if (sourceProperties) { - var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); - if (sourcePropertiesFiltered) { - return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + if (target.flags & 1048576 /* Union */) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (sourcePropertiesFiltered) { + return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + } } } return undefined; @@ -41004,7 +41685,7 @@ var ts; 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, reportErrors); + var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, /*isIntersectionConstituent*/ true); if (!related) { return 0 /* False */; } @@ -41014,7 +41695,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -41039,9 +41720,10 @@ var ts; } return result; } - function typeArgumentsRelatedTo(source, target, variances, reportErrors) { - var sources = source.typeArguments || ts.emptyArray; - var targets = target.typeArguments || ts.emptyArray; + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + if (sources === void 0) { sources = ts.emptyArray; } + if (targets === void 0) { targets = ts.emptyArray; } + if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { return 0 /* False */; } @@ -41095,7 +41777,7 @@ var ts; // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function recursiveTypeRelatedTo(source, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0 /* False */; } @@ -41138,7 +41820,7 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; - var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -41161,21 +41843,21 @@ var ts; function getConstraintForRelation(type) { return relation === definitelyAssignableRelation ? undefined : getConstraintOfType(type); } - function structuredTypeRelatedTo(source, target, reportErrors) { + function structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { var flags = source.flags & target.flags; - if (relation === identityRelation && !(flags & 131072 /* Object */)) { - if (flags & 1048576 /* Index */) { + if (relation === identityRelation && !(flags & 524288 /* Object */)) { + if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } var result_2 = 0 /* False */; - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { if (result_2 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result_2; } } } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result_2 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -41188,7 +41870,7 @@ var ts; } } } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; @@ -41196,9 +41878,22 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 65536 /* TypeParameter */) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + // 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 (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && + source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && + !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { + var variances = getAliasVariances(source.aliasSymbol); + if (result = typeArgumentsRelatedTo(source.aliasTypeArguments, target.aliasTypeArguments, variances, reportErrors)) { + return result; + } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; + } + if (target.flags & 262144 /* 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 */ && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); @@ -41208,9 +41903,9 @@ var ts; } } } - else if (target.flags & 1048576 /* Index */) { + else if (target.flags & 4194304 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 1048576 /* Index */) { + if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -41231,7 +41926,7 @@ var ts; } } } - else if (target.flags & 2097152 /* IndexedAccess */) { + else if (target.flags & 8388608 /* IndexedAccess */) { // A type S is related to a type T[K], where T and K aren't both type variables, if S is related to C, // where C is the base constraint of T[K] if (relation !== identityRelation && !(isGenericObjectType(target.objectType) && isGenericIndexType(target.indexType))) { @@ -41248,22 +41943,24 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 8388608 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (!isGenericMappedType(source) && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + // A source type T is related to a target type { [P in Q]: X } if Q is related to keyof T and T[Q] is related to X. + if (!isGenericMappedType(source) && isRelatedTo(getConstraintTypeFromMappedType(target), getIndexType(source))) { var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { return result; } } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; } } - if (source.flags & 2162688 /* TypeVariable */) { - if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8650752 /* TypeVariable */) { + if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { // 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, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); @@ -41274,29 +41971,32 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { + if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } } - else { - var instantiated = getTypeWithThisArgument(constraint, source); - if (result = isRelatedTo(instantiated, target, reportErrors)) { - errorInfo = 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, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = 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, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = saveErrorInfo; + return result; } } - else if (source.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 4194304 /* Conditional */) { - if (target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */) { + if (target.flags & 16777216 /* 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. @@ -41345,7 +42045,7 @@ var ts; if (relation === definitelyAssignableRelation && isGenericMappedType(source)) { return 0 /* False */; } - var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } @@ -41355,7 +42055,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - if (result = typeArgumentsRelatedTo(source, target, variances, reportErrors)) { + if (result = typeArgumentsRelatedTo(source.typeArguments, target.typeArguments, variances, reportErrors)) { return result; } // The type arguments did not relate appropriately, but it may be because we have no variance @@ -41390,7 +42090,7 @@ var ts; // 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 (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors); @@ -41440,7 +42140,24 @@ var ts; var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties)); + if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code && + headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) { + suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it + } + if (props.length === 1) { + var propName = symbolToString(unmatchedProperty); + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, typeToString(source), typeToString(target)); + if (ts.length(unmatchedProperty.declarations)) { + associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); + } + } + else if (props.length > 5) { // arbitrary cutoff for too-long list form + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, typeToString(source), typeToString(target), ts.map(props.slice(0, 4), function (p) { return symbolToString(p); }).join(", "), props.length - 4); + } + else { + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); + } } return 0 /* False */; } @@ -41487,8 +42204,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { - var targetProp = properties_3[_b]; + for (var _b = 0, properties_2 = properties; _b < properties_2.length; _b++) { + var targetProp = properties_2[_b]; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { @@ -41559,7 +42276,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { + if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -41687,7 +42404,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 8192 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -41806,20 +42523,19 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; } - function hasCommonProperties(source, target) { - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + function hasCommonProperties(source, target, isComparingJsxAttributes) { for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { @@ -41835,62 +42551,71 @@ var ts; result.objectFlags |= 8192 /* MarkerType */; return result; } + 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 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 if we're not in strictFunctionTypes mode or if the function // has been invoked recursively for the given generic type. + function getVariancesWorker(typeParameters, cache, createMarkerType) { + if (typeParameters === void 0) { typeParameters = ts.emptyArray; } + var variances = cache.variances; + if (!variances) { + // The emptyArray singleton is used to signal a recursive invocation. + cache.variances = ts.emptyArray; + variances = []; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var tp = typeParameters_1[_i]; + // 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 */; + } + variances.push(variance); + } + cache.variances = variances; + } + return variances; + } function getVariances(type) { if (!strictFunctionTypes) { return ts.emptyArray; } - var typeParameters = type.typeParameters || ts.emptyArray; - var variances = type.variances; - if (!variances) { - if (type === globalArrayType || type === globalReadonlyArrayType) { - // Arrays are known to be covariant, no need to spend time computing this - variances = [1 /* Covariant */]; - } - else { - // The emptyArray singleton is used to signal a recursive invocation. - type.variances = ts.emptyArray; - variances = []; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - // 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 = getMarkerTypeReference(type, tp, markerSuperType); - var typeWithSub = getMarkerTypeReference(type, 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(getMarkerTypeReference(type, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; - } - variances.push(variance); - } - } - type.variances = variances; + if (type === globalArrayType || type === globalReadonlyArrayType) { + // Arrays are known to be covariant, no need to spend time computing this (emptyArray implies covariance for all parameters) + return ts.emptyArray; } - return variances; + return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference); } // 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(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 16384 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 65536 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); @@ -41983,13 +42708,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 131072 /* Object */) { + if (depth >= 5 && type.flags & 524288 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 131072 /* Object */ && t.symbol === symbol) { + if (t.flags & 524288 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -42095,7 +42820,7 @@ var ts; for (var i = 0; i < targetLen; i++) { var s = getTypeAtPosition(source, i); var t = getTypeAtPosition(target, i); - var related = compareTypes(s, t); + var related = compareTypes(t, s); if (!related) { return 0 /* False */; } @@ -42140,9 +42865,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -42159,7 +42884,7 @@ var ts; // 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 return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -42179,35 +42904,37 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); + return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 27072 /* Unit */); + return !!(type.flags & 109440 /* Unit */); } function isLiteralType(type) { return type.flags & 16 /* Boolean */ ? true : - type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : - type; + return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 512 /* BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type; } function getWidenedLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, 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 */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -42233,6 +42960,10 @@ var ts; function getLengthOfTupleType(type) { return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); } + function isZeroBigInt(_a) { + var value = _a.value; + return value.base10Value === "0"; + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -42245,15 +42976,16 @@ 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 & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : - type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : - type.flags & 256 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 256 /* BooleanLiteral */ : 0 : - type.flags & 29148 /* PossiblyFalsy */; + 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 */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { @@ -42262,12 +42994,14 @@ var ts; function getDefinitelyFalsyPartOfType(type) { return type.flags & 4 /* String */ ? emptyStringType : type.flags & 8 /* Number */ ? zeroType : - type === regularFalseType || - type === falseType || - type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || - type.flags & 64 /* StringLiteral */ && type.value === "" || - type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : - neverType; + type.flags & 64 /* BigInt */ ? zeroBigIntType : + type === regularFalseType || + type === falseType || + type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */) || + type.flags & 128 /* StringLiteral */ && type.value === "" || + type.flags & 256 /* NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + neverType; } /** * Add undefined or null or both to a type if they are missing. @@ -42275,15 +43009,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); return missing === 0 ? type : - missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 16384 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -42293,7 +43027,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -42336,7 +43070,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -42346,7 +43080,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; + regularNew.flags = resolved.flags; regularNew.objectFlags |= 128 /* ObjectLiteral */ | (ts.getObjectFlags(resolved) & 16384 /* JSLiteral */); type.regularType = regularNew; return regularNew; @@ -42434,15 +43168,15 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (type.flags & 402653184 /* RequiresWidening */) { - if (type.flags & 24576 /* Nullable */) { + if (type.flags & 98304 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* 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 {}). @@ -42468,7 +43202,7 @@ var ts; function reportWideningErrorsInType(type) { var errorReported = false; if (type.flags & 134217728 /* ContainsWideningType */) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -42512,39 +43246,42 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 202 /* BinaryExpression */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + case 204 /* BinaryExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* 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 149 /* Parameter */: + case 151 /* Parameter */: diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + 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 184 /* BindingElement */: + case 186 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + diagnostic = noImplicitAny ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type : ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage; break; - case 179 /* MappedType */: + case 181 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } return; default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + diagnostic = noImplicitAny ? ts.Diagnostics.Variable_0_implicitly_has_an_1_type : ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; } errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } @@ -42623,11 +43360,11 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 15794176 /* Instantiable */ || + return !!(type.flags & 63176704 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -42636,13 +43373,13 @@ var ts; return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 3145728 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, 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 & 64 /* StringLiteral */)) { + if (!(t.flags & 128 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -42663,25 +43400,25 @@ var ts; * property is computed by inferring from the source property type to X for the type * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ - function inferTypeForHomomorphicMappedType(source, target) { - var key = source.id + "," + target.id; + function inferTypeForHomomorphicMappedType(source, target, constraint) { + var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } reverseMappedCache.set(key, undefined); - var type = createReverseMappedType(source, target); + var type = createReverseMappedType(source, target, constraint); reverseMappedCache.set(key, type); return type; } - function createReverseMappedType(source, target) { + function createReverseMappedType(source, target, constraint) { var properties = getPropertiesOfType(source); if (properties.length === 0 && !getIndexInfoOfType(source, 0 /* String */)) { return undefined; } // If any property contains context sensitive functions that have been skipped, the source type // is incomplete and we can't infer a meaningful input type. - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var prop = properties_3[_i]; if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } @@ -42689,13 +43426,13 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isReadonlyArrayType(source)) { - return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target); }); + var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.associatedNames); @@ -42705,30 +43442,46 @@ var ts; var reversed = createObjectType(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; + reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType); + return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); } - function inferReverseMappedType(sourceType, target) { - var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target)); + function inferReverseMappedType(sourceType, target, constraint) { + var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); var inference = createInferenceInfo(typeParameter); inferTypes([inference], sourceType, templateType); return getTypeFromInference(inference); } - function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; - if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (!sourceProp) { - return targetProp; - } + function getUnmatchedProperties(source, target, requireOptionalProperties) { + var properties, _i, properties_4, targetProp, sourceProp; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + properties = target.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + _i = 0, properties_4 = properties; + _a.label = 1; + case 1: + if (!(_i < properties_4.length)) return [3 /*break*/, 4]; + targetProp = properties_4[_i]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */))) return [3 /*break*/, 3]; + sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (!!sourceProp) return [3 /*break*/, 3]; + return [4 /*yield*/, targetProp]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; } - } - return undefined; + }); + } + function getUnmatchedProperty(source, target, requireOptionalProperties) { + return getUnmatchedProperties(source, target, requireOptionalProperties).next().value; } function tupleTypesDefinitelyUnrelated(source, target) { return target.target.minLength > source.target.minLength || @@ -42778,8 +43531,8 @@ var ts; } return; } - if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || - source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { + if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || + source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -42802,7 +43555,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { + else if (t.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -42817,7 +43570,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 2162688 /* TypeVariable */) { + if (target.flags & 8650752 /* 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 @@ -42825,7 +43578,7 @@ 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.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType || (priority & 8 /* ReturnType */ && (source === autoType || source === autoArrayType))) { return; } var inference = getInferenceInfoForType(target); @@ -42847,12 +43600,30 @@ var ts; inference.candidates = ts.appendIfUnique(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } return; } + else { + // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine + var simplified = getSimplifiedType(target); + if (simplified !== target) { + inferFromTypesOnce(source, simplified); + } + else if (target.flags & 8388608 /* IndexedAccess */) { + var indexType = getSimplifiedType(target.indexType); + // 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 & 63176704 /* Instantiable */) { + var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType), indexType); + if (simplified_1 && simplified_1 !== target) { + inferFromTypesOnce(source, simplified_1); + } + } + } + } } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments @@ -42869,12 +43640,12 @@ var ts; } } } - else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -42883,20 +43654,20 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */ && target.flags & 16777216 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 4194304 /* Conditional */) { + else if (target.flags & 16777216 /* Conditional */) { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } - else if (target.flags & 786432 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -42921,7 +43692,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 262144 /* Union */) { + else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -42930,12 +43701,12 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 63176704 /* 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 & (131072 /* Object */ | 524288 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* 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 @@ -42948,7 +43719,7 @@ var ts; } source = apparentSource; } - if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -42958,7 +43729,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 131072 /* Object */ && + var isNonConstructorObject = target.flags & 524288 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -42974,6 +43745,13 @@ var ts; } } } + function inferFromTypesOnce(source, target) { + var key = source.id + "," + target.id; + if (!visited || !visited.get(key)) { + (visited || (visited = ts.createMap())).set(key, true); + inferFromTypes(source, target); + } + } } function inferFromContravariantTypes(source, target) { if (strictFunctionTypes || priority & 64 /* AlwaysStrict */) { @@ -42986,7 +43764,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -42996,6 +43774,44 @@ var ts; } return undefined; } + function inferFromMappedTypeConstraint(source, target, constraintType) { + if (constraintType.flags & 1048576 /* Union */) { + var result = false; + for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { + var type = _a[_i]; + result = inferFromMappedTypeConstraint(source, target, type) || result; + } + return result; + } + if (constraintType.flags & 4194304 /* 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 + // such that direct inferences to T get priority over inferences to Partial, for example. + var inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + var savePriority = priority; + priority |= 2 /* HomomorphicMappedType */; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + return true; + } + if (constraintType.flags & 262144 /* TypeParameter */) { + // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type + // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. + var savePriority = priority; + priority |= 4 /* MappedTypeConstraint */; + inferFromTypes(getIndexType(source), constraintType); + priority = savePriority; + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return true; + } + return false; + } function inferFromObjectTypes(source, target) { if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer @@ -43005,31 +43821,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 1048576 /* 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 - // such that direct inferences to T get priority over inferences to Partial, for example. - var inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - var inferredType = inferTypeForHomomorphicMappedType(source, target); - if (inferredType) { - var savePriority = priority; - priority |= 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - return; - } - if (constraintType.flags & 65536 /* TypeParameter */) { - // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type - // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. - var savePriority = priority; - priority |= 4 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; - inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + if (inferFromMappedTypeConstraint(source, target, constraintType)) { return; } } @@ -43069,8 +43861,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -43093,7 +43885,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ || kind === 155 /* Constructor */; + bivariant = bivariant || kind === 156 /* MethodDeclaration */ || kind === 155 /* MethodSignature */ || kind === 157 /* Constructor */; forEachMatchingParameterType(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -43147,11 +43939,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 4194304 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 32764 /* Primitive */ | 1048576 /* Index */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -43200,7 +43992,7 @@ var ts; var inferredContravariantType = getContravariantInference(inference); // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype and not 'never'. - inferredType = inferredCovariantType && !(inferredCovariantType.flags & 32768 /* Never */) && + inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ? inferredCovariantType : inferredContravariantType; } @@ -43259,17 +44051,17 @@ var ts; case "console": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; case "$": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig; case "describe": case "suite": case "it": case "test": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig; case "process": case "require": case "Buffer": case "module": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig; case "Map": case "Set": case "Promise": @@ -43295,7 +44087,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 === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 167 /* TypeQuery */ ? true : n.kind === 72 /* Identifier */ || n.kind === 148 /* 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 @@ -43304,20 +44096,20 @@ var ts; // occurring in an apparent type position with '@' because the control flow type // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; } - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { return "0"; } - if (node.kind === 187 /* PropertyAccessExpression */) { + if (node.kind === 189 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 184 /* BindingElement */) { + if (node.kind === 186 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 186 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -43326,14 +44118,14 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 182 /* ObjectBindingPattern */) { + if (parent.kind === 184 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; default: @@ -43347,29 +44139,29 @@ var ts; } function isMatchingReference(source, target) { switch (source.kind) { - case 71 /* Identifier */: - return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && + case 72 /* Identifier */: + return target.kind === 72 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 237 /* VariableDeclaration */ || target.kind === 186 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 99 /* ThisKeyword */: - return target.kind === 99 /* ThisKeyword */; - case 97 /* SuperKeyword */: - return target.kind === 97 /* SuperKeyword */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 100 /* ThisKeyword */: + return target.kind === 100 /* ThisKeyword */; + case 98 /* SuperKeyword */: + return target.kind === 98 /* SuperKeyword */; + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return (ts.isPropertyAccessExpression(target) || ts.isElementAccessExpression(target)) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 184 /* BindingElement */: - if (target.kind !== 187 /* PropertyAccessExpression */) + case 186 /* BindingElement */: + if (target.kind !== 189 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 186 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 235 /* VariableDeclaration */) { + if (source.parent.parent.kind === 237 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -43382,7 +44174,7 @@ var ts; undefined; } function containsMatchingReference(source, target) { - while (source.kind === 187 /* PropertyAccessExpression */) { + while (source.kind === 189 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -43395,23 +44187,23 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 187 /* PropertyAccessExpression */ && + return target.kind === 189 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 71 /* Identifier */) { + if (expr.kind === 72 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 187 /* PropertyAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantType(type) { - if (type.flags & 262144 /* Union */) { - if (type.flags & (16 /* Boolean */ | 512 /* EnumLiteral */)) { + if (type.flags & 1048576 /* Union */) { + if (type.flags & (16 /* Boolean */ | 1024 /* EnumLiteral */)) { return true; } var combined = 0; @@ -43419,14 +44211,14 @@ var ts; var t = _a[_i]; combined |= t.flags; } - if (combined & 27072 /* Unit */ && !(combined & 15794176 /* Instantiable */)) { + if (combined & 109440 /* Unit */ && !(combined & 63176704 /* Instantiable */)) { return true; } } return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 262144 /* Union */) { + if (type && type.flags & 1048576 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { @@ -43437,6 +44229,10 @@ var ts; } return false; } + function hasNarrowableDeclaredType(expr) { + var type = getDeclaredTypeOfReference(expr); + return !!(type && type.flags & 1048576 /* Union */); + } function findDiscriminantProperties(sourceProperties, target) { var result; for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { @@ -43463,7 +44259,7 @@ var ts; } } } - if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 189 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -43477,7 +44273,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 262144 /* Union */)) { + if (!(source.flags & 1048576 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -43493,11 +44289,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 32768 /* Never */) { + if (assignedType.flags & 131072 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 33554432 /* FreshLiteral */ && assignedType.flags & 256 /* BooleanLiteral */) { + if (assignedType.flags & 512 /* 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. @@ -43528,57 +44324,66 @@ var ts; function getTypeFacts(type) { var flags = type.flags; if (flags & 4 /* String */) { - return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; + return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; } - if (flags & 64 /* StringLiteral */) { + if (flags & 128 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : - isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; } if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; + return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; } - if (flags & 128 /* NumberLiteral */) { + if (flags & 256 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : - isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; + isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + } + if (flags & 64 /* BigInt */) { + return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + } + if (flags & 2048 /* BigIntLiteral */) { + var isZero = isZeroBigInt(type); + return strictNullChecks ? + isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; } if (flags & 16 /* Boolean */) { - return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; + return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; } - if (flags & 272 /* BooleanLike */) { + if (flags & 528 /* BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 4079615 /* EmptyObjectStrictFacts */ : 4194303 /* EmptyObjectFacts */ : + strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : - strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : + strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { - return 2457472 /* UndefinedFacts */; + if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { + return 9830144 /* UndefinedFacts */; } - if (flags & 16384 /* Null */) { - return 2340752 /* NullFacts */; + if (flags & 65536 /* Null */) { + return 9363232 /* NullFacts */; } - if (flags & 3072 /* ESSymbolLike */) { - return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; + if (flags & 12288 /* ESSymbolLike */) { + return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; } - if (flags & 16777216 /* NonPrimitive */) { - return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + if (flags & 67108864 /* NonPrimitive */) { + return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & 15794176 /* Instantiable */) { + if (flags & 63176704 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 786432 /* UnionOrIntersection */) { + if (flags & 3145728 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } - return 4194303 /* All */; + return 16777215 /* All */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -43586,7 +44391,7 @@ var ts; function getTypeWithDefault(type, defaultExpression) { if (defaultExpression) { var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 131072 /* NEUndefined */), defaultType]); + return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); } return type; } @@ -43606,15 +44411,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 187 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 275 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 204 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 227 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -43631,21 +44436,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return stringType; - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return undefinedType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -43653,7 +44458,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 182 /* ObjectBindingPattern */ ? + var type = pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -43671,39 +44476,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 224 /* ForInStatement */) { + if (node.parent.parent.kind === 226 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.parent.kind === 227 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 235 /* VariableDeclaration */ ? + return node.kind === 237 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 235 /* VariableDeclaration */ && node.initializer && + return node.kind === 237 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && + node.kind !== 186 /* BindingElement */ && node.parent.kind === 204 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return getReferenceCandidate(node.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return getReferenceCandidate(node.right); } } @@ -43711,13 +44516,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 193 /* ParenthesizedExpression */ || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 195 /* ParenthesizedExpression */ || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */ && parent.left === node || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -43739,8 +44544,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 269 /* CaseClause */) { - if (clause.expression.kind === 9 /* StringLiteral */) { + if (clause.kind === 271 /* CaseClause */) { + if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; } @@ -43751,13 +44556,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* 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 & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -43766,30 +44571,30 @@ var ts; } return true; } - if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 262144 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfPrimitiveTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.primitiveTypesOnly); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return type; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return mapper(type); } var types = type.types; @@ -43819,12 +44624,14 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) || + isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : - t; + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : + t; }); } return typeWithPrimitives; @@ -43858,9 +44665,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 32768 /* Never */ ? + return elementType.flags & 131072 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 262144 /* Union */ ? + createArrayType(elementType.flags & 1048576 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -43878,7 +44685,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - if (!(t.flags & 32768 /* Never */)) { + if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -43900,15 +44707,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 189 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 191 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 190 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 202 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 58 /* EqualsToken */ && + parent.parent.kind === 204 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 59 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -43919,7 +44726,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 97 /* SuperKeyword */) { + if (node.expression.kind !== 98 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -43941,7 +44748,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -43951,8 +44758,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent && reference.parent.kind === 213 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -44024,9 +44831,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 187 /* PropertyAccessExpression */ && - reference.kind !== 188 /* ElementAccessExpression */ && - reference.kind !== 99 /* ThisKeyword */) { + reference.kind !== 189 /* PropertyAccessExpression */ && + reference.kind !== 190 /* ElementAccessExpression */ && + reference.kind !== 100 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -44064,7 +44871,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 262144 /* Union */) { + if (declaredType.flags & 1048576 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); } return declaredType; @@ -44078,19 +44885,23 @@ 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 === 194 /* FunctionExpression */ || init.kind === 195 /* ArrowFunction */)) { + if (init && (init.kind === 196 /* FunctionExpression */ || init.kind === 197 /* 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 === 226 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + } // Assignment doesn't affect reference return undefined; } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 189 /* CallExpression */ ? + var expr = node.kind === 191 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -44098,7 +44909,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -44107,7 +44918,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, 168 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -44121,7 +44932,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -44138,7 +44949,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 131072 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -44154,7 +44965,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 197 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 199 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } return createFlowType(type, isIncomplete(flowType)); @@ -44270,8 +45081,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 262144 /* Union */) || - expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (!(computedType.flags & 1048576 /* Union */) || + expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { return false; } var access = expr; @@ -44292,10 +45103,10 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); + return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } if (isMatchingReferenceDiscriminant(expr, declaredType)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); }); + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; @@ -44313,7 +45124,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -44321,19 +45132,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -44352,15 +45163,15 @@ var ts; return declaredType; } break; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 92 /* InKeyword */: + case 93 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); } break; - case 26 /* CommaToken */: + case 27 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -44369,28 +45180,28 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 24576 /* Nullable */) { + if (valueType.flags & 98304 /* Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; + var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 16384 /* Null */ ? - assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : - assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; + assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : + valueType.flags & 65536 /* Null */ ? + assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : + assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 16909315 /* NotUnionOrUnit */) { + if (type.flags & 67637251 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 131072 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -44402,22 +45213,22 @@ var ts; // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { - // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, target)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, a + // 'typeof x === ...' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, target) && hasNarrowableDeclaredType(target)) { return declaredType; } return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); function narrowTypeForTypeof(type) { if (type.flags & 2 /* Unknown */ && literal.text === "object") { @@ -44434,7 +45245,7 @@ var ts; if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -44453,13 +45264,37 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + } + function getImpliedTypeFromTypeofCase(type, text) { + switch (text) { + case "function": + return type.flags & 1 /* Any */ ? type : globalFunctionType; + case "object": + return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + default: + return typeofTypesByName.get(text) || type; + } + } + function narrowTypeForTypeofSwitch(candidate) { + return function (type) { + if (isTypeSubtypeOf(candidate, type)) { + return candidate; + } + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(candidate, constraint)) { + return getIntersectionType([type, candidate]); + } + } + return type; + }; } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); @@ -44478,7 +45313,7 @@ var ts; // that we don't have to worry about undefined // in the witness array. var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; }); - // The adjust clause start and end after removing the `default` statement. + // The adjusted clause start and end after removing the `default` statement. var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart; var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd; clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd); @@ -44488,6 +45323,9 @@ var ts; clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); } + if (hasDefaultClause) { + return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }); + } /* The implied type is the raw type suggested by a value being caught in this clause. @@ -44516,33 +45354,18 @@ var ts; boolean. We know that number cannot be selected because it is caught in the first clause. */ - if (!(hasDefaultClause || (type.flags & 262144 /* Union */))) { - var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return typeofTypesByName.get(text) || neverType; })), switchFacts); - if (impliedType.flags & 262144 /* Union */) { - impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOfType(type) || type); - } - if (!(impliedType.flags & 32768 /* Never */)) { - if (isTypeSubtypeOf(impliedType, type)) { - return impliedType; - } - if (type.flags & 15794176 /* Instantiable */) { - var constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(impliedType, constraint)) { - return getIntersectionType([type, impliedType]); - } - } - } + var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts); + if (impliedType.flags & 1048576 /* Union */) { + impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type)); } - return hasDefaultClause ? - filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }) : - getTypeWithFacts(type, switchFacts); + return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { - // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, left)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, an + // 'x instanceof T' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, left) && hasNarrowableDeclaredType(left)) { return declaredType; } return type; @@ -44579,9 +45402,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 & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 32768 /* Never */)) { + if (!(assignableType.flags & 131072 /* Never */)) { return assignableType; } } @@ -44621,7 +45444,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 190 /* ElementAccessExpression */ || invokedExpression.kind === 189 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -44638,20 +45461,20 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 200 /* PrefixUnaryExpression */: - if (expr.operator === 51 /* ExclamationToken */) { + case 202 /* PrefixUnaryExpression */: + if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -44665,7 +45488,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 === 71 /* Identifier */) { + if (location.kind === 72 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -44686,9 +45509,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 243 /* ModuleBlock */ || - node.kind === 277 /* SourceFile */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 245 /* ModuleBlock */ || + node.kind === 279 /* SourceFile */ || + node.kind === 154 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -44707,10 +45530,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 151 /* Parameter */) { symbol.isAssigned = true; } } @@ -44725,21 +45548,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 149 /* Parameter */ && + declaration.kind === 151 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 8192 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; + getFalsyFlags(declaredType) & 32768 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 187 /* PropertyAccessExpression */ || - parent.kind === 189 /* CallExpression */ && parent.expression === node || - parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 189 /* PropertyAccessExpression */ || + parent.kind === 191 /* CallExpression */ && parent.expression === node || + parent.kind === 190 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 186 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); + return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 98304 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -44770,7 +45593,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -44791,7 +45614,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 238 /* ClassDeclaration */ + if (declaration.kind === 240 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -44803,14 +45626,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 207 /* ClassExpression */) { + else if (declaration.kind === 209 /* 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 !== 277 /* SourceFile */) { + while (container.kind !== 279 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -44854,7 +45677,7 @@ 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 === 149 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 151 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -44863,8 +45686,8 @@ var ts; // 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 === 194 /* FunctionExpression */ || - flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 196 /* FunctionExpression */ || + flowContainer.kind === 197 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -44873,9 +45696,9 @@ var ts; // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || - node.parent.kind === 211 /* NonNullExpression */ || - declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 257 /* ExportSpecifier */) || + node.parent.kind === 213 /* NonNullExpression */ || + declaration.kind === 237 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -44884,7 +45707,7 @@ var ts; // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType || type === autoArrayType) { + if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) { if (flowType === autoType || flowType === autoArrayType) { if (noImplicitAny) { error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); @@ -44893,7 +45716,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* 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; @@ -44909,7 +45732,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -44932,7 +45755,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -44950,8 +45773,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 223 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && + if (container.kind === 225 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -44969,7 +45792,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 193 /* ParenthesizedExpression */) { + while (current.parent.kind === 195 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -44977,9 +45800,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 202 /* PrefixUnaryExpression */ || current.parent.kind === 203 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; + isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -44990,7 +45813,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { + if (container.kind === 154 /* PropertyDeclaration */ || container.kind === 157 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -45058,37 +45881,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 155 /* Constructor */) { + if (container.kind === 157 /* 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 === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* 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 241 /* EnumDeclaration */: + case 243 /* 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 155 /* Constructor */: + case 157 /* 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 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -45099,9 +45922,15 @@ var ts; var type = tryGetThisTypeAt(node, container); if (!type && noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' - error(node, capturedByArrowFunction && container.kind === 277 /* SourceFile */ ? + var diag = error(node, capturedByArrowFunction && container.kind === 279 /* SourceFile */ ? ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + if (!ts.isSourceFile(container)) { + var outsideThis = tryGetThisTypeAt(container); + if (outsideThis) { + addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + } + } } return type || anyType; } @@ -45127,7 +45956,7 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 194 /* FunctionExpression */ || container.kind === 237 /* FunctionDeclaration */) && + (container.kind === 196 /* FunctionExpression */ || container.kind === 239 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { var classType = getJSClassType(container.symbol); if (classType) { @@ -45153,7 +45982,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 194 /* FunctionExpression */ && + if (container.kind === 196 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -45163,24 +45992,49 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 154 /* MethodDeclaration */ && - container.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 156 /* MethodDeclaration */ && + container.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 194 /* FunctionExpression */ && - container.parent.kind === 273 /* PropertyAssignment */ && - container.parent.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 196 /* FunctionExpression */ && + container.parent.kind === 275 /* PropertyAssignment */ && + container.parent.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* 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 === 196 /* 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 */) { + return container.parent.parent.parent.arguments[0].expression; + } + // Object.defineProperty(x, "method", { value() { } }); + // Object.defineProperty(x, "method", { set(x: () => void) {} }); + // Object.defineProperty(x, "method", { get() { return () => {} } }); + else if (ts.isMethodDeclaration(container) && + ts.isIdentifier(container.name) && + (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") && + ts.isObjectLiteralExpression(container.parent) && + ts.isCallExpression(container.parent.parent) && + container.parent.parent.arguments[2] === container.parent && + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + return container.parent.parent.arguments[0].expression; + } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -45194,15 +46048,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 151 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 189 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 191 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 195 /* ArrowFunction */) { + while (container && container.kind === 197 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -45215,14 +46069,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); - if (current && current.kind === 147 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 149 /* ComputedPropertyName */; }); + if (current && current.kind === 149 /* 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 === 186 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -45230,7 +46084,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 155 /* Constructor */) { + if (!isCallExpression && container.kind === 157 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -45299,7 +46153,7 @@ 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 === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 156 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -45313,7 +46167,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (container.parent.kind === 188 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -45334,7 +46188,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 155 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 157 /* 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; @@ -45349,7 +46203,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 === 155 /* Constructor */; + return container.kind === 157 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -45357,21 +46211,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */; } else { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */ || - container.kind === 152 /* PropertyDeclaration */ || - container.kind === 151 /* PropertySignature */ || - container.kind === 155 /* Constructor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */ || + container.kind === 154 /* PropertyDeclaration */ || + container.kind === 153 /* PropertySignature */ || + container.kind === 157 /* Constructor */; } } } @@ -45379,10 +46233,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 154 /* MethodDeclaration */ || - func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 156 /* MethodDeclaration */ || + func.kind === 158 /* GetAccessor */ || + func.kind === 159 /* SetAccessor */) && func.parent.kind === 188 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 196 /* FunctionExpression */ && func.parent.kind === 275 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -45390,11 +46244,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -45421,7 +46275,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 273 /* PropertyAssignment */) { + if (literal.parent.kind !== 275 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -45435,9 +46289,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */) { var target = parent.left; - if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { + if (target.kind === 189 /* PropertyAccessExpression */ || target.kind === 190 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -45497,7 +46351,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -45509,7 +46363,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 184 /* BindingElement */) { + if (parentDeclaration.kind !== 186 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -45599,10 +46453,13 @@ var ts; // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); + if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { + return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 191 /* TaggedTemplateExpression */) { + if (template.parent.kind === 193 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -45611,7 +46468,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: if (node !== right) { return undefined; } @@ -45620,15 +46477,15 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); return !type && node === right && !ts.isDefaultedExpandoInitializer(binaryExpression) ? getTypeOfExpression(left) : type; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression) : undefined; default: return undefined; @@ -45695,13 +46552,17 @@ var ts; } var thisType = checkThisExpression(thisAccess.expression); return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - if (t.flags & 917504 /* StructuredType */) { + if (t.flags & 3670016 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -45712,8 +46573,8 @@ var ts; return restType; } } - return isNumericLiteralName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); + return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1 /* Number */) || + getIndexTypeOfContextualType(t, 0 /* String */); } return undefined; }, /*noReductions*/ true); @@ -45757,7 +46618,6 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || getIndexTypeOfContextualType(arrayContextualType, 1 /* Number */) || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -45799,35 +46659,36 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 71 /* Identifier */: - case 140 /* UndefinedKeyword */: + case 9 /* BigIntLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: + case 141 /* UndefinedKeyword */: return true; - case 187 /* PropertyAccessExpression */: - case 193 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 195 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 273 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 275 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 265 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 267 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (contextualType && contextualType.flags & 262144 /* Union */) { + if (contextualType && contextualType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, contextualType); } @@ -45864,54 +46725,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 186 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 195 /* ArrowFunction */: - case 228 /* ReturnStatement */: + case 197 /* ArrowFunction */: + case 230 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 185 /* ArrayLiteralExpression */: { + case 187 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 214 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); + case 216 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 206 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 193 /* ParenthesizedExpression */: { + case 195 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -45927,67 +46788,10 @@ var ts; // (as below) instead! return node.parent.contextualType; } - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - var valueType = checkExpression(node.tagName); - if (isTypeAny(valueType)) { - // Short-circuit if the class tag is using an element type 'any' - return anyType; - } - var isJs = ts.isInJSFile(node); - return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); + return getContextualTypeForArgumentAtIndex(node, 0); } - function getJsxSignaturesParameterTypes(valueType, isJs, context) { - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 4 /* String */) { - return anyType; - } - else if (valueType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = valueType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - } - return anyType; - } - // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(valueType, 1 /* Construct */); - var ctor = true; - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(valueType, 0 /* Call */); - ctor = false; - if (signatures.length === 0) { - // We found no signatures at all, which is an error - return errorType; - } - } - var links = getNodeLinks(context); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(valueType); - var cachedResolved = links.resolvedSignatures.get(cacheKey); - if (cachedResolved && cachedResolved !== resolvingSignaturesArray) { - signatures = cachedResolved; - } - else if (!cachedResolved) { - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); - links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures)); - } - return getUnionType(ts.map(signatures, ctor ? function (t) { return getJsxPropsTypeFromClassType(t, isJs, context, /*reportErrors*/ false); } : function (t) { return getJsxPropsTypeFromCallSignature(t, context); }), 0 /* None */); + function getEffectiveFirstArgumentForJsxSignature(signature, node) { + return getJsxReferenceKind(node) !== 0 /* Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); @@ -46002,22 +46806,40 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getStaticTypeOfReferencedJsxConstructor(context) { + if (isJsxIntrinsicIdentifier(context.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context); + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + var tagType = checkExpressionCached(context.tagName); + if (tagType.flags & 128 /* StringLiteral */) { + var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); + if (!result) { + return errorType; + } + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + return tagType; + } function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var ctorType = getStaticTypeOfReferencedJsxConstructor(context); if (ts.length(declaredManagedType.typeParameters) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); } } return attributesType; } - function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { + function getJsxPropsTypeFromClassType(sig, context) { var ns = getJsxNamespaceAt(context); var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined @@ -46030,7 +46852,7 @@ var ts; : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation); if (!attributesType) { // There is no property named 'props' on this instance type - if (reportErrors && !!forcedLookupLocation && !!ts.length(context.attributes.properties)) { + if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) { error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation)); } return emptyObjectType; @@ -46048,7 +46870,7 @@ var ts; var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams - ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isJs)) + ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context))) : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); @@ -46084,7 +46906,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; + return node.kind === 196 /* FunctionExpression */ || node.kind === 197 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -46103,7 +46925,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -46112,7 +46934,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -46151,8 +46973,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 184 /* BindingElement */ && !!node.initializer) || - (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 186 /* BindingElement */ && !!node.initializer) || + (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -46163,7 +46985,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 208 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -46188,12 +47010,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 208 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 208 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -46220,15 +47042,15 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 185 /* ArrayBindingPattern */ || pattern.kind === 187 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementCount; i < patternElements.length; i++) { var e = patternElements[i]; if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { - if (e.kind !== 208 /* OmittedExpression */) { + else if (i < patternElements.length - 1 || !(e.kind === 186 /* BindingElement */ && e.dotDotDotToken || e.kind === 208 /* SpreadElement */)) { + if (e.kind !== 210 /* OmittedExpression */) { error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -46246,12 +47068,12 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isNumericComputedName(name); - case 71 /* Identifier */: + case 72 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return isNumericLiteralName(name.text); default: return false; @@ -46260,7 +47082,7 @@ 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), 168 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -46295,8 +47117,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 24576 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -46323,10 +47145,10 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 33554432 /* FreshLiteral */; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 184 /* ObjectBindingPattern */ || contextualType.pattern.kind === 188 /* ObjectLiteralExpression */); var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -46339,13 +47161,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 149 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 273 /* PropertyAssignment */ || - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 275 /* PropertyAssignment */ || + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 275 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -46358,7 +47180,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -46369,8 +47191,8 @@ var ts; 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 === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 275 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 276 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -46395,12 +47217,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 275 /* SpreadAssignment */) { + else if (memberDecl.kind === 277 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); propertiesArray = []; propertiesTable = ts.createSymbolTable(); hasComputedStringProperty = false; @@ -46412,7 +47234,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 32768 /* FreshLiteral */); offset = i + 1; continue; } @@ -46422,10 +47244,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 === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 158 /* GetAccessor */ || memberDecl.kind === 159 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -46459,7 +47281,7 @@ var ts; } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); } return spread; } @@ -46468,9 +47290,8 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; - result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); - result.objectFlags |= 128 /* ObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags & 939524096 /* PropagatingFlags */; + result.objectFlags |= 128 /* ObjectLiteral */ | freshObjectLiteralFlag; if (isJSObjectLiteral) { result.objectFlags |= 16384 /* JSLiteral */; } @@ -46480,20 +47301,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 24576 /* Nullable */)) { - propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); - } + propagatedFlags |= result.flags & 939524096 /* PropagatingFlags */; return result; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || - getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 131072 /* Object */ && !isGenericMappedType(type) || - type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); + return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { - checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node); } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); @@ -46501,7 +47319,7 @@ var ts; } function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -46509,18 +47327,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } + checkJsxChildren(node); } function checkJsxElement(node, _checkMode) { checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxFragment(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment, checkMode); + function checkJsxFragment(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment); if (compilerOptions.jsx === 2 /* React */ && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) { error(node, compilerOptions.jsxFactory ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma); } + checkJsxChildren(node); return getJsxElementTypeAt(node) || anyType; } /** @@ -46534,7 +47354,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 === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 72 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -46553,18 +47373,19 @@ var ts; function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createSymbolTable(); - var spread = emptyObjectType; + var spread = emptyJsxObjectType; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var propagatingFlags = 0; + var typeFlags = 0; + var objectFlags = 4096 /* 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); - propagatingFlags |= (exprType.flags & 939524096 /* PropagatingFlags */); + typeFlags |= exprType.flags & 939524096 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | 33554432 /* Transient */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -46579,9 +47400,9 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 269 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); attributesTable = ts.createSymbolTable(); } var exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -46589,7 +47410,7 @@ var ts; hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, openingLikeElement.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, exprType, attributes.symbol, typeFlags, objectFlags); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -46598,11 +47419,11 @@ var ts; } if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 260 /* 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); @@ -46622,25 +47443,26 @@ var ts; (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, /*hasRestElement*/ false) || createArrayType(getUnionType(childrenTypes))); var childPropMap = ts.createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); - spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, typeFlags, objectFlags); } } if (hasSpreadAnyType) { return anyType; } - if (typeToIntersect && spread !== emptyObjectType) { + if (typeToIntersect && spread !== emptyJsxObjectType) { return getIntersectionType([typeToIntersect, spread]); } - return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); + return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread); /** * Create anonymous type from given attributes symbol table. * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable * @param attributesTable a symbol table of attributes property */ function createJsxAttributesType() { + objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= (propagatingFlags |= 268435456 /* ContainsObjectLiteral */); - result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + result.objectFlags |= 128 /* ObjectLiteral */ | objectFlags; return result; } } @@ -46650,7 +47472,7 @@ 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 === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { if (!child.containsOnlyWhiteSpaces) { childrenTypes.push(stringType); } @@ -46713,57 +47535,6 @@ var ts; } return links.resolvedSymbol; } - function instantiateJsxSignatures(node, signatures) { - var instantiatedSignatures = []; - var candidateForTypeArgumentError; - var hasTypeArgumentError = !!node.typeArguments; - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; - if (signature.typeParameters) { - var isJavascript = ts.isInJSFile(node); - var typeArgumentInstantiated = getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, /*reportErrors*/ false); - if (typeArgumentInstantiated) { - hasTypeArgumentError = false; - instantiatedSignatures.push(typeArgumentInstantiated); - } - else { - if (node.typeArguments && hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - candidateForTypeArgumentError = signature; - } - var inferenceContext = createInferenceContext(signature.typeParameters, signature, /*flags*/ isJavascript ? 2 /* AnyDefault */ : 0 /* None */); - var typeArguments = inferJsxTypeArguments(signature, node, inferenceContext); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); - } - } - else { - instantiatedSignatures.push(signature); - } - } - if (node.typeArguments && hasTypeArgumentError) { - if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true); - } - // Length check to avoid issuing an arity error on length=0, the "Type argument list cannot be empty" grammar error alone is fine - else if (node.typeArguments.length !== 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, node.typeArguments)); - } - } - return instantiatedSignatures; - } - function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { - if (reportErrors === void 0) { reportErrors = false; } - if (!node.typeArguments) { - return; - } - if (!hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - return; - } - var args = checkTypeArguments(signature, node.typeArguments, reportErrors); - if (!args) { - return; - } - return getSignatureInstantiation(signature, args, isJavascript); - } function getJsxNamespaceAt(location) { var links = location && getNodeLinks(location); if (links && links.jsxNamespace) { @@ -46834,217 +47605,63 @@ var ts; function getJsxElementChildrenPropertyName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } - function getApparentTypeOfJsxPropsType(propsType) { - if (!propsType) { - return undefined; - } - if (propsType.flags & 524288 /* Intersection */) { - var propsApparentType = []; - for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { - var t = _a[_i]; - propsApparentType.push(getApparentType(t)); - } - return getIntersectionType(propsApparentType); - } - return getApparentType(propsType); - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return only attributes type of successfully resolved call signature. - * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) - * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. - var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined, /*isForSignatureHelp*/ false); - if (callSignature !== unknownSignature) { - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } - } - } - return undefined; - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return all attributes type of resolved call signature including candidate signatures. - * This function assumes that the caller handled other possible element type of the JSX element. - * This function is a behavior used by language service when looking up completion in JSX element. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. - var candidatesOutArray = []; - getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, /*isForSignatureHelp*/ false); - var result = void 0; - var allMatchingAttributesType = void 0; - for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { - var candidate = candidatesOutArray_1[_i]; - var callReturnType = getReturnTypeOfSignature(candidate); - // TODO: GH#18217: callReturnType should always be defined... - var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - var shouldBeCandidate = true; - for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { - var attribute = _b[_a]; - if (ts.isJsxAttribute(attribute) && - isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 - shouldBeCandidate = false; - break; - } - } - if (shouldBeCandidate) { - result = intersectTypes(result, paramType); - } - allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); - } - } - // If we can't find any matching, just return everything. - if (!result) { - result = allMatchingAttributesType; - } - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - result = intersectTypes(intrinsicAttributes, result); - } - return result; - } - } - return undefined; - } - function getInstantiatedJsxSignatures(openingLikeElement, elementType, reportErrors) { - var links = getNodeLinks(openingLikeElement); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(elementType); - if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) === resolvingSignaturesArray) { - return; - } - else if (links.resolvedSignatures.get(cacheKey)) { - return links.resolvedSignatures.get(cacheKey); - } - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + function getUninstantiatedJsxSignaturesOfType(elementType) { // Resolve the signatures, preferring constructor var signatures = getSignaturesOfType(elementType, 1 /* Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures signatures = getSignaturesOfType(elementType, 0 /* Call */); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - if (reportErrors) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(openingLikeElement.tagName)); - } + } + if (signatures.length === 0 && elementType.flags & 1048576 /* Union */) { + // If each member has some combination of new/call signatures; make a union signature list for those + signatures = getUnionSignatures(ts.map(elementType.types, getUninstantiatedJsxSignaturesOfType)); + } + return signatures; + } + function getIntrinsicAttributesTypeFromStringLiteralType(type, location) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location); + if (intrinsicElementsType !== errorType) { + var stringLiteralTypeName = type.value; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + return indexSignatureType; + } + return undefined; + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } + function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { + if (refKind === 1 /* Function */) { + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + if (sfcReturnConstraint) { + checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else if (refKind === 0 /* Component */) { + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (classConstraint) { + // Issue an error if this return type isn't assignable to JSX.ElementClass or JSX.Element, failing that + checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else { // Mixed + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (!sfcReturnConstraint || !classConstraint) { return; } + var combined = getUnionType([sfcReturnConstraint, classConstraint]); + checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } - // Instantiate in context of source type - var results = instantiateJsxSignatures(openingLikeElement, signatures); - links.resolvedSignatures.set(cacheKey, results); - return results; - } - /** - * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. - * For instance: - * declare function Foo(attr: { p1: string}): JSX.Element; - * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" - * - * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. - * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component - * - * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement - * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature - * @param sourceAttributesType Is the attributes type the user passed, and is used to create inferences in the target type if present - * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) - * @return attributes type if able to resolve the type of node - * anyType if there is no type ElementAttributesProperty or there is an error - * emptyObjectType if there is no "prop" in the element instance type - */ - function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 262144 /* Union */) { - var types = elementType.types; - return getUnionType(types.map(function (type) { - return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); - }), 2 /* Subtype */); - } - // Shortcircuit any - if (isTypeAny(elementType)) { - return elementType; - } - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 4 /* String */) { - return anyType; - } - else if (elementType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = elementType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); - } - // If we need to report an error, we already done so here. So just return any to prevent any more error downstream - return anyType; - } - // Get the element instance type (the result of newing or invoking this tag) - var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); - if (!ts.length(instantiatedSignatures)) { - return errorType; - } - var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); - // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. - // Otherwise get only attributes type from the signature picked by choose-overload logic. - var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? - tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : - defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); - if (statelessAttributesType) { - return statelessAttributesType; - } - // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elementClassType) { - checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - var isJs = ts.isInJSFile(openingLikeElement); - return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -47068,53 +47685,6 @@ var ts; } return links.resolvedJsxElementAttributesType; } - /** - * Get attributes type of the given custom opening-like JSX element. - * This function is intended to be called from a caller that handles intrinsic JSX element already. - * @param node a custom JSX opening-like element - * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component - */ - function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { - return resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, checkExpression(node.tagName), getJsxElementClassTypeAt(node)); - } - /** - * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. - * This function is called by language service (see: completions-tryGetGlobalSymbols). - * @param node a JSX opening-like element to get attributes type for - */ - function getAllAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - // Because in language service, the given JSX opening-like element may be incomplete and therefore, - // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); - } - } - /** - * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. - * @param node a JSXOpeningLikeElement node - * @return an attributes type of the given node - */ - function getAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); - } - } - /** - * Given a JSX attribute, returns the symbol for the corresponds property - * of the element attributes type. Will return unknownSymbol for attributes - * that have no matching element attributes type property. - */ - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); - var prop = getPropertyOfType(attributesType, attrib.name.escapedText); - return prop || unknownSymbol; - } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); if (type === errorType) @@ -47148,7 +47718,7 @@ var ts; } } } - function checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode) { + function checkJsxOpeningLikeElementOrOpeningFragment(node) { var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node); if (isNodeOpeningLikeElement) { checkGrammarJsxElement(node); @@ -47170,10 +47740,8 @@ var ts; } } if (isNodeOpeningLikeElement) { - checkJsxAttributesAssignableToTagNameAttributes(node, checkMode); - } - else { - checkJsxChildren(node.parent); + var sig = getResolvedSignature(node); + checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(node), getReturnTypeOfSignature(sig), node); } } /** @@ -47190,7 +47758,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 131072 /* Object */) { + if (targetType.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -47200,7 +47768,7 @@ var ts; return true; } } - else if (targetType.flags & 786432 /* UnionOrIntersection */) { + else if (targetType.flags & 3145728 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -47208,55 +47776,12 @@ var ts; } } } - else if (targetType.flags & 4194304 /* Conditional */) { + else if (targetType.flags & 16777216 /* Conditional */) { return isKnownProperty(targetType.root.trueType, name, isComparingJsxAttributes) || isKnownProperty(targetType.root.falseType, name, isComparingJsxAttributes); } return false; } - /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ - function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement, checkMode) { - // The function involves following steps: - // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. - // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) - // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. - // 3. Check if the two are assignable to each other - // targetAttributesType is a type of an attribute from resolving tagName of an opening-like JSX element. - var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? - getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : - getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); - // sourceAttributesType is a type of an attributes properties. - // i.e
- // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); - // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties - var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); - // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. - // This will allow excess properties in spread type as it is very common pattern to spread outer attributes into React component in its render method. - if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { - for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { - var attribute = _a[_i]; - if (!ts.isJsxAttribute(attribute)) { - continue; - } - var attrName = attribute.name; - var isNotIgnoredJsxProperty = (isUnhyphenatedJsxName(ts.idText(attrName)) || !!(getPropertyOfType(targetAttributesType, attrName.escapedText))); - if (isNotIgnoredJsxProperty && !isKnownProperty(targetAttributesType, attrName.escapedText, /*isComparingJsxAttributes*/ true)) { - error(attribute, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(attrName), typeToString(targetAttributesType)); - // We break here so that errors won't be cascading - break; - } - } - } - else if (!isSourceAttributeTypeAssignableToTarget) { - checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); - } - } function checkJsxExpression(node, checkMode) { if (node.expression) { var type = checkExpression(node.expression, checkMode); @@ -47296,7 +47821,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 146 /* QualifiedName */ ? node.right : node.kind === 181 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 148 /* QualifiedName */ ? node.right : node.kind === 183 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -47368,13 +47893,13 @@ var ts; return false; } var thisType = getTypeFromTypeNode(thisParameter.type); - enclosingClass = ((thisType.flags & 65536 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); + enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); } // No further restrictions for static properties if (flags & 32 /* Static */) { return true; } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -47394,19 +47919,26 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function getNonNullableTypeIfNeeded(type) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + if (kind) { + return getNonNullableType(type); + } + return type; + } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? + error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; + return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } @@ -47439,7 +47971,7 @@ var ts; return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } return errorType; } @@ -47450,9 +47982,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 100 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 97 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 98 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); @@ -47464,9 +47996,9 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 187 /* PropertyAccessExpression */ || + if (node.kind !== 189 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -47474,11 +48006,11 @@ 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 && left.kind === 99 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && left.kind === 100 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 157 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -47490,7 +48022,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { error(right, 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; @@ -47509,8 +48041,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && - node.parent.kind !== 162 /* TypeReference */ && + else if (valueDeclaration.kind === 240 /* ClassDeclaration */ && + node.parent.kind !== 164 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -47522,9 +48054,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -47562,7 +48094,7 @@ var ts; function reportNonexistentProperty(propNode, containingType) { var errorInfo; var relatedInfo; - if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { + if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -47671,16 +48203,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 97 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 98 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 148 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 181 /* ImportType */: + case 183 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind !== 181 /* ImportType */ && node.expression.kind === 97 /* SuperKeyword */, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind !== 183 /* ImportType */ && node.expression.kind === 98 /* SuperKeyword */, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -47707,20 +48239,20 @@ var ts; var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, isSuper, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJSFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); + : ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer.kind === 238 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 71 /* Identifier */) { + else if (initializer.kind === 72 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -47737,13 +48269,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 71 /* Identifier */) { + if (e.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 224 /* ForInStatement */ && + if (node.kind === 226 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -47761,7 +48293,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 190 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 192 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -47777,7 +48309,7 @@ var ts; if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -47792,7 +48324,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -47819,8 +48351,7 @@ var ts; return true; } function callLikeExpressionMayHaveTypeArguments(node) { - // TODO: Also include tagged templates (https://github.com/Microsoft/TypeScript/issues/11947) - return ts.isCallOrNewExpression(node); + return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); } function resolveUntypedCall(node) { if (callLikeExpressionMayHaveTypeArguments(node)) { @@ -47828,10 +48359,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 150 /* Decorator */) { + else if (ts.isJsxOpeningLikeElement(node)) { + checkExpression(node.attributes); + } + else if (node.kind !== 152 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -47858,8 +48392,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var signature = signatures_4[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -47895,22 +48429,23 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 208 /* SpreadElement */ || arg.kind === 215 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } + function acceptsVoid(t) { + return !!(t.flags & 16384 /* Void */); + } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } - if (ts.isJsxOpeningLikeElement(node)) { - // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". - return true; - } var argCount; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 191 /* TaggedTemplateExpression */) { + var effectiveParameterCount = getParameterCount(signature); + var effectiveMinimumArguments = getMinArgumentCount(signature); + if (node.kind === 193 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 204 /* TemplateExpression */) { + if (node.template.kind === 206 /* 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. @@ -47921,17 +48456,26 @@ 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 === 13 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 150 /* Decorator */) { + else if (node.kind === 152 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } + else if (ts.isJsxOpeningLikeElement(node)) { + callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + argCount = effectiveMinimumArguments === 0 ? args.length : 1; + effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1; // class may have argumentless ctor functions - still resolve ctor and compare vs props member type + effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1); // sfc may specify context argument - handled by framework and not typechecked + } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 190 /* NewExpression */); + ts.Debug.assert(node.kind === 192 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -47944,12 +48488,21 @@ var ts; } } // Too many arguments implies incorrect arity. - if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { + if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= getMinArgumentCount(signature); - return callIsIncomplete || hasEnoughArguments; + // JSX signatures can have extra parameters provided by the library which we don't check + if (callIsIncomplete || argCount >= effectiveMinimumArguments) { + return true; + } + for (var i = argCount; i < effectiveMinimumArguments; i++) { + var type = getTypeAtPosition(signature, i); + if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + return false; + } + } + return true; } function hasCorrectTypeArgumentArity(signature, typeArguments) { // If the user supplied type arguments, but the number of type arguments does not match @@ -47961,7 +48514,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -47983,14 +48536,9 @@ var ts; } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); } - function inferJsxTypeArguments(signature, node, context) { - // Skip context sensitive pass - var skipContextParamType = getTypeAtPosition(signature, 0); - var checkAttrTypeSkipContextSensitive = checkExpressionWithContextualType(node.attributes, skipContextParamType, identityMapper); - inferTypes(context.inferences, checkAttrTypeSkipContextSensitive, skipContextParamType); - // Standard pass - var paramType = getTypeAtPosition(signature, 0); - var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context); + function inferJsxTypeArguments(node, signature, excludeArgument, context) { + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] !== undefined ? identityMapper : context); inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } @@ -48006,11 +48554,14 @@ var ts; inference.inferredType = undefined; } } + if (ts.isJsxOpeningLikeElement(node)) { + return inferJsxTypeArguments(node, signature, excludeArgument, context); + } // If a contextual type is available, infer from that type to the return type of the call expression. For // example, given a 'function wrap(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 !== 150 /* Decorator */) { + if (node.kind !== 152 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -48043,7 +48594,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards @@ -48059,7 +48610,7 @@ var ts; return getInferredTypes(context); } function getArrayifiedType(type) { - if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 15794176 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { + if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 63176704 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { return createArrayType(getIndexTypeOfType(type, 1 /* Number */) || errorType); } return type; @@ -48070,13 +48621,13 @@ 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 arg.kind === 213 /* SyntheticExpression */ ? + return arg.kind === 215 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context)); } } var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */); var types = []; var spreadIndex = -1; for (var i = index; i < argCount; i++) { @@ -48112,6 +48663,19 @@ var ts; } return typeArgumentTypes; } + function getJsxReferenceKind(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return 2 /* Mixed */; + } + var tagType = getApparentType(checkExpression(node.tagName)); + if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { + return 0 /* Component */; + } + if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { + return 1 /* Function */; + } + return 2 /* Mixed */; + } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. * @param node a JSX opening-like element we are trying to figure its call signature @@ -48119,37 +48683,20 @@ var ts; * @param relation a relationship to check parameter and argument type * @param excludeArgument */ - function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { - // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: - // 1. callIsIncomplete - // 2. attributes property has same number of properties as the parameter object type. - // We can figure that out by resolving attributes property and check number of properties in the resolved type - // If the call has correct arity, we will then check if the argument type and parameter type is assignable - var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete - if (callIsIncomplete) { - return true; - } - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors) { // Stateless function components can have maximum of three arguments: "props", "context", and "updater". // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, // can be specified by users through attributes property. - var paramType = getTypeAtPosition(signature, 0); - var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); - var argProperties = getPropertiesOfType(attributesType); - for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { - var arg = argProperties_1[_i]; - if (!getPropertyOfType(paramType, arg.escapedName) && isUnhyphenatedJsxName(arg.escapedName)) { - return false; - } - } - return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] ? identityMapper : undefined); + return checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes); } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { if (ts.isJsxOpeningLikeElement(node)) { - return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 190 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 192 /* 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. @@ -48166,7 +48713,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), @@ -48189,15 +48736,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { + if (callee.kind === 189 /* PropertyAccessExpression */ || callee.kind === 190 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(213 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(215 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -48207,21 +48754,21 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - if (node.kind === 150 /* Decorator */) { + if (node.kind === 152 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { - return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; + return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray; } var args = node.arguments || ts.emptyArray; var length = args.length; @@ -48247,30 +48794,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 149 /* Parameter */: + case 151 /* 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 === 155 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 157 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 !== 152 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 154 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -48284,17 +48831,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 1; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return 2; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 149 /* Parameter */: + case 151 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -48307,8 +48854,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -48352,8 +48899,8 @@ var ts; function getTypeArgumentArityError(node, signatures, typeArguments) { var min = Infinity; var max = -Infinity; - for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { - var sig = signatures_6[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); max = Math.max(max, ts.length(sig.typeParameters)); } @@ -48361,14 +48908,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp, fallbackError) { - var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 150 /* Decorator */; + var isTaggedTemplate = node.kind === 193 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 152 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); + 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 !== 97 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 98 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -48376,7 +48924,9 @@ var ts; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + if (reportErrors) { + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + } return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -48421,7 +48971,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 = isForSignatureHelp && node.kind === 189 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = isForSignatureHelp && node.kind === 191 /* 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 @@ -48445,34 +48995,32 @@ var ts; // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. - if (candidateForArgumentError) { - if (isJsxOpeningOrSelfClosingElement) { - // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". - return candidateForArgumentError; + if (reportErrors) { + if (candidateForArgumentError) { + // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] + // The importance of excludeArgument is to prevent us from typing function expression parameters + // in arguments too early. If possible, we'd like to only type them once we know the correct + // overload. However, this matters for the case where the call is correct. When the call is + // an error, we don't need to exclude any arguments, although it would cause no harm to do so. + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } - // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] - // The importance of excludeArgument is to prevent us from typing function expression parameters - // in arguments too early. If possible, we'd like to only type them once we know the correct - // overload. However, this matters for the case where the call is correct. When the call is - // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); - } - else if (candidateForArgumentArityError) { - diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); - } - else if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); - } - else { - var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); - if (signaturesWithCorrectTypeArgumentArity.length === 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + else if (candidateForArgumentArityError) { + diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); } - else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + else if (candidateForTypeArgumentError) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); } - else if (fallbackError) { - diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + else { + var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); + if (signaturesWithCorrectTypeArgumentArity.length === 0) { + diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + } + else if (!isDecorator) { + diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + } + else if (fallbackError) { + diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + } } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); @@ -48675,7 +49223,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, isForSignatureHelp) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -48730,7 +49278,7 @@ var ts; } else { var relatedInformation = void 0; - if (node.arguments.length === 1 && isTypeAssertion(ts.first(node.arguments))) { + if (node.arguments.length === 1) { var text = ts.getSourceFileOfNode(node).text; if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); @@ -48754,8 +49302,8 @@ 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 & 65536 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 262144 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 /* Union */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, isForSignatureHelp) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -48833,7 +49381,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 524288 /* Intersection */) { + if (firstBase.flags & 2097152 /* Intersection */) { var types = firstBase.types; var mixinCount = ts.countWhere(types, isMixinConstructorType); var i = 0; @@ -48933,16 +49481,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -48978,6 +49526,58 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp, 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, 67897832 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(120 /* AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + parameterSymbol.type = result; + return createSignature(declaration, + /*typeParameters*/ undefined, + /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, + /*returnTypePredicate*/ undefined, 1, + /*hasRestparameter*/ false, + /*hasLiteralTypes*/ false); + } + function resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + var fakeSignature = createSignatureForJSXIntrinsic(node, result); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), result, node.tagName, node.attributes); + return fakeSignature; + } + var exprTypes = checkExpression(node.tagName); + var apparentType = getApparentType(exprTypes); + if (apparentType === errorType) { + return resolveErrorCall(node); + } + if (exprTypes.flags & 128 /* StringLiteral */) { + var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(exprTypes, node); + if (!intrinsicType) { + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, exprTypes.value, "JSX." + JsxNames.IntrinsicElements); + return resolveUntypedCall(node); + } + else { + var fakeSignature = createSignatureForJSXIntrinsic(node, intrinsicType); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), intrinsicType, node.tagName, node.attributes); + return fakeSignature; + } + } + var signatures = getUninstantiatedJsxSignaturesOfType(apparentType); + if (exprTypes.flags & 4 /* String */ || isUntypedFunctionCall(exprTypes, apparentType, signatures.length, /*constructSignatures*/ 0)) { + return resolveUntypedCall(node); + } + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return resolveErrorCall(node); + } + return resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp); + } /** * Sometimes, we have a decorator that could accept zero arguments, * but is receiving too many arguments as part of the decorator invocation. @@ -48990,49 +49590,19 @@ var ts; signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } - /** - * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. - * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName - * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) - * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. - * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function - * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. - * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; - * the function will fill it up with appropriate candidate signatures - */ - function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, isForSignatureHelp) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); - if (callSignatures && callSignatures.length > 0) { - return resolveCall(openingLikeElement, callSignatures, candidatesOutArray, isForSignatureHelp); - } - return undefined; - } function resolveSignature(node, candidatesOutArray, isForSignatureHelp) { switch (node.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, isForSignatureHelp); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, isForSignatureHelp); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, isForSignatureHelp); - case 150 /* Decorator */: + case 152 /* Decorator */: return resolveDecorator(node, candidatesOutArray, isForSignatureHelp); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - // This code-path is called by language service - var exprTypes = checkExpression(node.tagName); - return forEachType(exprTypes, function (exprType) { - var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray, isForSignatureHelp); - if (sfcResult && sfcResult !== unknownSignature) { - return sfcResult; - } - var sigs = getInstantiatedJsxSignatures(node, exprType); - if (candidatesOutArray && ts.length(sigs)) { - candidatesOutArray.push.apply(candidatesOutArray, sigs); - } - return ts.length(sigs) ? sigs[0] : unknownSignature; - }) || unknownSignature; + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + return resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -49084,7 +49654,7 @@ var ts; return false; } function isJSConstructorType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); } @@ -49119,10 +49689,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 187 /* PropertyAccessExpression */) { + while (parent && parent.kind === 189 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 59 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -49148,15 +49718,15 @@ var ts; if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return voidType; } - if (node.kind === 190 /* NewExpression */) { + if (node.kind === 192 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 155 /* Constructor */ && - declaration.kind !== 159 /* ConstructSignature */ && - declaration.kind !== 164 /* ConstructorType */ && + declaration.kind !== 157 /* Constructor */ && + declaration.kind !== 161 /* ConstructSignature */ && + declaration.kind !== 166 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -49164,7 +49734,7 @@ var ts; // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. var funcSymbol = checkExpression(node.expression).symbol; - if (!funcSymbol && node.expression.kind === 71 /* Identifier */) { + if (!funcSymbol && node.expression.kind === 72 /* Identifier */) { funcSymbol = getResolvedSymbol(node.expression); } var type = funcSymbol && getJSClassType(funcSymbol); @@ -49184,7 +49754,7 @@ 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 & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } var jsAssignmentType; @@ -49230,7 +49800,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -49283,9 +49853,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 237 /* FunctionDeclaration */ + ? 239 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 235 /* VariableDeclaration */ + ? 237 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -49321,10 +49891,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 94 /* NewKeyword */) { + if (node.keywordToken === 95 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 91 /* ImportKeyword */) { + if (node.keywordToken === 92 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -49335,7 +49905,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 === 155 /* Constructor */) { + else if (container.kind === 157 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -49506,7 +50076,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71 /* Identifier */) { + if (element.name.kind === 72 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -49520,7 +50090,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* Identifier */) { // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType) { links.type = getTypeFromBindingPattern(decl.name); @@ -49570,7 +50140,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 216 /* Block */) { + if (func.body.kind !== 218 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -49680,7 +50250,7 @@ var ts; 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]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -49690,7 +50260,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -49698,7 +50268,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]) || 64 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -49712,14 +50282,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 197 /* TypeOfExpression */) { + if (node.expression.kind === 199 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // 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_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 32768 /* Never */); + return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -49735,7 +50305,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 232 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -49757,7 +50327,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, 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 & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -49778,11 +50348,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 154 /* MethodDeclaration */: - return func.parent.kind === 186 /* ObjectLiteralExpression */; + case 156 /* MethodDeclaration */: + return func.parent.kind === 188 /* ObjectLiteralExpression */; default: return false; } @@ -49801,16 +50371,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 4096 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 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 === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 155 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 218 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 32768 /* Never */) { + if (returnType && returnType.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -49839,7 +50409,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -49859,7 +50429,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 196 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -49904,7 +50474,7 @@ var ts; getAwaitedType(type) || errorType : type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -49920,7 +50490,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 216 /* Block */) { + if (node.body.kind === 218 /* Block */) { checkSourceElement(node.body); } else { @@ -49943,34 +50513,66 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { + if (!isTypeAssignableTo(type, numberOrBigIntType)) { error(operand, diagnostic); return false; } return true; } + function isReadonlyAssignmentDeclaration(d) { + if (!ts.isCallExpression(d)) { + return false; + } + if (!ts.isBindableObjectDefinePropertyCall(d)) { + return false; + } + var objectLitType = checkExpressionCached(d.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + var writableProp = getPropertyOfType(objectLitType, "writable"); + var writableType = writableProp && getTypeOfSymbol(writableProp); + if (!writableType || writableType === falseType || writableType === regularFalseType) { + return true; + } + // We include this definition whereupon we walk back and check the type at the declaration because + // The usual definition of `Object.defineProperty` will _not_ cause literal types to be preserved in the + // argument types, should the type be contextualized by the call itself. + if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) { + var initializer = writableProp.valueDeclaration.initializer; + var rawOriginalType = checkExpression(initializer); + if (rawOriginalType === falseType || rawOriginalType === regularFalseType) { + return true; + } + } + return false; + } + var setProp = getPropertyOfType(objectLitType, "set"); + return !setProp; + } function isReadonlySymbol(symbol) { // The following symbols are considered read-only: // Properties with a 'readonly' modifier // Variables declared with 'const' // Get accessors without matching set accessors // 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 */); + symbol.flags & 8 /* EnumMember */ || + ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && - expr.expression.kind === 99 /* ThisKeyword */) { + (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) && + expr.expression.kind === 100 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 155 /* Constructor */)) { + if (!(func && func.kind === 157 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -49983,13 +50585,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 249 /* NamespaceImport */; + return !!declaration && declaration.kind === 251 /* NamespaceImport */; } } } @@ -49998,7 +50600,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 72 /* Identifier */ && node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -50007,7 +50609,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -50044,37 +50646,52 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operand.kind === 8 /* NumericLiteral */) { - if (node.operator === 38 /* MinusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - } - else if (node.operator === 37 /* PlusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); - } + switch (node.operand.kind) { + case 8 /* NumericLiteral */: + switch (node.operator) { + case 39 /* MinusToken */: + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + case 38 /* PlusToken */: + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } + break; + case 9 /* BigIntLiteral */: + if (node.operator === 39 /* MinusToken */) { + return getFreshTypeOfLiteralType(getLiteralType({ + negative: true, + base10Value: ts.parsePseudoBigInt(node.operand.text) + })); + } } switch (node.operator) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - return numberType; - case 51 /* ExclamationToken */: + if (node.operator === 38 /* PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + } + return numberType; + } + return getUnaryResultType(operandType); + case 52 /* ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); - return facts === 1048576 /* Truthy */ ? falseType : - facts === 2097152 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); + return facts === 4194304 /* Truthy */ ? falseType : + facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + case 44 /* PlusPlusToken */: + case 45 /* 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } - return numberType; + return getUnaryResultType(operandType); } return errorType; } @@ -50083,11 +50700,20 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } + return getUnaryResultType(operandType); + } + function getUnaryResultType(operandType) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + ? numberOrBigIntType + : bigintType; + } + // If it's not a bigint type, implicit coercion will result in a number return numberType; } // Return true if type might be of the given kind. A union or intersection type might be of a given @@ -50096,7 +50722,7 @@ var ts; if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -50111,21 +50737,22 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { return false; } - return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 132 /* 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); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 262144 /* Union */ ? + return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } @@ -50145,7 +50772,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, 32764 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* 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 @@ -50164,10 +50791,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -50177,8 +50804,8 @@ var ts; if (strictNullChecks && properties.length === 0) { return checkNonNullType(sourceType, node); } - for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { - var p = properties_7[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var p = properties_6[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis); } return sourceType; @@ -50186,9 +50813,9 @@ var ts; /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) { if (rightIsThis === void 0) { rightIsThis = false; } - if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */ || property.kind === 276 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -50197,13 +50824,13 @@ var ts; var type = getTypeOfObjectLiteralDestructuringProperty(objectLiteralType, name, property, rightIsThis); if (type) { // non-shorthand property assignments should always have initializers - return checkDestructuringAssignment(property.kind === 274 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 276 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } else { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 275 /* SpreadAssignment */) { + else if (property.kind === 277 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -50255,8 +50882,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 208 /* OmittedExpression */) { - if (element.kind !== 206 /* SpreadElement */) { + if (element.kind !== 210 /* OmittedExpression */) { + if (element.kind !== 208 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType : everyType(sourceType, isTupleLikeType) ? getTupleElementType(sourceType, elementIndex) : @@ -50280,7 +50907,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 204 /* BinaryExpression */ && restExpression.operatorToken.kind === 59 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -50297,14 +50924,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 276 /* 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)) & 8192 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -50313,21 +50940,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 204 /* BinaryExpression */ && target.operatorToken.kind === 59 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 186 /* ObjectLiteralExpression */) { + if (target.kind === 188 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 185 /* ArrayLiteralExpression */) { + if (target.kind === 187 /* 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 === 275 /* SpreadAssignment */ ? + var error = target.parent.kind === 277 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -50346,58 +50973,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 191 /* TaggedTemplateExpression */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 193 /* TaggedTemplateExpression */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 140 /* UndefinedKeyword */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 197 /* TypeOfExpression */: - case 211 /* NonNullExpression */: - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 141 /* UndefinedKeyword */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 199 /* TypeOfExpression */: + case 213 /* NonNullExpression */: + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: return true; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 51 /* ExclamationToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 52 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 198 /* VoidExpression */: // Explicit opt-out - case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 200 /* VoidExpression */: // Explicit opt-out + case 194 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 212 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { @@ -50407,11 +51035,11 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 99 /* ThisKeyword */); + if (operator === 59 /* EqualsToken */ && (left.kind === 188 /* ObjectLiteralExpression */ || left.kind === 187 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 100 /* ThisKeyword */); } var leftType; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -50419,28 +51047,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 39 /* AsteriskToken */: - case 40 /* AsteriskAsteriskToken */: - case 61 /* AsteriskEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 42 /* PercentToken */: - case 64 /* PercentEqualsToken */: - case 38 /* MinusToken */: - case 60 /* MinusEqualsToken */: - case 45 /* LessThanLessThanToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: + case 40 /* AsteriskToken */: + case 41 /* AsteriskAsteriskToken */: + case 62 /* AsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 43 /* PercentToken */: + case 65 /* PercentEqualsToken */: + case 39 /* MinusToken */: + case 61 /* MinusEqualsToken */: + case 46 /* LessThanLessThanToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -50449,36 +51077,61 @@ 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 & 272 /* BooleanLike */) && - (rightType.flags & 272 /* BooleanLike */) && + if ((leftType.flags & 528 /* BooleanLike */) && + (rightType.flags & 528 /* 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; } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + 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 */)) || + // Or, if neither could be bigint, implicit coercion results in a number result + !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + resultType_1 = numberType; } + // At least one is assignable to bigint, so both should be only assignable to bigint + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + switch (operator) { + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + reportOperatorError(); + } + resultType_1 = bigintType; + } + else { + reportOperatorError(); + resultType_1 = errorType; + } + if (leftOk && rightOk) { + checkAssignmentOperator(resultType_1); + } + return resultType_1; } - return numberType; - case 37 /* PlusToken */: - case 59 /* PlusEqualsToken */: + case 38 /* PlusToken */: + case 60 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 132 /* StringLike */) && !isTypeAssignableToKind(rightType, 132 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* 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, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* 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, 132 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 132 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -50495,26 +51148,27 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 59 /* PlusEqualsToken */) { + if (operator === 60 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); - if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { + if (!(isTypeComparableTo(leftType, rightType) || isTypeComparableTo(rightType, leftType) || + (isTypeAssignableTo(leftType, numberOrBigIntType) && isTypeAssignableTo(rightType, numberOrBigIntType)))) { reportOperatorError(); } } return booleanType; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -50525,19 +51179,19 @@ var ts; reportOperatorError(); } return booleanType; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 53 /* AmpersandAmpersandToken */: - return getTypeFacts(leftType) & 1048576 /* Truthy */ ? + case 54 /* AmpersandAmpersandToken */: + return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 54 /* BarBarToken */: - return getTypeFacts(leftType) & 2097152 /* Falsy */ ? + case 55 /* BarBarToken */: + return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, right); if (isAssignmentDeclaration(declKind)) { @@ -50547,7 +51201,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 26 /* CommaToken */: + case 27 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -50573,12 +51227,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 72 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 12288 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -50588,15 +51242,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - return 54 /* BarBarToken */; - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - return 35 /* ExclamationEqualsEqualsToken */; - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: - return 53 /* AmpersandAmpersandToken */; + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + return 55 /* BarBarToken */; + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + return 36 /* ExclamationEqualsEqualsToken */; + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: + return 54 /* AmpersandAmpersandToken */; default: return undefined; } @@ -50643,11 +51297,11 @@ var ts; } function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { switch (operatorToken.kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); } return undefined; @@ -50725,14 +51379,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } }); return stringType; } function getContextNode(node) { - if (node.kind === 266 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 268 /* 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; @@ -50768,7 +51422,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; + return node.kind === 194 /* TypeAssertionExpression */ || node.kind === 212 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -50777,7 +51431,7 @@ var ts; ts.isDeclarationReadonly(declaration) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 24576 /* Nullable */) { + if (widened.flags & 98304 /* Nullable */) { reportImplicitAny(declaration, anyType); return anyType; } @@ -50790,26 +51444,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 786432 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* 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) || emptyObjectType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || + 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 */) || 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 & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || - contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */) && 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 false; } @@ -50825,7 +51481,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -50836,7 +51492,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -50867,14 +51523,14 @@ var ts; var 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 (expr.kind === 189 /* CallExpression */ && expr.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 191 /* CallExpression */ && expr.expression.kind !== 98 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - else if (expr.kind === 192 /* TypeAssertionExpression */ || expr.kind === 210 /* AsExpression */) { + else if (expr.kind === 194 /* TypeAssertionExpression */ || expr.kind === 212 /* AsExpression */) { return getTypeFromTypeNode(expr.type); } // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions @@ -50909,7 +51565,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode, forceTuple) { var type; - if (node.kind === 146 /* QualifiedName */) { + if (node.kind === 148 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -50921,10 +51577,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 167 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } @@ -50940,94 +51596,97 @@ var ts; } function checkExpressionWorker(node, checkMode, forceTuple) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return checkIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return checkThisExpression(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkSuperExpression(node); - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullWideningType; - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101 /* TrueKeyword */: + case 9 /* BigIntLiteral */: + checkGrammarBigIntLiteral(node); + return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); + case 102 /* TrueKeyword */: return trueType; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: return falseType; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return checkTemplateExpression(node); - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 189 /* CallExpression */: - if (node.expression.kind === 91 /* ImportKeyword */) { + case 191 /* CallExpression */: + if (node.expression.kind === 92 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 190 /* NewExpression */: + case 192 /* NewExpression */: return checkCallExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return checkClassExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return checkAssertion(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return checkNonNullAssertion(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return checkMetaProperty(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkDeleteExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return checkVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return checkAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return undefinedWideningType; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return checkYieldExpression(node); - case 213 /* SyntheticExpression */: + case 215 /* SyntheticExpression */: return node.type; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return checkJsxElement(node, checkMode); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 262 /* JsxFragment */: - return checkJsxFragment(node, checkMode); - case 266 /* JsxAttributes */: + case 264 /* JsxFragment */: + return checkJsxFragment(node); + case 268 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -51065,7 +51724,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 157 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -51076,10 +51735,10 @@ 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 === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { + if (func.kind === 157 /* Constructor */ || func.kind === 161 /* ConstructSignature */ || func.kind === 166 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -51134,13 +51793,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 195 /* ArrowFunction */: - case 158 /* CallSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 163 /* FunctionType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 197 /* ArrowFunction */: + case 160 /* CallSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 165 /* FunctionType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -51154,11 +51813,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 71 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 72 /* 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 === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { + else if (name.kind === 185 /* ArrayBindingPattern */ || name.kind === 184 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -51167,13 +51826,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* 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 === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || - node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || - node.kind === 159 /* ConstructSignature */) { + else if (node.kind === 165 /* FunctionType */ || node.kind === 239 /* FunctionDeclaration */ || node.kind === 166 /* ConstructorType */ || + node.kind === 160 /* CallSignature */ || node.kind === 157 /* Constructor */ || + node.kind === 161 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -51203,10 +51862,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -51236,7 +51895,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -51253,7 +51912,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 155 /* Constructor */) { + if (member.kind === 157 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -51268,16 +51927,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: addName(names, name, memberName, 1 /* Getter */); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: addName(names, name, memberName, 2 /* Setter */); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* Property */); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: addName(names, name, memberName, 4 /* Method */); break; } @@ -51340,15 +51999,15 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* PropertySignature */) { + if (member.kind === 153 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: memberName = name.text; break; - case 71 /* Identifier */: + case 72 /* Identifier */: memberName = ts.idText(name); break; default: @@ -51365,7 +52024,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* 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 @@ -51385,7 +52044,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -51393,7 +52052,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -51420,7 +52079,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 156 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -51445,7 +52104,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 152 /* PropertyDeclaration */ && + return n.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -51475,7 +52134,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -51500,7 +52159,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -51510,13 +52169,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -51534,7 +52193,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -51582,7 +52241,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 164 /* 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); } var type = getTypeFromTypeReference(node); @@ -51630,7 +52289,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 170 /* RestType */) { + if (e.kind === 172 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -51639,7 +52298,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 169 /* OptionalType */) { + else if (e.kind === 171 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -51654,14 +52313,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 2097152 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* 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 === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 190 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -51669,7 +52328,7 @@ 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. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -51701,7 +52360,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 175 /* 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); @@ -51718,9 +52377,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 239 /* InterfaceDeclaration */ && - n.parent.kind !== 238 /* ClassDeclaration */ && - n.parent.kind !== 207 /* ClassExpression */ && + if (n.parent.kind !== 241 /* InterfaceDeclaration */ && + n.parent.kind !== 240 /* ClassDeclaration */ && + n.parent.kind !== 209 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* 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 @@ -51811,7 +52470,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && + var reportError = (node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -51850,7 +52509,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 241 /* InterfaceDeclaration */ || node.parent.kind === 168 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -51861,7 +52520,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 239 /* FunctionDeclaration */ || node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */ || node.kind === 157 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -51913,8 +52572,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_7 = signatures; _a < signatures_7.length; _a++) { - var signature = signatures_7[_a]; + for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { + var signature = signatures_6[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -51990,22 +52649,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -52013,17 +52672,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: var result_4 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_4 |= getDeclarationSpaces(d); }); return result_4; - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 237 /* FunctionDeclaration */: - case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 239 /* FunctionDeclaration */: + case 253 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -52070,7 +52729,7 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } @@ -52101,7 +52760,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -52252,7 +52911,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 71 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 72 /* 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 { @@ -52291,24 +52950,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 149 /* Parameter */: + case 151 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -52329,7 +52988,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 71 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 72 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -52354,50 +53013,55 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 172 /* IntersectionType */: - case 171 /* UnionType */: - var commonEntityName = void 0; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { - typeNode = typeNode.type; // Skip parens if need be - } - if (typeNode.kind === 131 /* NeverKeyword */) { - continue; // Always elide `never` from the union/intersection if possible - } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* 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); - if (!individualEntityName) { - // Individual is something like string number - // So it would be serialized to either that type or object - // Safe to return here - return undefined; - } - if (commonEntityName) { - // Note this is in sync with the transformation that happens for type node. - // Keep this in sync with serializeUnionOrIntersectionType - // Verify if they refer to same entity and is identifier - // return undefined if they dont match because we would emit object - if (!ts.isIdentifier(commonEntityName) || - !ts.isIdentifier(individualEntityName) || - commonEntityName.escapedText !== individualEntityName.escapedText) { - return undefined; - } - } - else { - commonEntityName = individualEntityName; - } - } - return commonEntityName; - case 175 /* ParenthesizedType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return getEntityNameForDecoratorMetadataFromTypeList(node.types); + case 175 /* ConditionalType */: + return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + case 177 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; } } } + function getEntityNameForDecoratorMetadataFromTypeList(types) { + var commonEntityName; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { + typeNode = typeNode.type; // Skip parens if need be + } + if (typeNode.kind === 132 /* NeverKeyword */) { + continue; // Always elide `never` from the union/intersection if possible + } + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); + if (!individualEntityName) { + // Individual is something like string number + // So it would be serialized to either that type or object + // Safe to return here + return undefined; + } + if (commonEntityName) { + // Note this is in sync with the transformation that happens for type node. + // Keep this in sync with serializeUnionOrIntersectionType + // Verify if they refer to same entity and is identifier + // return undefined if they dont match because we would emit object + if (!ts.isIdentifier(commonEntityName) || + !ts.isIdentifier(individualEntityName) || + commonEntityName.escapedText !== individualEntityName.escapedText) { + return undefined; + } + } + else { + commonEntityName = individualEntityName; + } + } + return commonEntityName; + } function getParameterTypeNodeForDecoratorCheck(node) { var typeNode = ts.getEffectiveTypeAnnotationNode(node); return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode; @@ -52417,14 +53081,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -52433,23 +53097,23 @@ var ts; } } break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 154 /* MethodDeclaration */: + case 156 /* 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 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 149 /* Parameter */: + case 151 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -52502,16 +53166,22 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } } } } + function checkJSDocFunctionType(node) { + if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) { + reportImplicitAny(node, anyType); + } + checkSignatureDeclaration(node); + } function checkJSDocAugmentsTag(node) { var classLike = ts.getJSDocHost(node); if (!ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { @@ -52534,9 +53204,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -52549,7 +53219,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 === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -52578,7 +53248,7 @@ var ts; } } } - var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 155 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); @@ -52623,42 +53293,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 277 /* SourceFile */: - case 242 /* ModuleDeclaration */: - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 279 /* SourceFile */: + case 244 /* ModuleDeclaration */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 240 /* TypeAliasDeclaration */: - case 174 /* InferType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 242 /* TypeAliasDeclaration */: + case 176 /* InferType */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -52679,11 +53349,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 154 /* MethodDeclaration */: - case 152 /* PropertyDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 156 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + if (member.kind === 159 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -52692,7 +53362,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -52700,8 +53370,8 @@ var ts; } } break; - case 160 /* IndexSignature */: - case 215 /* SemicolonClassElement */: + case 162 /* IndexSignature */: + case 217 /* SemicolonClassElement */: // Can't be private break; default: @@ -52713,9 +53383,9 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (node.flags & 4194304 /* Ambient */ || node.kind !== 174 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) + if (node.flags & 4194304 /* Ambient */ || node.kind !== 176 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) return; - if (node.kind === 174 /* InferType */) { + if (node.kind === 176 /* InferType */) { 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))); @@ -52730,7 +53400,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 174 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 176 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -52816,7 +53486,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 251 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -52834,7 +53504,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 237 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 238 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -52855,7 +53525,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -52867,24 +53537,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; + return node.kind === 250 /* ImportClause */ || node.kind === 253 /* ImportSpecifier */ || node.kind === 251 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 250 /* ImportClause */ ? decl : decl.kind === 251 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 216 /* Block */) { + if (node.kind === 218 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -52914,12 +53584,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 152 /* PropertyDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 154 /* MethodDeclaration */ || - node.kind === 153 /* MethodSignature */ || - node.kind === 156 /* GetAccessor */ || - node.kind === 157 /* SetAccessor */) { + if (node.kind === 154 /* PropertyDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 156 /* MethodDeclaration */ || + node.kind === 155 /* MethodSignature */ || + node.kind === 158 /* GetAccessor */ || + node.kind === 159 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -52928,7 +53598,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 151 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -52938,7 +53608,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 71 /* Identifier */; + var isDeclaration_1 = node.kind !== 72 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -52953,7 +53623,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 71 /* Identifier */; + var isDeclaration_2 = node.kind !== 72 /* 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); } @@ -52979,7 +53649,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -52994,7 +53664,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -53029,7 +53699,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 237 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -53041,17 +53711,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 217 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 238 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 219 /* 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 === 216 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 243 /* ModuleBlock */ || - container.kind === 242 /* ModuleDeclaration */ || - container.kind === 277 /* SourceFile */); + (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 245 /* ModuleBlock */ || + container.kind === 244 /* ModuleDeclaration */ || + container.kind === 279 /* 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 @@ -53066,7 +53736,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 151 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -53077,11 +53747,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 187 /* PropertyAccessExpression */) { + if (n.kind === 189 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 71 /* Identifier */) { + else if (n.kind === 72 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.escapedText, 67220415 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -53096,8 +53766,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 184 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 151 /* Parameter */ || + symbol.valueDeclaration.kind === 186 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -53111,7 +53781,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 152 /* PropertyDeclaration */ && + (current.parent.kind === 154 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -53144,18 +53814,18 @@ 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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 184 /* BindingElement */) { - if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 186 /* BindingElement */) { + if (node.parent.kind === 184 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -53168,27 +53838,27 @@ var ts; var property = getPropertyOfType(parentType, nameText); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { - checkPropertyAccessibility(parent, parent.initializer.kind === 97 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, parent.initializer.kind === 98 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 185 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 151 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 226 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -53211,11 +53881,16 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 226 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } + if (symbol.declarations.length > 1) { + if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); + } + } } else { // Node is a secondary declaration, check that type is identical to primary declaration and check that @@ -53230,14 +53905,13 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { - error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { + if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -53246,14 +53920,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* PropertySignature */ + var message = nextDeclaration.kind === 154 /* PropertyDeclaration */ || nextDeclaration.kind === 153 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || - (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 151 /* Parameter */ && right.kind === 237 /* VariableDeclaration */) || + (left.kind === 237 /* VariableDeclaration */ && right.kind === 151 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -53292,7 +53966,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 218 /* EmptyStatement */) { + if (node.thenStatement.kind === 220 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -53311,7 +53985,7 @@ var ts; } function checkTruthinessExpression(node, checkMode) { var type = checkExpression(node, checkMode); - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -53319,12 +53993,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 238 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -53358,14 +54032,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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. @@ -53391,13 +54065,13 @@ var ts; function checkForInStatement(node) { // Grammar checking checkGrammarForInOrForOfStatement(node); - var rightType = checkNonNullExpression(node.expression); + var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); // TypeScript 1.0 spec (April 2014): 5.4 // In a 'for-in' statement of the form // 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 === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* 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); @@ -53411,7 +54085,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 === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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)) { @@ -53424,7 +54098,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, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* 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); @@ -53479,16 +54153,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 262144 /* Union */) { + if (arrayType.flags & 1048576 /* 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 & 68 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 68 /* StringLike */) { + else if (arrayType.flags & 132 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -53501,7 +54175,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 & 32768 /* Never */) { + if (arrayType.flags & 131072 /* Never */) { return stringType; } } @@ -53532,7 +54206,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 68 /* StringLike */) { + if (arrayElementType.flags & 132 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -53746,7 +54420,7 @@ var ts; var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -53762,7 +54436,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -53771,12 +54445,12 @@ var ts; // for generators. return; } - else if (func.kind === 157 /* SetAccessor */) { + else if (func.kind === 159 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 155 /* Constructor */) { + else if (func.kind === 157 /* 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); } @@ -53797,7 +54471,7 @@ var ts; } } } - else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 157 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -53826,7 +54500,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 === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 272 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -53838,7 +54512,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 271 /* 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. @@ -53867,7 +54541,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 233 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -53974,8 +54648,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 202 /* BinaryExpression */ || - name.kind === 147 /* ComputedPropertyName */ || + (propDeclaration.kind === 204 /* BinaryExpression */ || + name.kind === 149 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -54004,6 +54678,7 @@ var ts; case "any": case "unknown": case "number": + case "bigint": case "boolean": case "string": case "symbol": @@ -54183,10 +54858,10 @@ var ts; // 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 & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 8650752 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { + 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. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -54281,7 +54956,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; + return d.kind === 240 /* ClassDeclaration */ || d.kind === 241 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -54320,7 +54995,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 207 /* ClassExpression */) { + if (derivedClassDecl.kind === 209 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -54370,8 +55045,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { - var prop = properties_8[_a]; + for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { + var prop = properties_7[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -54402,7 +55077,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* 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)); } @@ -54412,7 +55087,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 152 /* PropertyDeclaration */ && + return node.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -54423,7 +55098,7 @@ var ts; reference.parent = constructor; reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 8192 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -54436,7 +55111,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -54541,60 +55216,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 37 /* PlusToken */: return value_2; - case 38 /* MinusToken */: return -value_2; - case 52 /* TildeToken */: return ~value_2; + case 38 /* PlusToken */: return value_2; + case 39 /* MinusToken */: return -value_2; + case 53 /* TildeToken */: return ~value_2; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 49 /* BarToken */: return left | right; - case 48 /* AmpersandToken */: return left & right; - case 46 /* GreaterThanGreaterThanToken */: return left >> right; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 45 /* LessThanLessThanToken */: return left << right; - case 50 /* CaretToken */: return left ^ right; - case 39 /* AsteriskToken */: return left * right; - case 41 /* SlashToken */: return left / right; - case 37 /* PlusToken */: return left + right; - case 38 /* MinusToken */: return left - right; - case 42 /* PercentToken */: return left % right; - case 40 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 50 /* BarToken */: return left | right; + case 49 /* AmpersandToken */: return left & right; + case 47 /* GreaterThanGreaterThanToken */: return left >> right; + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 46 /* LessThanLessThanToken */: return left << right; + case 51 /* CaretToken */: return left ^ right; + case 40 /* AsteriskToken */: return left * right; + case 42 /* SlashToken */: return left / right; + case 38 /* PlusToken */: return left + right; + case 39 /* MinusToken */: return left - right; + case 43 /* PercentToken */: return left % right; + case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 37 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { return left + right; } break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 71 /* Identifier */: + case 72 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 187 /* PropertyAccessExpression */) { + if (ex.kind === 189 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -54625,10 +55300,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 71 /* Identifier */ || - node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 9 /* StringLiteral */; + return node.kind === 72 /* Identifier */ || + node.kind === 189 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 190 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -54665,7 +55340,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 !== 241 /* EnumDeclaration */) { + if (declaration.kind !== 243 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -54688,8 +55363,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 238 /* ClassDeclaration */ || - (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 240 /* ClassDeclaration */ || + (declaration.kind === 239 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -54726,7 +55401,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 9 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -54752,7 +55427,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 240 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -54802,23 +55477,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -54829,12 +55504,12 @@ var ts; break; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 237 /* FunctionDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -54847,7 +55522,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -54855,17 +55530,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; } } @@ -54879,9 +55554,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 253 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -54914,14 +55589,14 @@ var ts; (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 255 /* ExportSpecifier */ ? + var message = node.kind === 257 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 255 /* ExportSpecifier */ + && node.kind === 257 /* ExportSpecifier */ && !(target.flags & 67220415 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -54948,7 +55623,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -54972,7 +55647,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 259 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67220415 /* Value */) { @@ -55008,10 +55683,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -55028,7 +55703,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -55057,8 +55732,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 === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -55071,7 +55746,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { markExportAsReferenced(node); if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); @@ -55146,7 +55821,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 239 /* FunctionDeclaration */ && declaration.kind !== 156 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -55164,158 +55839,158 @@ 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return checkTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return checkParameter(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return checkPropertyDeclaration(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return checkSignatureDeclaration(node); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return checkMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return checkConstructorDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return checkAccessorDeclaration(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return checkTypeReferenceNode(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return checkTypePredicate(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return checkTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return checkTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return checkArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return checkTupleType(node); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 175 /* ParenthesizedType */: - case 169 /* OptionalType */: - case 170 /* RestType */: + case 177 /* ParenthesizedType */: + case 171 /* OptionalType */: + case 172 /* RestType */: return checkSourceElement(node.type); - case 176 /* ThisType */: + case 178 /* ThisType */: return checkThisType(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return checkTypeOperator(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return checkConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return checkInferType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return checkImportType(node); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 287 /* JSDocFunctionType */: - checkSignatureDeclaration(node); + case 289 /* JSDocFunctionType */: + checkJSDocFunctionType(node); // falls through - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: - case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: + case 292 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 281 /* JSDocTypeExpression */: + case 283 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return checkMappedType(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return checkBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return checkVariableStatement(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return checkExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return checkIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return checkDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return checkWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return checkForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return checkForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkForOfStatement(node); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return checkReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return checkSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return checkThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return checkTryStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return checkBindingElement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return checkClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return checkImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return checkExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return checkExportAssignment(node); - case 218 /* EmptyStatement */: - case 234 /* DebuggerStatement */: + case 220 /* EmptyStatement */: + case 236 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -55406,23 +56081,23 @@ var ts; } links.deferredNodes.forEach(function (node) { switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 258 /* JsxElement */: + case 260 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -55459,6 +56134,7 @@ var ts; ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); ts.forEach(node.statements, checkSourceElement); + checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); if (ts.isExternalOrCommonJsModule(node)) { registerForUnusedIdentifiersCheck(node); @@ -55551,13 +56227,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) + break; + // falls through + case 244 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -55565,8 +56245,8 @@ var ts; // falls through // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* 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. @@ -55575,7 +56255,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -55617,17 +56297,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 71 /* Identifier */ && + return name.kind === 72 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 148 /* TypeParameter */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 150 /* TypeParameter */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -55635,16 +56315,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 162 /* TypeReference */; + return node.parent.kind === 164 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 187 /* PropertyAccessExpression */) { + while (node.parent.kind === 189 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 209 /* ExpressionWithTypeArguments */; + return node.parent.kind === 211 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -55672,13 +56352,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 148 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 248 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 254 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -55704,7 +56384,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 183 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -55714,7 +56394,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 187 /* PropertyAccessExpression */ && + entityName.parent.kind === 189 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -55722,7 +56402,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 254 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -55732,7 +56412,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 248 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -55750,7 +56430,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 211 /* ExpressionWithTypeArguments */) { meaning = 67897832 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -55766,10 +56446,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 297 /* JSDocParameterTag */) { + if (entityName.parent.kind === 299 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 301 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -55779,19 +56459,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 71 /* Identifier */) { + if (entityName.kind === 72 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 189 /* PropertyAccessExpression */ || entityName.kind === 148 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 187 /* PropertyAccessExpression */) { + if (entityName.kind === 189 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -55801,20 +56481,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 164 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 265 /* JsxAttribute */) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 161 /* TypePredicate */) { + if (entityName.parent.kind === 163 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -55830,12 +56507,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 184 /* BindingElement */ && - grandParent.kind === 182 /* ObjectBindingPattern */ && + else if (parent.kind === 186 /* BindingElement */ && + grandParent.kind === 184 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -55845,11 +56522,11 @@ var ts; } } switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -55861,29 +56538,32 @@ var ts; return checkExpression(node).symbol; } // falls through - case 176 /* ThisType */: + case 178 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkExpression(node).symbol; - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 157 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: + case 14 /* 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 === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 249 /* ImportDeclaration */ || node.parent.kind === 255 /* 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); } + if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) { + return getSymbolOfNode(parent); + } // falls through case 8 /* NumericLiteral */: // index access @@ -55893,19 +56573,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 79 /* DefaultKeyword */: - case 89 /* FunctionKeyword */: - case 36 /* EqualsGreaterThanToken */: - case 75 /* ClassKeyword */: + case 80 /* DefaultKeyword */: + case 90 /* FunctionKeyword */: + case 37 /* EqualsGreaterThanToken */: + case 76 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; + case 85 /* ExportKeyword */: + return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 276 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -55973,28 +56655,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 188 /* ObjectLiteralExpression */ || expr.kind === 187 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 225 /* ForOfStatement */) { + if (expr.parent.kind === 227 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 202 /* BinaryExpression */) { + if (expr.parent.kind === 204 /* 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 === 273 /* PropertyAssignment */) { + if (expr.parent.kind === 275 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 187 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -56030,14 +56712,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return getLiteralType(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: ts.Debug.fail("Unsupported property name."); return errorType; @@ -56092,7 +56774,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -56148,7 +56830,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* 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. @@ -56203,7 +56885,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 218 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -56244,18 +56926,18 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return node.expression - && node.expression.kind === 71 /* Identifier */ + && node.expression.kind === 72 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -56263,7 +56945,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -56290,7 +56972,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -56363,15 +57046,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 276 /* EnumMember */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 278 /* EnumMember */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 276 /* EnumMember */) { + if (node.kind === 278 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -56385,7 +57068,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. @@ -56422,22 +57105,25 @@ var ts; else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + return ts.TypeReferenceSerializationKind.BigIntLikeType; + } + else if (isTypeAssignableToKind(type, 132 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -56453,14 +57139,14 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* 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 */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 2048 /* UniqueESSymbol */ && + if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -56472,7 +57158,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56480,7 +57166,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56518,19 +57204,18 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } - function literalTypeToNode(type, enclosing) { - var enumResult = type.flags & 512 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing) + function literalTypeToNode(type, enclosing, tracker) { + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } - function createLiteralConstValue(node) { + function createLiteralConstValue(node, tracker) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return literalTypeToNode(type, node); + return literalTypeToNode(type, node, tracker); } function createResolver() { // this variable and functions that use it are deliberately moved here from the outer scope @@ -56603,12 +57288,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* SetAccessor */; + var otherKind = accessor.kind === 159 /* SetAccessor */ ? 158 /* GetAccessor */ : 159 /* 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 === 157 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 159 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 158 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -56624,7 +57309,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; + return node.parent && node.parent.kind === 211 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 273 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -56636,7 +57321,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 72 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 189 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -56687,7 +57372,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -56702,12 +57387,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 244 /* 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, 277 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -56885,14 +57570,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 154 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 156 /* 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 === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */) { + else if (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* 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); @@ -56909,23 +57594,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { + if (modifier.kind !== 133 /* ReadonlyKeyword */) { + if (node.kind === 153 /* PropertySignature */ || node.kind === 155 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 76 /* ConstKeyword */: - if (node.kind !== 241 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); + case 77 /* ConstKeyword */: + if (node.kind !== 243 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(77 /* ConstKeyword */)); } break; - case 114 /* PublicKeyword */: - case 113 /* ProtectedKeyword */: - case 112 /* PrivateKeyword */: + case 115 /* PublicKeyword */: + case 114 /* ProtectedKeyword */: + case 113 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -56939,11 +57624,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* 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 === 112 /* PrivateKeyword */) { + if (modifier.kind === 113 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -56952,7 +57637,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -56962,10 +57647,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -56974,18 +57659,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 132 /* ReadonlyKeyword */: + case 133 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { + else if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */ && node.kind !== 162 /* IndexSignature */ && node.kind !== 151 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -56998,52 +57683,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 79 /* DefaultKeyword */: - var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 80 /* DefaultKeyword */: + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 124 /* DeclareKeyword */: + case 125 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 245 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 117 /* AbstractKeyword */: + case 118 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 238 /* ClassDeclaration */) { - if (node.kind !== 154 /* MethodDeclaration */ && - node.kind !== 152 /* PropertyDeclaration */ && - node.kind !== 156 /* GetAccessor */ && - node.kind !== 157 /* SetAccessor */) { + if (node.kind !== 240 /* ClassDeclaration */) { + if (node.kind !== 156 /* MethodDeclaration */ && + node.kind !== 154 /* PropertyDeclaration */ && + node.kind !== 158 /* GetAccessor */ && + node.kind !== 159 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 240 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -57055,14 +57740,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -57070,7 +57755,7 @@ var ts; break; } } - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -57085,13 +57770,13 @@ var ts; } return false; } - else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 249 /* ImportDeclaration */ || node.kind === 248 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -57112,38 +57797,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 242 /* ModuleDeclaration */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 149 /* Parameter */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 244 /* ModuleDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 151 /* Parameter */: return false; default: - if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return false; } switch (node.kind) { - case 237 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 238 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 239 /* InterfaceDeclaration */: - case 217 /* VariableStatement */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AsyncKeyword */); + case 240 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 118 /* AbstractKeyword */); + case 241 /* InterfaceDeclaration */: + case 219 /* VariableStatement */: + case 242 /* TypeAliasDeclaration */: return true; - case 241 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); + case 243 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 77 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -57155,10 +57840,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -57276,12 +57961,12 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { + if (parameter.type.kind !== 138 /* StringKeyword */ && parameter.type.kind !== 135 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(getTypeFromTypeNode(node.type))); } - if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -57312,7 +57997,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 208 /* OmittedExpression */) { + if (arg.kind === 210 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -57342,7 +58027,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 === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -57355,7 +58040,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -57371,14 +58056,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -57389,20 +58074,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 147 /* ComputedPropertyName */) { + if (node.kind !== 149 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 204 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 237 /* FunctionDeclaration */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 154 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 239 /* FunctionDeclaration */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 156 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -57428,15 +58113,15 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */) { + if (prop.kind === 277 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 274 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 276 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -57445,7 +58130,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { + if (mod.kind !== 121 /* AsyncKeyword */ || prop.kind !== 156 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -57460,23 +58145,23 @@ 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 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); /* tslint:disable:no-switch-case-fall-through */ - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: @@ -57513,7 +58198,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 267 /* JsxSpreadAttribute */) { + if (attr.kind === 269 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -57523,7 +58208,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 270 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -57532,12 +58217,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 227 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 238 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -57552,20 +58237,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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); @@ -57592,11 +58277,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 158 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 157 /* SetAccessor */) { + else if (kind === 159 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -57620,23 +58305,23 @@ 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 === 156 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 141 /* UniqueKeyword */) { - if (node.type.kind !== 138 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(138 /* SymbolKeyword */)); + if (node.operator === 142 /* UniqueKeyword */) { + if (node.type.kind !== 139 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(139 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* 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)) { @@ -57646,13 +58331,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { 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 151 /* PropertySignature */: + case 153 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* 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); } @@ -57671,10 +58356,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 156 /* MethodDeclaration */) { + if (node.parent.kind === 188 /* 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 === 120 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 121 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -57700,14 +58385,14 @@ var ts; if (node.flags & 4194304 /* 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 === 154 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 156 /* 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 === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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 === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* 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); } } @@ -57718,11 +58403,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 231 /* LabeledStatement */: + case 233 /* 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 === 226 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 228 /* 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); @@ -57730,8 +58415,8 @@ var ts; return false; } break; - case 230 /* SwitchStatement */: - if (node.kind === 227 /* BreakStatement */ && !node.label) { + case 232 /* SwitchStatement */: + if (node.kind === 229 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -57746,13 +58431,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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 === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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); @@ -57775,34 +58460,43 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } + function isBigIntLiteralExpression(expr) { + return expr.kind === 9 /* BigIntLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.operand.kind === 9 /* BigIntLiteral */; + } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) - return !!(checkExpressionCached(expr).flags & 512 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); } function checkAmbientInitializer(node) { - if (node.initializer) { - var isInvalidInitializer = !(isStringOrNumberLiteralExpression(node.initializer) || isSimpleLiteralEnumReference(node.initializer) || node.initializer.kind === 101 /* TrueKeyword */ || node.initializer.kind === 86 /* FalseKeyword */); + var initializer = node.initializer; + if (initializer) { + var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || + isSimpleLiteralEnumReference(initializer) || + initializer.kind === 102 /* TrueKeyword */ || initializer.kind === 87 /* FalseKeyword */ || + isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { if (isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); + return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); } } else { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { + if (node.parent.parent.kind !== 226 /* ForInStatement */ && node.parent.parent.kind !== 227 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -57815,7 +58509,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 219 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -57832,7 +58526,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -57849,8 +58543,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 71 /* Identifier */) { - if (name.originalKeywordKind === 110 /* LetKeyword */) { + if (name.kind === 72 /* Identifier */) { + if (name.originalKeywordKind === 111 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -57877,15 +58571,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return false; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -57903,12 +58597,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 94 /* NewKeyword */: + case 95 /* 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 91 /* ImportKeyword */: + case 92 /* 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"); } @@ -57963,7 +58657,7 @@ var ts; return true; } } - else if (node.parent.kind === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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; } @@ -57971,7 +58665,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -58000,13 +58694,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 240 /* TypeAliasDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 253 /* ExportDeclaration */ || - node.kind === 252 /* ExportAssignment */ || - node.kind === 245 /* NamespaceExportDeclaration */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 242 /* TypeAliasDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 255 /* ExportDeclaration */ || + node.kind === 254 /* ExportAssignment */ || + node.kind === 247 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -58015,7 +58709,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 === 217 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 219 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -58042,7 +58736,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 === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -58064,20 +58758,32 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 182 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 278 /* 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 === 38 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } return false; } + function checkGrammarBigIntLiteral(node) { + var literalType = ts.isLiteralTypeNode(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); + if (!literalType) { + if (languageVersion < 6 /* ESNext */) { + if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ESNext)) { + return true; + } + } + } + return false; + } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -58122,8 +58828,8 @@ var ts; /** 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 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -58131,14 +58837,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 248 /* ImportClause */: // For default import - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: // For rename import `x as y` + case 250 /* ImportClause */: // For default import + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: // For rename import `x as y` return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 251 /* ImportSpecifier */; + return decl.parent.kind === 253 /* ImportSpecifier */; default: return false; } @@ -58158,7 +58864,7 @@ var ts; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function typeIsLiteralType(type) { - return !!(type.flags & 448 /* Literal */); + return !!(type.flags & 2944 /* Literal */); } })(ts || (ts = {})); var ts; @@ -58222,6 +58928,9 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt + return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); + } if (typeof value === "boolean") { return value ? createTrue() : createFalse(); } @@ -58241,14 +58950,20 @@ var ts; return node; } ts.createNumericLiteral = createNumericLiteral; + function createBigIntLiteral(value) { + var node = createSynthesizedNode(9 /* BigIntLiteral */); + node.text = value; + return node; + } + ts.createBigIntLiteral = createBigIntLiteral; function createStringLiteral(text) { - var node = createSynthesizedNode(9 /* StringLiteral */); + var node = createSynthesizedNode(10 /* StringLiteral */); node.text = text; return node; } ts.createStringLiteral = createStringLiteral; function createRegularExpressionLiteral(text) { - var node = createSynthesizedNode(12 /* RegularExpressionLiteral */); + var node = createSynthesizedNode(13 /* RegularExpressionLiteral */); node.text = text; return node; } @@ -58259,7 +58974,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(71 /* Identifier */); + var node = createSynthesizedNode(72 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -58340,23 +59055,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(97 /* SuperKeyword */); + return createSynthesizedNode(98 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(99 /* ThisKeyword */); + return createSynthesizedNode(100 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(95 /* NullKeyword */); + return createSynthesizedNode(96 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(101 /* TrueKeyword */); + return createSynthesizedNode(102 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(86 /* FalseKeyword */); + return createSynthesizedNode(87 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -58367,44 +59082,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(84 /* ExportKeyword */)); + result.push(createModifier(85 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(124 /* DeclareKeyword */)); + result.push(createModifier(125 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(79 /* DefaultKeyword */)); + result.push(createModifier(80 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(76 /* ConstKeyword */)); + result.push(createModifier(77 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(114 /* PublicKeyword */)); + result.push(createModifier(115 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(112 /* PrivateKeyword */)); + result.push(createModifier(113 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(113 /* ProtectedKeyword */)); + result.push(createModifier(114 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(117 /* AbstractKeyword */)); + result.push(createModifier(118 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(115 /* StaticKeyword */)); + result.push(createModifier(116 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(132 /* ReadonlyKeyword */)); + result.push(createModifier(133 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(120 /* AsyncKeyword */)); + result.push(createModifier(121 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(146 /* QualifiedName */); + var node = createSynthesizedNode(148 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -58423,7 +59138,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(147 /* ComputedPropertyName */); + var node = createSynthesizedNode(149 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -58436,7 +59151,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(148 /* TypeParameter */); + var node = createSynthesizedNode(150 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -58452,7 +59167,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(149 /* Parameter */); + var node = createSynthesizedNode(151 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -58476,7 +59191,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(150 /* Decorator */); + var node = createSynthesizedNode(152 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -58489,7 +59204,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertySignature */); + var node = createSynthesizedNode(153 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -58509,12 +59224,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(152 /* PropertyDeclaration */); + var node = createSynthesizedNode(154 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -58524,8 +59239,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -58533,7 +59248,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(155 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -58550,7 +59265,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(154 /* MethodDeclaration */); + var node = createSynthesizedNode(156 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -58578,7 +59293,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(155 /* Constructor */); + var node = createSynthesizedNode(157 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -58598,7 +59313,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(156 /* GetAccessor */); + var node = createSynthesizedNode(158 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58621,7 +59336,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(157 /* SetAccessor */); + var node = createSynthesizedNode(159 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58642,7 +59357,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(160 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -58650,7 +59365,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(161 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -58658,7 +59373,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(160 /* IndexSignature */); + var node = createSynthesizedNode(162 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -58698,7 +59413,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(161 /* TypePredicate */); + var node = createSynthesizedNode(163 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -58712,7 +59427,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(162 /* TypeReference */); + var node = createSynthesizedNode(164 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -58726,7 +59441,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -58734,7 +59449,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(166 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -58742,7 +59457,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(165 /* TypeQuery */); + var node = createSynthesizedNode(167 /* TypeQuery */); node.exprName = exprName; return node; } @@ -58754,7 +59469,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(166 /* TypeLiteral */); + var node = createSynthesizedNode(168 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -58766,7 +59481,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(167 /* ArrayType */); + var node = createSynthesizedNode(169 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -58778,7 +59493,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(168 /* TupleType */); + var node = createSynthesizedNode(170 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -58790,7 +59505,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(169 /* OptionalType */); + var node = createSynthesizedNode(171 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -58802,7 +59517,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(170 /* RestType */); + var node = createSynthesizedNode(172 /* RestType */); node.type = type; return node; } @@ -58814,7 +59529,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(173 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -58822,7 +59537,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(174 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -58841,7 +59556,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(173 /* ConditionalType */); + var node = createSynthesizedNode(175 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -58859,7 +59574,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(174 /* InferType */); + var node = createSynthesizedNode(176 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -58871,7 +59586,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(181 /* ImportType */); + var node = createSynthesizedNode(183 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -58889,7 +59604,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(175 /* ParenthesizedType */); + var node = createSynthesizedNode(177 /* ParenthesizedType */); node.type = type; return node; } @@ -58901,12 +59616,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(176 /* ThisType */); + return createSynthesizedNode(178 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(177 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; + var node = createSynthesizedNode(179 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 129 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -58916,7 +59631,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(178 /* IndexedAccessType */); + var node = createSynthesizedNode(180 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -58930,7 +59645,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(179 /* MappedType */); + var node = createSynthesizedNode(181 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -58948,7 +59663,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(180 /* LiteralType */); + var node = createSynthesizedNode(182 /* LiteralType */); node.literal = literal; return node; } @@ -58961,7 +59676,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(182 /* ObjectBindingPattern */); + var node = createSynthesizedNode(184 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58973,7 +59688,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(183 /* ArrayBindingPattern */); + var node = createSynthesizedNode(185 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58985,7 +59700,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(184 /* BindingElement */); + var node = createSynthesizedNode(186 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -59004,7 +59719,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(187 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -59018,7 +59733,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(188 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -59032,7 +59747,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(187 /* PropertyAccessExpression */); + var node = createSynthesizedNode(189 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -59049,7 +59764,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(188 /* ElementAccessExpression */); + var node = createSynthesizedNode(190 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -59063,7 +59778,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(189 /* CallExpression */); + var node = createSynthesizedNode(191 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -59079,7 +59794,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(190 /* NewExpression */); + var node = createSynthesizedNode(192 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -59095,7 +59810,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(193 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -59118,7 +59833,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(192 /* TypeAssertionExpression */); + var node = createSynthesizedNode(194 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -59132,7 +59847,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(193 /* ParenthesizedExpression */); + var node = createSynthesizedNode(195 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -59144,7 +59859,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(194 /* FunctionExpression */); + var node = createSynthesizedNode(196 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -59168,12 +59883,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(195 /* ArrowFunction */); + var node = createSynthesizedNode(197 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -59190,7 +59905,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(196 /* DeleteExpression */); + var node = createSynthesizedNode(198 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59202,7 +59917,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(197 /* TypeOfExpression */); + var node = createSynthesizedNode(199 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59214,7 +59929,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(198 /* VoidExpression */); + var node = createSynthesizedNode(200 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59226,7 +59941,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(199 /* AwaitExpression */); + var node = createSynthesizedNode(201 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59238,7 +59953,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(202 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -59251,7 +59966,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(203 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -59264,7 +59979,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(202 /* BinaryExpression */); + var node = createSynthesizedNode(204 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -59281,11 +59996,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(203 /* ConditionalExpression */); + var node = createSynthesizedNode(205 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(56 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -59301,7 +60016,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(204 /* TemplateExpression */); + var node = createSynthesizedNode(206 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -59315,33 +60030,33 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createTemplateHead(text) { - var node = createSynthesizedNode(14 /* TemplateHead */); + var node = createSynthesizedNode(15 /* TemplateHead */); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; function createTemplateMiddle(text) { - var node = createSynthesizedNode(15 /* TemplateMiddle */); + var node = createSynthesizedNode(16 /* TemplateMiddle */); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; function createTemplateTail(text) { - var node = createSynthesizedNode(16 /* TemplateTail */); + var node = createSynthesizedNode(17 /* TemplateTail */); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(13 /* NoSubstitutionTemplateLiteral */); + var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); node.text = text; return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(205 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(207 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -59353,7 +60068,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(206 /* SpreadElement */); + var node = createSynthesizedNode(208 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -59365,7 +60080,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(207 /* ClassExpression */); + var node = createSynthesizedNode(209 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59386,11 +60101,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(208 /* OmittedExpression */); + return createSynthesizedNode(210 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(211 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -59404,7 +60119,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(210 /* AsExpression */); + var node = createSynthesizedNode(212 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -59418,7 +60133,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(211 /* NonNullExpression */); + var node = createSynthesizedNode(213 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -59430,7 +60145,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(212 /* MetaProperty */); + var node = createSynthesizedNode(214 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -59444,7 +60159,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(214 /* TemplateSpan */); + var node = createSynthesizedNode(216 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -59458,12 +60173,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(215 /* SemicolonClassElement */); + return createSynthesizedNode(217 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(216 /* Block */); + var block = createSynthesizedNode(218 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -59477,7 +60192,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(217 /* VariableStatement */); + var node = createSynthesizedNode(219 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -59492,11 +60207,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(218 /* EmptyStatement */); + return createSynthesizedNode(220 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(219 /* ExpressionStatement */); + var node = createSynthesizedNode(221 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -59512,7 +60227,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(220 /* IfStatement */); + var node = createSynthesizedNode(222 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -59528,7 +60243,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(221 /* DoStatement */); + var node = createSynthesizedNode(223 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -59542,7 +60257,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(222 /* WhileStatement */); + var node = createSynthesizedNode(224 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -59556,7 +60271,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(223 /* ForStatement */); + var node = createSynthesizedNode(225 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -59574,7 +60289,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(224 /* ForInStatement */); + var node = createSynthesizedNode(226 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -59590,7 +60305,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(225 /* ForOfStatement */); + var node = createSynthesizedNode(227 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -59608,7 +60323,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(226 /* ContinueStatement */); + var node = createSynthesizedNode(228 /* ContinueStatement */); node.label = asName(label); return node; } @@ -59620,7 +60335,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(227 /* BreakStatement */); + var node = createSynthesizedNode(229 /* BreakStatement */); node.label = asName(label); return node; } @@ -59632,7 +60347,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(228 /* ReturnStatement */); + var node = createSynthesizedNode(230 /* ReturnStatement */); node.expression = expression; return node; } @@ -59644,7 +60359,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(229 /* WithStatement */); + var node = createSynthesizedNode(231 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -59658,7 +60373,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(230 /* SwitchStatement */); + var node = createSynthesizedNode(232 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -59672,7 +60387,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(231 /* LabeledStatement */); + var node = createSynthesizedNode(233 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -59686,7 +60401,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(232 /* ThrowStatement */); + var node = createSynthesizedNode(234 /* ThrowStatement */); node.expression = expression; return node; } @@ -59698,7 +60413,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(233 /* TryStatement */); + var node = createSynthesizedNode(235 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -59714,11 +60429,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(234 /* DebuggerStatement */); + return createSynthesizedNode(236 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(235 /* VariableDeclaration */); + var node = createSynthesizedNode(237 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -59735,7 +60450,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(236 /* VariableDeclarationList */); + var node = createSynthesizedNode(238 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -59748,7 +60463,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(237 /* FunctionDeclaration */); + var node = createSynthesizedNode(239 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -59774,7 +60489,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(238 /* ClassDeclaration */); + var node = createSynthesizedNode(240 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59796,7 +60511,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(239 /* InterfaceDeclaration */); + var node = createSynthesizedNode(241 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59818,7 +60533,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(242 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59838,7 +60553,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(241 /* EnumDeclaration */); + var node = createSynthesizedNode(243 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59857,7 +60572,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(242 /* ModuleDeclaration */); + var node = createSynthesizedNode(244 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -59876,7 +60591,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(243 /* ModuleBlock */); + var node = createSynthesizedNode(245 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -59888,7 +60603,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(244 /* CaseBlock */); + var node = createSynthesizedNode(246 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -59900,7 +60615,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(247 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -59912,7 +60627,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(248 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59930,7 +60645,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(247 /* ImportDeclaration */); + var node = createSynthesizedNode(249 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -59948,7 +60663,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(248 /* ImportClause */); + var node = createSynthesizedNode(250 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -59962,7 +60677,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(249 /* NamespaceImport */); + var node = createSynthesizedNode(251 /* NamespaceImport */); node.name = name; return node; } @@ -59974,7 +60689,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(250 /* NamedImports */); + var node = createSynthesizedNode(252 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -59986,7 +60701,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ImportSpecifier */); + var node = createSynthesizedNode(253 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -60000,11 +60715,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(252 /* ExportAssignment */); + var node = createSynthesizedNode(254 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(58 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(59 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -60017,7 +60732,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(253 /* ExportDeclaration */); + var node = createSynthesizedNode(255 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -60035,7 +60750,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(254 /* NamedExports */); + var node = createSynthesizedNode(256 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -60047,7 +60762,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(255 /* ExportSpecifier */); + var node = createSynthesizedNode(257 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -60062,7 +60777,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(257 /* ExternalModuleReference */); + var node = createSynthesizedNode(259 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -60073,9 +60788,57 @@ var ts; : node; } ts.updateExternalModuleReference = updateExternalModuleReference; + // JSDoc + /* @internal */ + function createJSDocTypeExpression(type) { + var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + node.type = type; + return node; + } + ts.createJSDocTypeExpression = createJSDocTypeExpression; + /* @internal */ + function createJSDocTypeTag(typeExpression, comment) { + var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocTypeTag = createJSDocTypeTag; + /* @internal */ + function createJSDocReturnTag(typeExpression, comment) { + var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocReturnTag = createJSDocReturnTag; + /* @internal */ + function createJSDocParamTag(name, isBracketed, typeExpression, comment) { + var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + tag.typeExpression = typeExpression; + tag.name = name; + tag.isBracketed = isBracketed; + tag.comment = comment; + return tag; + } + ts.createJSDocParamTag = createJSDocParamTag; + /* @internal */ + function createJSDocComment(comment, tags) { + var node = createSynthesizedNode(291 /* JSDocComment */); + node.comment = comment; + node.tags = tags; + return node; + } + ts.createJSDocComment = createJSDocComment; + /* @internal */ + function createJSDocTag(kind, tagName) { + var node = createSynthesizedNode(kind); + node.tagName = createIdentifier(tagName); + return node; + } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(258 /* JsxElement */); + var node = createSynthesizedNode(260 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -60091,7 +60854,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(261 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60107,7 +60870,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(260 /* JsxOpeningElement */); + var node = createSynthesizedNode(262 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60123,7 +60886,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(261 /* JsxClosingElement */); + var node = createSynthesizedNode(263 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -60135,7 +60898,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(262 /* JsxFragment */); + var node = createSynthesizedNode(264 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -60151,7 +60914,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(265 /* JsxAttribute */); + var node = createSynthesizedNode(267 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -60165,7 +60928,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(266 /* JsxAttributes */); + var node = createSynthesizedNode(268 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -60177,7 +60940,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(269 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -60189,7 +60952,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(268 /* JsxExpression */); + var node = createSynthesizedNode(270 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -60203,7 +60966,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(269 /* CaseClause */); + var node = createSynthesizedNode(271 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -60217,7 +60980,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(270 /* DefaultClause */); + var node = createSynthesizedNode(272 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -60229,7 +60992,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(271 /* HeritageClause */); + var node = createSynthesizedNode(273 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -60242,7 +61005,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(272 /* CatchClause */); + var node = createSynthesizedNode(274 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -60257,7 +61020,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(273 /* PropertyAssignment */); + var node = createSynthesizedNode(275 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -60272,7 +61035,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(276 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -60286,7 +61049,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(275 /* SpreadAssignment */); + var node = createSynthesizedNode(277 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -60299,7 +61062,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(276 /* EnumMember */); + var node = createSynthesizedNode(278 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -60320,7 +61083,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(277 /* SourceFile */); + var updated = createSynthesizedNode(279 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -60404,7 +61167,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(305 /* NotEmittedStatement */); + var node = createSynthesizedNode(307 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -60416,7 +61179,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(309 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60428,7 +61191,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(308 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60443,7 +61206,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(306 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -60459,17 +61222,17 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 307 /* CommaListExpression */) { + if (node.kind === 309 /* CommaListExpression */) { return node.elements; } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { return [node.left, node.right]; } } return node; } function createCommaList(elements) { - var node = createSynthesizedNode(307 /* CommaListExpression */); + var node = createSynthesizedNode(309 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -60482,14 +61245,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(278 /* Bundle */); + var node = ts.createNode(280 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(279 /* UnparsedSource */); + var node = ts.createNode(281 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -60497,7 +61260,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(280 /* InputFiles */); + var node = ts.createNode(282 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -60539,47 +61302,47 @@ var ts; } ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { - return createBinary(left, 26 /* CommaToken */, right); + return createBinary(left, 27 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 27 /* LessThanToken */, right); + return createBinary(left, 28 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 58 /* EqualsToken */, right); + return createBinary(left, 59 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 34 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 35 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 37 /* PlusToken */, right); + return createBinary(left, 38 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 38 /* MinusToken */, right); + return createBinary(left, 39 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 43 /* PlusPlusToken */); + return createPostfix(operand, 44 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 53 /* AmpersandAmpersandToken */, right); + return createBinary(left, 54 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 54 /* BarBarToken */, right); + return createBinary(left, 55 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(51 /* ExclamationToken */, operand); + return createPrefix(52 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -60640,7 +61403,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 === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -61151,7 +61914,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 233 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -61163,19 +61926,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return cacheIdentifiers; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: return false; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -61190,7 +61954,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 97 /* SuperKeyword */) { + else if (callee.kind === 98 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -61202,7 +61966,7 @@ var ts; } else { switch (callee.kind) { - case 187 /* PropertyAccessExpression */: { + case 189 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61215,7 +61979,7 @@ var ts; } break; } - case 188 /* ElementAccessExpression */: { + case 190 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61272,14 +62036,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -61287,7 +62051,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_9 = []; + var properties_8 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -61298,7 +62062,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_9.push(getter); + properties_8.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -61310,15 +62074,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_9.push(setter); + properties_8.push(setter); } - properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_9, multiLine) + ts.createObjectLiteral(properties_8, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -61605,7 +62369,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 === 193 /* ParenthesizedExpression */) { + if (skipped.kind === 195 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -61639,10 +62403,10 @@ 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(202 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(204 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 195 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 197 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -61654,7 +62418,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 205 /* YieldExpression */) { + && operand.kind === 207 /* YieldExpression */) { return false; } return true; @@ -61691,7 +62455,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 37 /* PlusToken */) { + if (binaryOperator === 38 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -61726,10 +62490,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 === 39 /* AsteriskToken */ - || binaryOperator === 49 /* BarToken */ - || binaryOperator === 48 /* AmpersandToken */ - || binaryOperator === 50 /* CaretToken */; + return binaryOperator === 40 /* AsteriskToken */ + || binaryOperator === 50 /* BarToken */ + || binaryOperator === 49 /* AmpersandToken */ + || binaryOperator === 51 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -61742,7 +62506,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -61757,7 +62521,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(205 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -61792,8 +62556,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: needsParens = true; } } @@ -61809,9 +62573,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.createParen(expression); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -61834,7 +62598,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 192 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -61872,7 +62636,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -61883,29 +62647,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { + if (kind === 196 /* FunctionExpression */ || kind === 197 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { + if (leftmostExpressionKind === 188 /* ObjectLiteralExpression */ || leftmostExpressionKind === 196 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 175 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -61913,9 +62677,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 174 /* InferType */: + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 176 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -61941,28 +62705,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: node = node.operand; continue; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: node = node.left; continue; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: node = node.condition; continue; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: node = node.tag; continue; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 210 /* AsExpression */: - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: - case 211 /* NonNullExpression */: - case 306 /* PartiallyEmittedExpression */: + case 212 /* AsExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 213 /* NonNullExpression */: + case 308 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -61970,15 +62734,15 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 188 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || - node.kind === 307 /* CommaListExpression */; + return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 309 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -61991,13 +62755,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 211 /* NonNullExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -62022,7 +62786,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 213 /* NonNullExpression */) { node = node.expression; } return node; @@ -62030,11 +62794,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 306 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 195 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -62052,7 +62816,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 193 /* ParenthesizedExpression */ + return node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -62117,10 +62881,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 249 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 255 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -62136,7 +62900,7 @@ var ts; */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 - if (moduleName.kind === 9 /* StringLiteral */) { + if (moduleName.kind === 10 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) || ts.getSynthesizedClone(moduleName); @@ -62239,7 +63003,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -62251,11 +63015,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -62287,12 +63051,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 151 /* Parameter */: + case 186 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 206 /* SpreadElement */: - case 275 /* SpreadAssignment */: + case 208 /* SpreadElement */: + case 277 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -62304,7 +63068,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 184 /* BindingElement */: + case 186 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -62316,7 +63080,7 @@ var ts; : propertyName; } break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -62328,7 +63092,7 @@ var ts; : propertyName; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -62343,7 +63107,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ + return kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */; } /** @@ -62351,13 +63115,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -62397,11 +63161,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -62562,276 +63326,276 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */) || kind === 178 /* ThisType */) { return node; } switch (kind) { // Names - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 150 /* Decorator */: + case 152 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 155 /* Constructor */: + case 157 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 168 /* TupleType */: + case 170 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 170 /* RestType */: + case 172 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 171 /* UnionType */: + case 173 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 174 /* InferType */: + case 176 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 179 /* MappedType */: + case 181 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 216 /* Block */: + case 218 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -62873,58 +63637,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { + if ((kind >= 163 /* TypePredicate */ && kind <= 182 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 215 /* SemicolonClassElement */: - case 218 /* EmptyStatement */: - case 208 /* OmittedExpression */: - case 234 /* DebuggerStatement */: - case 305 /* NotEmittedStatement */: + case 217 /* SemicolonClassElement */: + case 220 /* EmptyStatement */: + case 210 /* OmittedExpression */: + case 236 /* DebuggerStatement */: + case 307 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 149 /* Parameter */: + case 151 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 150 /* Decorator */: + case 152 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62933,12 +63697,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* Constructor */: + case 157 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62946,7 +63710,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62954,49 +63718,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 190 /* NewExpression */: + case 192 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -63004,123 +63769,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ParenthesizedExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 210 /* AsExpression */: + case 212 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 216 /* Block */: + case 218 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 222 /* WhileStatement */: - case 229 /* WithStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63129,7 +63894,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63137,139 +63902,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); + result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -63342,7 +64108,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 211 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -63392,7 +64158,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -63429,288 +64195,623 @@ var ts; /* @internal */ var ts; (function (ts) { - function createSourceFileLikeCache(host) { - var cached = ts.createMap(); + function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) { + var _a = generatorOptions.extendedDiagnostics + ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap") + : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit; + // Current source map file and its index in the sources list + var rawSources = []; + var sources = []; + var sourceToSourceIndexMap = ts.createMap(); + var sourcesContent; + var names = []; + var nameToNameIndexMap; + var mappings = ""; + // Last recorded and encoded mappings + var lastGeneratedLine = 0; + var lastGeneratedCharacter = 0; + var lastSourceIndex = 0; + var lastSourceLine = 0; + var lastSourceCharacter = 0; + var lastNameIndex = 0; + var hasLast = false; + var pendingGeneratedLine = 0; + var pendingGeneratedCharacter = 0; + var pendingSourceIndex = 0; + var pendingSourceLine = 0; + var pendingSourceCharacter = 0; + var pendingNameIndex = 0; + var hasPending = false; + var hasPendingSource = false; + var hasPendingName = false; return { - get: function (path) { - if (cached.has(path)) { - return cached.get(path); + getSources: function () { return rawSources; }, + addSource: addSource, + setSourceContent: setSourceContent, + addName: addName, + addMapping: addMapping, + appendSourceMap: appendSourceMap, + toJSON: toJSON, + toString: function () { return JSON.stringify(toJSON()); } + }; + function addSource(fileName) { + enter(); + var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + var sourceIndex = sourceToSourceIndexMap.get(source); + if (sourceIndex === undefined) { + sourceIndex = sources.length; + sources.push(source); + rawSources.push(fileName); + sourceToSourceIndexMap.set(source, sourceIndex); + } + exit(); + return sourceIndex; + } + function setSourceContent(sourceIndex, content) { + enter(); + if (content !== null) { + if (!sourcesContent) + sourcesContent = []; + while (sourcesContent.length < sourceIndex) { + // tslint:disable-next-line:no-null-keyword boolean-trivia + sourcesContent.push(null); } - if (!host.fileExists || !host.readFile || !host.fileExists(path)) - return; - // And failing that, check the disk - var text = host.readFile(path); // TODO: GH#18217 - var file = { - text: text, - lineMap: undefined, - getLineAndCharacterOfPosition: function (pos) { - return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + sourcesContent[sourceIndex] = content; + } + exit(); + } + function addName(name) { + enter(); + if (!nameToNameIndexMap) + nameToNameIndexMap = ts.createMap(); + var nameIndex = nameToNameIndexMap.get(name); + if (nameIndex === undefined) { + nameIndex = names.length; + names.push(name); + nameToNameIndexMap.set(name, nameIndex); + } + exit(); + return nameIndex; + } + function isNewGeneratedPosition(generatedLine, generatedCharacter) { + return !hasPending + || pendingGeneratedLine !== generatedLine + || pendingGeneratedCharacter !== generatedCharacter; + } + function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) { + return sourceIndex !== undefined + && sourceLine !== undefined + && sourceCharacter !== undefined + && pendingSourceIndex === sourceIndex + && (pendingSourceLine > sourceLine + || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter); + } + function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) { + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative"); + ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative"); + ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative"); + enter(); + // If this location wasn't recorded or the location in source is going backwards, record the mapping + if (isNewGeneratedPosition(generatedLine, generatedCharacter) || + isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) { + commitPendingMapping(); + pendingGeneratedLine = generatedLine; + pendingGeneratedCharacter = generatedCharacter; + hasPendingSource = false; + hasPendingName = false; + hasPending = true; + } + if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) { + pendingSourceIndex = sourceIndex; + pendingSourceLine = sourceLine; + pendingSourceCharacter = sourceCharacter; + hasPendingSource = true; + if (nameIndex !== undefined) { + pendingNameIndex = nameIndex; + hasPendingName = true; + } + } + exit(); + } + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + var _a; + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + enter(); + // First, decode the old component sourcemap + var sourceIndexToNewSourceIndexMap = []; + var nameIndexToNewNameIndexMap; + var mappingIterator = decodeMappings(map.mappings); + for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + // Then reencode all the updated mappings into the overall map + var newSourceIndex = void 0; + var newSourceLine = void 0; + var newSourceCharacter = void 0; + var newNameIndex = void 0; + if (raw.sourceIndex !== undefined) { + newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex]; + if (newSourceIndex === undefined) { + // Apply offsets to each position and fixup source entries + var rawPath = map.sources[raw.sourceIndex]; + var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath); + sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath); + if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") { + setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]); + } } - }; - cached.set(path, file); - return file; + newSourceLine = raw.sourceLine; + newSourceCharacter = raw.sourceCharacter; + if (map.names && raw.nameIndex !== undefined) { + if (!nameIndexToNewNameIndexMap) + nameIndexToNewNameIndexMap = []; + newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex]; + if (newNameIndex === undefined) { + nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]); + } + } + } + var newGeneratedLine = raw.generatedLine + generatedLine; + var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); + } + exit(); + } + function shouldCommitMapping() { + return !hasLast + || lastGeneratedLine !== pendingGeneratedLine + || lastGeneratedCharacter !== pendingGeneratedCharacter + || lastSourceIndex !== pendingSourceIndex + || lastSourceLine !== pendingSourceLine + || lastSourceCharacter !== pendingSourceCharacter + || lastNameIndex !== pendingNameIndex; + } + function commitPendingMapping() { + if (!hasPending || !shouldCommitMapping()) { + return; + } + enter(); + // Line/Comma delimiters + if (lastGeneratedLine < pendingGeneratedLine) { + // Emit line delimiters + do { + mappings += ";"; + lastGeneratedLine++; + lastGeneratedCharacter = 0; + } while (lastGeneratedLine < pendingGeneratedLine); + } + else { + ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); + // Emit comma to separate the entry + if (hasLast) { + mappings += ","; + } + } + // 1. Relative generated character + mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + lastGeneratedCharacter = pendingGeneratedCharacter; + if (hasPendingSource) { + // 2. Relative sourceIndex + mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + lastSourceIndex = pendingSourceIndex; + // 3. Relative source line + mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + lastSourceLine = pendingSourceLine; + // 4. Relative source character + mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + lastSourceCharacter = pendingSourceCharacter; + if (hasPendingName) { + // 5. Relative nameIndex + mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + lastNameIndex = pendingNameIndex; + } + } + hasLast = true; + exit(); + } + function toJSON() { + commitPendingMapping(); + return { + version: 3, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings, + sourcesContent: sourcesContent, + }; + } + } + ts.createSourceMapGenerator = createSourceMapGenerator; + // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + /** + * Tries to find the sourceMappingURL comment at the end of a file. + * @param text The source text of the file. + * @param lineStarts The line starts of the file. + */ + function tryGetSourceMappingURL(text, lineStarts) { + if (lineStarts === void 0) { lineStarts = ts.computeLineStarts(text); } + for (var index = lineStarts.length - 1; index >= 0; index--) { + var line = text.substring(lineStarts[index], lineStarts[index + 1]); + var comment = sourceMapCommentRegExp.exec(line); + if (comment) { + return comment[1]; + } + // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!line.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + function isStringOrNull(x) { + // tslint:disable-next-line:no-null-keyword + return typeof x === "string" || x === null; + } + function isRawSourceMap(x) { + // tslint:disable-next-line:no-null-keyword + return x !== null + && typeof x === "object" + && x.version === 3 + && typeof x.file === "string" + && typeof x.mappings === "string" + && ts.isArray(x.sources) && ts.every(x.sources, ts.isString) + && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string") + && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull)) + && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); + } + ts.isRawSourceMap = isRawSourceMap; + function tryParseRawSourceMap(text) { + try { + var parsed = JSON.parse(text); + if (isRawSourceMap(parsed)) { + return parsed; + } + } + catch (_a) { + // empty + } + return undefined; + } + ts.tryParseRawSourceMap = tryParseRawSourceMap; + function decodeMappings(mappings) { + var done = false; + var pos = 0; + var generatedLine = 0; + var generatedCharacter = 0; + var sourceIndex = 0; + var sourceLine = 0; + var sourceCharacter = 0; + var nameIndex = 0; + var error; + return { + get pos() { return pos; }, + get error() { return error; }, + get state() { return captureMapping(/*hasSource*/ true, /*hasName*/ true); }, + next: function () { + while (!done && pos < mappings.length) { + var ch = mappings.charCodeAt(pos); + if (ch === 59 /* semicolon */) { + // new line + generatedLine++; + generatedCharacter = 0; + pos++; + continue; + } + if (ch === 44 /* comma */) { + // Next entry is on same line - no action needed + pos++; + continue; + } + var hasSource = false; + var hasName = false; + generatedCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (generatedCharacter < 0) + return setErrorAndStopIterating("Invalid generatedCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasSource = true; + sourceIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceIndex < 0) + return setErrorAndStopIterating("Invalid sourceIndex found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex"); + sourceLine += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceLine < 0) + return setErrorAndStopIterating("Invalid sourceLine found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine"); + sourceCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceCharacter < 0) + return setErrorAndStopIterating("Invalid sourceCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasName = true; + nameIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (nameIndex < 0) + return setErrorAndStopIterating("Invalid nameIndex found"); + if (!isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex"); + } + } + return { value: captureMapping(hasSource, hasName), done: done }; + } + return stopIterating(); } }; + function captureMapping(hasSource, hasName) { + return { + generatedLine: generatedLine, + generatedCharacter: generatedCharacter, + sourceIndex: hasSource ? sourceIndex : undefined, + sourceLine: hasSource ? sourceLine : undefined, + sourceCharacter: hasSource ? sourceCharacter : undefined, + nameIndex: hasName ? nameIndex : undefined + }; + } + function stopIterating() { + done = true; + return { value: undefined, done: true }; + } + function setError(message) { + if (error === undefined) { + error = message; + } + } + function setErrorAndStopIterating(message) { + setError(message); + return stopIterating(); + } + function hasReportedError() { + return error !== undefined; + } + function isSourceMappingSegmentEnd() { + return (pos === mappings.length || + mappings.charCodeAt(pos) === 44 /* comma */ || + mappings.charCodeAt(pos) === 59 /* semicolon */); + } + function base64VLQFormatDecode() { + var moreDigits = true; + var shiftCount = 0; + var value = 0; + for (; moreDigits; pos++) { + if (pos >= mappings.length) + return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1; + // 6 digit number + var currentByte = base64FormatDecode(mappings.charCodeAt(pos)); + if (currentByte === -1) + return setError("Invalid character in VLQ"), -1; + // If msb is set, we still have more bits to continue + moreDigits = (currentByte & 32) !== 0; + // least significant 5 bits are the next msbs in the final value. + value = value | ((currentByte & 31) << shiftCount); + shiftCount += 5; + } + // Least significant bit if 1 represents negative and rest of the msb is actual absolute value + if ((value & 1) === 0) { + // + number + value = value >> 1; + } + else { + // - number + value = value >> 1; + value = -value; + } + return value; + } } - ts.createSourceFileLikeCache = createSourceFileLikeCache; -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - var sourcemaps; - (function (sourcemaps) { - sourcemaps.identitySourceMapper = { getOriginalPosition: ts.identity, getGeneratedPosition: ts.identity }; - function decode(host, mapPath, map, program, fallbackCache) { - if (fallbackCache === void 0) { fallbackCache = ts.createSourceFileLikeCache(host); } - var currentDirectory = ts.getDirectoryPath(mapPath); - var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory; - var decodedMappings; - var generatedOrderedMappings; - var sourceOrderedMappings; - return { - getOriginalPosition: getOriginalPosition, - getGeneratedPosition: getGeneratedPosition - }; - function getGeneratedPosition(loc) { - var maps = getSourceOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { sourcePath: loc.fileName, sourcePosition: loc.position }, ts.identity, compareProcessedPositionSourcePositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - if (!maps[targetIndex] || ts.comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot) !== 0) { - return loc; - } - return { fileName: ts.toPath(map.file, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].emittedPosition }; // Closest pos - } - function getOriginalPosition(loc) { - var maps = getGeneratedOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { emittedPosition: loc.position }, ts.identity, compareProcessedPositionEmittedPositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - return { fileName: ts.toPath(maps[targetIndex].sourcePath, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].sourcePosition }; // Closest pos - } - function getSourceFileLike(fileName, location) { - // Lookup file in program, if provided - var path = ts.toPath(fileName, location, host.getCanonicalFileName); - var file = program && program.getSourceFile(path); - // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file - if (!file || file.resolvedPath !== path) { - // Otherwise check the cache (which may hit disk) - return fallbackCache.get(path); - } - return file; - } - function getPositionOfLineAndCharacterUsingName(fileName, directory, line, character) { - var file = getSourceFileLike(fileName, directory); - if (!file) { - return -1; - } - return ts.getPositionOfLineAndCharacter(file, line, character); - } - function getDecodedMappings() { - return decodedMappings || (decodedMappings = calculateDecodedMappings(map, processPosition, host)); - } - function getSourceOrderedMappings() { - return sourceOrderedMappings || (sourceOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionSourcePositions)); - } - function getGeneratedOrderedMappings() { - return generatedOrderedMappings || (generatedOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionEmittedPositions)); - } - function compareProcessedPositionSourcePositions(a, b) { - return ts.comparePaths(a.sourcePath, b.sourcePath, sourceRoot) || - ts.compareValues(a.sourcePosition, b.sourcePosition); - } - function compareProcessedPositionEmittedPositions(a, b) { - return ts.compareValues(a.emittedPosition, b.emittedPosition); - } - function processPosition(position) { - var sourcePath = map.sources[position.sourceIndex]; - return { - emittedPosition: getPositionOfLineAndCharacterUsingName(map.file, currentDirectory, position.emittedLine, position.emittedColumn), - sourcePosition: getPositionOfLineAndCharacterUsingName(sourcePath, sourceRoot, position.sourceLine, position.sourceColumn), - sourcePath: sourcePath, - }; - } + ts.decodeMappings = decodeMappings; + function sameMapping(left, right) { + return left === right + || left.generatedLine === right.generatedLine + && left.generatedCharacter === right.generatedCharacter + && left.sourceIndex === right.sourceIndex + && left.sourceLine === right.sourceLine + && left.sourceCharacter === right.sourceCharacter + && left.nameIndex === right.nameIndex; + } + ts.sameMapping = sameMapping; + function isSourceMapping(mapping) { + return mapping.sourceIndex !== undefined + && mapping.sourceLine !== undefined + && mapping.sourceCharacter !== undefined; + } + 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 */ : + ts.Debug.fail(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 : + -1; + } + function base64VLQFormatEncode(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; } - sourcemaps.decode = decode; - /*@internal*/ - function decodeMappings(map) { - var state = { - encodedText: map.mappings, - currentNameIndex: undefined, - sourceMapNamesLength: map.names ? map.names.length : undefined, - currentEmittedColumn: 0, - currentEmittedLine: 0, - currentSourceColumn: 0, - currentSourceLine: 0, - currentSourceIndex: 0, - decodingIndex: 0 - }; - function captureSpan() { - return { - emittedColumn: state.currentEmittedColumn, - emittedLine: state.currentEmittedLine, - sourceColumn: state.currentSourceColumn, - sourceIndex: state.currentSourceIndex, - sourceLine: state.currentSourceLine, - nameIndex: state.currentNameIndex - }; + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + return encodedStr; + } + function isSourceMappedPosition(value) { + return value.sourceIndex !== undefined + && value.sourcePosition !== undefined; + } + function sameMappedPosition(left, right) { + return left.generatedPosition === right.generatedPosition + && left.sourceIndex === right.sourceIndex + && left.sourcePosition === right.sourcePosition; + } + function compareSourcePositions(left, right) { + return ts.compareValues(left.sourceIndex, right.sourceIndex); + } + function compareGeneratedPositions(left, right) { + return ts.compareValues(left.generatedPosition, right.generatedPosition); + } + function getSourcePositionOfMapping(value) { + return value.sourcePosition; + } + function getGeneratedPositionOfMapping(value) { + return value.generatedPosition; + } + function createDocumentPositionMapper(host, map, mapPath) { + var mapDirectory = ts.getDirectoryPath(mapPath); + var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory; + var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory); + var generatedCanonicalFilePath = host.getCanonicalFileName(generatedAbsoluteFilePath); + var generatedFile = host.getSourceFileLike(generatedCanonicalFilePath); + var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); }); + var sourceFileCanonicalPaths = sourceFileAbsolutePaths.map(function (source) { return host.getCanonicalFileName(source); }); + var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileCanonicalPaths.map(function (source, i) { return [source, i]; })); + var decodedMappings; + var generatedMappings; + var sourceMappings; + return { + getSourcePosition: getSourcePosition, + getGeneratedPosition: getGeneratedPosition + }; + function processMapping(mapping) { + var generatedPosition = generatedFile !== undefined + ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter) + : -1; + var source; + var sourcePosition; + if (isSourceMapping(mapping)) { + var sourceFilePath = sourceFileCanonicalPaths[mapping.sourceIndex]; + var sourceFile = host.getSourceFileLike(sourceFilePath); + source = map.sources[mapping.sourceIndex]; + sourcePosition = sourceFile !== undefined + ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter) + : -1; } return { - get decodingIndex() { return state.decodingIndex; }, - get error() { return state.error; }, - get lastSpan() { return captureSpan(); }, - next: function () { - if (hasCompletedDecoding(state) || state.error) - return { done: true, value: undefined }; - if (!decodeSinglePosition(state)) - return { done: true, value: undefined }; - return { done: false, value: captureSpan() }; - } + generatedPosition: generatedPosition, + source: source, + sourceIndex: mapping.sourceIndex, + sourcePosition: sourcePosition, + nameIndex: mapping.nameIndex }; } - sourcemaps.decodeMappings = decodeMappings; - function calculateDecodedMappings(map, processPosition, host) { - var decoder = decodeMappings(map); - var positions = ts.arrayFrom(decoder, processPosition); - if (decoder.error) { - if (host && host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); - } - return []; - } - return positions; - } - function hasCompletedDecoding(state) { - return state.decodingIndex === state.encodedText.length; - } - function decodeSinglePosition(state) { - while (state.decodingIndex < state.encodedText.length) { - var char = state.encodedText.charCodeAt(state.decodingIndex); - if (char === 59 /* semicolon */) { - // New line - state.currentEmittedLine++; - state.currentEmittedColumn = 0; - state.decodingIndex++; - continue; - } - if (char === 44 /* comma */) { - // Next entry is on same line - no action needed - state.decodingIndex++; - continue; - } - // Read the current position - // 1. Column offset from prev read jsColumn - state.currentEmittedColumn += base64VLQFormatDecode(); - // Incorrect emittedColumn dont support this map - if (createErrorIfCondition(state.currentEmittedColumn < 0, "Invalid emittedColumn found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted column")) { - return false; - } - // 2. Relative sourceIndex - state.currentSourceIndex += base64VLQFormatDecode(); - // Incorrect sourceIndex dont support this map - if (createErrorIfCondition(state.currentSourceIndex < 0, "Invalid sourceIndex found")) { - return false; - } - // Dont support reading mappings that dont have information about original source position - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after sourceIndex")) { - return false; - } - // 3. Relative sourceLine 0 based - state.currentSourceLine += base64VLQFormatDecode(); - // Incorrect sourceLine dont support this map - if (createErrorIfCondition(state.currentSourceLine < 0, "Invalid sourceLine found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted Line")) { - return false; - } - // 4. Relative sourceColumn 0 based - state.currentSourceColumn += base64VLQFormatDecode(); - // Incorrect sourceColumn dont support this map - if (createErrorIfCondition(state.currentSourceColumn < 0, "Invalid sourceLine found")) { - return false; - } - // 5. Check if there is name: - if (!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex)) { - if (state.currentNameIndex === undefined) { - state.currentNameIndex = 0; + function getDecodedMappings() { + if (decodedMappings === undefined) { + var decoder = decodeMappings(map.mappings); + var mappings = ts.arrayFrom(decoder, processMapping); + if (decoder.error !== undefined) { + if (host.log) { + host.log("Encountered error while decoding sourcemap: " + decoder.error); } - state.currentNameIndex += base64VLQFormatDecode(); - // Incorrect nameIndex dont support this map - // TODO: If we start using `name`s, issue errors when they aren't correct in the sourcemap - // if (createErrorIfCondition(state.currentNameIndex < 0 || state.currentNameIndex >= state.sourceMapNamesLength, "Invalid name index for the source map entry")) { - // return; - // } - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: There are more entries after " + (state.currentNameIndex === undefined ? "sourceColumn" : "nameIndex"))) { - return false; - } - // Entry should be complete - return true; - } - createErrorIfCondition(/*condition*/ true, "No encoded entry found"); - return false; - function createErrorIfCondition(condition, errormsg) { - if (state.error) { - // An error was already reported - return true; - } - if (condition) { - state.error = errormsg; - } - return condition; - } - function base64VLQFormatDecode() { - var moreDigits = true; - var shiftCount = 0; - var value = 0; - for (; moreDigits; state.decodingIndex++) { - if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return undefined; // TODO: GH#18217 - } - // 6 digit number - var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); - // If msb is set, we still have more bits to continue - moreDigits = (currentByte & 32) !== 0; - // least significant 5 bits are the next msbs in the final value. - value = value | ((currentByte & 31) << shiftCount); - shiftCount += 5; - } - // Least significant bit if 1 represents negative and rest of the msb is actual absolute value - if ((value & 1) === 0) { - // + number - value = value >> 1; + decodedMappings = ts.emptyArray; } else { - // - number - value = value >> 1; - value = -value; + decodedMappings = mappings; } - return value; } + return decodedMappings; } - function base64FormatDecode(char) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(char); + function getSourceMappings(sourceIndex) { + if (sourceMappings === undefined) { + var lists = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + if (!isSourceMappedPosition(mapping)) + continue; + var list = lists[mapping.sourceIndex]; + if (!list) + lists[mapping.sourceIndex] = list = []; + list.push(mapping); + } + sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); }); + } + return sourceMappings[sourceIndex]; } - function isSourceMappingSegmentEnd(encodedText, pos) { - return (pos === encodedText.length || - encodedText.charCodeAt(pos) === 44 /* comma */ || - encodedText.charCodeAt(pos) === 59 /* semicolon */); + function getGeneratedMappings() { + if (generatedMappings === undefined) { + var list = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + list.push(mapping); + } + generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition); + } + return generatedMappings; } - })(sourcemaps = ts.sourcemaps || (ts.sourcemaps = {})); + function getGeneratedPosition(loc) { + var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName)); + if (sourceIndex === undefined) + return loc; + var sourceMappings = getSourceMappings(sourceIndex); + if (!ts.some(sourceMappings)) + return loc; + var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = sourceMappings[targetIndex]; + if (mapping === undefined || mapping.sourceIndex !== sourceIndex) { + return loc; + } + return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition }; // Closest pos + } + function getSourcePosition(loc) { + var generatedMappings = getGeneratedMappings(); + if (!ts.some(generatedMappings)) + return loc; + var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = generatedMappings[targetIndex]; + if (mapping === undefined || !isSourceMappedPosition(mapping)) { + return loc; + } + return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition }; // Closest pos + } + } + ts.createDocumentPositionMapper = createDocumentPositionMapper; + ts.identitySourceMapConsumer = { + getSourcePosition: ts.identity, + getGeneratedPosition: ts.identity + }; })(ts || (ts = {})); /* @internal */ var ts; @@ -63733,7 +64834,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -63779,7 +64880,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -63787,13 +64888,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 246 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + case 248 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -63823,13 +64924,13 @@ var ts; } } break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -63837,7 +64938,7 @@ var ts; } } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -63857,7 +64958,7 @@ var ts; } } break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -64473,8 +65574,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -64504,14 +65605,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -64560,16 +65661,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 243 /* ModuleBlock */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 245 /* ModuleBlock */: + case 218 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -64581,7 +65682,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 === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 240 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -64629,10 +65730,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -64653,13 +65754,13 @@ var ts; return node; } switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -64679,11 +65780,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 253 /* ExportDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 248 /* ImportClause */ || - (node.kind === 246 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 257 /* ExternalModuleReference */)) { + if (node.kind === 255 /* ExportDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 250 /* ImportClause */ || + (node.kind === 248 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 259 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -64713,19 +65814,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 152 /* PropertyDeclaration */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -64735,7 +65836,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 84 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 85 /* ExportKeyword */) { return undefined; } return node; @@ -64752,67 +65853,67 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 133 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 166 /* TypeLiteral */: - case 161 /* TypePredicate */: - case 148 /* TypeParameter */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 122 /* BooleanKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 105 /* VoidKeyword */: - case 138 /* SymbolKeyword */: - case 164 /* ConstructorType */: - case 163 /* FunctionType */: - case 165 /* TypeQuery */: - case 162 /* TypeReference */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 175 /* ParenthesizedType */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 168 /* TypeLiteral */: + case 163 /* TypePredicate */: + case 150 /* TypeParameter */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 123 /* BooleanKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 132 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 139 /* SymbolKeyword */: + case 166 /* ConstructorType */: + case 165 /* FunctionType */: + case 167 /* TypeQuery */: + case 164 /* TypeReference */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 177 /* ParenthesizedType */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: // TypeScript type nodes are elided. - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: // TypeScript index signatures are elided. - case 150 /* Decorator */: + case 152 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 152 /* PropertyDeclaration */: + case 154 /* 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 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructor(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64823,7 +65924,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64834,35 +65935,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -64872,35 +65973,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -64937,7 +66038,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -65006,7 +66107,7 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -65208,7 +66309,7 @@ var ts; pendingExpressions = undefined; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85 /* ExtendsKeyword */; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 86 /* ExtendsKeyword */; })); var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); @@ -65384,7 +66485,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -65455,7 +66556,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 152 /* PropertyDeclaration */ + return member.kind === 154 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -65466,8 +66567,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -65483,8 +66584,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); ts.startOnNewLine(expression); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -65595,12 +66696,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -65753,7 +66854,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 152 /* PropertyDeclaration */ + ? member.kind === 154 /* 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`. ? ts.createVoidZero() @@ -65854,13 +66955,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -65876,10 +66977,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 152 /* PropertyDeclaration */; + return kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 154 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -65889,7 +66990,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -65900,12 +67001,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; } return false; @@ -65922,15 +67023,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: return serializeTypeNode(node.type); - case 157 /* SetAccessor */: - case 156 /* GetAccessor */: + case 159 /* SetAccessor */: + case 158 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 156 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -65967,7 +67068,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 156 /* GetAccessor */) { + if (container && node.kind === 158 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -66012,77 +67113,83 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: return ts.createVoidZero(); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createIdentifier("Function"); - case 167 /* ArrayType */: - case 168 /* TupleType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: return ts.createIdentifier("Array"); - case 161 /* TypePredicate */: - case 122 /* BooleanKeyword */: + case 163 /* TypePredicate */: + case 123 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return ts.createIdentifier("String"); - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 180 /* LiteralType */: + case 182 /* LiteralType */: switch (node.literal.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + return getGlobalBigIntNameWithFallback(); + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 138 /* SymbolKeyword */: + case 146 /* BigIntKeyword */: + return getGlobalBigIntNameWithFallback(); + case 139 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return serializeTypeReferenceNode(node); - case 172 /* IntersectionType */: - case 171 /* UnionType */: - return serializeUnionOrIntersectionType(node); - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 166 /* TypeLiteral */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 176 /* ThisType */: - case 181 /* ImportType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return serializeTypeList(node.types); + case 175 /* ConditionalType */: + return serializeTypeList([node.trueType, node.falseType]); + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 168 /* TypeLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 178 /* ThisType */: + case 183 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); } return ts.createIdentifier("Object"); } - function serializeUnionOrIntersectionType(node) { + function serializeTypeList(types) { // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 131 /* NeverKeyword */) { + if (typeNode.kind === 132 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); @@ -66118,6 +67225,10 @@ var ts; var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: + // From conditional type type reference that cannot be resolved is Similar to any or unknown + if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { + return ts.createIdentifier("Object"); + } var serialized = serializeEntityNameAsExpressionFallback(node.typeName); var temp = ts.createTempVariable(hoistVariableDeclaration); return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object")); @@ -66125,6 +67236,8 @@ var ts; return serializeEntityNameAsExpression(node.typeName); case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.createVoidZero(); + case ts.TypeReferenceSerializationKind.BigIntLikeType: + return getGlobalBigIntNameWithFallback(); case ts.TypeReferenceSerializationKind.BooleanType: return ts.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -66156,12 +67269,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 71 /* Identifier */) { + if (node.left.kind === 72 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -66177,7 +67290,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* 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.getMutableClone(node); @@ -66185,7 +67298,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -66206,6 +67319,15 @@ var ts; function getGlobalSymbolNameWithFallback() { return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object")); } + /** + * Gets an expression that points to the global "BigInt" constructor at runtime if it is + * available. + */ + function getGlobalBigIntNameWithFallback() { + return languageVersion < 6 /* ESNext */ + ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object")) + : ts.createIdentifier("BigInt"); + } /** * A simple inlinable expression is an expression which can be copied into multiple locations * without risk of repeating any sideeffects and whose value could not possibly change between @@ -66286,9 +67408,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 85 /* ExtendsKeyword */) { + if (node.token === 86 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(85 /* ExtendsKeyword */, types), node); + return ts.setTextRange(ts.createHeritageClause(86 /* ExtendsKeyword */, types), node); } return undefined; } @@ -66684,7 +67806,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -66765,12 +67887,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 241 /* EnumDeclaration */) { + if (node.kind === 243 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -66895,7 +68017,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 243 /* ModuleBlock */) { + if (body.kind === 245 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -66941,13 +68063,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 243 /* ModuleBlock */) { + if (body.kind !== 245 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -66988,7 +68110,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 249 /* NamespaceImport */) { + if (node.kind === 251 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -67201,7 +68323,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -67209,7 +68331,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -67219,17 +68341,17 @@ var ts; enabledSubstitutions |= 2 /* 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(71 /* Identifier */); - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); + context.enableSubstitution(72 /* Identifier */); + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(242 /* ModuleDeclaration */); + context.enableEmitNotification(244 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 244 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 243 /* EnumDeclaration */; } /** * Hook for node emit. @@ -67288,11 +68410,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -67330,9 +68452,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 !== 277 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); + if (container && container.kind !== 279 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -67472,26 +68594,26 @@ var ts; return node; } switch (node.kind) { - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -67502,27 +68624,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 216 /* Block */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 229 /* WithStatement */: - case 231 /* LabeledStatement */: + case 218 /* Block */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 231 /* WithStatement */: + case 233 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -67723,7 +68845,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 195 /* ArrowFunction */; + var isArrowFunction = node.kind === 197 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -67808,17 +68930,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -67866,23 +68988,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -67902,11 +69024,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -67973,7 +69095,7 @@ var ts; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -68041,7 +69163,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 120 /* AsyncKeyword */) { + if (node.kind === 121 /* AsyncKeyword */) { return undefined; } return node; @@ -68051,55 +69173,55 @@ var ts; return node; } switch (node.kind) { - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitVoidExpression(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructorDeclaration(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -68135,7 +69257,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 227 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -68147,7 +69269,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 275 /* SpreadAssignment */) { + if (e.kind === 277 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -68156,7 +69278,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 275 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -68174,7 +69296,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 188 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -68202,7 +69324,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 262144 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -68430,7 +69552,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); @@ -68499,17 +69621,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -68557,23 +69679,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -68593,11 +69715,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -68706,13 +69828,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -68720,15 +69842,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 10 /* JsxText */: + case 11 /* JsxText */: return visitJsxText(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -68796,14 +69918,14 @@ var ts; if (node === undefined) { return ts.createTrue(); } - else if (node.kind === 9 /* StringLiteral */) { + else if (node.kind === 10 /* 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 literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text); literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 268 /* JsxExpression */) { + else if (node.kind === 270 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -68897,7 +70019,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 258 /* JsxElement */) { + if (node.kind === 260 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -69203,7 +70325,7 @@ var ts; return node; } switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69211,9 +70333,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 62 /* AsteriskAsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69441,13 +70563,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 228 /* ReturnStatement */ + && node.kind === 230 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 218 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -69466,104 +70588,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: return undefined; // elide static keyword - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return visitClassExpression(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 71 /* Identifier */: + case 72 /* Identifier */: return visitIdentifier(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return visitTemplateLiteral(node); - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitSpreadElement(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return visitThisKeyword(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitMetaProperty(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -69650,14 +70772,14 @@ 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 === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 229 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -69668,7 +70790,7 @@ var ts; } } else { - if (node.kind === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -69687,10 +70809,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 26 /* CommaToken */, copyExpr); + expr = ts.createBinary(expr, 27 /* CommaToken */, copyExpr); } } - returnExpression = ts.createBinary(expr, 26 /* CommaToken */, returnExpression); + returnExpression = ts.createBinary(expr, 27 /* CommaToken */, returnExpression); } return ts.createReturn(returnExpression); } @@ -69824,7 +70946,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -69929,7 +71051,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -69968,11 +71090,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 228 /* ReturnStatement */) { + if (statement.kind === 230 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 220 /* IfStatement */) { + else if (statement.kind === 222 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -69980,7 +71102,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 216 /* Block */) { + else if (statement.kind === 218 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -70038,7 +71160,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -70048,8 +71170,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (8192 /* ContainsLexicalThis */ | 16384 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 202 /* BinaryExpression */ - || superCallExpression.left.kind !== 189 /* CallExpression */) { + if (superCallExpression.kind !== 204 /* BinaryExpression */ + || superCallExpression.left.kind !== 191 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -70194,7 +71316,7 @@ var ts; * synthesized call to `super` */ function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 71 /* Identifier */ && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 72 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** * Adds statements to the body of a function-like node if it contains a rest parameter. @@ -70246,7 +71368,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { + if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 197 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -70265,25 +71387,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return statements; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 94 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70311,20 +71433,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -70516,7 +71638,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 239 /* FunctionDeclaration */ || node.kind === 196 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -70561,7 +71683,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 195 /* ArrowFunction */); + ts.Debug.assert(node.kind === 197 /* 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 @@ -70599,7 +71721,7 @@ var ts; ts.setEmitFlags(block, 1 /* SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 18 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -70629,9 +71751,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -70650,9 +71772,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -70687,7 +71809,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 58 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 59 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -70861,14 +71983,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -71052,7 +72174,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 147 /* ComputedPropertyName */) { + if (property.name.kind === 149 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -71107,7 +72229,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -71173,11 +72295,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 223 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 224 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 225 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 221 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 222 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 225 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 226 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 227 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 223 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 224 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -71202,11 +72324,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 238 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -71357,7 +72479,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -71419,7 +72541,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(51 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -71457,7 +72579,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -71468,7 +72590,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 58 /* EqualsToken */, source); + return ts.createBinary(target, 59 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -71481,7 +72603,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -71495,7 +72617,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -71516,10 +72638,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -71605,20 +72727,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -71729,7 +72851,7 @@ var ts; var body = node.transformFlags & (16384 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -71906,10 +73028,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 131072 /* ContainsRestOrSpread */ || - node.expression.kind === 97 /* SuperKeyword */ || + node.expression.kind === 98 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -71942,7 +73064,7 @@ var ts; resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -72007,7 +73129,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 187 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -72124,7 +73246,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 === 13 /* NoSubstitutionTemplateLiteral */ || node.kind === 16 /* TemplateTail */; + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's @@ -72222,7 +73344,7 @@ var ts; : ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 94 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 95 /* NewKeyword */ && node.name.escapedText === "target") { if (hierarchyFacts & 8192 /* ComputedPropertyName */) { hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; } @@ -72259,7 +73381,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } /** @@ -72269,14 +73391,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(155 /* Constructor */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(195 /* ArrowFunction */); - context.enableEmitNotification(194 /* FunctionExpression */); - context.enableEmitNotification(237 /* FunctionDeclaration */); + context.enableSubstitution(100 /* ThisKeyword */); + context.enableEmitNotification(157 /* Constructor */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(197 /* ArrowFunction */); + context.enableEmitNotification(196 /* FunctionExpression */); + context.enableEmitNotification(239 /* FunctionDeclaration */); } } /** @@ -72317,10 +73439,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 237 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -72333,9 +73455,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -72402,19 +73524,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 221 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 191 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 98 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 208 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -72467,15 +73589,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(260 /* JsxOpeningElement */); - context.enableEmitNotification(261 /* JsxClosingElement */); - context.enableEmitNotification(259 /* JsxSelfClosingElement */); + context.enableEmitNotification(262 /* JsxOpeningElement */); + context.enableEmitNotification(263 /* JsxClosingElement */); + context.enableEmitNotification(261 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(273 /* PropertyAssignment */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(275 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -72494,9 +73616,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -72553,7 +73675,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -72828,13 +73950,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -72847,24 +73969,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return visitBreakStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return visitContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 4194304 /* ContainsYield */) { @@ -72885,21 +74007,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitConditionalExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -72912,9 +74034,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -73113,23 +74235,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 59 /* FirstCompoundAssignment */ - && kind <= 70 /* LastCompoundAssignment */; + return kind >= 60 /* FirstCompoundAssignment */ + && kind <= 71 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 59 /* PlusEqualsToken */: return 37 /* PlusToken */; - case 60 /* MinusEqualsToken */: return 38 /* MinusToken */; - case 61 /* AsteriskEqualsToken */: return 39 /* AsteriskToken */; - case 62 /* AsteriskAsteriskEqualsToken */: return 40 /* AsteriskAsteriskToken */; - case 63 /* SlashEqualsToken */: return 41 /* SlashToken */; - case 64 /* PercentEqualsToken */: return 42 /* PercentToken */; - case 65 /* LessThanLessThanEqualsToken */: return 45 /* LessThanLessThanToken */; - case 66 /* GreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanToken */; - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanGreaterThanToken */; - case 68 /* AmpersandEqualsToken */: return 48 /* AmpersandToken */; - case 69 /* BarEqualsToken */: return 49 /* BarToken */; - case 70 /* CaretEqualsToken */: return 50 /* CaretToken */; + case 60 /* PlusEqualsToken */: return 38 /* PlusToken */; + case 61 /* MinusEqualsToken */: return 39 /* MinusToken */; + case 62 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; + case 63 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; + case 64 /* SlashEqualsToken */: return 42 /* SlashToken */; + case 65 /* PercentEqualsToken */: return 43 /* PercentToken */; + case 66 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; + case 67 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; + case 69 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; + case 70 /* BarEqualsToken */: return 50 /* BarToken */; + case 71 /* CaretEqualsToken */: return 51 /* CaretToken */; } } /** @@ -73142,7 +74264,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -73154,7 +74276,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -73186,7 +74308,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -73241,7 +74363,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 === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -73272,7 +74394,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -73530,35 +74652,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: return transformAndEmitBlock(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return transformAndEmitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return transformAndEmitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return transformAndEmitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return transformAndEmitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -73988,7 +75110,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 272 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -74001,7 +75123,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -74313,7 +75435,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -75229,12 +76351,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(279 /* 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. @@ -75562,23 +76684,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -75605,24 +76727,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -76100,7 +77222,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -76155,10 +77277,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -76340,8 +77462,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -76357,7 +77479,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -76419,12 +77541,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -76445,7 +77567,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -76513,15 +77635,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 203 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 60 /* PlusEqualsToken */ : 61 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -76595,12 +77717,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(279 /* 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. @@ -76821,7 +77943,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 255 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -76846,7 +77968,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 253 /* ExportDeclaration */) { + if (externalImport.kind !== 255 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -76924,19 +78046,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -76986,15 +78108,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -77170,7 +78292,7 @@ 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 === 277 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -77234,7 +78356,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -77296,10 +78418,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -77479,43 +78601,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitDefaultClause(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitTryStatement(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -77698,7 +78820,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 202 /* BinaryExpression */) { + && node.kind === 204 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -77763,7 +78885,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 277 /* SourceFile */; + return container !== undefined && container.kind === 279 /* SourceFile */; } else { return false; @@ -77779,8 +78901,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -77796,7 +78918,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -77844,7 +78966,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -77878,12 +79000,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -77969,22 +79091,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ + var expression = node.kind === 203 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 201 /* PostfixUnaryExpression */) { - expression = node.operator === 43 /* PlusPlusToken */ + if (node.kind === 203 /* PostfixUnaryExpression */) { + expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -78005,7 +79127,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -78044,8 +79166,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(277 /* SourceFile */); - context.enableSubstitution(71 /* Identifier */); + context.enableEmitNotification(279 /* SourceFile */); + context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -78073,10 +79195,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -78183,7 +79305,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78212,7 +79334,7 @@ var ts; 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 === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78259,7 +79381,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78268,8 +79390,8 @@ var ts; } // 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 === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || - (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 154 /* PropertyDeclaration */ || node.kind === 153 /* PropertySignature */ || + (node.kind === 151 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -78278,7 +79400,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 240 /* ClassDeclaration */ || node.kind === 151 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78303,7 +79425,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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.hasModifier(node, 32 /* Static */)) { @@ -78342,26 +79464,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78369,7 +79491,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78383,7 +79505,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78408,30 +79530,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 159 /* ConstructSignature */: - case 164 /* ConstructorType */: + case 161 /* ConstructSignature */: + case 166 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78439,7 +79561,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78452,8 +79574,8 @@ 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 237 /* FunctionDeclaration */: - case 163 /* FunctionType */: + case 239 /* FunctionDeclaration */: + case 165 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78467,34 +79589,34 @@ 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 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* 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 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -78509,9 +79631,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + if (node.parent.parent.kind === 240 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 108 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 109 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -78676,10 +79798,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -78702,14 +79824,14 @@ 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_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(124 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(125 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -78823,11 +79945,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { return name; } else { - if (name.kind === 183 /* ArrayBindingPattern */) { + if (name.kind === 185 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -78835,7 +79957,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 208 /* OmittedExpression */) { + if (elem.kind === 210 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -78848,7 +79970,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(55 /* QuestionToken */)) : undefined, ensureType(p, 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 || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -78860,7 +79982,7 @@ var ts; } function ensureNoInitializer(node) { if (shouldPrintWithInitializer(node)) { - return resolver.createLiteralConstValue(ts.getParseTreeNode(node)); // TODO: Make safe + return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker); // TODO: Make safe } return undefined; } @@ -78873,19 +79995,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 149 /* Parameter */ && + var shouldUseResolverType = node.kind === 151 /* 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) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(120 /* AnyKeyword */); } - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -78893,12 +80015,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 149 /* Parameter */ - || node.kind === 152 /* PropertyDeclaration */ - || node.kind === 151 /* PropertySignature */) { + if (node.kind === 151 /* Parameter */ + || node.kind === 154 /* PropertyDeclaration */ + || node.kind === 153 /* 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)); @@ -78909,26 +80031,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(119 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(120 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return false; } return false; @@ -78982,7 +80104,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 244 /* ModuleDeclaration */ && parent.kind !== 183 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -79002,7 +80124,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 259 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -79029,7 +80151,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 251 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -79134,68 +80256,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 168 /* TypeLiteral */ || input.kind === 181 /* MappedType */) && input.parent.kind !== 242 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 209 /* ExpressionWithTypeArguments */: { + case 211 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 162 /* TypeReference */: { + case 164 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 155 /* Constructor */: { + case 157 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(157 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 154 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 156 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(155 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 156 /* GetAccessor */: { + case 158 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 157 /* SetAccessor */: { + case 159 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 153 /* MethodSignature */: { + case 155 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 158 /* CallSignature */: { + case 160 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 160 /* IndexSignature */: { + case 162 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(120 /* AnyKeyword */))); } - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -79203,13 +80325,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 148 /* TypeParameter */: { + case 150 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 173 /* ConditionalType */: { + case 175 /* 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); @@ -79221,13 +80343,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 163 /* FunctionType */: { + case 165 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 164 /* ConstructorType */: { + case 166 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 181 /* ImportType */: { + case 183 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -79256,7 +80378,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 156 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -79266,7 +80388,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 253 /* ExportDeclaration */: { + case 255 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -79275,13 +80397,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 252 /* ExportAssignment */: { + case 254 /* 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 === 71 /* Identifier */) { + if (input.expression.kind === 72 /* Identifier */) { return input; } else { @@ -79291,7 +80413,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -79305,10 +80427,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -79329,14 +80451,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 242 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 239 /* InterfaceDeclaration */: { + case 241 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 237 /* FunctionDeclaration */: { + case 239 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), @@ -79358,10 +80480,10 @@ var ts; return clean; } } - case 242 /* ModuleDeclaration */: { + case 244 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 243 /* ModuleBlock */) { + if (inner && inner.kind === 245 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -79382,7 +80504,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 238 /* ClassDeclaration */: { + case 240 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -79393,7 +80515,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 71 /* Identifier */) { + if (param.name.kind === 72 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -79423,7 +80545,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 96 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ @@ -79432,16 +80554,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 85 /* ExtendsKeyword */) { + if (clause.token === 86 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 96 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -79452,10 +80574,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 241 /* EnumDeclaration */: { + case 243 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -79474,7 +80596,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 242 /* ModuleDeclaration */) { + if (input.kind === 244 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -79495,7 +80617,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 208 /* OmittedExpression */) { + if (e.kind === 210 /* OmittedExpression */) { return; } if (e.name) { @@ -79558,7 +80680,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 277 /* SourceFile */; + var parentIsFile = node.parent.kind === 279 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -79600,13 +80722,13 @@ var ts; } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 85 /* ExtendsKeyword */ && t.expression.kind === 95 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 86 /* ExtendsKeyword */ && t.expression.kind === 96 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* InterfaceDeclaration */) { return true; } return false; @@ -79631,7 +80753,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 156 /* GetAccessor */ + return accessor.kind === 158 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -79640,52 +80762,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 217 /* VariableStatement */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 219 /* VariableStatement */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 235 /* VariableDeclaration */: - case 148 /* TypeParameter */: - case 209 /* ExpressionWithTypeArguments */: - case 162 /* TypeReference */: - case 173 /* ConditionalType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 181 /* ImportType */: + case 161 /* ConstructSignature */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 237 /* VariableDeclaration */: + case 150 /* TypeParameter */: + case 211 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 175 /* ConditionalType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 183 /* ImportType */: return true; } return false; @@ -79750,6 +80872,14 @@ var ts; return transformers; } ts.getTransformers = getTransformers; + function noEmitSubstitution(_hint, node) { + return node; + } + ts.noEmitSubstitution = noEmitSubstitution; + function noEmitNotification(hint, node, callback) { + callback(hint, node); + } + ts.noEmitNotification = noEmitNotification; /** * Transforms an array of SourceFiles by passing them through each transformer. * @@ -79761,7 +80891,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(310 /* Count */); + var enabledSyntaxKindFeatures = new Array(312 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -79769,8 +80899,8 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; - var onSubstituteNode = function (_, node) { return node; }; - var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var onSubstituteNode = noEmitSubstitution; + var onEmitNode = noEmitNotification; var state = 0 /* Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer @@ -80019,825 +81149,11 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans - var defaultLastEncodedSourceMapSpan = { - emittedLine: 0, - emittedColumn: 0, - sourceLine: 0, - sourceColumn: 0, - sourceIndex: 0 - }; - function createSourceMapWriter(host, writer, compilerOptions) { - if (compilerOptions === void 0) { compilerOptions = host.getCompilerOptions(); } - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var currentSource; - var currentSourceText; - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex; - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan; - var lastEncodedNameIndex; - // Source map data - var sourceMapData; - var sourceMapDataList; - var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); - return { - initialize: initialize, - reset: reset, - setSourceFile: setSourceFile, - emitPos: emitPos, - emitNodeWithSourceMap: emitNodeWithSourceMap, - emitTokenWithSourceMap: emitTokenWithSourceMap, - getText: getText, - getSourceMappingURL: getSourceMappingURL, - }; - /** - * Skips trivia such as comments and white-space that can optionally overriden by the source map source - */ - function skipSourceTrivia(pos) { - return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); - } - /** - * Initialize the SourceMapWriter for a new output file. - * - * @param filePath The path to the generated output file. - * @param sourceMapFilePath The path to the output source map file. - * @param sourceFileOrBundle The input source file or bundle for the program. - */ - function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { - return; - } - if (sourceMapData) { - reset(); - } - sourceMapDataList = outputSourceMapDataList; - currentSource = undefined; - currentSourceText = undefined; - // Current source map file and its index in the sources list - sourceMapSourceIndex = -1; - // Last recorded and encoded spans - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; - lastEncodedNameIndex = 0; - // Initialize source map data - sourceMapData = { - sourceMapFilePath: sourceMapFilePath, - jsSourceMappingURL: !compilerOptions.inlineSourceMap ? ts.getBaseFileName(ts.normalizeSlashes(sourceMapFilePath)) : undefined, - sourceMapFile: ts.getBaseFileName(ts.normalizeSlashes(filePath)), - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 277 /* SourceFile */) { // emitting single module file - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle.fileName, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(filePath)); - } - } - /** - * Reset the SourceMapWriter to an empty state. - */ - function reset() { - if (disabled) { - return; - } - // Record source map data for the test harness. - if (sourceMapDataList) { - sourceMapDataList.push(sourceMapData); - } - currentSource = undefined; - sourceMapDir = undefined; - sourceMapSourceIndex = undefined; - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = undefined; - lastEncodedNameIndex = undefined; - sourceMapData = undefined; - sourceMapDataList = undefined; - } - function captureSection() { - return { - version: 3, - file: sourceMapData.sourceMapFile, - sourceRoot: sourceMapData.sourceMapSourceRoot, - sources: sourceMapData.sourceMapSources, - names: sourceMapData.sourceMapNames, - mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent, - }; - } - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - ts.Debug.assert(lastRecordedSourceMapSpan.emittedColumn >= 0, "lastEncodedSourceMapSpan.emittedColumn was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceIndex >= 0, "lastEncodedSourceMapSpan.sourceIndex was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceLine >= 0, "lastEncodedSourceMapSpan.sourceLine was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceColumn >= 0, "lastEncodedSourceMapSpan.sourceColumn was negative"); - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 0; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - } - /** - * Emits a mapping. - * - * If the position is synthetic (undefined or a negative value), no mapping will be - * created. - * - * @param pos The position. - */ - function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeSourcemap"); - } - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSource, pos); - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - sourceIndex: sourceMapSourceIndex - }; - } - else { - // Take the new pos instead since there is no change in emittedLine and column since last location - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - if (extendedDiagnostics) { - ts.performance.mark("afterSourcemap"); - ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); - } - } - function isPossiblySourceMap(x) { - return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; - } - /** - * Emits a node with possible leading and trailing source maps. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to emit. - * @param emitCallback The callback used to emit the node. - */ - function emitNodeWithSourceMap(hint, node, emitCallback) { - var _a; - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(hint, node); - } - if (node) { - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var text = node.sourceMapText; - var parsed = void 0; - try { - parsed = JSON.parse(text); - } - catch (_b) { - // empty - } - if (!parsed || !isPossiblySourceMap(parsed)) { - return emitCallback(hint, node); - } - var offsetLine = writer.getLine(); - var firstLineColumnOffset = writer.getColumn(); - // First, decode the old component sourcemap - var originalMap = parsed; - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache = ts.createMap(); - var absolutePathCache = ts.createMap(); - var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); - for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { - var pathCacheKey = "" + raw.sourceIndex; - // Apply offsets to each position and fixup source entries - if (!resolvedPathCache.has(pathCacheKey)) { - var rawPath = originalMap.sources[raw.sourceIndex]; - var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - resolvedPathCache.set(pathCacheKey, resolvedPath_1); - absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); - } - var resolvedPath = resolvedPathCache.get(pathCacheKey); - var absolutePath = absolutePathCache.get(pathCacheKey); - // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? - var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); - // Then reencode all the updated spans into the overall map - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); - } - // And actually emit the text these sourcemaps are for - return emitCallback(hint, node); - } - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.sourceMapRange; - var _d = range || node, pos = _d.pos, end = _d.end; - var source = range && range.source; - var oldSource = currentSource; - if (source === oldSource) - source = undefined; - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitPos(skipSourceTrivia(pos)); - } - if (source) - setSourceFile(oldSource); - if (emitFlags & 64 /* NoNestedSourceMaps */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitPos(end); - } - if (source) - setSourceFile(oldSource); - } - } - /** - * Emits a token of a node with possible leading and trailing source maps. - * - * @param node The node containing the token. - * @param token The token to emit. - * @param tokenStartPos The start pos of the token. - * @param emitCallback The callback used to emit the token. - */ - function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(token, writer, tokenPos); - } - var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; - tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - tokenPos = emitCallback(token, writer, tokenPos); - if (range) - tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - return tokenPos; - } - function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); - } - /** - * Set the current source file. - * - * @param sourceFile The source file. - */ - function setSourceFile(sourceFile) { - if (disabled) { - return; - } - currentSource = sourceFile; - currentSourceText = currentSource.text; - if (isJsonSourceMapSource(sourceFile)) { - return; - } - setupSourceEntry(sourceFile.fileName, sourceFile.text); - } - function setupSourceEntry(fileName, content, source) { - if (!source) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); - if (sourceMapSourceIndex === -1) { - sourceMapSourceIndex = sourceMapData.sourceMapSources.length; - sourceMapData.sourceMapSources.push(source); - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(fileName); - if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent.push(content); - } - } - } - /** - * Gets the text for the source map. - */ - function getText() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - encodeLastRecordedSourceMapSpan(); - return JSON.stringify(captureSection()); - } - /** - * Gets the SourceMappingURL for the source map. - */ - function getSourceMappingURL() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.base64encode(ts.sys, getText()); - return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; - } - else { - return sourceMapData.jsSourceMappingURL; - } - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - function base64FormatEncode(inValue) { - if (inValue < 64) { - return base64Chars.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - function createCommentWriter(printerOptions, emitPos) { - var extendedDiagnostics = printerOptions.extendedDiagnostics; - var newLine = ts.getNewLineCharacter(printerOptions); - var writer; - var containerPos = -1; - var containerEnd = -1; - var declarationListContainerEnd = -1; - var currentSourceFile; - var currentText; - var currentLineMap; - var detachedCommentsInfo; - var hasWrittenComment = false; - var disabled = !!printerOptions.removeComments; - return { - reset: reset, - setWriter: setWriter, - setSourceFile: setSourceFile, - emitNodeWithComments: emitNodeWithComments, - emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, - emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, - }; - function emitNodeWithComments(hint, node, emitCallback) { - if (disabled) { - emitCallback(hint, node); - return; - } - if (node) { - hasWrittenComment = false; - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; - if ((pos < 0 && end < 0) || (pos === end)) { - // Both pos and end are synthesized, so just emit the node without comments. - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - } - else { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithComment"); - } - var isEmittedNode = node.kind !== 305 /* NotEmittedStatement */; - // 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 === 10 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 10 /* JsxText */; - // 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); - } - // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { - // Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments. - containerPos = pos; - } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* 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 === 236 /* VariableDeclarationList */) { - declarationListContainerEnd = end; - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithComment"); - } - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithComment"); - } - // Restore previous container state. - containerPos = savedContainerPos; - containerEnd = savedContainerEnd; - 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 && isEmittedNode) { - emitTrailingComments(end); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithComment"); - } - } - } - } - function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { - var leadingComments = emitNode && emitNode.leadingComments; - if (ts.some(leadingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithSynthesizedComments"); - } - ts.forEach(leadingComments, emitLeadingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); - } - } - emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); - var trailingComments = emitNode && emitNode.trailingComments; - if (ts.some(trailingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithSynthesizedComments"); - } - ts.forEach(trailingComments, emitTrailingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); - } - } - } - function emitLeadingSynthesizedComment(comment) { - if (comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function emitTrailingSynthesizedComment(comment) { - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - } - function writeSynthesizedComment(comment) { - var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; - ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); - } - function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; - } - function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - } - function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitBodyWithDetachedComments"); - } - var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = disabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; - if (!skipLeadingComments) { - emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); - } - if (emitFlags & 2048 /* NoNestedComments */ && !disabled) { - disabled = true; - emitCallback(node); - disabled = false; - } - else { - emitCallback(node); - } - if (extendedDiagnostics) { - ts.performance.mark("beginEmitBodyWithDetachedComments"); - } - if (!skipTrailingComments) { - emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); - if (hasWrittenComment && !writer.isAtStartOfLine()) { - writer.writeLine(); - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitBodyWithDetachedComments"); - } - } - function emitLeadingComments(pos, isEmittedNode) { - hasWrittenComment = false; - if (isEmittedNode) { - forEachLeadingCommentToEmit(pos, emitLeadingComment); - } - else if (pos === 0) { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted - forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); - } - } - function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); - } - } - function shouldWriteComment(text, pos) { - if (printerOptions.onlyPrintJsDocStyle) { - return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); - } - return true; - } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (!hasWrittenComment) { - ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); - hasWrittenComment = true; - } - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else if (kind === 3 /* MultiLineCommentTrivia */) { - writer.write(" "); - } - } - function emitLeadingCommentsOfPosition(pos) { - if (disabled || pos === -1) { - return; - } - emitLeadingComments(pos, /*isEmittedNode*/ true); - } - function emitTrailingComments(pos) { - forEachTrailingCommentToEmit(pos, emitTrailingComment); - } - function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - } - function emitTrailingCommentsOfPosition(pos, prefixSpace) { - if (disabled) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); - } - forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); - } - } - function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function forEachLeadingCommentToEmit(pos, cb) { - // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments - if (containerPos === -1 || pos !== containerPos) { - if (hasDetachedComments(pos)) { - forEachLeadingCommentWithoutDetachedComments(cb); - } - else { - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - } - } - function forEachTrailingCommentToEmit(end, cb) { - // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments - if (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd)) { - ts.forEachTrailingCommentRange(currentText, end, cb); - } - } - function reset() { - currentSourceFile = undefined; - currentText = undefined; - currentLineMap = undefined; - detachedCommentsInfo = undefined; - } - function setWriter(output) { - writer = output; - } - function setSourceFile(sourceFile) { - currentSourceFile = sourceFile; - currentText = currentSourceFile.text; - currentLineMap = ts.getLineStarts(currentSourceFile); - detachedCommentsInfo = undefined; - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; - } - function forEachLeadingCommentWithoutDetachedComments(cb) { - // get the leading comments from detachedPos - var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentText, currentLineMap, writer, writeComment, range, newLine, disabled); - if (currentDetachedCommentInfo) { - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - */ - function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); - } - } - ts.createCommentWriter = createCommentWriter; -})(ts || (ts = {})); var ts; (function (ts) { var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); + var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. @@ -80875,7 +81191,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 278 /* Bundle */) { + if (sourceFile.kind === 280 /* Bundle */) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); @@ -80937,22 +81253,16 @@ var ts; var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); - var newLine = host.getNewLine(); + var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); - var sourceMap = ts.createSourceMapWriter(host, writer); - var declarationSourceMap = ts.createSourceMapWriter(host, writer, { - sourceMap: compilerOptions.declarationMap, - sourceRoot: compilerOptions.sourceRoot, - mapRoot: compilerOptions.mapRoot, - extendedDiagnostics: compilerOptions.extendedDiagnostics, - }); + var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; var bundleInfo = createDefaultBundleInfo(); var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file - ts.performance.mark("beforePrint"); + enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); - ts.performance.measure("printTime", "beforePrint"); + exit(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -80995,22 +81305,27 @@ var ts; } // Transform the source files var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], transformers, /*allowDtsFiles*/ false); + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: compilerOptions.noEmitHelpers, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + inlineSources: compilerOptions.inlineSources, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }; // Create a printer to print the nodes - var printer = createPrinter(__assign({}, compilerOptions, { noEmitHelpers: compilerOptions.noEmitHelpers }), { + var printer = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, // transform hooks onEmitNode: transform.emitNodeWithNotification, substituteNode: transform.substituteNode, - // sourcemap hooks - onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: sourceMap.emitPos, - // emitter hooks - onSetSourceFile: setSourceFile, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, sourceMap); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); } @@ -81034,14 +81349,20 @@ var ts; emitterDiagnostics.add(diagnostic); } } - var declarationPrinter = createPrinter(__assign({}, compilerOptions, { onlyPrintJsDocStyle: true, noEmitHelpers: true }), { + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: true, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + onlyPrintJsDocStyle: true, + }; + var declarationPrinter = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, - // sourcemap hooks - onEmitSourceMapOfNode: declarationSourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: declarationSourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: declarationSourceMap.emitPos, - onSetSourceFile: setSourceFileForDeclarationSourceMaps, // transform hooks onEmitNode: declarationTransform.emitNodeWithNotification, substituteNode: declarationTransform.substituteNode, @@ -81050,8 +81371,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, declarationSourceMap); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 277 /* SourceFile */) { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + sourceMap: compilerOptions.declarationMap, + sourceRoot: compilerOptions.sourceRoot, + mapRoot: compilerOptions.mapRoot, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }); + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -81060,7 +81386,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -81071,25 +81397,41 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; - mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); + var sourceMapGenerator; + if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { + sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); + } if (bundle) { - printer.writeBundle(bundle, writer, bundleInfo); + printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); } else { - printer.writeFile(sourceFile, writer); + printer.writeFile(sourceFile, writer, sourceMapGenerator); } - writer.writeLine(); - var sourceMappingURL = mapRecorder.getSourceMappingURL(); - if (sourceMappingURL) { - writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + if (sourceMapGenerator) { + if (sourceMapDataList) { + sourceMapDataList.push({ + inputSourceFileNames: sourceMapGenerator.getSources(), + sourceMap: sourceMapGenerator.toJSON() + }); + } + var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile); + if (sourceMappingURL) { + if (!writer.isAtStartOfLine()) + writer.rawWrite(newLine); + writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + } + // Write the source map + if (sourceMapFilePath) { + var sourceMap = sourceMapGenerator.toString(); + ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); + } } - // Write the source map - if (sourceMapFilePath) { - ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); + else { + writer.writeLine(); } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); @@ -81099,32 +81441,84 @@ var ts; ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); } // Reset state - mapRecorder.reset(); writer.clear(); bundleInfo = createDefaultBundleInfo(); } - function setSourceFile(node) { - sourceMap.setSourceFile(node); + function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { + return (mapOptions.sourceMap || mapOptions.inlineSourceMap) + && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } - function setSourceFileForDeclarationSourceMaps(node) { - declarationSourceMap.setSourceFile(node); + function getSourceRoot(mapOptions) { + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); + return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot; + } + function getSourceMapDirectory(mapOptions, filePath, sourceFile) { + if (mapOptions.sourceRoot) + return host.getCommonSourceDirectory(); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + } + return sourceMapDir; + } + return ts.getDirectoryPath(ts.normalizePath(filePath)); + } + function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) { + if (mapOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var sourceMapText = sourceMapGenerator.toString(); + var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); + return "data:application/json;base64," + base64SourceMapText; + } + var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath))); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapFile), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + return ts.combinePaths(sourceMapDir, sourceMapFile); + } + } + return sourceMapFile; } } ts.emitFiles = emitFiles; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; - PipelinePhase[PipelinePhase["Comments"] = 1] = "Comments"; - PipelinePhase[PipelinePhase["SourceMaps"] = 2] = "SourceMaps"; - PipelinePhase[PipelinePhase["Emit"] = 3] = "Emit"; + PipelinePhase[PipelinePhase["Substitution"] = 1] = "Substitution"; + PipelinePhase[PipelinePhase["Comments"] = 2] = "Comments"; + PipelinePhase[PipelinePhase["SourceMaps"] = 3] = "SourceMaps"; + PipelinePhase[PipelinePhase["Emit"] = 4] = "Emit"; })(PipelinePhase || (PipelinePhase = {})); function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); - var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var moduleKind = ts.getEmitModuleKind(printerOptions); + var bundledHelpers = ts.createMap(); var currentSourceFile; var nodeIdToGeneratedName; // Map of generated names for specific nodes. var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. @@ -81134,19 +81528,23 @@ var ts; var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes. var reservedNames; // TempFlags to reserve in nested name generation scopes. var writer; - var ownWriter; + var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; - var commitPendingSemicolon = ts.noop; - var writeSemicolon = writeSemicolonInternal; - var pendingSemicolon = false; - if (printerOptions.omitTrailingSemicolon) { - commitPendingSemicolon = commitPendingSemicolonInternal; - writeSemicolon = deferWriteSemicolon; - } - var syntheticParent = { pos: -1, end: -1 }; - var moduleKind = ts.getEmitModuleKind(printerOptions); - var bundledHelpers = ts.createMap(); var isOwnFileEmit; + // Source Maps + var sourceMapsDisabled = true; + var sourceMapGenerator; + var sourceMapSource; + var sourceMapSourceIndex = -1; + // Comments + var containerPos = -1; + var containerEnd = -1; + var declarationListContainerEnd = -1; + var currentLineMap; + var detachedCommentsInfo; + var hasWrittenComment = false; + var commentsDisabled = !!printerOptions.removeComments; + var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { // public API @@ -81173,9 +81571,9 @@ var ts; break; } switch (node.kind) { - case 277 /* SourceFile */: return printFile(node); - case 278 /* Bundle */: return printBundle(node); - case 279 /* UnparsedSource */: return printUnparsedSource(node); + case 279 /* SourceFile */: return printFile(node); + case 280 /* Bundle */: return printBundle(node); + case 281 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -81185,11 +81583,11 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, beginPrint()); + writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { - writeFile(sourceFile, beginPrint()); + writeFile(sourceFile, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printUnparsedSource(unparsed) { @@ -81198,14 +81596,14 @@ var ts; } function writeNode(hint, node, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(hint, node, sourceFile); reset(); writer = previousWriter; } function writeList(format, nodes, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); if (sourceFile) { setSourceFile(sourceFile); } @@ -81213,18 +81611,18 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, output, bundleInfo) { + function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { isOwnFileEmit = false; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(bundle); emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { var prepend = _b[_a]; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); writeLine(); + print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); } if (bundleInfo) { bundleInfo.originalOffset = writer.getTextPos(); @@ -81238,15 +81636,15 @@ var ts; } function writeUnparsedSource(unparsed, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } - function writeFile(sourceFile, output) { + function writeFile(sourceFile, output, sourceMapGenerator) { isOwnFileEmit = true; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); print(0 /* SourceFile */, sourceFile, sourceFile); @@ -81265,19 +81663,24 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, hint); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; - comments.setSourceFile(sourceFile); - if (onSetSourceFile) { - onSetSourceFile(sourceFile); + currentLineMap = undefined; + detachedCommentsInfo = undefined; + if (sourceFile) { + setSourceMapSource(sourceFile); } } - function setWriter(output) { - writer = output; // TODO: GH#18217 - comments.setWriter(output); + function setWriter(_writer, _sourceMapGenerator) { + if (_writer && printerOptions.omitTrailingSemicolon) { + _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + } + writer = _writer; // TODO: GH#18217 + sourceMapGenerator = _sourceMapGenerator; + sourceMapsDisabled = !writer || !sourceMapGenerator; } function reset() { nodeIdToGeneratedName = []; @@ -81286,68 +81689,66 @@ var ts; tempFlagsStack = []; tempFlags = 0 /* Auto */; reservedNamesStack = []; - comments.reset(); - setWriter(/*output*/ undefined); + currentSourceFile = undefined; + currentLineMap = undefined; + detachedCommentsInfo = undefined; + setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); + } + function getCurrentLineMap() { + return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } function emit(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 4 /* Unspecified */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); } function emitIdentifierName(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 2 /* IdentifierName */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(2 /* IdentifierName */, node); } function emitExpression(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(1 /* Expression */, node); } - function getPipelinePhase(phase, hint) { + function getPipelinePhase(phase, node) { switch (phase) { case 0 /* Notification */: - if (onEmitNode) { + if (onEmitNode !== ts.noEmitNotification) { return pipelineEmitWithNotification; } // falls through - case 1 /* Comments */: - if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + case 1 /* Substitution */: + if (substituteNode !== ts.noEmitSubstitution) { + return pipelineEmitWithSubstitution; + } + // falls through + case 2 /* Comments */: + if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { return pipelineEmitWithComments; } - return pipelineEmitWithoutComments; - case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { + // falls through + case 3 /* SourceMaps */: + if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through - case 3 /* Emit */: + case 4 /* Emit */: return pipelineEmitWithHint; default: - return ts.Debug.assertNever(phase, "Unexpected value for PipelinePhase: " + phase); + return ts.Debug.assertNever(phase); } } - function getNextPipelinePhase(currentPhase, hint) { - return getPipelinePhase(currentPhase + 1, hint); + function getNextPipelinePhase(currentPhase, node) { + return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); - } - function pipelineEmitWithComments(hint, node) { - ts.Debug.assertDefined(emitNodeWithComments); - ts.Debug.assert(hint !== 0 /* SourceFile */); - emitNodeWithComments(hint, trySubstituteNode(hint, node), getNextPipelinePhase(1 /* Comments */, hint)); - } - function pipelineEmitWithoutComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Comments */, hint); - pipelinePhase(hint, trySubstituteNode(hint, node)); - } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */); - ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); + var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); + onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -81356,254 +81757,285 @@ var ts; return emitIdentifier(ts.cast(node, ts.isIdentifier)); if (hint === 3 /* MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + if (hint === 5 /* EmbeddedStatement */) { + ts.Debug.assertNode(node, ts.isEmptyStatement); + return emitEmptyStatement(/*isEmbeddedStatement*/ true); + } if (hint === 4 /* Unspecified */) { if (ts.isKeyword(node.kind)) return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return emitLiteral(node); - case 279 /* UnparsedSource */: + case 281 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return emitQualifiedName(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return emitTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return emitParameter(node); - case 150 /* Decorator */: + case 152 /* Decorator */: return emitDecorator(node); // Type members - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return emitPropertySignature(node); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return emitMethodSignature(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return emitConstructor(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return emitAccessorDeclaration(node); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return emitCallSignature(node); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return emitConstructSignature(node); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return emitIndexSignature(node); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return emitTypePredicate(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return emitTypeReference(node); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return emitFunctionType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return emitConstructorType(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return emitTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return emitTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return emitArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return emitTupleType(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return emitOptionalType(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return emitUnionType(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return emitIntersectionType(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return emitConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return emitInferType(node); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return emitParenthesizedType(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return emitThisType(); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return emitTypeOperator(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return emitMappedType(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return emitLiteralType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return emitImportTypeNode(node); - case 282 /* JSDocAllType */: - write("*"); + case 284 /* JSDocAllType */: + writePunctuation("*"); return; - case 283 /* JSDocUnknownType */: - write("?"); + case 285 /* JSDocUnknownType */: + writePunctuation("?"); return; - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 170 /* RestType */: - case 288 /* JSDocVariadicType */: + case 172 /* RestType */: + case 290 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return emitBindingElement(node); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return emitTemplateSpan(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 216 /* Block */: + case 218 /* Block */: return emitBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return emitVariableStatement(node); - case 218 /* EmptyStatement */: - return emitEmptyStatement(); - case 219 /* ExpressionStatement */: + case 220 /* EmptyStatement */: + return emitEmptyStatement(/*isEmbeddedStatement*/ false); + case 221 /* ExpressionStatement */: return emitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return emitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return emitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return emitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return emitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return emitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return emitForOfStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return emitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return emitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return emitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return emitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return emitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return emitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return emitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return emitTryStatement(node); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return emitClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return emitModuleBlock(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return emitCaseBlock(node); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return emitImportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return emitImportClause(node); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return emitNamespaceImport(node); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return emitNamedImports(node); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return emitImportSpecifier(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return emitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return emitExportDeclaration(node); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return emitNamedExports(node); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return emitExportSpecifier(node); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 10 /* JsxText */: + case 11 /* JsxText */: return emitJsxText(node); - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 261 /* JsxClosingElement */: - case 264 /* JsxClosingFragment */: + case 263 /* JsxClosingElement */: + case 266 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return emitJsxAttribute(node); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return emitJsxAttributes(node); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return emitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return emitDefaultClause(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return emitHeritageClause(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return emitEnumMember(node); - // JSDoc nodes (ignored) + // JSDoc nodes (only used in codefixes currently) + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + return emitJSDocPropertyLikeTag(node); + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 301 /* JSDocThisTag */: + case 298 /* JSDocEnumTag */: + return emitJSDocSimpleTypedTag(node); + case 295 /* JSDocAugmentsTag */: + return emitJSDocAugmentsTag(node); + case 303 /* JSDocTemplateTag */: + return emitJSDocTemplateTag(node); + case 304 /* JSDocTypedefTag */: + return emitJSDocTypedefTag(node); + case 297 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + case 293 /* JSDocSignature */: + return emitJSDocSignature(node); + case 292 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 296 /* JSDocClassTag */: + case 294 /* JSDocTag */: + return emitJSDocSimpleTag(node); + case 291 /* JSDocComment */: + return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; - node = trySubstituteNode(1 /* Expression */, node); + if (substituteNode !== ts.noEmitSubstitution) { + node = substituteNode(hint, node); + } } else if (ts.isToken(node)) { return writeTokenNode(node, writePunctuation); @@ -81613,89 +82045,90 @@ var ts; switch (node.kind) { // Literals case 8 /* NumericLiteral */: - return emitNumericLiteral(node); - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + return emitNumericOrBigIntLiteral(node); + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Reserved words - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 101 /* TrueKeyword */: - case 99 /* ThisKeyword */: - case 91 /* ImportKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 102 /* TrueKeyword */: + case 100 /* ThisKeyword */: + case 92 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return emitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return emitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return emitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return emitArrowFunction(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return emitDeleteExpression(node); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return emitVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return emitAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return emitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return emitConditionalExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return emitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return emitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return emitSpreadExpression(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return emitClassExpression(node); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: return emitAsExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return emitNonNullExpression(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return emitJsxElement(node); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return emitCommaList(node); } } @@ -81707,12 +82140,13 @@ var ts; writeSpace(); emit(node.constraint); } - function trySubstituteNode(hint, node) { - return node && substituteNode && substituteNode(hint, node) || node; + function pipelineEmitWithSubstitution(hint, node) { + var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); + pipelinePhase(hint, substituteNode(hint, node)); } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 278 /* Bundle */ ? node : undefined; + var bundle = node.kind === 280 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -81761,7 +82195,8 @@ var ts; // Literals/Pseudo-literals // // SyntaxKind.NumericLiteral - function emitNumericLiteral(node) { + // SyntaxKind.BigIntLiteral + function emitNumericOrBigIntLiteral(node) { emitLiteral(node); } // SyntaxKind.StringLiteral @@ -81773,7 +82208,7 @@ var ts; function emitLiteral(node) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -81791,7 +82226,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 26896 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -81802,7 +82237,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -81838,7 +82273,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -81860,7 +82295,7 @@ var ts; emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitPropertyDeclaration(node) { emitDecorators(node, node.decorators); @@ -81870,7 +82305,7 @@ var ts; emit(node.exclamationToken); emitTypeAnnotation(node.type); emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node); - writeSemicolon(); + writeTrailingSemicolon(); } function emitMethodSignature(node) { pushNameGenerationScope(node); @@ -81881,7 +82316,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitMethodDeclaration(node) { @@ -81900,7 +82335,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 158 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -81912,7 +82347,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitConstructSignature(node) { @@ -81924,7 +82359,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitIndexSignature(node) { @@ -81932,10 +82367,10 @@ var ts; emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitSemicolonClassElement() { - writeSemicolon(); + writeTrailingSemicolon(); } // // Types @@ -81962,22 +82397,22 @@ var ts; popNameGenerationScope(node); } function emitJSDocFunctionType(node) { - write("function"); + writeKeyword("function"); emitParameters(node, node.parameters); - write(":"); + writePunctuation(":"); emit(node.type); } function emitJSDocNullableType(node) { - write("?"); + writePunctuation("?"); emit(node.type); } function emitJSDocNonNullableType(node) { - write("!"); + writePunctuation("!"); emit(node.type); } function emitJSDocOptionalType(node) { emit(node.type); - write("="); + writePunctuation("="); } function emitConstructorType(node) { pushNameGenerationScope(node); @@ -81998,8 +82433,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineTypeLiteralMembers */ : 16449 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 262144 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -82008,23 +82443,23 @@ var ts; writePunctuation("]"); } function emitRestOrJSDocVariadicType(node) { - write("..."); + writePunctuation("..."); emit(node.type); } function emitTupleType(node) { writePunctuation("["); - emitList(node, node.elementTypes, 272 /* TupleTypeElements */); + emitList(node, node.elementTypes, 528 /* TupleTypeElements */); writePunctuation("]"); } function emitOptionalType(node) { emit(node.type); - write("?"); + writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 260 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */); } function emitIntersectionType(node) { - emitList(node, node.types, 264 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */); } function emitConditionalType(node) { emit(node.checkType); @@ -82077,25 +82512,25 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 3 /* MappedTypeParameter */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 55 /* QuestionToken */) { + if (node.questionToken.kind !== 56 /* QuestionToken */) { writePunctuation("?"); } } writePunctuation(":"); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); if (emitFlags & 1 /* SingleLine */) { writeSpace(); } @@ -82128,12 +82563,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 262448 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -82151,8 +82586,8 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -82160,9 +82595,9 @@ var ts; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + 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); if (indentedFlag) { decreaseIndent(); } @@ -82173,20 +82608,20 @@ var ts; if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = ts.createToken(23 /* DotToken */); + var dotToken = ts.createToken(24 /* DotToken */); dotToken.pos = dotRangeStart; dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } emitExpression(node.expression); - increaseIndentIf(indentBeforeDot); + increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(23 /* DotToken */, node.expression.end, writePunctuation, node); - increaseIndentIf(indentAfterDot); + emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } @@ -82198,7 +82633,7 @@ var ts; // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); return !expression.numericLiteralFlags - && !ts.stringContains(text, ts.tokenToString(23 /* DotToken */)); + && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -82211,21 +82646,21 @@ var ts; } function emitElementAccessExpression(node) { emitExpression(node.expression); - emitTokenWithComment(21 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(22 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(94 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(95 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { emitExpression(node.tag); @@ -82240,9 +82675,9 @@ var ts; emitExpression(node.expression); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(19 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -82261,22 +82696,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(80 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(103 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(105 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(121 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(122 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -82301,24 +82736,24 @@ 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 === 200 /* PrefixUnaryExpression */ - && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) - || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); + return operand.kind === 202 /* PrefixUnaryExpression */ + && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) + || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator, writeOperator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 26 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); - increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 93 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - increaseIndentIf(indentAfterOperator, " "); + increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); } @@ -82328,23 +82763,23 @@ var ts; var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken); var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); - increaseIndentIf(indentBeforeQuestion, " "); + increaseIndentIf(indentBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); - increaseIndentIf(indentAfterQuestion, " "); + increaseIndentIf(indentAfterQuestion, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); - increaseIndentIf(indentBeforeColon, " "); + increaseIndentIf(indentBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); - increaseIndentIf(indentAfterColon, " "); + increaseIndentIf(indentAfterColon, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 131072 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(116 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(117 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -82392,38 +82827,45 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineBlockStatements */ : 65 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(18 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); emit(node.declarationList); - writeSemicolon(); + writeTrailingSemicolon(); } - function emitEmptyStatement() { - writeSemicolon(); + function emitEmptyStatement(isEmbeddedStatement) { + // While most trailing semicolons are possibly insignificant, an embedded "empty" + // statement is significant and cannot be elided by a trailing-semicolon-omitting writer. + if (isEmbeddedStatement) { + writePunctuation(";"); + } + else { + writeTrailingSemicolon(); + } } function emitExpressionStatement(node) { emitExpression(node.expression); // 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)) { - writeSemicolon(); + writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(91 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 220 /* IfStatement */) { + emitTokenWithComment(83 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 222 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -82433,14 +82875,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(106 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(81 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -82456,45 +82898,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.condition ? node.condition.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(20 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(92 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(93 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(147 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 236 /* VariableDeclarationList */) { + if (node.kind === 238 /* VariableDeclarationList */) { emit(node); } else { @@ -82503,14 +82945,14 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(77 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(78 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(72 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(73 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) { var node = ts.getParseTreeNode(contextNode); @@ -82536,40 +82978,40 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(96 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(97 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(107 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(108 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(98 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(56 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(100 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(101 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(102 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -82578,14 +83020,14 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(87 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(88 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(78 /* DebuggerKeyword */, node.pos, writeKeyword); - writeSemicolon(); + writeToken(79 /* DebuggerKeyword */, node.pos, writeKeyword); + writeTrailingSemicolon(); } // // Declarations @@ -82598,7 +83040,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 272 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -82646,7 +83088,7 @@ var ts; } else { emitSignatureHead(node); - writeSemicolon(); + writeTrailingSemicolon(); } } function emitSignatureHead(node) { @@ -82698,7 +83140,7 @@ var ts; emitBlockFunctionBody(body); } decreaseIndent(); - writeToken(18 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -82710,7 +83152,7 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); increaseIndent(); } else { @@ -82737,7 +83179,7 @@ var ts; emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* ClassMembers */); + emitList(node, node.members, 129 /* ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -82750,10 +83192,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 256 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* InterfaceMembers */); + emitList(node, node.members, 129 /* InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -82767,7 +83209,7 @@ var ts; writePunctuation("="); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitEnumDeclaration(node) { emitModifiers(node, node.modifiers); @@ -82776,7 +83218,7 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 81 /* EnumMembers */); + emitList(node, node.members, 145 /* EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { @@ -82788,8 +83230,8 @@ var ts; emit(node.name); var body = node.body; if (!body) - return writeSemicolon(); - while (body.kind === 242 /* ModuleDeclaration */) { + return writeTrailingSemicolon(); + while (body.kind === 244 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -82804,23 +83246,23 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 65 /* CaseBlockClauses */); - emitTokenWithComment(18 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* CaseBlockClauses */); + emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(59 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); - writeSemicolon(); + writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -82829,29 +83271,29 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); - writeSemicolon(); + writeTrailingSemicolon(); } function emitImportClause(node) { emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(26 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(39 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -82862,45 +83304,45 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(58 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(59 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(79 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(80 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(39 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(118 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(119 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(130 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(131 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamedExports(node) { emitNamedImportsOrExports(node); @@ -82910,14 +83352,14 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -82936,7 +83378,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -82948,7 +83390,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -82963,7 +83405,6 @@ var ts; writePunctuation(">"); } function emitJsxText(node) { - commitPendingSemicolon(); writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); } function emitJsxClosingElementOrFragment(node) { @@ -82974,7 +83415,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 131328 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -82994,7 +83435,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -83005,13 +83446,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(73 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(74 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(79 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(80 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -83021,14 +83462,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 81985 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 64 /* Indented */); + format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -83036,15 +83477,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 272 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(74 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(75 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(20 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -83093,6 +83534,142 @@ var ts; emitInitializer(node.initializer, node.name.end, node); } // + // JSDoc + // + function emitJSDoc(node) { + write("/**"); + if (node.comment) { + var lines = node.comment.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } + } + if (node.tags) { + if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + writeSpace(); + emit(node.tags[0]); + } + else { + emitList(node, node.tags, 33 /* JSDocComment */); + } + } + writeSpace(); + write("*/"); + } + function emitJSDocSimpleTypedTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.typeExpression); + emitJSDocComment(tag.comment); + } + function emitJSDocAugmentsTag(tag) { + emitJSDocTagName(tag.tagName); + writeSpace(); + writePunctuation("{"); + emit(tag.class); + writePunctuation("}"); + emitJSDocComment(tag.comment); + } + function emitJSDocTemplateTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.constraint); + writeSpace(); + emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitJSDocComment(tag.comment); + } + function emitJSDocTypedefTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.typeExpression) { + if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + emitJSDocTypeExpression(tag.typeExpression); + } + else { + writeSpace(); + writePunctuation("{"); + write("Object"); + if (tag.typeExpression.isArrayType) { + writePunctuation("["); + writePunctuation("]"); + } + writePunctuation("}"); + } + } + if (tag.fullName) { + writeSpace(); + emit(tag.fullName); + } + emitJSDocComment(tag.comment); + if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + emitJSDocTypeLiteral(tag.typeExpression); + } + } + function emitJSDocCallbackTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.name) { + writeSpace(); + emit(tag.name); + } + emitJSDocComment(tag.comment); + emitJSDocSignature(tag.typeExpression); + } + function emitJSDocSimpleTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocComment(tag.comment); + } + function emitJSDocTypeLiteral(lit) { + emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + } + function emitJSDocSignature(sig) { + if (sig.typeParameters) { + emitList(sig, ts.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + } + if (sig.parameters) { + emitList(sig, ts.createNodeArray(sig.parameters), 33 /* JSDocComment */); + } + if (sig.type) { + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + emit(sig.type); + } + } + function emitJSDocPropertyLikeTag(param) { + emitJSDocTagName(param.tagName); + emitJSDocTypeExpression(param.typeExpression); + writeSpace(); + if (param.isBracketed) { + writePunctuation("["); + } + emit(param.name); + if (param.isBracketed) { + writePunctuation("]"); + } + emitJSDocComment(param.comment); + } + function emitJSDocTagName(tagName) { + writePunctuation("@"); + emit(tagName); + } + function emitJSDocComment(comment) { + if (comment) { + writeSpace(); + write(comment); + } + } + function emitJSDocTypeExpression(typeExpression) { + if (typeExpression) { + writeSpace(); + writePunctuation("{"); + emit(typeExpression.type); + writePunctuation("}"); + } + } + // // Top-level nodes // function emitSourceFile(node) { @@ -83120,38 +83697,38 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - write("/// "); + writeComment("/// "); } else { - write("/// "); + writeComment("/// "); } writeLine(); } } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; - write("/// "); + writeComment("/// "); writeLine(); } - for (var _d = 0, types_16 = types; _d < types_16.length; _d++) { - var directive = types_16[_d]; - write("/// "); + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; + writeComment("/// "); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; - write("/// "); + writeComment("/// "); writeLine(); } } @@ -83170,7 +83747,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 272 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -83210,13 +83787,14 @@ var ts; setSourceFile(sourceFile); emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); } + setSourceFile(undefined); } } function emitShebangIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { - write(shebang); + writeComment(shebang); writeLine(); return true; } @@ -83244,7 +83822,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 131328 /* Modifiers */); + emitList(node, modifiers, 262656 /* Modifiers */); writeSpace(); } } @@ -83258,7 +83836,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(59 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -83295,24 +83873,30 @@ var ts; else { writeLine(); increaseIndent(); - emit(node); + if (ts.isEmptyStatement(node)) { + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); + pipelinePhase(5 /* EmbeddedStatement */, node); + } + else { + emit(node); + } decreaseIndent(); } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 24577 /* Decorators */); + emitList(parentNode, decorators, 49153 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 26896 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */); } 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, 26896 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 1296 /* Parameters */); + emitList(parentNode, parameters, 2576 /* Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -83333,14 +83917,14 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 1296 /* Parameters */ & ~1024 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 4432 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } function emitList(parentNode, children, format, start, count) { emitNodeList(emit, parentNode, children, format, start, count); @@ -83349,7 +83933,7 @@ var ts; emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { - switch (format & 28 /* DelimitersMask */) { + switch (format & 60 /* DelimitersMask */) { case 0 /* None */: break; case 16 /* CommaDelimited */: @@ -83359,6 +83943,11 @@ var ts; writeSpace(); writePunctuation("|"); break; + case 32 /* AsteriskDelimited */: + writeSpace(); + writePunctuation("*"); + writeSpace(); + break; case 8 /* AmpersandDelimited */: writeSpace(); writePunctuation("&"); @@ -83369,11 +83958,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 & 8192 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 16384 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -83382,7 +83971,7 @@ var ts; } return; } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { // TODO: GH#18217 @@ -83397,23 +83986,23 @@ var ts; if (format & 1 /* MultiLine */) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */ && !(format & 262144 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { writeSpace(); } } else { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { increaseIndent(); } // Emit each child. @@ -83422,14 +84011,19 @@ 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 (previousSibling) { + if (format & 32 /* AsteriskDelimited */) { + // always write JSDoc in the format "\n *" + writeLine(); + writeDelimiter(format); + } + else if (previousSibling) { // i.e // function commentedParameters( // /* Parameter a */ // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -83437,14 +84031,14 @@ var ts; if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 64 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 256 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { writeSpace(); } } @@ -83466,7 +84060,7 @@ var ts; previousSibling = child; } // Write a trailing comma, if requested. - var hasTrailingComma = (format & 32 /* AllowTrailingComma */) && children.hasTrailingComma; + var hasTrailingComma = (format & 64 /* AllowTrailingComma */) && children.hasTrailingComma; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { writePunctuation(","); } @@ -83476,25 +84070,25 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { + if (previousSibling && format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { emitLeadingCommentsOfPosition(previousSibling.end); } // Decrease the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { decreaseIndent(); } // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { if (isEmpty && !isUndefined) { // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists @@ -83502,73 +84096,55 @@ var ts; writePunctuation(getClosingBracket(format)); } } - function commitPendingSemicolonInternal() { - if (pendingSemicolon) { - writeSemicolonInternal(); - pendingSemicolon = false; - } - } + // Writers function writeLiteral(s) { - commitPendingSemicolon(); writer.writeLiteral(s); } function writeStringLiteral(s) { - commitPendingSemicolon(); writer.writeStringLiteral(s); } function writeBase(s) { - commitPendingSemicolon(); writer.write(s); } function writeSymbol(s, sym) { - commitPendingSemicolon(); writer.writeSymbol(s, sym); } function writePunctuation(s) { - commitPendingSemicolon(); writer.writePunctuation(s); } - function deferWriteSemicolon() { - pendingSemicolon = true; - } - function writeSemicolonInternal() { - writer.writePunctuation(";"); + function writeTrailingSemicolon() { + writer.writeTrailingSemicolon(";"); } function writeKeyword(s) { - commitPendingSemicolon(); writer.writeKeyword(s); } function writeOperator(s) { - commitPendingSemicolon(); writer.writeOperator(s); } function writeParameter(s) { - commitPendingSemicolon(); writer.writeParameter(s); } + function writeComment(s) { + writer.writeComment(s); + } function writeSpace() { - commitPendingSemicolon(); writer.writeSpace(" "); } function writeProperty(s) { - commitPendingSemicolon(); writer.writeProperty(s); } function writeLine() { - commitPendingSemicolon(); writer.writeLine(); } function increaseIndent() { - commitPendingSemicolon(); writer.increaseIndent(); } function decreaseIndent() { - commitPendingSemicolon(); writer.decreaseIndent(); } function writeToken(token, pos, writer, contextNode) { - return onEmitSourceMapOfToken - ? onEmitSourceMapOfToken(contextNode, token, writer, pos, writeTokenText) + return !sourceMapsDisabled + ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText) : writeTokenText(token, writer, pos); } function writeTokenNode(node, writer) { @@ -83596,23 +84172,23 @@ var ts; function writeLines(text) { var lines = text.split(/\r\n?|\n/g); var indentation = ts.guessIndentation(lines); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var lineText = lines_2[_a]; + for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) { + var lineText = lines_3[_a]; var line = indentation ? lineText.slice(indentation) : lineText; if (line.length) { writeLine(); write(line); - writeLine(); + writer.rawWrite(newLine); } } } - function increaseIndentIf(value, valueToWriteWhenNotIndenting) { + function increaseIndentIf(value, writeSpaceIfNotIndenting) { if (value) { increaseIndent(); writeLine(); } - else if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); + else if (writeSpaceIfNotIndenting) { + writeSpace(); } } // Helper function to decrease the indent if we previously indented. Allows multiple @@ -83632,7 +84208,7 @@ var ts; return true; } if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var firstChild = children[0]; @@ -83671,10 +84247,10 @@ var ts; } function shouldWriteClosingLineTerminator(parentNode, children, format) { if (format & 1 /* MultiLine */) { - return (format & 65536 /* NoTrailingNewLine */) === 0; + return (format & 131072 /* NoTrailingNewLine */) === 0; } else if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var lastChild = ts.lastOrUndefined(children); @@ -83696,11 +84272,11 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { parent = skipSynthesizedParentheses(parent); @@ -83720,7 +84296,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -83732,7 +84308,7 @@ var ts; else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { return ts.idText(node); } - else if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { @@ -83741,7 +84317,7 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape) { - if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode)) { return neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? @@ -83785,81 +84361,81 @@ var ts; if (!node) return; switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: ts.forEach(node.statements, generateNames); break; - case 231 /* LabeledStatement */: - case 229 /* WithStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 233 /* LabeledStatement */: + case 231 /* WithStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: generateNames(node.statement); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: generateNames(node.declarationList); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: generateNames(node.importClause); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -83868,12 +84444,12 @@ var ts; if (!node) return; switch (node.kind) { - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -84053,23 +84629,23 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 254 /* ExportAssignment */: return generateNameForExportDefault(); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return generateNameForClassExpression(); - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -84110,21 +84686,396 @@ var ts; // otherwise, return the original node for the source; return node; } + // Comments + function pipelineEmitWithComments(hint, node) { + enterComment(); + hasWrittenComment = false; + var emitFlags = ts.getEmitFlags(node); + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + // 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 */; + // Save current container state on the stack. + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + 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); + } + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* 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)) { + // 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 === 238 /* VariableDeclarationList */) { + declarationListContainerEnd = end; + } + } + } + ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); + exitComment(); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, node); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + pipelinePhase(hint, node); + commentsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + enterComment(); + ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); + if ((pos > 0 || end > 0) && pos !== end) { + // Restore previous container state. + containerPos = savedContainerPos; + containerEnd = savedContainerEnd; + 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 && isEmittedNode) { + emitTrailingComments(end); + } + } + exitComment(); + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 /* MultiLineCommentTrivia */ + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { + 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; + if (!skipLeadingComments) { + emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); + } + exitComment(); + if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + commentsDisabled = true; + emitCallback(node); + commentsDisabled = false; + } + else { + emitCallback(node); + } + enterComment(); + if (!skipTrailingComments) { + emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); + if (hasWrittenComment && !writer.isAtStartOfLine()) { + writer.writeLine(); + } + } + exitComment(); + } + function emitLeadingComments(pos, isEmittedNode) { + hasWrittenComment = false; + if (isEmittedNode) { + forEachLeadingCommentToEmit(pos, emitLeadingComment); + } + else if (pos === 0) { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted + forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); + } + } + function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (isTripleSlashComment(commentPos, commentEnd)) { + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + } + } + function shouldWriteComment(text, pos) { + if (printerOptions.onlyPrintJsDocStyle) { + return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); + } + return true; + } + function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + if (!hasWrittenComment) { + ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); + hasWrittenComment = true; + } + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + else if (kind === 3 /* MultiLineCommentTrivia */) { + writer.writeSpace(" "); + } + } + function emitLeadingCommentsOfPosition(pos) { + if (commentsDisabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } + function emitTrailingComments(pos) { + forEachTrailingCommentToEmit(pos, emitTrailingComment); + } + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + } + function emitTrailingCommentsOfPosition(pos, prefixSpace) { + if (commentsDisabled) { + return; + } + enterComment(); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); + exitComment(); + } + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + // 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 (hasTrailingNewLine) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function forEachLeadingCommentToEmit(pos, cb) { + // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) { + if (hasDetachedComments(pos)) { + forEachLeadingCommentWithoutDetachedComments(cb); + } + else { + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + } + } + function forEachTrailingCommentToEmit(end, cb) { + // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) { + ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; + } + function forEachLeadingCommentWithoutDetachedComments(cb) { + // get the leading comments from detachedPos + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + function emitDetachedCommentsAndUpdateCommentsInfo(range) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + emitPos(commentPos); + ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + */ + function isTripleSlashComment(commentPos, commentEnd) { + return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + } + // Source Maps + function pipelineEmitWithSourceMap(hint, node) { + var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); + if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { + var parsed = ts.tryParseRawSourceMap(node.sourceMapText); + if (parsed) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + } + pipelinePhase(hint, node); + } + else { + var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; + var emitFlags = ts.getEmitFlags(node); + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + && pos >= 0) { + emitSourcePos(source, skipSourceTrivia(source, pos)); + } + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = true; + pipelinePhase(hint, node); + sourceMapsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + && end >= 0) { + emitSourcePos(source, end); + } + } + } + /** + * Skips trivia such as comments and white-space that can optionally overriden by the source map source + */ + function skipSourceTrivia(source, pos) { + return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(sourceMapSource.text, pos); + } + /** + * Emits a mapping. + * + * If the position is synthetic (undefined or a negative value), no mapping will be + * created. + * + * @param pos The position. + */ + function emitPos(pos) { + if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) { + return; + } + var _a = ts.getLineAndCharacterOfPosition(currentSourceFile, pos), sourceLine = _a.line, sourceCharacter = _a.character; + sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, + /*nameIndex*/ undefined); + } + function emitSourcePos(source, pos) { + if (source !== sourceMapSource) { + var savedSourceMapSource = sourceMapSource; + setSourceMapSource(source); + emitPos(pos); + setSourceMapSource(savedSourceMapSource); + } + else { + emitPos(pos); + } + } + /** + * Emits a token of a node with possible leading and trailing source maps. + * + * @param node The node containing the token. + * @param token The token to emit. + * @param tokenStartPos The start pos of the token. + * @param emitCallback The callback used to emit the token. + */ + function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { + if (sourceMapsDisabled || node && ts.isInJsonFile(node)) { + return emitCallback(token, writer, tokenPos); + } + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags || 0 /* 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) { + emitSourcePos(source, tokenPos); + } + tokenPos = emitCallback(token, writer, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + emitSourcePos(source, tokenPos); + } + return tokenPos; + } + function setSourceMapSource(source) { + if (sourceMapsDisabled) { + return; + } + sourceMapSource = source; + if (isJsonSourceMapSource(source)) { + return; + } + sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName); + if (printerOptions.inlineSources) { + sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text); + } + } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* Braces */] = ["{", "}"]; + brackets[2048 /* Parenthesis */] = ["(", ")"]; + brackets[4096 /* AngleBrackets */] = ["<", ">"]; + brackets[8192 /* SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; + return brackets[format & 15360 /* BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; + return brackets[format & 15360 /* BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -84819,7 +85770,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function loadWithLocalCache(names, containingFile, loader) { + function loadWithLocalCache(names, containingFile, redirectedReference, loader) { if (names.length === 0) { return []; } @@ -84832,7 +85783,7 @@ var ts; result = cache.get(name); } else { - cache.set(name, result = loader(name, containingFile)); + cache.set(name, result = loader(name, containingFile, redirectedReference)); } resolutions.push(result); } @@ -84851,6 +85802,7 @@ var ts; if (program.getRootFileNames().length !== rootFileNames.length) { return false; } + var seenResolvedRefs; // If project references dont match if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { return false; @@ -84876,7 +85828,7 @@ var ts; return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || - hasInvalidatedResolution(sourceFile.resolvedPath); + hasInvalidatedResolution(sourceFile.path); } function sourceFileVersionUptoDate(sourceFile) { return sourceFile.version === getSourceVersion(sourceFile.resolvedPath); @@ -84885,10 +85837,24 @@ var ts; if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { return false; } - var oldResolvedRef = program.getResolvedProjectReferences()[index]; + return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + } + function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { + if (ts.contains(seenResolvedRefs, oldResolvedRef)) { + // Assume true + return true; + } // If sourceFile for the oldResolvedRef existed, check the version for uptodate - return sourceFileVersionUptoDate(oldResolvedRef.sourceFile); + if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + return false; + } + // Add to seen before checking the referenced paths of this config file + (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); + // If child project references are upto date, this project reference is uptodate + return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) { + return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]); + }); } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. @@ -84935,7 +85901,7 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; - var modifiedFilePaths; + var ambientModuleNameToUnmodifiedFileName = ts.createMap(); var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -84967,12 +85933,11 @@ var ts; // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createMap(); var _compilerOptionsObjectLiteralSyntax; - var _referencesArrayLiteralSyntax; var moduleResolutionCache; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -84984,16 +85949,16 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 - resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; + var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 + resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, 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). @@ -85009,7 +85974,7 @@ var ts; // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; // A parallel array to projectReferences storing the results of reading in the referenced tsconfig files - var resolvedProjectReferences = projectReferences ? [] : undefined; + var resolvedProjectReferences; var projectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -85017,23 +85982,25 @@ var ts; processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { - for (var _i = 0, projectReferences_1 = projectReferences; _i < projectReferences_1.length; _i++) { - var ref = projectReferences_1[_i]; - var parsedRef = parseProjectReferenceConfigFile(ref); - resolvedProjectReferences.push(parsedRef); - if (parsedRef) { - var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - var dtsOutfile = ts.changeExtension(out, ".d.ts"); - processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (!resolvedProjectReferences) { + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + } + if (rootNames.length) { + for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { + var parsedRef = resolvedProjectReferences_1[_i]; + if (parsedRef) { + var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; + if (out) { + var dtsOutfile = ts.changeExtension(out, ".d.ts"); + processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } - addProjectReferenceRedirects(parsedRef.commandLine); } } } ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false); }); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); @@ -85047,7 +86014,7 @@ var ts; // - The '--noLib' flag is used. // - A 'no-default-lib' reference comment is encountered in // processing the root files. - if (!skipDefaultLib) { + if (rootNames.length && !skipDefaultLib) { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file var defaultLibraryFileName = getDefaultLibraryFileName(); @@ -85072,10 +86039,18 @@ var ts; var oldSourceFiles = oldProgram.getSourceFiles(); for (var _a = 0, oldSourceFiles_1 = oldSourceFiles; _a < oldSourceFiles_1.length; _a++) { var oldSourceFile = oldSourceFiles_1[_a]; - if (!getSourceFile(oldSourceFile.path) || shouldCreateNewSourceFile) { - host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions()); + var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); + if (shouldCreateNewSourceFile || !newFile || + // old file wasnt redirect but new file is + (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { + host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; @@ -85116,7 +86091,10 @@ var ts; getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, getProjectReferences: getProjectReferences, getResolvedProjectReferences: getResolvedProjectReferences, - getProjectReferenceRedirect: getProjectReferenceRedirect + getProjectReferenceRedirect: getProjectReferenceRedirect, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, + forEachResolvedProjectReference: forEachResolvedProjectReference }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -85179,13 +86157,13 @@ var ts; } return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) { if (structuralIsReused === 0 /* 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, containingFile); + return resolveModuleNamesWorker(moduleNames, containingFile, /*reusedNames*/ undefined, getResolvedProjectReferenceToRedirect(file.originalFileName)); } - var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile); + var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); if (oldSourceFile !== file && file.resolvedModules) { // `file` was created for the new program. // @@ -85248,7 +86226,7 @@ var ts; } } else { - resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName); } if (resolvesToAmbientModuleInNonModifiedFile) { (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; @@ -85259,7 +86237,7 @@ var ts; } } var resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames) + ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName)) : ts.emptyArray; // Combine results of resolutions and predicted results if (!result) { @@ -85285,12 +86263,9 @@ var ts; return result; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. - function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - if (!oldProgramState.program) { - return false; - } - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 - var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) { + var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName); + var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same // place as we expected to find an actual module file. @@ -85299,16 +86274,34 @@ var ts; return false; } // at least one of declarations should come from non-modified source file - var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); }); - if (!firstUnmodifiedFile) { + var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName); + if (!unmodifiedFile) { return false; } if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile); } return true; } } + function canReuseProjectReferences() { + return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) { + var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var newResolvedRef = parseProjectReferenceConfigFile(newRef); + if (oldResolvedRef) { + // Resolved project reference has gone missing or changed + return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + } + else { + // A previously-unresolved reference may be resolved now + return newResolvedRef !== undefined; + } + }, function (oldProjectReferences, parent) { + // If array of references is changed, we cant resue old program + var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences; + return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo); + }); + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return 0 /* Not */; @@ -85329,40 +86322,14 @@ var ts; return oldProgram.structureIsReused = 0 /* Not */; } // Check if any referenced project tsconfig files are different - // If array of references is changed, we cant resue old program - var oldProjectReferences = oldProgram.getProjectReferences(); - if (!ts.arrayIsEqualTo(oldProjectReferences, projectReferences, ts.projectReferenceIsEqualTo)) { + if (!canReuseProjectReferences()) { return oldProgram.structureIsReused = 0 /* Not */; } - // Check the json files for the project references - var oldRefs = oldProgram.getResolvedProjectReferences(); if (projectReferences) { - // Resolved project referenced should be array if projectReferences provided are array - ts.Debug.assert(!!oldRefs); - for (var i = 0; i < projectReferences.length; i++) { - var oldRef = oldRefs[i]; - var newRef = parseProjectReferenceConfigFile(projectReferences[i]); - if (oldRef) { - if (!newRef || newRef.sourceFile !== oldRef.sourceFile) { - // Resolved project reference has gone missing or changed - return oldProgram.structureIsReused = 0 /* Not */; - } - } - else { - // A previously-unresolved reference may be resolved now - if (newRef !== undefined) { - return oldProgram.structureIsReused = 0 /* Not */; - } - } - } - } - else { - // Resolved project referenced should be undefined if projectReferences is undefined - ts.Debug.assert(!oldRefs); + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2 /* Completely */; // If the missing file paths are now present, it can change the progam structure, @@ -85413,7 +86380,6 @@ var ts; newSourceFile.originalFileName = oldSourceFile.originalFileName; newSourceFile.resolvedPath = oldSourceFile.resolvedPath; newSourceFile.fileName = oldSourceFile.fileName; - filePaths.push(newSourceFile.path); 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, @@ -85474,15 +86440,23 @@ var ts; if (oldProgram.structureIsReused !== 2 /* Completely */) { return oldProgram.structureIsReused; } - modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); + for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) { + var oldFile = oldSourceFiles_3[_a]; + if (!ts.contains(modifiedFiles, oldFile)) { + for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) { + var moduleName = _c[_b]; + ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); + } + } + } // try to verify results of module resolution - for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { - var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; + for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { + var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = getModuleNames(newSourceFile); - var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { @@ -85496,7 +86470,7 @@ var ts; if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); if (resolutionsChanged) { @@ -85516,28 +86490,22 @@ var ts; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping - for (var i = 0; i < newSourceFiles.length; i++) { - filesByName.set(filePaths[i], newSourceFiles[i]); + for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { + var newSourceFile = newSourceFiles_1[_f]; + var filePath = newSourceFile.path; + addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); // Set the file as found during node modules search if it was found that way in old progra, - if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) { - sourceFilesFoundSearchingNodeModules.set(filePaths[i], true); + if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePath))) { + sourceFilesFoundSearchingNodeModules.set(filePath, true); } } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) { - var modifiedFile = modifiedSourceFiles_2[_c]; + for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) { + var modifiedFile = modifiedSourceFiles_2[_g]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - resolvedProjectReferences = oldProgram.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - resolvedProjectReferences.forEach(function (ref) { - if (ref) { - addProjectReferenceRedirects(ref.commandLine); - } - }); - } sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; return oldProgram.structureIsReused = 2 /* Completely */; @@ -85800,22 +86768,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 149 /* Parameter */: - case 152 /* PropertyDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 235 /* VariableDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 237 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -85823,41 +86791,41 @@ var ts; } } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 108 /* ImplementsKeyword */) { + if (heritageClause.token === 109 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -85870,51 +86838,51 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 240 /* ClassDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 219 /* VariableStatement */); } break; - case 152 /* PropertyDeclaration */: + case 154 /* 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 !== 115 /* StaticKeyword */) { + if (modifier.kind !== 116 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -85931,24 +86899,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 124 /* DeclareKeyword */: - case 117 /* AbstractKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 125 /* DeclareKeyword */: + case 118 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 115 /* StaticKeyword */: - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 116 /* StaticKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: } } } @@ -85996,10 +86964,22 @@ var ts; return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } function getOptionsDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), options.configFile ? programDiagnostics.getDiagnostics(options.configFile.fileName) : []))); + return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile()))); + } + function getOptionsDiagnosticsOfConfigFile() { + if (!options.configFile) { + return ts.emptyArray; + } + var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); + } + }); + return diagnostics; } function getGlobalDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); + return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray; } function getConfigFileParsingDiagnostics() { return configFileParsingDiagnostics || ts.emptyArray; @@ -86011,9 +86991,9 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 71 /* Identifier */ - ? b.kind === 71 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 9 /* StringLiteral */ && a.text === b.text; + return a.kind === 72 /* Identifier */ + ? b.kind === 72 /* Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -86041,12 +87021,9 @@ var ts; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(node); - } } if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(file.endOfFileToken); + collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; file.moduleAugmentations = moduleAugmentations || ts.emptyArray; @@ -86094,24 +87071,37 @@ var ts; } } } - function collectDynamicImportOrRequireCalls(node) { - if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { - imports = ts.append(imports, node.arguments[0]); - } - // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. - else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { - imports = ts.append(imports, node.arguments[0]); - } - else if (ts.isLiteralImportTypeNode(node)) { - imports = ts.append(imports, node.argument.literal); - } - collectDynamicImportOrRequireCallsForEachChild(node); - if (ts.hasJSDocNodes(node)) { - ts.forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild); + function collectDynamicImportOrRequireCalls(file) { + var r = /import|require/g; + while (r.exec(file.text) !== null) { + var node = getNodeAtPosition(file, r.lastIndex); + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { + imports = ts.append(imports, node.arguments[0]); + } + // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. + else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { + imports = ts.append(imports, node.arguments[0]); + } + else if (ts.isLiteralImportTypeNode(node)) { + imports = ts.append(imports, node.argument.literal); + } } } - function collectDynamicImportOrRequireCallsForEachChild(node) { - ts.forEachChild(node, collectDynamicImportOrRequireCalls); + /** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */ + 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 */)))) { + return child; + } + }; + while (true) { + var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild); + if (!child) { + return current; + } + current = child; + } } } function getLibFileFromReference(ref) { @@ -86273,7 +87263,7 @@ var ts; // Instead of creating a duplicate, just redirect to the existing one. var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 redirectTargetsMap.add(fileFromPackageId.path, fileName); - filesByName.set(path, dupFile); + addFileToFilesByName(dupFile, path, redirectedPath); sourceFileToPackageName.set(path, packageId.name); processingOtherFiles.push(dupFile); return dupFile; @@ -86284,10 +87274,7 @@ var ts; sourceFileToPackageName.set(path, packageId.name); } } - filesByName.set(path, file); - if (redirectedPath) { - filesByName.set(redirectedPath, file); - } + addFileToFilesByName(file, path, redirectedPath); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; @@ -86321,24 +87308,82 @@ var ts; } return file; } + function addFileToFilesByName(file, path, redirectedPath) { + filesByName.set(path, file); + if (redirectedPath) { + filesByName.set(redirectedPath, file); + } + } function getProjectReferenceRedirect(fileName) { // Ignore dts or any of the non ts files - if (!projectReferenceRedirects || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to // look in the output folder of the referenced project rather than the input - return ts.forEach(projectReferenceRedirects, function (referencedProject) { + var referencedProject = getResolvedProjectReferenceToRedirect(fileName); + if (!referencedProject) { + return undefined; + } + var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out; + return out ? + ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine); + } + /** + * Get the referenced project if the file is input file from that reference project + */ + function getResolvedProjectReferenceToRedirect(fileName) { + return forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) { // not input file from the referenced project, ignore - if (!ts.contains(referencedProject.fileNames, fileName, isSameFile)) { + if (!referencedProject || + toPath(options.configFilePath) === referenceProjectPath || + !ts.contains(referencedProject.commandLine.fileNames, fileName, isSameFile)) { return undefined; } - var out = referencedProject.options.outFile || referencedProject.options.out; - return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : - ts.getOutputDeclarationFileName(fileName, referencedProject); + return referencedProject; }); } + function forEachResolvedProjectReference(cb) { + return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var resolvedRefPath = toPath(resolveProjectReferencePath(ref)); + return cb(resolvedRef, resolvedRefPath); + }); + } + function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { + var seenResolvedRefs; + return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); + function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) { + // Visit project references first + if (cbRef) { + var result = cbRef(projectReferences, parent); + if (result) { + return result; + } + } + return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { + if (ts.contains(seenResolvedRefs, resolvedRef)) { + // ignore recursives + return undefined; + } + var result = cbResolvedRef(resolvedRef, index, parent); + if (result) { + return result; + } + if (!resolvedRef) + return undefined; + (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef); + return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef); + }); + } + } + function getResolvedProjectReferenceByPath(projectReferencePath) { + if (!projectReferenceRedirects) { + return undefined; + } + return projectReferenceRedirects.get(projectReferencePath) || undefined; + } function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); @@ -86351,7 +87396,7 @@ var ts; if (!typeDirectives) { return; } - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName)); for (var i = 0; i < typeDirectives.length; i++) { var ref = file.typeReferenceDirectives[i]; var resolvedTypeReferenceDirective = resolutions[i]; @@ -86369,6 +87414,8 @@ var ts; } var saveResolution = true; if (resolvedTypeReferenceDirective) { + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 @@ -86393,6 +87440,8 @@ var ts; processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth--; } else { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 @@ -86437,8 +87486,7 @@ var ts; if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); - var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file); ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; @@ -86506,20 +87554,34 @@ var ts; return allFilesBelongToPath; } function parseProjectReferenceConfigFile(ref) { + if (!projectReferenceRedirects) { + projectReferenceRedirects = ts.createMap(); + } // The actual filename (i.e. add "/tsconfig.json" if necessary) var refPath = resolveProjectReferencePath(ref); + var sourceFilePath = toPath(refPath); + var fromCache = projectReferenceRedirects.get(sourceFilePath); + if (fromCache !== undefined) { + return fromCache || undefined; + } // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); return undefined; } - sourceFile.path = toPath(refPath); + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; var commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); - return { commandLine: commandLine, sourceFile: sourceFile }; - } - function addProjectReferenceRedirects(referencedProject) { - (projectReferenceRedirects || (projectReferenceRedirects = [])).push(referencedProject); + var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile }; + projectReferenceRedirects.set(sourceFilePath, resolvedRef); + if (commandLine.projectReferences) { + resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile); + } + return resolvedRef; } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { @@ -86555,30 +87617,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } } - if (projectReferences) { - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i] && resolvedProjectReferences[i].commandLine.options; - if (resolvedRefOpts === undefined) { - createDiagnosticForReference(i, ts.Diagnostics.File_0_does_not_exist, ref.path); - continue; - } - if (!resolvedRefOpts.composite) { - createDiagnosticForReference(i, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); - } - if (ref.prepend) { - var out = resolvedRefOpts.outFile || resolvedRefOpts.out; - if (out) { - if (!host.fileExists(out)) { - createDiagnosticForReference(i, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); - } - } - else { - createDiagnosticForReference(i, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); - } - } - } - } + verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); @@ -86657,12 +87696,12 @@ var ts; } var languageVersion = options.target || 0 /* ES3 */; var outFile = options.outFile || options.out; - var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + 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 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } - var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); @@ -86700,7 +87739,7 @@ var ts; // Precalculate and cache the common source directory var dir = getCommonSourceDirectory(); // If we failed to find a good common directory, but outDir is specified and at least one of our files is on a windows drive/URL/other resource, add a failure - if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { + if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) { createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } @@ -86770,6 +87809,35 @@ var ts; } } } + function verifyProjectReferences() { + forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var parentFile = parent && parent.sourceFile; + if (!resolvedRef) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path); + return; + } + var options = resolvedRef.commandLine.options; + if (!options.composite) { + // ok to not have composite if the current program is container only + var inputs = parent ? parent.commandLine.fileNames : rootNames; + if (inputs.length) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); + } + } + if (ref.prepend) { + var out = options.outFile || options.out; + if (out) { + if (!host.fileExists(out)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); + } + } + else { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); + } + } + }); + } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { var needCompilerDiagnostic = true; var pathsSyntax = getOptionPathsSyntax(); @@ -86820,10 +87888,10 @@ var ts; function createOptionValueDiagnostic(option1, message, arg0) { createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0); } - function createDiagnosticForReference(index, message, arg0, arg1) { - var referencesSyntax = getProjectReferencesSyntax(); + function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) { + var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; }); if (referencesSyntax && referencesSyntax.elements.length > index) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); } else { programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1)); @@ -86837,22 +87905,6 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2)); } } - function getProjectReferencesSyntax() { - if (_referencesArrayLiteralSyntax === undefined) { - _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword - if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 - for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { - var prop = _a[_i]; - if (ts.isArrayLiteralExpression(prop.initializer)) { - _referencesArrayLiteralSyntax = prop.initializer; - break; - } - } - } - } - return _referencesArrayLiteralSyntax; - } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword @@ -86927,7 +87979,8 @@ var ts; readFile: function (f) { return host.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: function () { return undefined; } + onUnRecoverableConfigFileDiagnostic: function () { return undefined; }, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost; @@ -86977,7 +88030,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 === 9 /* StringLiteral */) { + if (aug.kind === 10 /* StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -87202,6 +88255,11 @@ var ts; var latestSignature; if (sourceFile.isDeclarationFile) { latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.path) : undefined; + exportedModulesMapCache.set(sourceFile.path, references || false); + } } else { var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); @@ -87267,7 +88325,7 @@ var ts; return getAllFileNames(state, programOfThisState); } // If this is non module emit, or its a global file, it depends on all the source files - if (!state.referencedMap || (!ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile))) { + if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) { return getAllFileNames(state, programOfThisState); } // Get the references, traversing deep from the referenceMap @@ -87326,6 +88384,20 @@ var ts; } return true; } + /** + * Return true if file contains anything that augments to global scope we need to build them as if + * they are global files as well as module + */ + function containsGlobalScopeAugmentation(sourceFile) { + return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); }); + } + /** + * Return true if the file will invalidate all files because it affectes global scope + */ + function isFileAffectingGlobalScope(sourceFile) { + return containsGlobalScopeAugmentation(sourceFile) || + !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + } /** * Gets all files of the program excluding the default library file */ @@ -87366,7 +88438,7 @@ var ts; * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { - if (!ts.isExternalModule(sourceFileWithUpdatedShape) && !containsOnlyAmbientModules(sourceFileWithUpdatedShape)) { + if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } var compilerOptions = programOfThisState.getCompilerOptions(); @@ -87416,8 +88488,9 @@ var ts; } state.changedFilesSet = ts.createMap(); var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); + var oldCompilerOptions = useOldState ? oldState.program.getCompilerOptions() : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && - !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldState.program.getCompilerOptions()); + !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions); if (useOldState) { // Verify the sanity of old state if (!oldState.currentChangedFilePath) { @@ -87432,6 +88505,8 @@ var ts; // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; + var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck; + var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -87449,6 +88524,13 @@ var ts; state.changedFilesSet.set(sourceFilePath, true); } else if (canCopySemanticDiagnostics) { + var sourceFile = state.program.getSourceFileByPath(sourceFilePath); + if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { + return; + } + if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { + return; + } // Unchanged file copy diagnostics var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath); if (diagnostics) { @@ -87532,18 +88614,31 @@ var ts; // If there are no more diagnostics from old cache, done return; } + // Clean lib file diagnostics if its all files excluding default files to emit + if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles && !state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var options_2 = state.program.getCompilerOptions(); + if (ts.forEach(state.program.getSourceFiles(), function (f) { + return state.program.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2) && + removeSemanticDiagnosticsOf(state, f.path); + })) { + return; + } + } // If there was change in signature for the changed file, // then delete the semantic diagnostics for files that are affected by using exports of this module if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { return; } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); + var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { return exportedModules && exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); })) { return; } @@ -87551,16 +88646,44 @@ var ts; ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** * removes the semantic diagnostics of files referencing referencedPath and * returns true if there are no more semantic diagnostics from old state */ - function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath) { + function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile) { return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) { - return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOf(state, filePath); + return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile); + }); + } + /** + * Removes semantic diagnostics of file and anything that exports this file + */ + function removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile) { + if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) { + return false; + } + if (removeSemanticDiagnosticsOf(state, filePath)) { + // If there are no more diagnostics from old cache, done + return true; + } + 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 + if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { + return exportedModules && + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); + })) { + return true; + } + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + return !!ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { + return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** @@ -87569,7 +88692,7 @@ var ts; */ function removeSemanticDiagnosticsOf(state, path) { if (!state.semanticDiagnosticsFromOldState) { - return false; + return true; } state.semanticDiagnosticsFromOldState.delete(path); state.semanticDiagnosticsPerFile.delete(path); @@ -87842,6 +88965,10 @@ var ts; /*@internal*/ var ts; (function (ts) { + function isPathInNodeModulesStartingWithDot(path) { + return ts.stringContains(path, "/node_modules/."); + } + ts.isPathInNodeModulesStartingWithDot = isPathInNodeModulesStartingWithDot; ts.maxNumberOfFilesToIterateForInvalidation = 256; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; @@ -87855,11 +88982,11 @@ var ts; // The key in the map is source file's path. // The values are Map of resolutions with key being name lookedup. var resolvedModuleNames = ts.createMap(); - var perDirectoryResolvedModuleNames = ts.createMap(); - var nonRelaticeModuleNameCache = ts.createMap(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelaticeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); + var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); + var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); var resolvedTypeReferenceDirectives = ts.createMap(); - var perDirectoryResolvedTypeReferenceDirectives = ts.createMap(); + var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -87883,6 +89010,7 @@ var ts; resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives: resolveTypeReferenceDirectives, + removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects, removeResolutionsOfFile: removeResolutionsOfFile, invalidateResolutionOfFile: invalidateResolutionOfFile, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, @@ -87944,7 +89072,7 @@ var ts; } function clearPerDirectoryResolutions() { perDirectoryResolvedModuleNames.clear(); - nonRelaticeModuleNameCache.clear(); + nonRelativeModuleNameCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); @@ -87960,8 +89088,8 @@ var ts; } }); } - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache); + function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference); // 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; @@ -87979,10 +89107,11 @@ var ts; // Default return the result from the first pass return primaryResult; } - function resolveNamesWithLocalCache(names, containingFile, cache, perDirectoryCache, loader, getResolutionWithResolvedFileName, reusedNames, logChanges) { + function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) { var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); + var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); var perDirectoryResolution = perDirectoryCache.get(dirPath); if (!perDirectoryResolution) { perDirectoryResolution = ts.createMap(); @@ -87991,22 +89120,28 @@ var ts; var resolvedModules = []; var compilerOptions = resolutionHost.getCompilationSettings(); var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path); + // All the resolutions in this file are invalidated if this file wasnt resolved using same redirect + var program = resolutionHost.getCurrentProgram(); + var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile); + var unmatchedRedirects = oldRedirect ? + !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : + !!redirectedReference; var seenNamesInFile = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { var name = names_2[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && - allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated || + allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate - (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && !getResolutionWithResolvedFileName(resolution))) { + (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; } else { - resolution = loader(name, containingFile, compilerOptions, resolutionHost); + resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -88022,7 +89157,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -88050,12 +89185,14 @@ var ts; return oldResult.resolvedFileName === newResult.resolvedFileName; } } - function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile) { - return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) { + return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + /*shouldRetryResolution*/ function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, /*reusedNames*/ undefined, /*logChanges*/ false); } - function resolveModuleNames(moduleNames, containingFile, reusedNames) { - return resolveNamesWithLocalCache(moduleNames, containingFile, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, reusedNames, logChangesWhenResolvingModule); + function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { + return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, + /*shouldRetryResolution*/ function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule); } function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); @@ -88098,12 +89235,6 @@ var ts; } return true; } - function filterFSRootDirectoriesToWatch(watchPath, dirPath) { - if (!canWatchDirectory(dirPath)) { - watchPath.ignore = true; - } - return watchPath; - } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path @@ -88123,13 +89254,13 @@ var ts; } function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) { // If directory path contains node module, get the most parent node_modules directory for watching - while (ts.stringContains(dirPath, ts.nodeModulesPathPart)) { + while (ts.pathContainsNodeModules(dirPath)) { dir = ts.getDirectoryPath(dir); dirPath = ts.getDirectoryPath(dirPath); } // If the directory is node_modules use it to watch, always watch it recursively if (isNodeModulesDirectory(dirPath)) { - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); + return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -88147,7 +89278,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive }, dirPath); + return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -88176,8 +89307,9 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, nonRecursive = _a.nonRecursive, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive; // If the failed lookup location path is not one of the supported extensions, // store it in the custom path if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { @@ -88230,8 +89362,9 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dirPath = toWatch.dirPath; var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { if (refCount === 1) { @@ -88279,6 +89412,22 @@ var ts; cache.delete(filePath); } } + function removeResolutionsFromProjectReferenceRedirects(filePath) { + if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) { + return; + } + var program = resolutionHost.getCurrentProgram(); + if (!program) { + return; + } + // If this file is input file for the referenced project, get it + var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath); + if (!resolvedProjectReference) { + return; + } + // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution + resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); + } function removeResolutionsOfFile(filePath) { removeResolutionsOfFileFromCache(resolvedModuleNames, filePath); removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath); @@ -88340,6 +89489,9 @@ var ts; isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); }; } else { + // If something to do with folder/file starting with "." in node_modules folder, skip it + if (isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return false; // Some file or directory in the watching directory is created // Return early if it does not have any of the watching extension or not the custom failed lookup path var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); @@ -88380,8 +89532,8 @@ var ts; if (isInDirectoryPath(rootPath, typeRootPath)) { return rootPath; } - var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; + var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath); + return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -88869,7 +90021,6 @@ var ts; } return false; } - /** @internal */ ts.screenStartingMessageCodes = [ ts.Diagnostics.Starting_compilation_in_watch_mode.code, ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code, @@ -88910,6 +90061,23 @@ var ts; return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; + function getErrorCountForSummary(diagnostics) { + return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + ts.getErrorCountForSummary = getErrorCountForSummary; + function getWatchErrorSummaryDiagnosticMessage(errorCount) { + return errorCount === 1 ? + ts.Diagnostics.Found_1_error_Watching_for_file_changes : + ts.Diagnostics.Found_0_errors_Watching_for_file_changes; + } + ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage; + function getErrorSummaryText(errorCount, newLine) { + if (errorCount === 0) + return ""; + var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount); + return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine; + } + ts.getErrorSummaryText = getErrorSummaryText; /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ @@ -88948,7 +90116,7 @@ var ts; } } if (reportSummary) { - reportSummary(diagnostics.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length); + reportSummary(getErrorCountForSummary(diagnostics)); } if (emitSkipped && diagnostics.length > 0) { // If the emitter didn't emit anything, then pass that value along. @@ -89027,15 +90195,7 @@ var ts; function emitFilesAndReportErrorUsingBuilder(builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - var reportSummary = function (errorCount) { - if (errorCount === 1) { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_1_error_Watching_for_file_changes, errorCount), newLine, compilerOptions); - } - else { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_0_errors_Watching_for_file_changes, errorCount, errorCount), newLine, compilerOptions); - } - }; - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, reportSummary); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); } } /** @@ -89111,7 +90271,8 @@ var ts; fileExists: function (path) { return host.fileExists(path); }, readFile: readFile, getCurrentDirectory: getCurrentDirectory, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; // From tsc we want to get already parsed result and hence check for rootFileNames var newLine = updateNewLine(); @@ -89179,11 +90340,11 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }) : - (function (moduleNames, containingFile, reusedNames) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); }); + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }) : - (function (typeDirectiveNames, containingFile) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }); + (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; synchronizeProgram(); // Update the wild card directory watch @@ -89357,8 +90518,8 @@ var ts; var hostSourceFile = sourceFilesCache.get(path); return !hostSourceFile || isFileMissingOnHost(hostSourceFile) ? undefined : hostSourceFile.version.toString(); } - function onReleaseOldSourceFile(oldSourceFile, _oldOptions) { - var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.path); + function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { + var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); // If this is the source file thats in the cache and new program doesnt need it, // remove the cached entry. // Note we arent deleting entry if file became missing in new program or @@ -89372,8 +90533,10 @@ var ts; if (hostSourceFileInfo.fileWatcher) { hostSourceFileInfo.fileWatcher.close(); } - sourceFilesCache.delete(oldSourceFile.path); - resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + sourceFilesCache.delete(oldSourceFile.resolvedPath); + if (!hasSourceFileByPath) { + resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + } } } } @@ -89453,6 +90616,7 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.get(path)) { resolutionCache.invalidateResolutionOfFile(path); } + resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -89493,6 +90657,8 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } nextSourceFileVersion(fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) { @@ -89695,7 +90861,7 @@ var ts; }; } ts.createBuilderStatusReporter = createBuilderStatusReporter; - function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus) { + function createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) { if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker({}, /*setParentNodes*/ undefined, system); host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; @@ -89705,10 +90871,15 @@ var ts; host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; } + function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { + if (system === void 0) { system = ts.sys; } + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); + host.reportErrorSummary = reportErrorSummary; + return host; + } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { - if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); host.onWatchStatusChange = watchHost.onWatchStatusChange; host.watchFile = watchHost.watchFile; @@ -89725,12 +90896,6 @@ var ts; }); return result; } - /** - * A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but - * can dynamically add/remove other projects based on changes on the rootNames' references - * TODO: use SolutionBuilderWithWatchHost => watchedSolution - * use SolutionBuilderHost => Solution - */ function createSolutionBuilder(host, rootNames, defaultOptions) { var hostWithWatch = host; var currentDirectory = host.getCurrentDirectory(); @@ -90089,9 +91254,7 @@ var ts; globalDependencyGraph = undefined; } projectStatus.removeKey(resolved); - if (options.watch) { - diagnostics.removeKey(resolved); - } + diagnostics.removeKey(resolved); addProjToQueue(resolved, reloadLevel); } /** @@ -90153,7 +91316,7 @@ var ts; } } function reportErrorSummary() { - if (options.watch) { + if (options.watch || host.reportErrorSummary) { // Report errors from the other projects getGlobalDependencyGraph().buildQueue.forEach(function (project) { if (!projectErrorsReported.hasKey(project)) { @@ -90161,8 +91324,13 @@ var ts; } }); var totalErrors_1 = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += singleProjectErrors.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length; }); - reportWatchStatus(totalErrors_1 === 1 ? ts.Diagnostics.Found_1_error_Watching_for_file_changes : ts.Diagnostics.Found_0_errors_Watching_for_file_changes, totalErrors_1); + diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += ts.getErrorCountForSummary(singleProjectErrors); }); + if (options.watch) { + reportWatchStatus(ts.getWatchErrorSummaryDiagnosticMessage(totalErrors_1), totalErrors_1); + } + else { + host.reportErrorSummary(totalErrors_1); + } } } function buildSingleInvalidatedProject(resolved, reloadLevel) { @@ -90326,9 +91494,7 @@ var ts; type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime }; - if (options.watch) { - diagnostics.removeKey(proj); - } + diagnostics.removeKey(proj); projectStatus.setValue(proj, status); return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { @@ -90454,10 +91620,8 @@ var ts; } function reportAndStoreErrors(proj, errors) { reportErrors(errors); - if (options.watch) { - projectErrorsReported.setValue(proj, true); - diagnostics.setValue(proj, errors); - } + projectErrorsReported.setValue(proj, true); + diagnostics.setValue(proj, errors); } function reportErrors(errors) { errors.forEach(function (err) { return host.reportDiagnostic(err); }); @@ -90579,10 +91743,12 @@ var ts; if (builtin !== undefined) return builtin; var entries = getEntriesOfObject(value); - return { kind: 3 /* Object */, name: name, members: ts.flatMap(entries, function (_a) { - var key = _a.key, value = _a.value; - return getValueInfo(key, value, recurser); - }) }; + var hasNontrivialPrototype = Object.getPrototypeOf(value) !== Object.prototype; + var members = ts.flatMap(entries, function (_a) { + var key = _a.key, value = _a.value; + return getValueInfo(key, value, recurser); + }); + return { kind: 3 /* Object */, name: name, hasNontrivialPrototype: hasNontrivialPrototype, members: members }; } return { kind: 0 /* Const */, name: name, typeName: isNullOrUndefined(value) ? "any" : typeof value }; }, function (isCircularReference, keyStack) { return anyValue(name, " " + (isCircularReference ? "Circular reference" : "Too-deep object hierarchy") + " from " + keyStack.join(".")); }); @@ -90711,7 +91877,6 @@ var ts; : undefined; } server.findArgument = findArgument; - /*@internal*/ function nowString() { // E.g. "12:34:56.789" var d = new Date(); @@ -90725,13 +91890,11 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - /* @internal */ function isTypingUpToDate(cachedTyping, availableTypingVersions) { var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; - /* @internal */ JsTyping.nodeCoreModuleList = [ "assert", "async_hooks", @@ -90770,7 +91933,6 @@ var ts; "vm", "zlib" ]; - /* @internal */ JsTyping.nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); @@ -91066,30 +92228,32 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + function getDefaultFormatCodeSettings(newLineCharacter) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: newLineCharacter || "\n", + convertTabsToSpaces: true, + indentStyle: IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; /* @internal */ - ts.testFormatSettings = { - baseIndentSize: 0, - indentSize: 4, - tabSize: 4, - newLineCharacter: "\n", - convertTabsToSpaces: true, - indentStyle: IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterConstructor: false, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - insertSpaceAfterTypeAssertion: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - insertSpaceBeforeTypeAnnotation: false - }; + ts.testFormatSettings = getDefaultFormatCodeSettings("\n"); var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; @@ -91151,8 +92315,9 @@ var ts; TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + TokenClass[TokenClass["BigIntLiteral"] = 7] = "BigIntLiteral"; + TokenClass[TokenClass["StringLiteral"] = 8] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 9] = "RegExpLiteral"; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { @@ -91235,6 +92400,12 @@ var ts; ScriptElementKindModifier["staticModifier"] = "static"; ScriptElementKindModifier["abstractModifier"] = "abstract"; ScriptElementKindModifier["optionalModifier"] = "optional"; + ScriptElementKindModifier["dtsModifier"] = ".d.ts"; + ScriptElementKindModifier["tsModifier"] = ".ts"; + ScriptElementKindModifier["tsxModifier"] = ".tsx"; + ScriptElementKindModifier["jsModifier"] = ".js"; + ScriptElementKindModifier["jsxModifier"] = ".jsx"; + ScriptElementKindModifier["jsonModifier"] = ".json"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames; (function (ClassificationTypeNames) { @@ -91242,6 +92413,7 @@ var ts; ClassificationTypeNames["identifier"] = "identifier"; ClassificationTypeNames["keyword"] = "keyword"; ClassificationTypeNames["numericLiteral"] = "number"; + ClassificationTypeNames["bigintLiteral"] = "bigint"; ClassificationTypeNames["operator"] = "operator"; ClassificationTypeNames["stringLiteral"] = "string"; ClassificationTypeNames["whiteSpace"] = "whitespace"; @@ -91288,6 +92460,7 @@ var ts; ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + ClassificationType[ClassificationType["bigintLiteral"] = 25] = "bigintLiteral"; })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); // These utilities are common to multiple language service features. @@ -91305,37 +92478,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 272 /* CatchClause */: - case 265 /* JsxAttribute */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 274 /* CatchClause */: + case 267 /* JsxAttribute */: return 1 /* Value */; - case 148 /* TypeParameter */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 166 /* TypeLiteral */: + case 150 /* TypeParameter */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 168 /* TypeLiteral */: return 2 /* Type */; - case 302 /* JSDocTypedefTag */: + case 304 /* 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 276 /* EnumMember */: - case 238 /* ClassDeclaration */: + case 278 /* EnumMember */: + case 240 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -91345,26 +92518,26 @@ var ts; else { return 4 /* Namespace */; } - case 241 /* EnumDeclaration */: - case 250 /* NamedImports */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 243 /* EnumDeclaration */: + case 252 /* NamedImports */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 252 /* ExportAssignment */ || node.parent.kind === 257 /* ExternalModuleReference */) { + else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -91396,11 +92569,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 148 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 248 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -91412,27 +92585,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 146 /* QualifiedName */) { - while (root.parent && root.parent.kind === 146 /* QualifiedName */) { + if (root.parent.kind === 148 /* QualifiedName */) { + while (root.parent && root.parent.kind === 148 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 162 /* TypeReference */ && !isLastClause; + return root.parent.kind === 164 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 187 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { + if (root.parent.kind === 189 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 189 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 211 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 273 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 240 /* ClassDeclaration */ && root.parent.parent.token === 109 /* ImplementsKeyword */) || + (decl.kind === 241 /* InterfaceDeclaration */ && root.parent.parent.token === 86 /* ExtendsKeyword */); } return false; } @@ -91441,17 +92614,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return true; } switch (node.parent.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return true; - case 181 /* ImportType */: + case 183 /* ImportType */: return !node.parent.isTypeOf; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -91478,7 +92651,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 233 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -91494,11 +92667,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 71 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 71 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -91506,40 +92679,40 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 244 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 71 /* Identifier */ && + return node.kind === 72 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 276 /* EnumMember */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 242 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 278 /* EnumMember */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 244 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return true; - case 180 /* LiteralType */: - return node.parent.parent.kind === 178 /* IndexedAccessType */; + case 182 /* LiteralType */: + return node.parent.parent.kind === 180 /* IndexedAccessType */; default: return false; } @@ -91563,17 +92736,17 @@ var ts; return undefined; } switch (node.kind) { - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return node; } } @@ -91581,51 +92754,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return "class" /* classElement */; - case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 240 /* TypeAliasDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 242 /* TypeAliasDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 241 /* EnumDeclaration */: return "enum" /* enumElement */; - case 235 /* VariableDeclaration */: + case 243 /* EnumDeclaration */: return "enum" /* enumElement */; + case 237 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return "function" /* functionElement */; - case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 158 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 159 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return "property" /* memberVariableElement */; - case 160 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 159 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 158 /* CallSignature */: return "call" /* callSignatureElement */; - case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 276 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: - case 249 /* NamespaceImport */: + case 162 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 161 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 160 /* CallSignature */: return "call" /* callSignatureElement */; + case 157 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 150 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 278 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 151 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: + case 251 /* NamespaceImport */: return "alias" /* alias */; - case 202 /* BinaryExpression */: + case 204 /* 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 */: @@ -91646,7 +92822,7 @@ var ts; return "" /* unknown */; } } - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -91662,12 +92838,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 149 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 151 /* Parameter */; default: return false; } @@ -91732,42 +92908,42 @@ var ts; return false; } switch (n.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 182 /* ObjectBindingPattern */: - case 166 /* TypeLiteral */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 244 /* CaseBlock */: - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 272 /* CatchClause */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 168 /* TypeLiteral */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 246 /* CaseBlock */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); + case 274 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 190 /* NewExpression */: + case 192 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 189 /* CallExpression */: - case 193 /* ParenthesizedExpression */: - case 175 /* ParenthesizedType */: - return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 191 /* CallExpression */: + case 195 /* ParenthesizedExpression */: + case 177 /* ParenthesizedType */: + return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 197 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -91776,66 +92952,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 242 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); + case 244 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 220 /* IfStatement */: + case 222 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 185 /* ArrayLiteralExpression */: - case 183 /* ArrayBindingPattern */: - case 188 /* ElementAccessExpression */: - case 147 /* ComputedPropertyName */: - case 168 /* TupleType */: - return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); - case 160 /* IndexSignature */: + hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); + case 187 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 190 /* ElementAccessExpression */: + case 149 /* ComputedPropertyName */: + case 170 /* TupleType */: + return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); + case 162 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 107 /* WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 197 /* TypeOfExpression */: - case 196 /* DeleteExpression */: - case 198 /* VoidExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: + case 199 /* TypeOfExpression */: + case 198 /* DeleteExpression */: + case 200 /* VoidExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -91852,7 +93028,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 25 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -92014,7 +93190,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 277 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* 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. @@ -92076,25 +93252,25 @@ var ts; if (!token) { return false; } - if (token.kind === 10 /* JsxText */) { + if (token.kind === 11 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 263 /* JsxClosingElement */) { return true; } return false; @@ -92108,6 +93284,20 @@ var ts; return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; + function isInJSXText(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + if (ts.isJsxText(token)) { + return true; + } + if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + return false; + } + ts.isInJSXText = isInJSXText; function findPrecedingMatchingToken(token, matchingTokenKind, sourceFile) { var tokenKind = token.kind; var remainingMatchingTokens = 0; @@ -92154,7 +93344,7 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); if (!token || !ts.isIdentifier(token)) @@ -92164,53 +93354,54 @@ var ts; } remainingLessThanTokens--; break; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: remainingLessThanTokens++; break; - case 18 /* CloseBraceToken */: + case 19 /* 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, 17 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 20 /* CloseParenToken */: + case 21 /* 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, 19 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 22 /* CloseBracketToken */: + case 23 /* 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, 21 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 26 /* CommaToken */: + case 27 /* CommaToken */: nTypeArguments++; break; - case 36 /* EqualsGreaterThanToken */: - case 71 /* Identifier */: - case 9 /* StringLiteral */: + case 37 /* EqualsGreaterThanToken */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 103 /* TypeOfKeyword */: - case 85 /* ExtendsKeyword */: - case 128 /* KeyOfKeyword */: - case 23 /* DotToken */: - case 49 /* BarToken */: - case 55 /* QuestionToken */: - case 56 /* ColonToken */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 104 /* TypeOfKeyword */: + case 86 /* ExtendsKeyword */: + case 129 /* KeyOfKeyword */: + case 24 /* DotToken */: + case 50 /* BarToken */: + case 56 /* QuestionToken */: + case 57 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -92265,10 +93456,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { + if (node.kind === 164 /* TypeReference */ || node.kind === 191 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 240 /* ClassDeclaration */ || node.kind === 241 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -92279,8 +93470,8 @@ var ts; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 /* StringLiteral */ - || kind === 12 /* RegularExpressionLiteral */ + if (kind === 10 /* StringLiteral */ + || kind === 13 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -92288,7 +93479,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 71 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -92298,9 +93489,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: return true; } return false; @@ -92313,18 +93504,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 185 /* ArrayLiteralExpression */ || - node.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 187 /* ArrayLiteralExpression */ || + node.kind === 188 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 202 /* BinaryExpression */ && + if (node.parent.kind === 204 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 58 /* EqualsToken */) { + node.parent.operatorToken.kind === 59 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 225 /* ForOfStatement */ && + if (node.parent.kind === 227 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -92332,7 +93523,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 275 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -92376,21 +93567,21 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 119 /* AnyKeyword */, - 122 /* BooleanKeyword */, - 86 /* FalseKeyword */, - 128 /* KeyOfKeyword */, - 131 /* NeverKeyword */, - 95 /* NullKeyword */, - 134 /* NumberKeyword */, - 135 /* ObjectKeyword */, - 137 /* StringKeyword */, - 138 /* SymbolKeyword */, - 101 /* TrueKeyword */, - 105 /* VoidKeyword */, - 140 /* UndefinedKeyword */, - 141 /* UniqueKeyword */, - 142 /* UnknownKeyword */, + 120 /* AnyKeyword */, + 123 /* BooleanKeyword */, + 87 /* FalseKeyword */, + 129 /* KeyOfKeyword */, + 132 /* NeverKeyword */, + 96 /* NullKeyword */, + 135 /* NumberKeyword */, + 136 /* ObjectKeyword */, + 138 /* StringKeyword */, + 139 /* SymbolKeyword */, + 102 /* TrueKeyword */, + 106 /* VoidKeyword */, + 141 /* UndefinedKeyword */, + 142 /* UniqueKeyword */, + 143 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -92426,7 +93617,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 147 /* ComputedPropertyName */ + return name.kind === 149 /* 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.getTextOfIdentifierOrLiteral(name); @@ -92502,7 +93693,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 71 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 72 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -92515,13 +93706,7 @@ var ts; ts.isObjectBindingElementWithoutPropertyName = isObjectBindingElementWithoutPropertyName; function getPropertySymbolFromBindingElement(checker, bindingElement) { var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); - var propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - if (propSymbol && propSymbol.flags & 98304 /* Accessor */) { - // See GH#16922 - ts.Debug.assert(!!(propSymbol.flags & 33554432 /* Transient */)); - return propSymbol.target; - } - return propSymbol; + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; /** @@ -92574,7 +93759,6 @@ var ts; return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); } ts.findModifier = findModifier; - /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); if (lastImportDeclaration) { @@ -92598,7 +93782,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 151 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -92624,6 +93808,7 @@ var ts; writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeTrailingSemicolon: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, @@ -92632,7 +93817,7 @@ var ts; writeSymbol: writeSymbol, writeLine: writeLine, write: unknownWrite, - writeTextOfNode: unknownWrite, + writeComment: unknownWrite, getText: function () { return ""; }, getTextPos: function () { return 0; }, getColumn: function () { return 0; }, @@ -92783,7 +93968,6 @@ var ts; return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } ts.lineBreakPart = lineBreakPart; - /* @internal */ function mapToDisplayParts(writeDisplayParts) { try { writeDisplayParts(displayPartWriter); @@ -92818,7 +94002,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && + (location.parent.kind === 253 /* ImportSpecifier */ || location.parent.kind === 257 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -92865,6 +94049,13 @@ var ts; return position; } ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getPrecedingNonSpaceCharacterPosition(text, position) { + while (position > -1 && ts.isWhiteSpaceSingleLine(text.charCodeAt(position))) { + position -= 1; + } + return position + 1; + } + ts.getPrecedingNonSpaceCharacterPosition = getPrecedingNonSpaceCharacterPosition; /** * Creates a deep, memberwise clone of a node with no source map location. * @@ -92931,7 +94122,6 @@ var ts; /** * Sets EmitFlags to suppress leading and trailing trivia on the node. */ - /* @internal */ function suppressLeadingAndTrailingTrivia(node) { suppressLeadingTrivia(node); suppressTrailingTrivia(node); @@ -92940,7 +94130,6 @@ var ts; /** * Sets EmitFlags to suppress leading trivia on the node. */ - /* @internal */ function suppressLeadingTrivia(node) { addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); } @@ -92948,7 +94137,6 @@ var ts; /** * Sets EmitFlags to suppress trailing trivia on the node. */ - /* @internal */ function suppressTrailingTrivia(node) { addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); } @@ -92962,7 +94150,6 @@ var ts; function getFirstChild(node) { return node.forEachChild(function (child) { return child; }); } - /* @internal */ function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { @@ -92976,7 +94163,6 @@ var ts; * to be on the reference, rather than the declaration, because it's closer to where the * user was before extracting it. */ - /* @internal */ function getRenameLocation(edits, renameFilename, name, preferLastLocation) { var delta = 0; var lastPos = -1; @@ -93030,6 +94216,72 @@ var ts; idx = change.indexOf('"' + name); return idx === -1 ? -1 : idx + 1; } + function getContextualTypeFromParent(node, checker) { + var parent = node.parent; + switch (parent.kind) { + case 192 /* NewExpression */: + return checker.getContextualType(parent); + case 204 /* 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 271 /* CaseClause */: + return parent.expression === node ? getSwitchedType(parent, checker) : undefined; + default: + return checker.getContextualType(node); + } + } + ts.getContextualTypeFromParent = getContextualTypeFromParent; + function quote(text, preferences) { + if (/^\d+$/.test(text)) { + return text; + } + var quoted = JSON.stringify(text); + switch (preferences.quotePreference) { + case undefined: + case "double": + return quoted; + case "single": + return "'" + stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; + default: + return ts.Debug.assertNever(preferences.quotePreference); + } + } + ts.quote = quote; + function isEqualityOperatorKind(kind) { + switch (kind) { + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + return true; + default: + return false; + } + } + ts.isEqualityOperatorKind = isEqualityOperatorKind; + function isStringLiteralOrTemplate(node) { + switch (node.kind) { + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + return true; + default: + return false; + } + } + ts.isStringLiteralOrTemplate = isStringLiteralOrTemplate; + function hasIndexSignature(type) { + return !!type.getStringIndexType() || !!type.getNumberIndexType(); + } + ts.hasIndexSignature = hasIndexSignature; + function getSwitchedType(caseClause, checker) { + return checker.getTypeAtLocation(caseClause.parent.parent.expression); + } + ts.getSwitchedType = getSwitchedType; })(ts || (ts = {})); var ts; (function (ts) { @@ -93068,7 +94320,7 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(14 /* TemplateHead */); + templateStack.push(15 /* TemplateHead */); } scanner.setText(text); var endOfLineState = 0 /* None */; @@ -93110,65 +94362,65 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 12 /* RegularExpressionLiteral */) { - token = 12 /* RegularExpressionLiteral */; + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + token = 13 /* RegularExpressionLiteral */; } break; - case 27 /* LessThanToken */: - if (lastNonTriviaToken === 71 /* Identifier */) { + case 28 /* LessThanToken */: + if (lastNonTriviaToken === 72 /* 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 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 119 /* AnyKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: + case 120 /* AnyKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: templateStack.push(token); break; - case 17 /* OpenBraceToken */: + case 18 /* 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 18 /* CloseBraceToken */: + case 19 /* 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 === 14 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 16 /* TemplateTail */) { + if (token === 17 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 15 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 17 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -93177,15 +94429,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 23 /* DotToken */) { - token = 71 /* Identifier */; + if (lastNonTriviaToken === 24 /* DotToken */) { + token = 72 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } } } @@ -93199,22 +94451,23 @@ 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([ - 71 /* Identifier */, - 9 /* StringLiteral */, + 72 /* Identifier */, + 10 /* StringLiteral */, 8 /* NumericLiteral */, - 12 /* RegularExpressionLiteral */, - 99 /* ThisKeyword */, - 43 /* PlusPlusToken */, - 44 /* MinusMinusToken */, - 20 /* CloseParenToken */, - 22 /* CloseBracketToken */, - 18 /* CloseBraceToken */, - 101 /* TrueKeyword */, - 86 /* FalseKeyword */, + 9 /* BigIntLiteral */, + 13 /* RegularExpressionLiteral */, + 100 /* ThisKeyword */, + 44 /* PlusPlusToken */, + 45 /* MinusMinusToken */, + 21 /* CloseParenToken */, + 23 /* CloseBracketToken */, + 19 /* CloseBraceToken */, + 102 /* TrueKeyword */, + 87 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; @@ -93238,15 +94491,15 @@ var ts; return undefined; } switch (token) { - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return 5 /* InTemplateMiddleOrTail */; - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 14 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { @@ -93295,6 +94548,7 @@ var ts; 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; @@ -93321,10 +94575,10 @@ var ts; return true; } switch (keyword2) { - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 123 /* ConstructorKeyword */: - case 115 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 124 /* ConstructorKeyword */: + case 116 /* 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. @@ -93357,43 +94611,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 48 /* AmpersandToken */: - case 50 /* CaretToken */: - case 49 /* BarToken */: - case 53 /* AmpersandAmpersandToken */: - case 54 /* BarBarToken */: - case 69 /* BarEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 49 /* AmpersandToken */: + case 51 /* CaretToken */: + case 50 /* BarToken */: + case 54 /* AmpersandAmpersandToken */: + case 55 /* BarBarToken */: + case 70 /* BarEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return true; default: return false; @@ -93401,12 +94655,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: return true; default: return false; @@ -93419,15 +94673,17 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 17 /* FirstPunctuation */ && token <= 70 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 71 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + return 25 /* bigintLiteral */; + case 10 /* StringLiteral */: return 6 /* stringLiteral */; - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -93436,7 +94692,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 71 /* Identifier */: + case 72 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -93461,10 +94717,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -93539,6 +94795,7 @@ var ts; 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 */; @@ -93672,22 +94929,22 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); // "@" + pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -93758,10 +95015,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -93774,22 +95031,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -93806,7 +95063,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 27 /* LessThanToken */ || tokenKind === 29 /* GreaterThanToken */) { + if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* 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)) { @@ -93816,19 +95073,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 58 /* EqualsToken */) { + if (tokenKind === 59 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 235 /* VariableDeclaration */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 149 /* Parameter */ || - parent.kind === 265 /* JsxAttribute */) { + if (parent.kind === 237 /* VariableDeclaration */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 151 /* Parameter */ || + parent.kind === 267 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 202 /* BinaryExpression */ || - parent.kind === 200 /* PrefixUnaryExpression */ || - parent.kind === 201 /* PostfixUnaryExpression */ || - parent.kind === 203 /* ConditionalExpression */) { + if (parent.kind === 204 /* BinaryExpression */ || + parent.kind === 202 /* PrefixUnaryExpression */ || + parent.kind === 203 /* PostfixUnaryExpression */ || + parent.kind === 205 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -93837,11 +95094,14 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 9 /* BigIntLiteral */) { + return 25 /* bigintLiteral */; } - else if (tokenKind === 12 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* StringLiteral */) { + // TODO: GH#18217 + return token.parent.kind === 267 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + } + else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -93849,38 +95109,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 10 /* JsxText */) { + else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 71 /* Identifier */) { + else if (tokenKind === 72 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 149 /* Parameter */: + case 151 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -93914,37 +95174,245 @@ var ts; (function (ts) { var Completions; (function (Completions) { - var PathCompletions; - (function (PathCompletions) { - function nameAndKind(name, kind) { - return { name: name, kind: kind }; + var StringCompletions; + (function (StringCompletions) { + function getStringLiteralCompletions(sourceFile, position, contextToken, checker, options, host, log, preferences) { + if (ts.isInReferenceComment(sourceFile, position)) { + var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); + return entries && convertPathCompletions(entries); + } + if (ts.isInString(sourceFile, position, contextToken)) { + return !contextToken || !ts.isStringLiteralLike(contextToken) + ? undefined + : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host), sourceFile, checker, log, preferences); + } + } + StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; + function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { + if (completion === undefined) { + return undefined; + } + switch (completion.kind) { + case 0 /* Paths */: + return convertPathCompletions(completion.paths); + case 1 /* Properties */: { + var entries = []; + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; + } + case 2 /* Types */: { + var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; + } + default: + return ts.Debug.assertNever(completion); + } + } + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + if (!contextToken || !ts.isStringLiteralLike(contextToken)) + return undefined; + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); + } + StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; + function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { + switch (completion.kind) { + case 0 /* 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 */: { + 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; + default: + return ts.Debug.assertNever(completion); + } + } + function convertPathCompletions(pathCompletions) { + var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. + var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. + var entries = pathCompletions.map(function (_a) { + var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension; + return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span }); + }); + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + } + 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 undefined: return "" /* none */; + default: + return ts.Debug.assertNever(extension); + } + } + var StringLiteralCompletionKind; + (function (StringLiteralCompletionKind) { + StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; + })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + var parent = node.parent; + switch (parent.kind) { + case 182 /* LiteralType */: + switch (parent.parent.kind) { + case 164 /* TypeReference */: + return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; + case 180 /* IndexedAccessType */: + // Get all apparent property names + // i.e. interface Foo { + // foo: string; + // bar: string; + // } + // let x: Foo["/*completion position*/"] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); + case 183 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; + case 173 /* UnionType */: { + if (!ts.isTypeReferenceNode(parent.parent.parent)) + return undefined; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + } + default: + return undefined; + } + case 275 /* PropertyAssignment */: + if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); + } + return fromContextualType(); + case 190 /* ElementAccessExpression */: { + var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; + if (node === argumentExpression) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); + } + return undefined; + } + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); + } + // falls through (is `require("")` or `import("")`) + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 259 /* 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) }; + 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 }; + } + } + function getAlreadyUsedTypesInStringLiteralUnion(union, current) { + return ts.mapDefined(union.types, function (type) { + return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; + }); + } + function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { + var isNewIdentifier = false; + var uniques = ts.createMap(); + var candidates = []; + checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); + var types = ts.flatMap(candidates, function (candidate) { + if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + return; + var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + return getStringLiteralTypes(type, uniques); + }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + } + function stringLiteralCompletionsFromProperties(type) { + return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: ts.hasIndexSignature(type) }; + } + function getStringLiteralTypes(type, uniques) { + if (uniques === void 0) { uniques = ts.createMap(); } + if (!type) + 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; + } + function nameAndKind(name, kind, extension) { + return { name: name, kind: kind, extension: extension }; + } + function directoryResult(name) { + return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); return names.map(function (_a) { - var name = _a.name, kind = _a.kind; - return ({ name: name, kind: kind, span: span }); + var name = _a.name, kind = _a.kind, extension = _a.extension; + return ({ name: name, kind: kind, extension: extension, span: span }); }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } - PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); - if (compilerOptions.rootDirs) { - return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, compilerOptions, host, scriptPath); - } - else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, host, scriptPath); - } + return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + } + function getExtensionOptions(compilerOptions, includeExtensions) { + if (includeExtensions === void 0) { includeExtensions = false; } + return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; + } + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { + var extensionOptions = getExtensionOptions(compilerOptions); + if (compilerOptions.rootDirs) { + return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); } } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -93967,21 +95435,22 @@ var ts; // Now find a path for each potential directory that is to be merged with the one containing the script return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, compilerOptions, host, exclude) { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); var result = []; for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, host, exclude, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude, result); } return result; } /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, host, exclude, result) { + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { + var extensions = _a.extensions, includeExtensions = _a.includeExtensions; if (result === void 0) { result = []; } if (fragment === undefined) { fragment = ""; @@ -94002,55 +95471,53 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles.has(foundFileName)) { - foundFiles.set(foundFileName, true); - } + if (!tryDirectoryExists(host, baseDirectory)) + return result; + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); // maps file to its extension + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; } - ts.forEachKey(foundFiles, function (foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */)); - }); + var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { - var directory = directories_1[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - if (directoryName !== "@types") { - result.push(nameAndKind(directoryName, "directory" /* directory */)); - } + foundFiles.forEach(function (ext, foundFile) { + result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { + var directory = directories_1[_b]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + if (directoryName !== "@types") { + result.push(directoryResult(directoryName)); } } - // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); - if (packageJsonPath) { - var packageJson = ts.readJson(packageJsonPath, host); - var typesVersions = packageJson.typesVersions; - if (typeof typesVersions === "object") { - var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); - var versionPaths = versionResult && versionResult.paths; - var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); - if (versionPaths) { - addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); - } + } + // check for a version redirect + var packageJsonPath = findPackageJson(baseDirectory, host); + if (packageJsonPath) { + var packageJson = ts.readJson(packageJsonPath, host); + var typesVersions = packageJson.typesVersions; + if (typeof typesVersions === "object") { + var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); + var versionPaths = versionResult && versionResult.paths; + var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); + if (versionPaths) { + addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); } } } @@ -94062,15 +95529,15 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_10 = function (name, kind) { + var _loop_10 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { - result.push(nameAndKind(name, kind)); + result.push(nameAndKind(name, kind, extension)); } }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { - var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_10(name, kind); + var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; + _loop_10(name, kind, extension); } } } @@ -94085,21 +95552,21 @@ var ts; function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; var result = []; - var fileExtensions = getSupportedExtensionsForModuleResolution(compilerOptions); + var extensionOptions = getExtensionOptions(compilerOptions); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); - getCompletionEntriesForDirectoryFragment(fragment, absolute, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, fileExtensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); } } - var fragmentDirectory = containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + 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 */)); + result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, result); + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) { // 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.) @@ -94108,7 +95575,7 @@ var ts; var _loop_11 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); + result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -94120,13 +95587,16 @@ var ts; ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); if (tryDirectoryExists(host, nodeModules)) { - getCompletionEntriesForDirectoryFragment(fragment, nodeModules, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); } } return result; } + function getFragmentDirectory(fragment) { + return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + } function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. @@ -94138,7 +95608,7 @@ var ts; return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; + return ts.startsWith(name, fragment) ? [directoryResult(name)] : ts.emptyArray; } } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { @@ -94166,15 +95636,20 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]).map(function (name) { return ({ name: name, kind: "script" /* scriptElement */ }); }); - var directories = tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }).map(function (name) { return ({ name: name, kind: "directory" /* directory */ }); }); - // Trim away prefix and suffix - return ts.mapDefined(ts.concatenate(matches, directories), function (_a) { - var name = _a.name, kind = _a.kind; - var normalizedMatch = ts.normalizePath(name); - var inner = withoutStartAndEnd(normalizedMatch, completePrefix, normalizedSuffix); - return inner !== undefined ? { name: removeLeadingDirectorySeparator(ts.removeFileExtension(inner)), kind: kind } : undefined; + var matches = ts.mapDefined(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); }); + var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var name = trimPrefixAndSuffix(dir); + return name === undefined ? undefined : directoryResult(name); + }); + return matches.concat(directories); + function trimPrefixAndSuffix(path) { + var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); + return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); + } } function withoutStartAndEnd(s, start, end) { return ts.startsWith(s, start) && ts.endsWith(s, end) ? s.slice(start.length, s.length - end.length) : undefined; @@ -94209,62 +95684,48 @@ 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, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, host, sourceFile.path) - : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath) - : undefined; - return names && addReplacementSpans(toComplete, range.pos + prefix.length, names); + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, /*includeExtensions*/ true), host, sourceFile.path) + : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) + : ts.Debug.fail(); + return addReplacementSpans(toComplete, range.pos + prefix.length, names); } - PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; - function getCompletionEntriesFromTypings(host, options, scriptPath, result) { + function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var typesName = _a[_i]; - var moduleName = ts.unmangleScopedPackageName(typesName); - pushResult(moduleName); - } + var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; + getCompletionEntriesFromDirectories(root); } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch ( /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */_b) { /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */ } - if (typeRoots) { - for (var _c = 0, typeRoots_2 = typeRoots; _c < typeRoots_2.length; _c++) { - var root = typeRoots_2[_c]; - getCompletionEntriesFromDirectories(root); - } - } - // Also get all @types typings installed in visible node_modules directories - for (var _d = 0, _e = findPackageJsons(scriptPath, host); _d < _e.length; _d++) { - var packageJson = _e[_d]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(typesDir); - } + // Also get all @types typings installed in visible node_modules directories + for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + var packageJson = _b[_a]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - ts.Debug.assert(!!host.getDirectories); - if (tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_2 = directories; _i < directories_2.length; _i++) { - var typeDirectory = directories_2[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - var directoryName = ts.getBaseFileName(typeDirectory); - var moduleName = ts.unmangleScopedPackageName(directoryName); - pushResult(moduleName); + if (!tryDirectoryExists(host, directory)) + return; + for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + var typeDirectoryName = _a[_i]; + var packageName = ts.unmangleScopedPackageName(typeDirectoryName); + if (options.types && !ts.contains(options.types, packageName)) + continue; + if (fragmentDirectory === undefined) { + if (!seen.has(packageName)) { + result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + seen.set(packageName, true); + } + } + else { + var baseDirectory = ts.combinePaths(directory, typeDirectoryName); + var remainingFragment = ts.tryRemoveDirectoryPrefix(fragmentDirectory, packageName, ts.hostGetCanonicalFileName(host)); + if (remainingFragment !== undefined) { + getCompletionEntriesForDirectoryFragment(remainingFragment, baseDirectory, extensionOptions, host, /*exclude*/ undefined, result); } } - } - } - function pushResult(moduleName) { - if (!seen.has(moduleName)) { - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); - seen.set(moduleName, true); } } } @@ -94354,27 +95815,27 @@ var ts; return tryIOAndConsumeErrors(host, host.fileExists, path); } function tryDirectoryExists(host, path) { - try { - return ts.directoryProbablyExists(path, host); - } - catch ( /*ignore*/_a) { /*ignore*/ } - return false; + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + function tryAndIgnoreErrors(cb) { try { - return toApply && toApply.apply(host, args); + return cb(); + } + catch (_a) { + return undefined; } - catch ( /*ignore*/_a) { /*ignore*/ } - return undefined; } function containsSlash(fragment) { return ts.stringContains(fragment, ts.directorySeparator); } - })(PathCompletions = Completions.PathCompletions || (Completions.PathCompletions = {})); + })(StringCompletions = Completions.StringCompletions || (Completions.StringCompletions = {})); })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -94414,20 +95875,15 @@ var ts; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); - if (ts.isInReferenceComment(sourceFile, position)) { - var entries = Completions.PathCompletions.getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); - return entries && convertPathCompletions(entries); - } var contextToken = ts.findPrecedingToken(position, sourceFile); if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) return undefined; - if (ts.isInString(sourceFile, position, contextToken)) { - return !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host), sourceFile, typeChecker, log, preferences); + var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); + if (stringCompletions) { + return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 72 /* BreakKeyword */ || contextToken.kind === 77 /* ContinueKeyword */ || contextToken.kind === 71 /* Identifier */)) { + && (contextToken.kind === 73 /* BreakKeyword */ || contextToken.kind === 78 /* ContinueKeyword */ || contextToken.kind === 72 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); @@ -94450,35 +95906,6 @@ var ts; } } Completions.getCompletionsAtPosition = getCompletionsAtPosition; - function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { - if (completion === undefined) { - return undefined; - } - switch (completion.kind) { - case 0 /* Paths */: - return convertPathCompletions(completion.paths); - case 1 /* Properties */: { - var entries = []; - getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; - } - case 2 /* Types */: { - var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; - } - default: - return ts.Debug.assertNever(completion); - } - } - function convertPathCompletions(pathCompletions) { - var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. - var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. - var entries = pathCompletions.map(function (_a) { - var name = _a.name, kind = _a.kind, span = _a.span; - return ({ name: name, kind: kind, kindModifiers: "" /* none */, sortText: "0", replacementSpan: span }); - }); - return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - } function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } @@ -94492,7 +95919,7 @@ var ts; // The completion list at "1" will contain "div>" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 29 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -94557,7 +95984,9 @@ var ts; } }); } - var completionNameForLiteral = JSON.stringify; + var completionNameForLiteral = function (literal) { + return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal); + }; function createCompletionEntryForLiteral(literal) { return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" }; } @@ -94570,13 +95999,13 @@ var ts; var insertText; var replacementSpan; if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + quote(name, preferences) + "]" : "this." + name; + insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 23 /* DotToken */, sourceFile); + insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -94611,21 +96040,6 @@ var ts; replacementSpan: replacementSpan, }; } - function quote(text, preferences) { - if (/^\d+$/.test(text)) { - return text; - } - var quoted = JSON.stringify(text); - switch (preferences.quotePreference) { - case undefined: - case "double": - return quoted; - case "single": - return "'" + ts.stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; - default: - return ts.Debug.assertNever(preferences.quotePreference); - } - } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; @@ -94663,6 +96077,7 @@ var ts; log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); return uniques; } + Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { var entries = getLabelStatementCompletions(node); if (entries.length) { @@ -94693,131 +96108,6 @@ var ts; } return entries; } - var StringLiteralCompletionKind; - (function (StringLiteralCompletionKind) { - StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; - })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { - var parent = node.parent; - switch (parent.kind) { - case 180 /* LiteralType */: - switch (parent.parent.kind) { - case 162 /* TypeReference */: - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 178 /* IndexedAccessType */: - // Get all apparent property names - // i.e. interface Foo { - // foo: string; - // bar: string; - // } - // let x: Foo["/*completion position*/"] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 181 /* ImportType */: - return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 171 /* UnionType */: { - if (!ts.isTypeReferenceNode(parent.parent.parent)) - return undefined; - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; - } - default: - return undefined; - } - case 273 /* PropertyAssignment */: - if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); - } - return fromContextualType(); - case 188 /* ElementAccessExpression */: { - var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; - if (node === argumentExpression) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); - } - return undefined; - } - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); - } - // falls through (is `require("")` or `import("")`) - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 257 /* 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: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - 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(getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; - } - } - function getAlreadyUsedTypesInStringLiteralUnion(union, current) { - return ts.mapDefined(union.types, function (type) { - return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; - }); - } - function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { - var isNewIdentifier = false; - var uniques = ts.createMap(); - var candidates = []; - checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); - var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) - return; - var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); - return getStringLiteralTypes(type, uniques); - }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; - } - function stringLiteralCompletionsFromProperties(type) { - return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: hasIndexSignature(type) }; - } - function getStringLiteralTypes(type, uniques) { - if (uniques === void 0) { uniques = ts.createMap(); } - if (!type) - return ts.emptyArray; - type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 512 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; - } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); @@ -94856,10 +96146,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - var stringLiteralCompletions = !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host); - return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); // TODO: GH#18217 + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); @@ -94903,25 +96190,11 @@ var ts; }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } - function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { - switch (completion.kind) { - case 0 /* Paths */: { - var match = ts.find(completion.paths, function (p) { return p.name === name; }); - return match && createCompletionDetails(name, "" /* none */, match.kind, [ts.textPart(name)]); - } - case 1 /* Properties */: { - var match = ts.find(completion.symbols, function (s) { return s.name === name; }); - return match && createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); - } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; - default: - return ts.Debug.assertNever(completion); - } - } + Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } + Completions.createCompletionDetails = createCompletionDetails; function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { @@ -94952,7 +96225,7 @@ var ts; CompletionKind[CompletionKind["MemberLike"] = 3] = "MemberLike"; CompletionKind[CompletionKind["String"] = 4] = "String"; CompletionKind[CompletionKind["None"] = 5] = "None"; - })(CompletionKind || (CompletionKind = {})); + })(CompletionKind = Completions.CompletionKind || (Completions.CompletionKind = {})); function getRecommendedCompletion(previousToken, contextualType, checker) { // For a union, return the first one with a recommended completion. return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { @@ -94966,56 +96239,36 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 71 /* Identifier */: - return getContextualTypeFromParent(previousToken, checker); - case 58 /* EqualsToken */: + case 72 /* Identifier */: + return ts.getContextualTypeFromParent(previousToken, checker); + case 59 /* EqualsToken */: switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return checker.getContextualType(parent); - case 73 /* CaseKeyword */: - return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); - case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + case 74 /* CaseKeyword */: + return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); + case 18 /* OpenBraceToken */: + return ts.isJsxExpression(parent) && parent.parent.kind !== 260 /* JsxElement */ ? 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 === 26 /* CommaToken */ ? 1 : 0)) - : isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind) + ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* 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) : checker.getContextualType(previousToken); } } - function getContextualTypeFromParent(node, checker) { - var parent = node.parent; - switch (parent.kind) { - case 190 /* NewExpression */: - return checker.getContextualType(parent); - case 202 /* 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 269 /* CaseClause */: - return parent.expression === node ? getSwitchedType(parent, checker) : undefined; - default: - return checker.getContextualType(node); - } - } - function getSwitchedType(caseClause, checker) { - return checker.getTypeAtLocation(caseClause.parent.parent.expression); - } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) @@ -95023,7 +96276,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -95074,11 +96327,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 303 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -95104,9 +96357,9 @@ var ts; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { - var start_4 = ts.timestamp(); + var start_3 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 - log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); + log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_3)); } // Find the node where completion is requested on. // Also determine whether we are trying to complete with members of that node @@ -95125,21 +96378,21 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 23 /* DotToken */) { + if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: node = parent.left; break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: node = parent.name; break; - case 181 /* ImportType */: - case 212 /* MetaProperty */: + case 183 /* ImportType */: + case 214 /* MetaProperty */: node = parent; break; default: @@ -95152,56 +96405,56 @@ var ts; // // 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 === 187 /* PropertyAccessExpression */) { + if (parent && parent.kind === 189 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { + case 30 /* GreaterThanToken */: + if (currentToken.parent.kind === 260 /* JsxElement */ || currentToken.parent.kind === 262 /* JsxOpeningElement */) { location = currentToken; } break; - case 41 /* SlashToken */: - if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { + case 42 /* SlashToken */: + if (currentToken.parent.kind === 261 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 261 /* JsxClosingElement */: - if (contextToken.kind === 41 /* SlashToken */) { + case 263 /* JsxClosingElement */: + if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: - case 260 /* JsxOpeningElement */: - if (contextToken.kind === 27 /* LessThanToken */) { + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: + case 262 /* JsxOpeningElement */: + if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: switch (previousToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: isJsxInitializer = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: // For `
` 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, 58 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 59 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -95249,11 +96502,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: - case 298 /* JSDocReturnTag */: - case 300 /* JSDocTypeTag */: - case 302 /* JSDocTypedefTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 304 /* JSDocTypedefTag */: return true; default: return false; @@ -95293,15 +96546,15 @@ 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.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 94 /* NewKeyword */ || node.keywordToken === 91 /* ImportKeyword */)) { - var completion = (node.keywordToken === 94 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 95 /* NewKeyword */ || node.keywordToken === 92 /* ImportKeyword */)) { + var completion = (node.keywordToken === 95 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -95322,7 +96575,7 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 183 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -95376,10 +96629,10 @@ var ts; function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element - var attrsType = jsxContainer && typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); + var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) return 0 /* Continue */; - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); + symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -95425,7 +96678,7 @@ var ts; var symbolMeanings = 67897832 /* Type */ | 67220415 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -95461,10 +96714,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 277 /* SourceFile */: - case 204 /* TemplateExpression */: - case 268 /* JsxExpression */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 206 /* TemplateExpression */: + case 270 /* JsxExpression */: + case 218 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -95500,41 +96753,35 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 103 /* TypeOfKeyword */ && - (contextToken.parent.kind === 165 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 104 /* TypeOfKeyword */ && + (contextToken.parent.kind === 167 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 56 /* ColonToken */: - return parentKind === 152 /* PropertyDeclaration */ || - parentKind === 151 /* PropertySignature */ || - parentKind === 149 /* Parameter */ || - parentKind === 235 /* VariableDeclaration */ || + case 57 /* ColonToken */: + return parentKind === 154 /* PropertyDeclaration */ || + parentKind === 153 /* PropertySignature */ || + parentKind === 151 /* Parameter */ || + parentKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 58 /* EqualsToken */: - return parentKind === 240 /* TypeAliasDeclaration */; - case 118 /* AsKeyword */: - return parentKind === 210 /* AsExpression */; + case 59 /* EqualsToken */: + return parentKind === 242 /* TypeAliasDeclaration */; + case 119 /* AsKeyword */: + return parentKind === 212 /* AsExpression */; } } return false; } - function symbolCanBeReferencedAtTypeLocation(symbol) { - symbol = symbol.exportSymbol || symbol; - // This is an alias, follow what it aliases - symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & 67897832 /* Type */) { - return true; - } - if (symbol.flags & 1536 /* Module */) { - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - // If the exported symbols contains type, - // symbol can be referenced at locations where type is allowed - return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); - } - return false; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { + if (seenModules === void 0) { seenModules = ts.createMap(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); + return !!(sym.flags & 67897832 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); @@ -95562,13 +96809,16 @@ var ts; // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. // This is just to avoid adding duplicate completion entries. // - // If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. - // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { + || ts.some(symbol.declarations, function (d) { + // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); + })) { continue; } - var isDefaultExport = symbol.name === "default" /* Default */; + var isDefaultExport = symbol.escapedName === "default" /* Default */; if (isDefaultExport) { symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; } @@ -95622,15 +96872,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 10 /* JsxText */) { + if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { + if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 262 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; + if (contextToken.parent.kind === 263 /* JsxClosingElement */ || contextToken.parent.kind === 261 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 260 /* JsxElement */; } } return false; @@ -95640,41 +96890,41 @@ var ts; var containingNodeKind = previousToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { - case 26 /* CommaToken */: - return containingNodeKind === 189 /* CallExpression */ // func( a, | - || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 190 /* NewExpression */ // new C(a, | - || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| - case 19 /* OpenParenToken */: - return containingNodeKind === 189 /* CallExpression */ // func( | - || containingNodeKind === 155 /* Constructor */ // constructor( | - || containingNodeKind === 190 /* NewExpression */ // new C(a| - || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 21 /* OpenBracketToken */: - return containingNodeKind === 185 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 129 /* ModuleKeyword */: // module | - case 130 /* NamespaceKeyword */: // namespace | + case 27 /* CommaToken */: + return containingNodeKind === 191 /* CallExpression */ // func( a, | + || containingNodeKind === 157 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 192 /* NewExpression */ // new C(a, | + || containingNodeKind === 187 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 204 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 165 /* FunctionType */; // var x: (s: string, list| + case 20 /* OpenParenToken */: + return containingNodeKind === 191 /* CallExpression */ // func( | + || containingNodeKind === 157 /* Constructor */ // constructor( | + || containingNodeKind === 192 /* NewExpression */ // new C(a| + || containingNodeKind === 195 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 177 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* OpenBracketToken */: + return containingNodeKind === 187 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 162 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 149 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 130 /* ModuleKeyword */: // module | + case 131 /* NamespaceKeyword */: // namespace | return true; - case 23 /* DotToken */: - return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| - case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | - case 58 /* EqualsToken */: - return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 202 /* BinaryExpression */; // x = a| - case 14 /* TemplateHead */: - return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| - case 15 /* TemplateMiddle */: - return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */; // class A{ public | + case 24 /* DotToken */: + return containingNodeKind === 244 /* ModuleDeclaration */; // module A.| + case 18 /* OpenBraceToken */: + return containingNodeKind === 240 /* ClassDeclaration */; // class A{ | + case 59 /* EqualsToken */: + return containingNodeKind === 237 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 204 /* BinaryExpression */; // x = a| + case 15 /* TemplateHead */: + return containingNodeKind === 206 /* TemplateExpression */; // `aa ${| + case 16 /* TemplateMiddle */: + return containingNodeKind === 216 /* TemplateSpan */; // `aa ${10} dd ${| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -95701,16 +96951,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 188 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; - isNewIdentifierLocation = hasIndexSignature(typeForObject); + isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 184 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -95721,12 +96971,12 @@ 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 === 225 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 227 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 151 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 154 /* MethodDeclaration */ || rootDeclaration.parent.kind === 157 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 156 /* MethodDeclaration */ || rootDeclaration.parent.kind === 159 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -95762,13 +97012,13 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { // `import { |` or `import { a as 0, | }` - var namedImportsOrExports = contextToken && (contextToken.kind === 17 /* OpenBraceToken */ || contextToken.kind === 26 /* CommaToken */) + var namedImportsOrExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 252 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -95791,7 +97041,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 39 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* 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)) @@ -95799,7 +97049,7 @@ var ts; var classElement = contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 71 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 72 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -95828,15 +97078,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 17 /* OpenBraceToken */: // const x = { | - case 26 /* CommaToken */: // const x = { a: 0, | + case 18 /* OpenBraceToken */: // const x = { | + case 27 /* CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 71 /* Identifier */: + case 72 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -95855,8 +97105,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 19 /* OpenParenToken */: - case 26 /* CommaToken */: + case 20 /* OpenParenToken */: + case 27 /* CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -95886,17 +97136,17 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 28 /* LessThanSlashToken */: - case 41 /* SlashToken */: - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 266 /* JsxAttributes */: - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { + case 29 /* LessThanSlashToken */: + case 42 /* SlashToken */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 268 /* JsxAttributes */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 261 /* JsxSelfClosingElement */ || parent.kind === 262 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 265 /* JsxAttribute */) { + else if (parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95907,8 +97157,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 9 /* StringLiteral */: - if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { + case 10 /* StringLiteral */: + if (parent && ((parent.kind === 267 /* JsxAttribute */) || (parent.kind === 269 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95916,10 +97166,10 @@ var ts; return parent.parent.parent; } break; - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: if (parent && - parent.kind === 268 /* JsxExpression */ && - parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { + parent.kind === 270 /* JsxExpression */ && + parent.parent && parent.parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95927,7 +97177,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 269 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95946,65 +97196,65 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 26 /* CommaToken */: - return containingNodeKind === 235 /* VariableDeclaration */ || - containingNodeKind === 236 /* VariableDeclarationList */ || - containingNodeKind === 217 /* VariableStatement */ || - containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | + case 27 /* CommaToken */: + return containingNodeKind === 237 /* VariableDeclaration */ || + containingNodeKind === 238 /* VariableDeclarationList */ || + containingNodeKind === 219 /* VariableStatement */ || + containingNodeKind === 243 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 23 /* DotToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| - case 56 /* ColonToken */: - return containingNodeKind === 184 /* BindingElement */; // var {x :html| - case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| - case 19 /* OpenParenToken */: - return containingNodeKind === 272 /* CatchClause */ || + case 24 /* DotToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [.| + case 57 /* ColonToken */: + return containingNodeKind === 186 /* BindingElement */; // var {x :html| + case 22 /* OpenBracketToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [x| + case 20 /* OpenParenToken */: + return containingNodeKind === 274 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 17 /* OpenBraceToken */: - return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | - case 27 /* LessThanToken */: - return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | - containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | + case 18 /* OpenBraceToken */: + return containingNodeKind === 243 /* EnumDeclaration */; // enum a { | + case 28 /* LessThanToken */: + return containingNodeKind === 240 /* ClassDeclaration */ || // class A< | + containingNodeKind === 209 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 241 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 242 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 115 /* StaticKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 24 /* DotDotDotToken */: - return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 118 /* AsKeyword */: - return containingNodeKind === 251 /* ImportSpecifier */ || - containingNodeKind === 255 /* ExportSpecifier */ || - containingNodeKind === 249 /* NamespaceImport */; - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* DotDotDotToken */: + return containingNodeKind === 151 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 185 /* ArrayBindingPattern */); // var [...z| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 151 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 119 /* AsKeyword */: + return containingNodeKind === 253 /* ImportSpecifier */ || + containingNodeKind === 257 /* ExportSpecifier */ || + containingNodeKind === 251 /* NamespaceImport */; + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 109 /* InterfaceKeyword */: - case 89 /* FunctionKeyword */: - case 104 /* VarKeyword */: - case 91 /* ImportKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 116 /* YieldKeyword */: - case 139 /* TypeKeyword */: // type htm| + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 110 /* InterfaceKeyword */: + case 90 /* FunctionKeyword */: + case 105 /* VarKeyword */: + case 92 /* ImportKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 117 /* YieldKeyword */: + case 140 /* TypeKeyword */: // type htm| return true; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -96025,22 +97275,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 117 /* AbstractKeyword */: - case 75 /* ClassKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 83 /* EnumKeyword */: - case 89 /* FunctionKeyword */: - case 109 /* InterfaceKeyword */: - case 110 /* LetKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 115 /* StaticKeyword */: - case 104 /* VarKeyword */: - case 116 /* YieldKeyword */: + case 118 /* AbstractKeyword */: + case 76 /* ClassKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 84 /* EnumKeyword */: + case 90 /* FunctionKeyword */: + case 110 /* InterfaceKeyword */: + case 111 /* LetKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 116 /* StaticKeyword */: + case 105 /* VarKeyword */: + case 117 /* YieldKeyword */: return true; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -96050,7 +97300,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 155 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 157 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -96073,12 +97323,12 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 273 /* PropertyAssignment */ && - m.kind !== 274 /* ShorthandPropertyAssignment */ && - m.kind !== 184 /* BindingElement */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 275 /* PropertyAssignment */ && + m.kind !== 276 /* ShorthandPropertyAssignment */ && + m.kind !== 186 /* BindingElement */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -96088,7 +97338,7 @@ var ts; var existingName = void 0; if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 71 /* Identifier */) { + if (m.propertyName.kind === 72 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -96113,10 +97363,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 !== 152 /* PropertyDeclaration */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 154 /* PropertyDeclaration */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -96156,7 +97406,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 265 /* JsxAttribute */) { + if (attr.kind === 267 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -96200,7 +97450,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72 /* FirstKeyword */; i <= 145 /* LastKeyword */; i++) { + for (var i = 73 /* FirstKeyword */; i <= 147 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -96217,8 +97467,8 @@ var ts; case 0 /* None */: return false; case 1 /* All */: - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 124 /* DeclareKeyword */ || kind === 129 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 140 /* UndefinedKeyword */; + return kind === 121 /* AsyncKeyword */ || 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 125 /* DeclareKeyword */ || kind === 130 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 141 /* UndefinedKeyword */; case 2 /* ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); case 3 /* InterfaceElementKeywords */: @@ -96235,37 +97485,26 @@ var ts; })); } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 132 /* ReadonlyKeyword */; + return kind === 133 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 117 /* AbstractKeyword */: - case 123 /* ConstructorKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 120 /* AsyncKeyword */: + case 118 /* AbstractKeyword */: + case 124 /* ConstructorKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 121 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; } - function isEqualityOperatorKind(kind) { - switch (kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - return true; - default: - return false; - } - } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { var jsdoc = ts.findAncestor(node, ts.isJSDoc); @@ -96275,7 +97514,7 @@ var ts; return contextualType.isUnion() ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - return !(memberType.flags & 32764 /* Primitive */ || + return !(memberType.flags & 131068 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); @@ -96298,31 +97537,31 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 304 /* SyntaxList */: + case 306 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { return cls; } } if (!contextToken) return undefined; switch (contextToken.kind) { - case 25 /* SemicolonToken */: // class c {getValue(): number; | } - case 18 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SemicolonToken */: // class c {getValue(): number; | } + case 19 /* CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 17 /* OpenBraceToken */: // class c { | - case 26 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* OpenBraceToken */: // class c { | + case 27 /* CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) return undefined; var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 39 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -96330,9 +97569,6 @@ var ts; function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); } - function hasIndexSignature(type) { - return !!type.getStringIndexType() || !!type.getNumberIndexType(); - } function isValidTrigger(sourceFile, triggerCharacter, contextToken, position) { switch (triggerCharacter) { case ".": @@ -96342,14 +97578,14 @@ var ts; case "'": case "`": // Only automatically bring up completions if this is an opening quote. - return !!contextToken && isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; + return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 41 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -96358,17 +97594,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function isStringLiteralOrTemplate(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - return true; - default: - return false; - } - } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -96421,40 +97646,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 90 /* IfKeyword */: - case 82 /* ElseKeyword */: + case 91 /* IfKeyword */: + case 83 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 96 /* ReturnKeyword */: + case 97 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 102 /* TryKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: - var tryStatement = node.kind === 74 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 103 /* TryKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: + var tryStatement = node.kind === 75 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 73 /* CaseKeyword */: - case 79 /* DefaultKeyword */: + case 74 /* CaseKeyword */: + case 80 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 72 /* BreakKeyword */: - case 77 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 78 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 88 /* ForKeyword */: - case 106 /* WhileKeyword */: - case 81 /* DoKeyword */: + case 89 /* ForKeyword */: + case 107 /* WhileKeyword */: + case 82 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 123 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [123 /* ConstructorKeyword */]); - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [125 /* GetKeyword */, 136 /* SetKeyword */]); - case 121 /* AwaitKeyword */: + case 124 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [124 /* ConstructorKeyword */]); + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [126 /* GetKeyword */, 137 /* SetKeyword */]); + case 122 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 116 /* YieldKeyword */: + case 117 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -96497,7 +97722,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -96529,16 +97754,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 230 /* SwitchStatement */: - if (statement.kind === 226 /* ContinueStatement */) { + case 232 /* SwitchStatement */: + if (statement.kind === 228 /* ContinueStatement */) { return false; } // falls through - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -96554,11 +97779,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 216 /* Block */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 218 /* Block */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -96566,12 +97791,12 @@ var ts; else { return container.statements; } - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: 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. @@ -96602,12 +97827,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 89 /* ForKeyword */, 107 /* WhileKeyword */, 82 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 221 /* DoStatement */) { + if (loopNode.kind === 223 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 107 /* WhileKeyword */)) { break; } } @@ -96615,7 +97840,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */, 77 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */, 78 /* ContinueKeyword */); } }); return keywords; @@ -96624,13 +97849,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -96638,13 +97863,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 98 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 99 /* 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(), 73 /* CaseKeyword */, 79 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 74 /* CaseKeyword */, 80 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */); } }); }); @@ -96652,13 +97877,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 102 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 103 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 75 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 87 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 88 /* FinallyKeyword */); } return keywords; } @@ -96669,13 +97894,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* 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, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -96687,11 +97912,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* 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, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -96703,13 +97928,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 120 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 121 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 122 /* AwaitKeyword */); } }); }); @@ -96724,7 +97949,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 116 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 117 /* YieldKeyword */); } }); }); @@ -96743,7 +97968,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 === 82 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 83 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -96778,10 +98003,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], 90 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 91 /* 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], 82 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 83 /* ElseKeyword */)) { break; } } @@ -96814,13 +98039,6 @@ var ts; // for those settings. var buckets = ts.createMap(); var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets.get(key); - if (!bucket && createIfMissing) { - buckets.set(key, bucket = ts.createMap()); - } - return bucket; // TODO: GH#18217 - } function reportStats() { var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { var entries = buckets.get(name); @@ -96856,7 +98074,7 @@ var ts; return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); + var bucket = ts.getOrUpdate(buckets, key, ts.createMap); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; if (!entry && externalCache) { @@ -96910,8 +98128,7 @@ var ts; return releaseDocumentWithKey(path, key); } function releaseDocumentWithKey(path, key) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ false); - ts.Debug.assert(bucket !== undefined); + var bucket = ts.Debug.assertDefined(buckets.get(key)); var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); @@ -97005,12 +98222,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 237 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { directImports.push(name); break; } @@ -97019,22 +98236,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 71 /* Identifier */: // for 'const x = require("y"); + case 72 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 251 /* 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 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -97044,7 +98261,7 @@ var ts; directImports.push(direct); } break; - case 181 /* ImportType */: + case 183 /* ImportType */: directImports.push(direct); break; default: @@ -97061,7 +98278,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -97116,17 +98333,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 246 /* ImportEqualsDeclaration */) { + if (decl.kind === 248 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 71 /* Identifier */) { + if (decl.kind === 72 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 181 /* ImportType */) { + if (decl.kind === 183 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -97138,20 +98355,20 @@ var ts; return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 253 /* ExportDeclaration */) { + if (decl.kind === 255 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -97201,7 +98418,7 @@ var ts; } } else { - var localSymbol = element.kind === 255 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 257 /* 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); @@ -97230,7 +98447,7 @@ var ts; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 277 /* SourceFile */) { + if (searchSourceFile.kind === 279 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -97278,7 +98495,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 === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -97293,15 +98510,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: { + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -97325,7 +98542,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 187 /* PropertyAccessExpression */) { + if (parent.kind === 189 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -97447,10 +98664,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 235 /* VariableDeclaration */) { + if (parent.kind === 237 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 274 /* CatchClause */ ? undefined : p.parent.parent.kind === 219 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -97459,15 +98676,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -97500,21 +98717,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 277 /* SourceFile */) { + if (parent.kind === 279 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 244 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 259 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -97566,18 +98783,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* 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 === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var result_7 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_7.push(nodeEntry(node)); }); return result_7; } - else if (node.kind === 97 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 98 /* 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); @@ -97639,7 +98856,7 @@ var ts; } function getDefinitionKindAndDisplayParts(symbol, checker, node) { var meaning = FindAllReferences.Core.getIntersectingMeaningFromDeclarations(node, symbol); - var enclosingDeclaration = ts.firstOrUndefined(symbol.declarations) || node; + var enclosingDeclaration = symbol.declarations && ts.firstOrUndefined(symbol.declarations) || node; var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, enclosingDeclaration.getSourceFile(), enclosingDeclaration, enclosingDeclaration, meaning), displayParts = _a.displayParts, symbolKind = _a.symbolKind; return { displayParts: displayParts, kind: symbolKind }; } @@ -97657,7 +98874,7 @@ var ts; textSpan: textSpan, fileName: fileName, isWriteAccess: isWriteAccessForReference(node), - isDefinition: node.kind === 79 /* DefaultKeyword */ + isDefinition: node.kind === 80 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined, @@ -97712,16 +98929,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 207 /* ClassExpression */) { + else if (node.kind === 209 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] }; } else { @@ -97747,7 +98964,7 @@ var ts; function getTextSpan(node, sourceFile) { var start = node.getStart(sourceFile); var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { start += 1; end -= 1; } @@ -97756,7 +98973,7 @@ var ts; /** 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 === 79 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 80 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -97767,46 +98984,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 202 /* BinaryExpression */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 79 /* DefaultKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 255 /* ExportSpecifier */: - case 248 /* ImportClause */: // default import - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 239 /* InterfaceDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 265 /* JsxAttribute */: - case 242 /* ModuleDeclaration */: - case 245 /* NamespaceExportDeclaration */: - case 249 /* NamespaceImport */: - case 149 /* Parameter */: - case 274 /* ShorthandPropertyAssignment */: - case 240 /* TypeAliasDeclaration */: - case 148 /* TypeParameter */: + case 204 /* BinaryExpression */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 80 /* DefaultKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 257 /* ExportSpecifier */: + case 250 /* ImportClause */: // default import + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 241 /* InterfaceDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 267 /* JsxAttribute */: + case 244 /* ModuleDeclaration */: + case 247 /* NamespaceExportDeclaration */: + case 251 /* NamespaceImport */: + case 151 /* Parameter */: + case 276 /* ShorthandPropertyAssignment */: + case 242 /* TypeAliasDeclaration */: + case 150 /* TypeParameter */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return !!decl.body; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 153 /* MethodSignature */: - case 151 /* PropertySignature */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 155 /* MethodSignature */: + case 153 /* PropertySignature */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -97843,6 +99060,9 @@ var ts; // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. return !options.implementations && ts.isStringLiteral(node) ? getReferencesForStringLiteral(node, sourceFiles, cancellationToken) : undefined; } + if (symbol.escapedName === "export=" /* ExportEquals */) { + return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); + } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); var referencedNode = node; @@ -97887,10 +99107,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 277 /* SourceFile */: + case 279 /* 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -97900,6 +99120,22 @@ var ts; ts.Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } + var exported = symbol.exports.get("export=" /* ExportEquals */); + if (exported) { + for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { + var decl = _c[_b]; + var sourceFile = decl.getSourceFile(); + 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.assertDefined(ts.findChildOfKind(decl, 85 /* ExportKeyword */, sourceFile)) + : ts.getNameOfDeclaration(decl) || decl; + references.push(FindAllReferences.nodeEntry(node)); + } + } + } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** getReferencedSymbols for special node kinds. */ @@ -97921,7 +99157,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -97933,7 +99169,7 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - if (node && node.kind === 79 /* DefaultKeyword */) { + if (node && node.kind === 80 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -97958,9 +99194,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: return 1 /* Constructor */; - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -98192,7 +99428,7 @@ 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 === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 196 /* FunctionExpression */ || valueDeclaration.kind === 209 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -98202,7 +99438,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 240 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -98231,7 +99467,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 279 /* 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; @@ -98252,7 +99488,9 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = checker.getSymbolAtLocation(definition); + var symbol = ts.isParameterPropertyDeclaration(definition.parent) + ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) + : checker.getSymbolAtLocation(definition); if (!symbol) return undefined; for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { @@ -98337,16 +99575,16 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.text.length === searchSymbolName.length; - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { var str = node; - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(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 */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 79 /* DefaultKeyword */: + case 80 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -98410,7 +99648,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 71 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 72 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -98465,7 +99703,7 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!(referenceLocation === propertyName && state.options.isForRename)) { - var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; + var exportKind = referenceLocation.originalKeywordKind === 80 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); if (!exportInfo) return ts.Debug.fail(); @@ -98545,7 +99783,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 80 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -98571,7 +99809,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -98588,16 +99826,16 @@ var ts; function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { for (var _i = 0, _a = classSymbol.members.get("__constructor" /* Constructor */).declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 155 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 124 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 157 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 154 /* MethodDeclaration */) { + if (decl && decl.kind === 156 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 100 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -98614,10 +99852,10 @@ var ts; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 155 /* Constructor */); + ts.Debug.assert(decl.kind === 157 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 98 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -98631,10 +99869,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 71 /* Identifier */) { + if (refNode.kind !== 72 /* Identifier */) { return; } - if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 276 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -98654,7 +99892,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 216 /* Block */) { + if (body.kind === 218 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -98682,13 +99920,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 185 /* ArrayLiteralExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 187 /* ArrayLiteralExpression */: return true; default: return false; @@ -98741,13 +99979,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -98756,7 +99994,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 97 /* SuperKeyword */) { + if (node.kind !== 98 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -98772,34 +100010,34 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -98807,19 +100045,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 277 /* SourceFile */: - return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); + case 279 /* SourceFile */: + return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -99016,7 +100254,7 @@ var ts; var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); } @@ -99025,7 +100263,7 @@ var ts; function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var originalPath = sourceMapper && sourceMapper.tryGetOriginalLocation({ fileName: path, position: 0 }); + var originalPath = sourceMapper && sourceMapper.tryGetSourcePosition({ fileName: path, pos: 0 }); var updatedPath = getUpdatedPath(originalPath ? originalPath.fileName : path); return originalPath ? updatedPath === undefined ? undefined : makeCorrespondingRelativeChange(originalPath.fileName, updatedPath, path, getCanonicalFileName) @@ -99044,7 +100282,7 @@ var ts; var rel = ts.getRelativePathFromFile(a0, b0, getCanonicalFileName); return combinePathsSafe(ts.getDirectoryPath(a1), rel); } - function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + function updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) return; @@ -99062,7 +100300,8 @@ var ts; var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); // If there isn't some include for this, add a new one. - if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + if (ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && + !ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); } } @@ -99255,7 +100494,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 97 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 98 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -99263,7 +100502,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -99416,18 +100655,18 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 71 /* Identifier */) { + if (node.kind !== 72 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 248 /* ImportClause */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: return true; - case 251 /* ImportSpecifier */: - return declaration.parent.kind === 250 /* NamedImports */; + case 253 /* ImportSpecifier */: + return declaration.parent.kind === 252 /* NamedImports */; default: return false; } @@ -99437,7 +100676,7 @@ var ts; 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 */ && (ts.isNewExpressionTarget(node) || node.kind === 123 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 124 /* ConstructorKeyword */)) { var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -99511,9 +100750,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return true; default: return false; @@ -99631,11 +100870,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: return [declaration]; - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -99656,16 +100895,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return withNode(tag.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -99842,7 +101081,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 === 71 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 72 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -99852,23 +101091,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 155 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 151 /* PropertySignature */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 153 /* PropertySignature */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 242 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -99876,14 +101115,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 277 /* SourceFile */: + case 279 /* SourceFile */: return "quit"; - case 242 /* ModuleDeclaration */: + case 244 /* 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 === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 202 /* BinaryExpression */: { + return commentOwner.parent.kind === 244 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 204 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -99902,14 +101141,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 195 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return rightHandSide.parameters; - case 207 /* ClassExpression */: { + case 209 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -99971,9 +101210,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 248 /* ImportClause */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -99983,7 +101222,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 147 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 149 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -100000,7 +101239,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 === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 149 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -100169,7 +101408,7 @@ var ts; return; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* 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); @@ -100181,21 +101420,21 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 155 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -100207,7 +101446,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -100218,8 +101457,8 @@ var ts; } } break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -100240,12 +101479,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -100255,9 +101494,9 @@ var ts; } endNode(); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -100265,18 +101504,18 @@ var ts; } endNode(); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 255 /* ExportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 160 /* IndexSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 240 /* TypeAliasDeclaration */: + case 257 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 162 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 242 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -100288,6 +101527,9 @@ var ts; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -100355,12 +101597,12 @@ var ts; return false; } switch (a.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -100376,7 +101618,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 244 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -100406,7 +101648,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -100414,16 +101656,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -100433,16 +101675,16 @@ var ts; } } switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -100450,13 +101692,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return "new()"; - case 158 /* CallSignature */: + case 160 /* CallSignature */: return "()"; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "[]"; default: return ""; @@ -100480,25 +101722,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 277 /* SourceFile */: - case 240 /* TypeAliasDeclaration */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 242 /* TypeAliasDeclaration */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return true; - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 235 /* VariableDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 237 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -100508,10 +101750,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -100520,7 +101762,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; + return childKind !== 237 /* VariableDeclaration */ && childKind !== 186 /* BindingElement */; }); } } @@ -100577,7 +101819,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -100591,13 +101833,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 147 /* ComputedPropertyName */; + return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -100612,7 +101854,7 @@ var ts; return ts.declarationNameToString(parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -100650,9 +101892,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: return true; default: return false; @@ -100779,7 +102021,7 @@ var ts; ? specifier.text : undefined; } - /* @internal */ // Internal for testing + // Internal for testing /** * @param importGroup a list of ImportDeclarations, all with the same module name. */ @@ -100878,7 +102120,7 @@ var ts; } } OrganizeImports.coalesceImports = coalesceImports; - /* @internal */ // Internal for testing + // Internal for testing /** * @param exportGroup a list of ExportDeclarations, all with the same module name. */ @@ -100981,7 +102223,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 91 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 92 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -101088,31 +102330,31 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 197 /* ArrowFunction */); } // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 221 /* DoStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 272 /* CatchClause */: + case 223 /* DoStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 274 /* CatchClause */: return spanForNode(n.parent); - case 233 /* TryStatement */: + case 235 /* 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) { - return spanForNode(ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -101120,21 +102362,21 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanForNode(n.parent); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 244 /* CaseBlock */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 246 /* CaseBlock */: return spanForNode(n); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 185 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); - case 258 /* JsxElement */: + case 187 /* ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); + case 260 /* JsxElement */: return spanForJSXElement(n); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -101150,7 +102392,7 @@ var ts; return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -101159,9 +102401,9 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); - var close = open === 17 /* OpenBraceToken */ ? 18 /* CloseBraceToken */ : 22 /* CloseBracketToken */; + var close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; var closeToken = ts.findChildOfKind(n, close, sourceFile); if (!openToken || !closeToken) { return undefined; @@ -101520,11 +102762,11 @@ var ts; characterSpans: breakIntoCharacterSpans(text) }; } - /* @internal */ function breakIntoCharacterSpans(identifier) { + function breakIntoCharacterSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - /* @internal */ function breakIntoWordSpans(identifier) { + function breakIntoWordSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; @@ -101664,10 +102906,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 17 /* OpenBraceToken */) { + if (currentToken === 18 /* OpenBraceToken */) { braceNesting++; } - else if (currentToken === 18 /* CloseBraceToken */) { + else if (currentToken === 19 /* CloseBraceToken */) { braceNesting--; } return currentToken; @@ -101697,12 +102939,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 124 /* DeclareKeyword */) { + if (token === 125 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 129 /* ModuleKeyword */) { + if (token === 130 /* ModuleKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); } } @@ -101714,42 +102956,42 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 23 /* DotToken */) { + if (lastToken === 24 /* DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 91 /* ImportKeyword */) { + if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 9 /* StringLiteral */) { + else if (token === 10 /* StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 58 /* EqualsToken */) { + else if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 26 /* CommaToken */) { + else if (token === 27 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -101758,18 +103000,18 @@ var ts; return true; } } - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -101777,15 +103019,15 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 118 /* AsKeyword */) { + if (token === 119 /* AsKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -101801,21 +103043,21 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 84 /* ExportKeyword */) { + if (token === 85 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -101823,21 +103065,21 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 91 /* ImportKeyword */) { + else if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 58 /* EqualsToken */) { + if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -101850,11 +103092,11 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 133 /* RequireKeyword */) { + if (token === 134 /* RequireKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // require("mod"); recordModuleName(); } @@ -101865,16 +103107,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 71 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 72 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 19 /* OpenParenToken */) { + if (token !== 20 /* OpenParenToken */) { return true; } token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 26 /* CommaToken */) { + if (token === 27 /* CommaToken */) { token = nextToken(); } else { @@ -101883,15 +103125,15 @@ var ts; } } // should be start of dependency list - if (token !== 21 /* OpenBracketToken */) { + if (token !== 22 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordModuleName(); } token = nextToken(); @@ -101999,14 +103241,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 === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 80 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return getRenameInfoForModule(node, sourceFile, symbol); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 147 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 149 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -102053,7 +103295,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { // Exclude the quotes start += 1; width -= 2; @@ -102062,9 +103304,9 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -102157,13 +103399,13 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 26 /* CommaToken */: { + case 27 /* CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -102209,7 +103451,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 27 /* LessThanToken */ || node.kind === 19 /* OpenParenToken */) { + if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* 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 }; @@ -102262,10 +103504,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 193 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 206 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -102328,24 +103570,24 @@ var ts; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) { - if (startingToken.kind !== 19 /* OpenParenToken */ && startingToken.kind !== 26 /* CommaToken */) + if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 195 /* ParenthesizedExpression */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 19 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* 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) }; } @@ -102377,7 +103619,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 26 /* CommaToken */) { + if (child.kind !== 27 /* CommaToken */) { argumentIndex++; } } @@ -102396,8 +103638,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 !== 26 /* CommaToken */; }); - if (listChildren.length > 0 && ts.last(listChildren).kind === 26 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); + if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -102466,7 +103708,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 === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -102531,10 +103773,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(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(27 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(29 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(26 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; var prefixDisplayParts = callTargetDisplayParts.concat(prefix); @@ -102563,9 +103805,9 @@ var ts; var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(27 /* LessThanToken */)], suffix: [ts.punctuationPart(29 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = candidateSignature.hasRestParameter; @@ -102573,11 +103815,11 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration); })); - printer.writeList(26896 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); } }); var parameters = candidateSignature.parameters.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(19 /* OpenParenToken */)]), suffix: [ts.punctuationPart(20 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -102599,53 +103841,46 @@ var ts; /* @internal */ var ts; (function (ts) { - // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; - var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; - function getSourceMapper(getCanonicalFileName, currentDirectory, log, host, getProgram) { + function getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, getProgram) { + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var sourcemappedFileCache; - return { tryGetOriginalLocation: tryGetOriginalLocation, tryGetGeneratedLocation: tryGetGeneratedLocation, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + return { tryGetSourcePosition: tryGetSourcePosition, tryGetGeneratedPosition: tryGetGeneratedPosition, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + function toPath(fileName) { + return ts.toPath(fileName, currentDirectory, getCanonicalFileName); + } function scanForSourcemapURL(fileName) { - var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var mappedFile = sourcemappedFileCache.get(toPath(fileName)); if (!mappedFile) { return; } - var starts = ts.getLineStarts(mappedFile); - for (var index = starts.length - 1; index >= 0; index--) { - var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); - var comment = sourceMapCommentRegExp.exec(lineText); - if (comment) { - return comment[1]; - } - // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file - else if (!lineText.match(whitespaceOrMapCommentRegExp)) { - break; - } - } + return ts.tryGetSourceMappingURL(mappedFile.text, ts.getLineStarts(mappedFile)); } function convertDocumentToSourceMapper(file, contents, mapFileName) { - var maps; - try { - maps = JSON.parse(contents); - } - catch (_a) { - // swallow error - } - if (!maps || !maps.sources || !maps.file || !maps.mappings) { + var map = ts.tryParseRawSourceMap(contents); + if (!map || !map.sources || !map.file || !map.mappings) { // obviously invalid map - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - return file.sourceMapper = ts.sourcemaps.decode({ - readFile: function (s) { return host.readFile(s); }, - fileExists: function (s) { return host.fileExists(s); }, + var program = getProgram(); + return file.sourceMapper = ts.createDocumentPositionMapper({ + getSourceFileLike: function (s) { + // Lookup file in program, if provided + var file = program && program.getSourceFileByPath(s); + // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file + if (file === undefined || file.resolvedPath !== s) { + // Otherwise check the cache (which may hit disk) + return sourcemappedFileCache.get(s); + } + return file; + }, getCanonicalFileName: getCanonicalFileName, log: log, - }, mapFileName, maps, getProgram(), sourcemappedFileCache); + }, map, mapFileName); } function getSourceMapper(fileName, file) { if (!host.readFile || !host.fileExists) { - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } if (file.sourceMapper) { return file.sourceMapper; @@ -102674,20 +103909,24 @@ var ts; return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217 } } - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - function tryGetOriginalLocation(info) { + function tryGetSourcePosition(info) { if (!ts.isDeclarationFileName(info.fileName)) return undefined; var file = getFile(info.fileName); if (!file) return undefined; - var newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info); - return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc; + var newLoc = getSourceMapper(info.fileName, file).getSourcePosition(info); + return newLoc === info ? undefined : tryGetSourcePosition(newLoc) || newLoc; } - function tryGetGeneratedLocation(info) { + function tryGetGeneratedPosition(info) { var program = getProgram(); - var declarationPath = ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); + var options = program.getCompilerOptions(); + var outPath = options.outFile || options.out; + var declarationPath = outPath ? + ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; var declarationFile = getFile(declarationPath); @@ -102697,18 +103936,45 @@ var ts; return newLoc === info ? undefined : newLoc; } function getFile(fileName) { - return getProgram().getSourceFile(fileName) || sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var path = toPath(fileName); + var file = getProgram().getSourceFileByPath(path); + if (file && file.resolvedPath === path) { + return file; + } + return sourcemappedFileCache.get(path); } function toLineColumnOffset(fileName, position) { - var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217 + var file = getFile(fileName); // TODO: GH#18217 return file.getLineAndCharacterOfPosition(position); } function clearCache() { - sourcemappedFileCache = ts.createSourceFileLikeCache(host); + sourcemappedFileCache = createSourceFileLikeCache(host); } } ts.getSourceMapper = getSourceMapper; + function createSourceFileLikeCache(host) { + var cached = ts.createMap(); + return { + get: function (path) { + if (cached.has(path)) { + return cached.get(path); + } + if (!host.fileExists || !host.readFile || !host.fileExists(path)) + return; + // And failing that, check the disk + var text = host.readFile(path); // TODO: GH#18217 + var file = { + text: text, + lineMap: undefined, + getLineAndCharacterOfPosition: function (pos) { + return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + } + }; + cached.set(path, file); + return file; + } + }; + } })(ts || (ts = {})); /* @internal */ var ts; @@ -102744,7 +104010,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_2 = decl.symbol; @@ -102754,7 +104020,7 @@ var ts; } } // falls through if no diagnostic was created - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -102787,11 +104053,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -102808,58 +104074,42 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 251 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; default: return undefined; } } function addConvertToAsyncFunctionDiagnostics(node, checker, diags) { - if (ts.isAsyncFunction(node) || !node.body) { - return; + if (!ts.isAsyncFunction(node) && + node.body && + ts.isBlock(node.body) && + hasReturnStatementWithPromiseHandler(node.body) && + returnsPromise(node, checker)) { + diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); } + } + function returnsPromise(node, checker) { var functionType = checker.getTypeAtLocation(node); var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; - if (!returnType || !checker.getPromisedTypeOfPromise(returnType)) { - return; - } - // collect all the return statements - // check that a property access expression exists in there and that it is a handler - var returnStatements = getReturnStatementsWithPromiseHandlers(node); - if (returnStatements.length > 0) { - diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); - } + return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - /** @internal */ - function getReturnStatementsWithPromiseHandlers(node) { - var returnStatements = []; - if (ts.isFunctionLike(node)) { - ts.forEachChild(node, visit); - } - else { - visit(node); - } - function visit(child) { - if (ts.isFunctionLike(child)) { - return; - } - if (ts.isReturnStatement(child) && child.expression && isFixablePromiseHandler(child.expression)) { - returnStatements.push(child); - } - ts.forEachChild(child, visit); - } - return returnStatements; + function hasReturnStatementWithPromiseHandler(body) { + return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); } - ts.getReturnStatementsWithPromiseHandlers = getReturnStatementsWithPromiseHandlers; + function isReturnStatementWithFixablePromiseHandler(node) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + } + ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts function isFixablePromiseHandler(node) { // ensure outermost call exists and is a promise handler @@ -102876,17 +104126,18 @@ var ts; } return true; } + ts.isFixablePromiseHandler = isFixablePromiseHandler; function isPromiseHandler(node) { return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") || ts.hasPropertyAccessExpressionWithName(node, "catch")); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 95 /* NullKeyword */: - case 71 /* Identifier */: // identifier includes undefined - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: // identifier includes undefined + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -102906,7 +104157,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 209 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -102943,7 +104194,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 100 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -102994,11 +104245,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 260 /* JsxOpeningElement */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 265 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + return location.kind === 72 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 267 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -103025,13 +104276,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 100 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 99 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(99 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 100 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(100 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -103041,7 +104292,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 187 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 189 /* 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)) { @@ -103062,7 +104313,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 190 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 192 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 98 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -103080,7 +104331,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -103097,14 +104348,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* 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 */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -103117,29 +104368,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 155 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 124 /* ConstructorKeyword */ && location.parent.kind === 157 /* 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 = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 124 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 155 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 157 /* 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 === 155 /* Constructor */) { + if (functionDeclaration_1.kind === 157 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 160 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -103149,7 +104400,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 209 /* 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 @@ -103157,7 +104408,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(75 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(76 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -103165,45 +104416,45 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(109 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(110 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(77 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(83 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(84 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 244 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 72 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 131 /* NamespaceKeyword */ : 130 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -103214,7 +104465,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 148 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 150 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -103222,21 +104473,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 159 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + if (declaration.kind === 161 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 158 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 160 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 240 /* TypeAliasDeclaration */) { + else if (declaration.kind === 242 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -103248,11 +104499,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 276 /* EnumMember */) { + if (declaration.kind === 278 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -103278,41 +104529,41 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 245 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 247 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(131 /* NamespaceKeyword */)); break; - case 252 /* ExportAssignment */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 254 /* ExportAssignment */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 59 /* EqualsToken */ : 80 /* DefaultKeyword */)); break; - case 255 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 257 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(91 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(92 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 246 /* ImportEqualsDeclaration */) { + if (declaration.kind === 248 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(133 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(134 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -103326,7 +104577,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(99 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(100 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -103337,7 +104588,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -103375,10 +104626,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -103421,7 +104672,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(92 /* InKeyword */)); + displayParts.push(ts.keywordPart(93 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -103431,7 +104682,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(55 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -103454,9 +104705,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); return; } } @@ -103465,12 +104716,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(37 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(38 /* 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(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } var docComment = signature.getDocumentationComment(typeChecker); documentation = docComment.length === 0 ? undefined : docComment; @@ -103479,7 +104730,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration); - getPrinter().writeList(26896 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -103491,16 +104742,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 194 /* FunctionExpression */) { + if (declaration.kind === 196 /* FunctionExpression */) { return true; } - if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* FunctionDeclaration */) { + if (declaration.kind !== 237 /* VariableDeclaration */ && declaration.kind !== 239 /* 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 === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { + if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -103715,8 +104966,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 17 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 18 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -103798,11 +105049,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 31 /* GreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -103810,28 +105061,28 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 265 /* JsxAttribute */: - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 267 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* 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 === 71 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 72 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 12 /* RegularExpressionLiteral */; + return container.kind === 13 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 15 /* TemplateMiddle */ || - container.kind === 16 /* TemplateTail */; + return container.kind === 16 /* TemplateMiddle */ || + container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; + return t === 42 /* SlashToken */ || t === 64 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -103901,7 +105152,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -103917,7 +105168,7 @@ var ts; } break; case 3 /* RescanTemplateToken */: - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { lastScanAction = 3 /* RescanTemplateToken */; return scanner.reScanTemplateToken(); } @@ -103990,7 +105241,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 145 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 147 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -104002,255 +105253,255 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 145 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); - var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 145 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; - var unaryPrefixOperators = [43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]; + var keywords = tokenRangeFromRange(73 /* FirstKeyword */, 147 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 71 /* LastBinaryOperator */); + var binaryKeywordOperators = [93 /* InKeyword */, 94 /* InstanceOfKeyword */, 147 /* OfKeyword */, 119 /* AsKeyword */, 128 /* IsKeyword */]; + var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, - 17 /* OpenBraceToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 72 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostincrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; - var unaryPredecrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostdecrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; + var unaryPreincrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostincrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; + var unaryPredecrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostdecrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [71 /* Identifier */].concat(ts.typeKeywords); + var typeNames = [72 /* Identifier */].concat(ts.typeKeywords); // 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([71 /* Identifier */, 3 /* MultiLineCommentTrivia */, 75 /* ClassKeyword */, 84 /* ExportKeyword */, 91 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([72 /* Identifier */, 3 /* MultiLineCommentTrivia */, 76 /* ClassKeyword */, 85 /* ExportKeyword */, 92 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([20 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 81 /* DoKeyword */, 102 /* TryKeyword */, 87 /* FinallyKeyword */, 82 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 82 /* DoKeyword */, 103 /* TryKeyword */, 88 /* FinallyKeyword */, 83 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 56 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 56 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 55 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), + rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), + rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 23 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 23 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 91 /* ImportKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenImportParenInImportType", 92 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), // 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], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 43 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 44 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 43 /* PlusPlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 37 /* PlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 37 /* PlusToken */, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 44 /* MinusMinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 38 /* MinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 38 /* MinusToken */, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 18 /* CloseBraceToken */, [26 /* CommaToken */, 25 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 18 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 18 /* CloseBraceToken */, anyTokenExcept(20 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 18 /* CloseBraceToken */, 82 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 18 /* CloseBraceToken */, 106 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 83 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 107 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), // 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", 20 /* CloseParenToken */, 21 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 89 /* FunctionKeyword */, 39 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 39 /* AsteriskToken */, [71 /* Identifier */, 19 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 89 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 90 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), + rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, [72 /* Identifier */, 20 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), + rule("SpaceAfterFunctionInFuncDecl", 90 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 17 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), // 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", [125 /* GetKeyword */, 136 /* SetKeyword */], 71 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 116 /* YieldKeyword */, 39 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [116 /* YieldKeyword */, 39 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 96 /* ReturnKeyword */, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [104 /* VarKeyword */, 100 /* ThrowKeyword */, 94 /* NewKeyword */, 80 /* DeleteKeyword */, 96 /* ReturnKeyword */, 103 /* TypeOfKeyword */, 121 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [110 /* LetKeyword */, 76 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [126 /* GetKeyword */, 137 /* SetKeyword */], 72 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBetweenYieldKeywordAndStar", 117 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [117 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), + rule("NoSpaceBetweenReturnAndSemicolon", 97 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterCertainKeywords", [105 /* VarKeyword */, 101 /* ThrowKeyword */, 95 /* NewKeyword */, 81 /* DeleteKeyword */, 97 /* ReturnKeyword */, 104 /* TypeOfKeyword */, 122 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterLetConstInVariableDeclaration", [111 /* LetKeyword */, 77 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), // 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], 2 /* Space */), rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 105 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceAfterVoidOperator", 106 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 120 /* AsyncKeyword */, 19 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 120 /* AsyncKeyword */, 89 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 121 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 121 /* AsyncKeyword */, 90 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [71 /* Identifier */, 20 /* CloseParenToken */], [13 /* NoSubstitutionTemplateLiteral */, 14 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [72 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 71 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 41 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 41 /* SlashToken */, 29 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 58 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 58 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 72 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 59 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterEqualInJsxAttribute", 59 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [129 /* ModuleKeyword */, 133 /* RequireKeyword */], 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [130 /* ModuleKeyword */, 134 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 117 /* AbstractKeyword */, - 75 /* ClassKeyword */, - 124 /* DeclareKeyword */, - 79 /* DefaultKeyword */, - 83 /* EnumKeyword */, - 84 /* ExportKeyword */, - 85 /* ExtendsKeyword */, - 125 /* GetKeyword */, - 108 /* ImplementsKeyword */, - 91 /* ImportKeyword */, - 109 /* InterfaceKeyword */, - 129 /* ModuleKeyword */, - 130 /* NamespaceKeyword */, - 112 /* PrivateKeyword */, - 114 /* PublicKeyword */, - 113 /* ProtectedKeyword */, - 132 /* ReadonlyKeyword */, - 136 /* SetKeyword */, - 115 /* StaticKeyword */, - 139 /* TypeKeyword */, - 143 /* FromKeyword */, - 128 /* KeyOfKeyword */, - 126 /* InferKeyword */, + 118 /* AbstractKeyword */, + 76 /* ClassKeyword */, + 125 /* DeclareKeyword */, + 80 /* DefaultKeyword */, + 84 /* EnumKeyword */, + 85 /* ExportKeyword */, + 86 /* ExtendsKeyword */, + 126 /* GetKeyword */, + 109 /* ImplementsKeyword */, + 92 /* ImportKeyword */, + 110 /* InterfaceKeyword */, + 130 /* ModuleKeyword */, + 131 /* NamespaceKeyword */, + 113 /* PrivateKeyword */, + 115 /* PublicKeyword */, + 114 /* ProtectedKeyword */, + 133 /* ReadonlyKeyword */, + 137 /* SetKeyword */, + 116 /* StaticKeyword */, + 140 /* TypeKeyword */, + 144 /* FromKeyword */, + 129 /* KeyOfKeyword */, + 127 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 143 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [86 /* ExtendsKeyword */, 109 /* ImplementsKeyword */, 144 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 9 /* StringLiteral */, 17 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 36 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 36 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 24 /* DotDotDotToken */, 71 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 55 /* QuestionToken */, [20 /* CloseParenToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 72 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 20 /* CloseParenToken */, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 27 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 29 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 29 /* GreaterThanToken */, [19 /* OpenParenToken */, 21 /* OpenBracketToken */, 29 /* GreaterThanToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), // decorators - rule("SpaceBeforeAt", [20 /* CloseParenToken */, 71 /* Identifier */], 57 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 57 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 72 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 117 /* AbstractKeyword */, - 71 /* Identifier */, - 84 /* ExportKeyword */, - 79 /* DefaultKeyword */, - 75 /* ClassKeyword */, - 115 /* StaticKeyword */, - 114 /* PublicKeyword */, - 112 /* PrivateKeyword */, - 113 /* ProtectedKeyword */, - 125 /* GetKeyword */, - 136 /* SetKeyword */, - 21 /* OpenBracketToken */, - 39 /* AsteriskToken */, + 118 /* AbstractKeyword */, + 72 /* Identifier */, + 85 /* ExportKeyword */, + 80 /* DefaultKeyword */, + 76 /* ClassKeyword */, + 116 /* StaticKeyword */, + 115 /* PublicKeyword */, + 113 /* PrivateKeyword */, + 114 /* ProtectedKeyword */, + 126 /* GetKeyword */, + 137 /* SetKeyword */, + 22 /* OpenBracketToken */, + 40 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 51 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 94 /* NewKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 95 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), ]; // 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", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 19 /* OpenParenToken */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 19 /* OpenParenToken */, 20 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 21 /* OpenBracketToken */, 22 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), // Insert space before and after binary operators rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* 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, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), + rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), + rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), ]; // 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, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 26 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(120 /* AsyncKeyword */, 73 /* CaseKeyword */), 21 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 22 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 25 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(121 /* AsyncKeyword */, 74 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 88 /* ForKeyword */, 121 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 89 /* ForKeyword */, 122 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // 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", [20 /* CloseParenToken */, 81 /* DoKeyword */, 82 /* ElseKeyword */, 73 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 82 /* DoKeyword */, 83 /* ElseKeyword */, 74 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [102 /* TryKeyword */, 87 /* FinallyKeyword */], 17 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [103 /* TryKeyword */, 88 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); } @@ -104294,45 +105545,45 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 223 /* ForStatement */; + return context.contextNode.kind === 225 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 173 /* ConditionalType */: - case 210 /* AsExpression */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 161 /* TypePredicate */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 175 /* ConditionalType */: + case 212 /* AsExpression */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 163 /* TypePredicate */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 184 /* BindingElement */: + case 186 /* BindingElement */: // equals in type X = ... - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: // equal in p = 0; - case 149 /* Parameter */: - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; + case 151 /* Parameter */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + return context.currentTokenSpan.kind === 59 /* EqualsToken */ || context.nextTokenSpan.kind === 59 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 148 /* TypeParameter */: - return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; + case 150 /* TypeParameter */: + return context.currentTokenSpan.kind === 93 /* InKeyword */ || context.nextTokenSpan.kind === 93 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 225 /* ForOfStatement */: - return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; + case 227 /* ForOfStatement */: + return context.currentTokenSpan.kind === 147 /* OfKeyword */ || context.nextTokenSpan.kind === 147 /* OfKeyword */; } return false; } @@ -104344,22 +105595,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 152 /* PropertyDeclaration */ || - contextKind === 151 /* PropertySignature */ || - contextKind === 149 /* Parameter */ || - contextKind === 235 /* VariableDeclaration */ || + return contextKind === 154 /* PropertyDeclaration */ || + contextKind === 153 /* PropertySignature */ || + contextKind === 151 /* Parameter */ || + contextKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 203 /* ConditionalExpression */ || - context.contextNode.kind === 173 /* ConditionalType */; + return context.contextNode.kind === 205 /* ConditionalExpression */ || + context.contextNode.kind === 175 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 182 /* ObjectBindingPattern */ || - context.contextNode.kind === 179 /* MappedType */ || + return context.contextNode.kind === 184 /* ObjectBindingPattern */ || + context.contextNode.kind === 181 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -104385,31 +105636,31 @@ var ts; return true; } switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 186 /* ObjectLiteralExpression */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 188 /* ObjectLiteralExpression */: + case 245 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 158 /* CallSignature */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 197 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 241 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -104418,40 +105669,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; + return context.contextNode.kind === 239 /* FunctionDeclaration */ || context.contextNode.kind === 196 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 166 /* TypeLiteral */: - case 242 /* ModuleDeclaration */: - case 253 /* ExportDeclaration */: - case 254 /* NamedExports */: - case 247 /* ImportDeclaration */: - case 250 /* NamedImports */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 168 /* TypeLiteral */: + case 244 /* ModuleDeclaration */: + case 255 /* ExportDeclaration */: + case 256 /* NamedExports */: + case 249 /* ImportDeclaration */: + case 252 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 272 /* CatchClause */: - case 243 /* ModuleBlock */: - case 230 /* SwitchStatement */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 274 /* CatchClause */: + case 245 /* ModuleBlock */: + case 232 /* SwitchStatement */: return true; - case 216 /* Block */: { + case 218 /* 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 !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 197 /* ArrowFunction */ && blockParent.kind !== 196 /* FunctionExpression */) { return true; } } @@ -104460,64 +105711,64 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 229 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 231 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 272 /* CatchClause */: + case 274 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 186 /* ObjectLiteralExpression */; + return context.contextNode.kind === 188 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 189 /* CallExpression */; + return context.contextNode.kind === 191 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 190 /* NewExpression */; + return context.contextNode.kind === 192 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 26 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 195 /* ArrowFunction */; + return context.contextNode.kind === 197 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 181 /* ImportType */; + return context.contextNode.kind === 183 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; + return context.contextNode.kind !== 260 /* JsxElement */ && context.contextNode.kind !== 264 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; + return context.contextNode.kind === 270 /* JsxExpression */ || context.contextNode.kind === 269 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 265 /* JsxAttribute */; + return context.nextTokenParent.kind === 267 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 265 /* JsxAttribute */; + return context.contextNode.kind === 267 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 259 /* JsxSelfClosingElement */; + return context.contextNode.kind === 261 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -104532,45 +105783,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 238 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 242 /* ModuleDeclaration */; + return context.contextNode.kind === 244 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 168 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 159 /* ConstructSignature */; + return context.contextNode.kind === 161 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { + if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 162 /* TypeReference */: - case 192 /* TypeAssertionExpression */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 194 /* TypeAssertionExpression */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -104581,16 +105832,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 192 /* TypeAssertionExpression */; + return context.contextNode.kind === 194 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; + return context.currentTokenSpan.kind === 106 /* VoidKeyword */ && context.currentTokenParent.kind === 200 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 207 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 211 /* NonNullExpression */; + return context.contextNode.kind === 213 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -104641,12 +105892,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 145 /* LastKeyword */ && column <= 145 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 147 /* LastKeyword */ && column <= 147 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 145 /* LastToken */ + 1; + var mapRowLength = 147 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -104735,12 +105986,12 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 25 /* SemicolonToken */, sourceFile); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 17 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -104766,7 +106017,7 @@ var ts; } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 18 /* CloseBraceToken */, sourceFile); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; @@ -104824,17 +106075,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 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 277 /* SourceFile */: - case 216 /* Block */: - case 243 /* ModuleBlock */: + return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 279 /* SourceFile */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -104947,7 +106198,6 @@ var ts; } return 0; } - /* @internal */ function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: 0, end: sourceFileLike.text.length }; 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 @@ -104977,7 +106227,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine; + var indentationOnLastIndentedLine = -1 /* Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -104991,7 +106241,7 @@ var ts; if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); // TODO: GH#18217 + indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); trimTrailingWhitespacesForRemainingRange(); } } @@ -105036,7 +106286,7 @@ var ts; }; } else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 19 /* OpenParenToken */ && startLine === lastIndentedLine) { + if (node.kind === 20 /* 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) }; @@ -105057,19 +106307,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; - case 156 /* GetAccessor */: return 125 /* GetKeyword */; - case 157 /* SetAccessor */: return 136 /* SetKeyword */; - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: return 76 /* ClassKeyword */; + case 241 /* InterfaceDeclaration */: return 110 /* InterfaceKeyword */; + case 239 /* FunctionDeclaration */: return 90 /* FunctionKeyword */; + case 243 /* EnumDeclaration */: return 243 /* EnumDeclaration */; + case 158 /* GetAccessor */: return 126 /* GetKeyword */; + case 159 /* SetAccessor */: return 137 /* SetKeyword */; + case 156 /* MethodDeclaration */: if (node.asteriskToken) { - return 39 /* AsteriskToken */; + return 40 /* AsteriskToken */; } // falls through - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -105084,15 +106334,25 @@ var ts; // .. { // // comment // } - case 18 /* CloseBraceToken */: - case 22 /* CloseBracketToken */: - case 20 /* CloseParenToken */: + case 19 /* CloseBraceToken */: + case 23 /* CloseBracketToken */: + case 21 /* CloseParenToken */: return indentation + getDelta(container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; }, - getIndentationForToken: function (line, kind, container) { - return shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : 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. + // foo.then + // < + // number, + // string, + // >(); + // vs + // var a = xValue + // > yValue; + getIndentationForToken: function (line, kind, container, suppressDelta) { + return !suppressDelta && shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: getDelta, @@ -105106,26 +106366,25 @@ 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 17 /* OpenBraceToken */: - case 18 /* CloseBraceToken */: - case 19 /* OpenParenToken */: - case 20 /* CloseParenToken */: - case 82 /* ElseKeyword */: - case 106 /* WhileKeyword */: - case 57 /* AtToken */: + case 18 /* OpenBraceToken */: + case 19 /* CloseBraceToken */: + case 21 /* CloseParenToken */: + case 83 /* ElseKeyword */: + case 107 /* WhileKeyword */: + case 58 /* AtToken */: return false; - case 41 /* SlashToken */: - case 29 /* GreaterThanToken */: + case 42 /* SlashToken */: + case 30 /* GreaterThanToken */: switch (container.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: return false; } break; - case 21 /* OpenBracketToken */: - case 22 /* CloseBracketToken */: - if (container.kind !== 179 /* MappedType */) { + case 22 /* OpenBracketToken */: + case 23 /* CloseBracketToken */: + if (container.kind !== 181 /* MappedType */) { return false; } break; @@ -105210,22 +106469,22 @@ var ts; return inheritedIndentation; } // JSX text shouldn't affect indenting - if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { + if (ts.isToken(child) && child.kind !== 11 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 150 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 152 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { var range = { pos: child.getStart(), end: child.getEnd() }; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 187 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -105246,9 +106505,20 @@ var ts; else if (tokenInfo.token.kind === listStartToken) { // consume list start token startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_2 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_2.indentation, indentation_2.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); + var indentationOnListStartToken = void 0; + if (indentationOnLastIndentedLine !== -1 /* 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; + // }: {}; + indentationOnListStartToken = indentationOnLastIndentedLine; + } + else { + var startLinePosition = ts.getLineStartPositionForPosition(tokenInfo.token.pos, sourceFile); + indentationOnListStartToken = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, tokenInfo.token.pos, sourceFile, options); + } + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentationOnListStartToken, options.indentSize); // TODO: GH#18217 } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope @@ -105264,7 +106534,7 @@ var ts; var listEndToken = getCloseTokenForOpenToken(listStartToken); if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 26 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { formattingScanner.advance(); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; } @@ -105274,11 +106544,11 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo && tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent, /*isListEndToken*/ true); } } } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container) { + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container, isListEndToken) { ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); var indentToken = false; @@ -105310,32 +106580,12 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) : + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); - switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: - if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); - } - indentNextTokenOrTrivia = false; - break; - case 2 /* SingleLineCommentTrivia */: - if (indentNextTokenOrTrivia && triviaInRange) { - insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); - } - indentNextTokenOrTrivia = false; - break; - case 4 /* NewLineTrivia */: - indentNextTokenOrTrivia = true; - break; - } - } + 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) { @@ -105348,16 +106598,39 @@ var ts; childContextNode = parent; } } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + function indentTriviaItems(trivia, commentIndentation, indentNextTokenOrTrivia, indentSingleLine) { for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { var triviaItem = trivia_1[_i]; + var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); + switch (triviaItem.kind) { + case 3 /* MultiLineCommentTrivia */: + if (triviaInRange) { + indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + } + indentNextTokenOrTrivia = false; + break; + case 2 /* SingleLineCommentTrivia */: + if (indentNextTokenOrTrivia && triviaInRange) { + indentSingleLine(triviaItem); + } + indentNextTokenOrTrivia = false; + break; + case 4 /* NewLineTrivia */: + indentNextTokenOrTrivia = true; + break; + } + } + return indentNextTokenOrTrivia; + } + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0, trivia_2 = trivia; _i < trivia_2.length; _i++) { + var triviaItem = trivia_2[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); } } } - // TODO: GH#18217 use an enum instead of `boolean | undefined` function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAction = 0 /* None */; @@ -105529,7 +106802,10 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - var startPosition = previousRange ? previousRange.end : originalRange.pos; + if (!previousRange) { + return; + } + var startPosition = previousRange.end; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -105629,41 +106905,46 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 197 /* ArrowFunction */: if (node.typeParameters === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.parameters === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.arguments === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 162 /* TypeReference */: + case 164 /* TypeReference */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } + break; + case 168 /* TypeLiteral */: + return 18 /* OpenBraceToken */; } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 19 /* OpenParenToken */: - return 20 /* CloseParenToken */; - case 27 /* LessThanToken */: - return 29 /* GreaterThanToken */; + case 20 /* OpenParenToken */: + return 21 /* CloseParenToken */; + case 28 /* LessThanToken */: + return 30 /* GreaterThanToken */; + case 18 /* OpenBraceToken */: + return 19 /* CloseBraceToken */; } return 0 /* Unknown */; } @@ -105768,13 +107049,18 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 204 /* 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 */) { 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 + } return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options); } SmartIndenter.getIndentation = getIndentation; @@ -105785,12 +107071,12 @@ var ts; if (previousLine <= commentStartLine) { return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); } - var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); - var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + var startPositionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPositionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; if (column === 0) { return column; } - var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { @@ -105823,14 +107109,13 @@ var ts; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + // do not consider parent-child line sharing yet: + // 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 */) { return actualIndentation; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.indentSize; // TODO: GH#18217 - } previous = current; current = current.parent; } @@ -105857,23 +107142,17 @@ var ts; var start = current.getStart(sourceFile); useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; } - if (useActualIndentation) { - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } var containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); var parentAndChildShareLine = containingListOrParentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { - // try to fetch actual indentation for current node from source text - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + // try to fetch actual indentation for current node from source text + actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } @@ -105924,7 +107203,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -105941,11 +107220,11 @@ var ts; if (!nextToken) { return 0 /* Unknown */; } - if (nextToken.kind === 17 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* OpenBraceToken */) { // open braces are always indented at the parent level return 1 /* OpenBrace */; } - else if (nextToken.kind === 18 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* 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 { @@ -105972,8 +107251,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); + if (parent.kind === 222 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 83 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -105981,103 +107260,87 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getListIfStartEndIsInListRange(list, start, end) { - return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; - } function getContainingList(node, sourceFile) { - if (node.parent) { - var end = node.end; - switch (node.parent.kind) { - case 162 /* TypeReference */: - return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 186 /* ObjectLiteralExpression */: - return node.parent.properties; - case 185 /* ArrayLiteralExpression */: - return node.parent.elements; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || - getListIfStartEndIsInListRange(node.parent.parameters, start, end); - } - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: { - var typeParameters = node.parent.typeParameters; - return getListIfStartEndIsInListRange(typeParameters, node.getStart(sourceFile), end); - } - case 190 /* NewExpression */: - case 189 /* CallExpression */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || - getListIfStartEndIsInListRange(node.parent.arguments, start, end); - } - case 236 /* VariableDeclarationList */: - return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - } - } - return undefined; + return node.parent && getListByRange(node.getStart(sourceFile), node.getEnd(), node.parent, sourceFile); } SmartIndenter.getContainingList = getContainingList; - function getActualIndentationForListItem(node, sourceFile, options) { + function getListByPosition(pos, node, sourceFile) { + return node && getListByRange(pos, pos, node, sourceFile); + } + function getListByRange(start, end, node, sourceFile) { + switch (node.kind) { + case 164 /* TypeReference */: + return getList(node.typeArguments); + case 188 /* ObjectLiteralExpression */: + return getList(node.properties); + case 187 /* ArrayLiteralExpression */: + return getList(node.elements); + case 168 /* TypeLiteral */: + return getList(node.members); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: + return getList(node.typeParameters) || getList(node.parameters); + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + return getList(node.typeParameters); + case 192 /* NewExpression */: + case 191 /* CallExpression */: + return getList(node.typeArguments) || getList(node.arguments); + case 238 /* VariableDeclarationList */: + return getList(node.declarations); + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return getList(node.elements); + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + return getList(node.elements); + } + function getList(list) { + return list && ts.rangeContainsStartEnd(getVisualListRange(node, list, sourceFile), start, end) ? list : undefined; + } + } + function getVisualListRange(node, list, sourceFile) { + var children = node.getChildren(sourceFile); + for (var i = 1; i < children.length - 1; i++) { + if (children[i].pos === list.pos && children[i].end === list.end) { + return { pos: children[i - 1].end, end: children[i + 1].getStart(sourceFile) }; + } + } + return list; + } + function getActualIndentationForListStartLine(list, sourceFile, options) { + if (!list) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); + } + function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { + if (node.parent && node.parent.kind === 238 /* VariableDeclarationList */) { + // VariableDeclarationList has no wrapping tokens + return -1 /* Unknown */; + } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { - return deriveActualIndentationFromList(containingList, index, sourceFile, options); - } - } - return -1 /* Unknown */; - } - function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - // actual indentation should not be used when: - // - node is close parenthesis - this is the end of the expression - if (node.kind === 20 /* CloseParenToken */) { - return -1 /* Unknown */; - } - if (node.parent && ts.isCallOrNewExpression(node.parent) && node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1 /* Unknown */; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); - } - return -1 /* Unknown */; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - node = node.expression; - break; - default: - return node; + var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); + if (result !== -1 /* Unknown */) { + return result; } } + return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } + return -1 /* Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -106086,7 +107349,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 === 26 /* CommaToken */) { + if (list[i].kind === 27 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -106135,83 +107398,83 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 219 /* ExpressionStatement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 185 /* ArrayLiteralExpression */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 179 /* MappedType */: - case 168 /* TupleType */: - case 244 /* CaseBlock */: - case 270 /* DefaultClause */: - case 269 /* CaseClause */: - case 193 /* ParenthesizedExpression */: - case 187 /* PropertyAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 217 /* VariableStatement */: - case 252 /* ExportAssignment */: - case 228 /* ReturnStatement */: - case 203 /* ConditionalExpression */: - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: - case 259 /* JsxSelfClosingElement */: - case 268 /* JsxExpression */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 149 /* Parameter */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 175 /* ParenthesizedType */: - case 191 /* TaggedTemplateExpression */: - case 199 /* AwaitExpression */: - case 254 /* NamedExports */: - case 250 /* NamedImports */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 152 /* PropertyDeclaration */: + case 221 /* ExpressionStatement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 187 /* ArrayLiteralExpression */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 181 /* MappedType */: + case 170 /* TupleType */: + case 246 /* CaseBlock */: + case 272 /* DefaultClause */: + case 271 /* CaseClause */: + case 195 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 219 /* VariableStatement */: + case 254 /* ExportAssignment */: + case 230 /* ReturnStatement */: + case 205 /* ConditionalExpression */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: + case 261 /* JsxSelfClosingElement */: + case 270 /* JsxExpression */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 151 /* Parameter */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 177 /* ParenthesizedType */: + case 193 /* TaggedTemplateExpression */: + case 201 /* AwaitExpression */: + case 256 /* NamedExports */: + case 252 /* NamedImports */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 154 /* PropertyDeclaration */: return true; - case 235 /* VariableDeclaration */: - case 273 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 237 /* VariableDeclaration */: + case 275 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 188 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } return true; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return childKind !== 216 /* Block */; - case 253 /* ExportDeclaration */: - return childKind !== 254 /* NamedExports */; - case 247 /* ImportDeclaration */: - return childKind !== 248 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); - case 258 /* JsxElement */: - return childKind !== 261 /* JsxClosingElement */; - case 262 /* JsxFragment */: - return childKind !== 264 /* JsxClosingFragment */; - case 172 /* IntersectionType */: - case 171 /* UnionType */: - if (childKind === 166 /* TypeLiteral */) { + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return childKind !== 218 /* Block */; + case 255 /* ExportDeclaration */: + return childKind !== 256 /* NamedExports */; + case 249 /* ImportDeclaration */: + return childKind !== 250 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 252 /* NamedImports */); + case 260 /* JsxElement */: + return childKind !== 263 /* JsxClosingElement */; + case 264 /* JsxFragment */: + return childKind !== 266 /* JsxClosingFragment */; + case 174 /* IntersectionType */: + case 173 /* UnionType */: + if (childKind === 168 /* TypeLiteral */) { return false; } // falls through @@ -106222,11 +107485,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: - return parent.kind !== 216 /* Block */; + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: + return parent.kind !== 218 /* Block */; default: return false; } @@ -106354,7 +107617,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 === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 188 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -106426,13 +107689,16 @@ var ts; if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, options), newNodes, options); }; + ChangeTracker.prototype.replaceNodeWithText = function (sourceFile, oldNode, text) { + this.replaceRangeWithText(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, textChanges_3.useNonAdjustedPositions), text); + }; ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 26 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -106482,10 +107748,20 @@ var ts; var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); }; - ChangeTracker.prototype.insertCommentThenNewline = function (sourceFile, character, position, commentText) { - var token = ts.getTouchingToken(sourceFile, position); - var text = "/**" + commentText + "*/" + this.newLineCharacter + ts.repeatString(" ", character); - this.insertText(sourceFile, token.getStart(sourceFile), text); + ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { + var fnStart = node.getStart(sourceFile); + if (node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsdoc = _a[_i]; + this.deleteRange(sourceFile, { + pos: ts.getLineStartPositionForPosition(jsdoc.getStart(sourceFile), sourceFile), + end: getAdjustedEndPosition(sourceFile, jsdoc, /*options*/ {}) + }); + } + } + 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 }); }; ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) { this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text }); @@ -106493,28 +107769,11 @@ var ts; ChangeTracker.prototype.insertText = function (sourceFile, pos, text) { this.replaceRangeWithText(sourceFile, ts.createRange(pos), text); }; - ChangeTracker.prototype.tryInsertJSDocParameters = function (sourceFile, parameters) { - if (parameters.length === 0) { - return; - } - var parent = parameters[0].declaration.parent; - var indent = ts.getLineAndCharacterOfPosition(sourceFile, parent.getStart()).character; - var commentText = "\n"; - for (var _i = 0, parameters_3 = parameters; _i < parameters_3.length; _i++) { - var _a = parameters_3[_i], declaration = _a.declaration, typeNode = _a.typeNode, isOptional = _a.isOptional; - if (ts.isIdentifier(declaration.name)) { - var printed = changesToText.getNonformattedText(typeNode, sourceFile, this.newLineCharacter).text; - commentText += this.printJSDocParameter(indent, printed, declaration.name, isOptional); - } - } - commentText += ts.repeatString(" ", indent + 1); - this.insertCommentThenNewline(sourceFile, indent, parent.getStart(), commentText); - }; /** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */ ChangeTracker.prototype.tryInsertTypeAnnotation = function (sourceFile, node, type) { var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 20 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return; // Function missing parentheses, give up @@ -106523,32 +107782,13 @@ var ts; } } else { - endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 237 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; - ChangeTracker.prototype.tryInsertJSDocType = function (sourceFile, node, type) { - var printed = changesToText.getNonformattedText(type, sourceFile, this.newLineCharacter).text; - var commentText; - if (ts.isGetAccessorDeclaration(node)) { - commentText = " @return {" + printed + "} "; - } - else { - commentText = " @type {" + printed + "} "; - node = node.parent; - } - this.insertCommentThenNewline(sourceFile, ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile)).character, node.getStart(sourceFile), commentText); - }; - ChangeTracker.prototype.printJSDocParameter = function (indent, printed, name, isOptionalParameter) { - var printName = ts.unescapeLeadingUnderscores(name.escapedText); - if (isOptionalParameter) { - printName = "[" + printName + "]"; - } - return ts.repeatString(" ", indent) + (" * @param {" + printed + "} " + printName + "\n"); - }; 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, 19 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, doubleNewlines) { @@ -106642,7 +107882,7 @@ var ts; // 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.createToken(25 /* SemicolonToken */)); + this.replaceRange(sourceFile, ts.createRange(after.end), ts.createToken(26 /* SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -106654,18 +107894,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 235 /* VariableDeclaration */: - case 9 /* StringLiteral */: - case 71 /* Identifier */: + case 237 /* VariableDeclaration */: + case 10 /* StringLiteral */: + case 72 /* Identifier */: return { prefix: ", " }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: return { prefix: " " }; - case 149 /* Parameter */: + case 151 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -106674,28 +107914,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 195 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); + if (node.kind === 197 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(90 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 216 /* Block */) { + if (node.body.kind !== 218 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(97 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 196 /* FunctionExpression */ ? 90 /* FunctionKeyword */ : 76 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -106783,12 +108023,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 = 26 /* CommaToken */; + separator = 27 /* 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 : 26 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* 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; @@ -106828,7 +108068,7 @@ var ts; }; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var deletedNodesInLists = new ts.NodeSet(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. var _loop_17 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { @@ -106882,7 +108122,7 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - return [ts.findChildOfKind(cls, 17 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile).end]; + return [ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile).end]; } function getMembersOrProperties(cls) { return ts.isObjectLiteralExpression(cls) ? cls.properties : cls.members; @@ -106925,7 +108165,7 @@ var ts; var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 6 /* ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); - return applyChanges(nonFormattedText, changes); + return applyChanges(nonFormattedText, changes) + newLineCharacter; } changesToText.newFileChangesWorker = newFileChangesWorker; function computeNewText(change, sourceFile, newLineCharacter, formatContext, validate) { @@ -107050,6 +108290,9 @@ var ts; this.writer.write(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeComment = function (s) { + this.writer.writeComment(s); + }; Writer.prototype.writeKeyword = function (s) { this.writer.writeKeyword(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -107062,6 +108305,10 @@ var ts; this.writer.writePunctuation(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeTrailingSemicolon = function (s) { + this.writer.writeTrailingSemicolon(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; Writer.prototype.writeParameter = function (s) { this.writer.writeParameter(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -107082,9 +108329,6 @@ var ts; this.writer.writeSymbol(s, sym); this.setLastNonTriviaPosition(s, /*force*/ false); }; - Writer.prototype.writeTextOfNode = function (text, node) { - this.writer.writeTextOfNode(text, node); - }; Writer.prototype.writeLine = function () { this.writer.writeLine(); }; @@ -107126,10 +108370,25 @@ var ts; }; return Writer; }()); - function getInsertionPositionAtSourceFileTop(_a) { - var text = _a.text; - var shebang = ts.getShebang(text); + function getInsertionPositionAtSourceFileTop(sourceFile) { + var lastPrologue; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + if (ts.isPrologueDirective(node)) { + lastPrologue = node; + } + else { + break; + } + } var position = 0; + var text = sourceFile.text; + if (lastPrologue) { + position = lastPrologue.end; + advancePastLineBreak(); + return position; + } + var shebang = ts.getShebang(text); if (shebang !== undefined) { position = shebang.length; advancePastLineBreak(); @@ -107145,8 +108404,8 @@ var ts; ranges = ranges.slice(1); } // As well as any triple slash references - for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { - var range = ranges_1[_i]; + for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { + var range = ranges_1[_b]; if (range.kind === 2 /* SingleLineCommentTrivia */ && ts.isRecognizedTripleSlashComment(text, range.pos, range.end)) { position = range.end; advancePastLineBreak(); @@ -107168,45 +108427,40 @@ var ts; } } function isValidLocationToAddComment(sourceFile, position) { - return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position); + return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position) && !ts.isInJSXText(sourceFile, position); } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 149 /* 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 149 /* Parameter */: { + case 151 /* Parameter */: { var oldFunction = node.parent; - if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { + if (ts.isArrowFunction(oldFunction) && + oldFunction.parameters.length === 1 && + !ts.findChildOfKind(oldFunction, 20 /* 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`). - var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, // TODO: GH#18217 - oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); - // Drop leading and trailing trivia of the new function because we're only going - // to replace the span (vs the full span) of the old function - the old leading - // and trailing trivia will remain. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); + changes.replaceNodeWithText(sourceFile, node, "()"); } else { deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; } - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 185 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -107214,13 +108468,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -107229,7 +108483,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -107240,7 +108494,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } else { - deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + deleteNode(changes, sourceFile, node, node.kind === 26 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); } } } @@ -107254,7 +108508,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 === 26 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* 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 }); @@ -107276,15 +108530,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 249 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 272 /* CatchClause */) { + if (parent.kind === 274 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -107293,14 +108547,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -107445,6 +108699,32 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addConvertToUnknownForNonOverlappingTypes"; + var errorCodes = [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.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, + }); + function makeChange(changeTracker, sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var replacement = ts.isAsExpression(assertion) + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(143 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(143 /* UnknownKeyword */), assertion.expression); + changeTracker.replaceNode(sourceFile, assertion.expression, replacement); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107512,9 +108792,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(19 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -107524,7 +108804,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(20 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(21 /* CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -107539,26 +108819,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 235 /* VariableDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 237 /* VariableDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 154 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -107580,9 +108860,9 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 288 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -107620,8 +108900,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -107631,6 +108911,754 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "inferFromUsage"; + var errorCodes = [ + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, + ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, + //// Suggestions + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code, + ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var token = ts.getTokenAtPosition(sourceFile, start); + var declaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var markSeen = ts.nodeSeenTracker(); + return codefix.codeFixAll(context, errorCodes, function (changes, err) { + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + }); + }, + }); + function getDiagnostic(errorCode, token) { + switch (errorCode) { + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Infer_parameter_types_from_usage; + default: + return ts.Diagnostics.Infer_type_of_0_from_usage; + } + } + /** Map suggestion code to error code */ + function mapSuggestionDiagnostic(errorCode) { + switch (errorCode) { + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code; + case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code; + case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code; + } + return errorCode; + } + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 72 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 100 /* ThisKeyword */) { + return undefined; + } + var parent = token.parent; + errorCode = mapSuggestionDiagnostic(errorCode); + switch (errorCode) { + // Variable and Property declarations + case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: + if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + return parent; + } + if (ts.isPropertyAccessExpression(parent)) { + var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); + var typeNode = getTypeNodeIfAccessible(type, parent, program, host); + if (typeNode) { + // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags + var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ ""); + addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); + } + return parent; + } + return undefined; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { + var symbol = program.getTypeChecker().getSymbolAtLocation(token); + if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + return symbol.valueDeclaration; + } + return undefined; + } + } + var containingFunction = ts.getContainingFunction(token); + if (containingFunction === undefined) { + return undefined; + } + switch (errorCode) { + // Parameter declarations + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + // falls through + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + if (markSeen(containingFunction)) { + var param = ts.cast(parent, ts.isParameter); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + return param; + } + return undefined; + // Get Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: + case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: + if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + return containingFunction; + } + return undefined; + // Set Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + return undefined; + default: + return ts.Debug.fail(String(errorCode)); + } + } + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + if (ts.isIdentifier(declaration.name)) { + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + } + } + function isApplicableFunctionForInference(declaration) { + switch (declaration.kind) { + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + return true; + case 196 /* FunctionExpression */: + var parent = declaration.parent; + return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; + } + return false; + } + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + return; + } + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || + containingFunction.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + if (ts.isInJSFile(containingFunction)) { + annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); + } + else { + 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) { + annotate(changes, sourceFile, declaration, type, program, host); + } + } + } + } + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); + if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { + var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); + if (type === program.getTypeChecker().getAnyType()) { + type = inferTypeForVariableFromUsage(param.name, program, cancellationToken); + } + if (ts.isInJSFile(setAccessorDeclaration)) { + annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); + } + else { + annotate(changes, sourceFile, param, type, program, host); + } + } + } + function annotate(changes, sourceFile, declaration, type, program, host) { + var typeNode = getTypeNodeIfAccessible(type, declaration, program, host); + if (typeNode) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 153 /* PropertySignature */) { + var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; + if (!parent) { + return; + } + var typeExpression = ts.createJSDocTypeExpression(typeNode); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); + addJSDocTags(changes, sourceFile, parent, [typeTag]); + } + else { + changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); + } + } + } + function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { + var signature = parameterInferences.length && parameterInferences[0].declaration.parent; + if (!signature) { + return; + } + var paramTags = ts.mapDefined(parameterInferences, function (inference) { + var param = inference.declaration; + // only infer parameters that have (1) no type and (2) an accessible inferred type + if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name)) + return; + var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); + var name = ts.getSynthesizedClone(param.name); + ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), ""); + }); + addJSDocTags(changes, sourceFile, signature, paramTags); + } + function addJSDocTags(changes, sourceFile, parent, newTags) { + var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); + var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { + var merged = tryMergeJsdocTags(tag, newTag); + if (merged) + oldTags[i] = merged; + return !!merged; + }); }); + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); + changes.insertJsdocCommentBefore(sourceFile, parent, tag); + } + function tryMergeJsdocTags(oldTag, newTag) { + if (oldTag.kind !== newTag.kind) { + return undefined; + } + switch (oldTag.kind) { + case 299 /* JSDocParameterTag */: { + var oldParam = oldTag; + var newParam = newTag; + return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText + ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) + : undefined; + } + case 300 /* JSDocReturnTag */: + return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); + } + } + function getTypeNodeIfAccessible(type, enclosingScope, program, host) { + var checker = program.getTypeChecker(); + var typeIsAccessible = true; + var notAccessible = function () { typeIsAccessible = false; }; + var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { + trackSymbol: function (symbol, declaration, meaning) { + // TODO: GH#18217 + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + }, + reportInaccessibleThisError: notAccessible, + reportPrivateInBaseOfClassExpression: notAccessible, + reportInaccessibleUniqueSymbolError: notAccessible, + moduleResolverHost: { + readFile: host.readFile, + fileExists: host.fileExists, + directoryExists: host.directoryExists, + getSourceFiles: program.getSourceFiles, + getCurrentDirectory: program.getCurrentDirectory, + getCommonSourceDirectory: program.getCommonSourceDirectory, + } + }); + return typeIsAccessible ? res : undefined; + } + 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; + }); + } + function inferTypeForVariableFromUsage(token, program, cancellationToken) { + var references = getReferences(token, program, cancellationToken); + var checker = program.getTypeChecker(); + var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); + return InferFromReference.unifyFromContext(types, checker); + } + function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { + var searchToken; + switch (containingFunction.kind) { + case 157 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); + break; + case 196 /* FunctionExpression */: + var parent = containingFunction.parent; + searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? + parent.name : + containingFunction.name; + break; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + searchToken = containingFunction.name; + break; + } + if (searchToken) { + return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program, cancellationToken); + } + } + var InferFromReference; + (function (InferFromReference) { + function inferTypesFromReferences(references, checker, cancellationToken) { + var usageContext = {}; + for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { + var reference = references_1[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + return inferFromContext(usageContext, checker); + } + InferFromReference.inferTypesFromReferences = inferTypesFromReferences; + function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { + var checker = program.getTypeChecker(); + if (references.length === 0) { + return undefined; + } + if (!declaration.parameters) { + return undefined; + } + var usageContext = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + var isConstructor = declaration.kind === 157 /* Constructor */; + var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; + return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { + var types = []; + var isRest = ts.isRestParameter(parameter); + var isOptional = false; + for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { + var callContext = callContexts_1[_i]; + if (callContext.argumentTypes.length <= parameterIndex) { + isOptional = ts.isInJSFile(declaration); + types.push(checker.getUndefinedType()); + } + else if (isRest) { + for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + } + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + if (ts.isIdentifier(parameter.name)) { + types.push.apply(types, inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken)); + } + var type = unifyFromContext(types, checker); + return { + type: isRest ? checker.createArrayType(type) : type, + isOptional: isOptional && !isRest, + declaration: parameter + }; + }); + } + InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; + function inferTypeFromContext(node, checker, usageContext) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + switch (node.parent.kind) { + case 203 /* PostfixUnaryExpression */: + usageContext.isNumber = true; + break; + case 202 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + break; + case 204 /* BinaryExpression */: + inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + break; + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + break; + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (node.parent.expression === node) { + inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + } + else { + inferTypeFromContextualType(node, checker, usageContext); + } + break; + case 189 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + break; + case 190 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + break; + case 237 /* 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. + addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + } + break; + } + } + // falls through + default: + return inferTypeFromContextualType(node, checker, usageContext); + } + } + function inferTypeFromContextualType(node, checker, usageContext) { + if (ts.isExpressionNode(node)) { + addCandidateType(usageContext, checker.getContextualType(node)); + } + } + function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + switch (node.operator) { + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + usageContext.isNumber = true; + break; + case 38 /* PlusToken */: + usageContext.isNumber = true; + usageContext.isString = true; + break; + // case SyntaxKind.ExclamationToken: + // no inferences here; + } + } + function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + switch (parent.operatorToken.kind) { + // ExponentiationOperator + case 41 /* AsteriskAsteriskToken */: + // MultiplicativeOperator + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + // ShiftOperator + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // BitwiseOperator + case 49 /* AmpersandToken */: + case 50 /* BarToken */: + case 51 /* CaretToken */: + // CompoundAssignmentOperator + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 70 /* BarEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + // AdditiveOperator + case 39 /* MinusToken */: + // RelationalOperator + case 28 /* LessThanToken */: + case 31 /* LessThanEqualsToken */: + case 30 /* GreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (operandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, operandType); + } + else { + usageContext.isNumber = true; + } + break; + case 60 /* PlusEqualsToken */: + case 38 /* PlusToken */: + var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (otherOperandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, otherOperandType); + } + else if (otherOperandType.flags & 296 /* NumberLike */) { + usageContext.isNumber = true; + } + else if (otherOperandType.flags & 132 /* StringLike */) { + usageContext.isString = true; + } + else { + usageContext.isNumber = true; + usageContext.isString = true; + } + break; + // AssignmentOperators + case 59 /* EqualsToken */: + case 33 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + break; + case 93 /* InKeyword */: + if (node === parent.left) { + usageContext.isString = true; + } + break; + // LogicalOperator + case 55 /* BarBarToken */: + if (node === parent.left && + (node.parent.parent.kind === 237 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + // var x = x || {}; + // TODO: use getFalsyflagsOfType + addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + } + break; + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: + case 94 /* InstanceOfKeyword */: + // nothing to infer here + break; + } + } + function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { + addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + } + function inferTypeFromCallExpressionContext(parent, checker, usageContext) { + var callContext = { + argumentTypes: [], + returnType: {} + }; + if (parent.arguments) { + for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + } + } + inferTypeFromContext(parent, checker, callContext.returnType); + if (parent.kind === 191 /* CallExpression */) { + (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + } + else { + (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + } + } + function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + var name = ts.escapeLeadingUnderscores(parent.name.text); + if (!usageContext.properties) { + usageContext.properties = ts.createUnderscoreEscapedMap(); + } + var propertyUsageContext = usageContext.properties.get(name) || {}; + inferTypeFromContext(parent, checker, propertyUsageContext); + usageContext.properties.set(name, propertyUsageContext); + } + function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + if (node === parent.argumentExpression) { + usageContext.isNumber = true; + usageContext.isString = true; + return; + } + else { + var indexType = checker.getTypeAtLocation(parent.argumentExpression); + var indexUsageContext = {}; + inferTypeFromContext(parent, checker, indexUsageContext); + if (indexType.flags & 296 /* NumberLike */) { + usageContext.numberIndexContext = indexUsageContext; + } + else { + usageContext.stringIndexContext = indexUsageContext; + } + } + } + function unifyFromContext(inferences, checker, fallback) { + if (fallback === void 0) { fallback = checker.getAnyType(); } + if (!inferences.length) + return fallback; + var hasNonVacuousType = inferences.some(function (i) { return !(i.flags & (1 /* Any */ | 16384 /* Void */)); }); + var hasNonVacuousNonAnonymousType = inferences.some(function (i) { return !(i.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); + var anons = inferences.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); + var good = []; + if (!hasNonVacuousNonAnonymousType && anons.length) { + good.push(unifyAnonymousTypes(anons, checker)); + } + good.push.apply(good, inferences.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */) && !(hasNonVacuousType && i.flags & (1 /* Any */ | 16384 /* Void */)); })); + return checker.getWidenedType(checker.getUnionType(good)); + } + InferFromReference.unifyFromContext = unifyFromContext; + function unifyAnonymousTypes(anons, checker) { + if (anons.length === 1) { + return anons[0]; + } + var calls = []; + var constructs = []; + var stringIndices = []; + var numberIndices = []; + var stringIndexReadonly = false; + var numberIndexReadonly = false; + var props = ts.createMultiMap(); + for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) { + var anon = anons_1[_i]; + for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { + var p = _b[_a]; + props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + } + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); + if (anon.stringIndexInfo) { + stringIndices.push(anon.stringIndexInfo.type); + stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly; + } + if (anon.numberIndexInfo) { + numberIndices.push(anon.numberIndexInfo.type); + numberIndexReadonly = numberIndexReadonly || anon.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); + s.type = checker.getUnionType(types); + return [name, s]; + }); + return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); + } + function inferFromContext(usageContext, checker) { + var types = []; + if (usageContext.isNumber) { + types.push(checker.getNumberType()); + } + if (usageContext.isString) { + types.push(checker.getStringType()); + } + types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { + var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 + var types_19 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types_19.push(checker.createPromiseType(types_19.length ? checker.getUnionType(types_19, 2 /* Subtype */) : checker.getAnyType())); + } + else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + } + if (usageContext.numberIndexContext) { + return [checker.createArrayType(recur(usageContext.numberIndexContext))]; + } + else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + var members_6 = ts.createUnderscoreEscapedMap(); + var callSignatures = []; + var constructSignatures = []; + var stringIndexInfo = void 0; + if (usageContext.properties) { + usageContext.properties.forEach(function (context, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = recur(context); + members_6.set(name, symbol); + }); + } + if (usageContext.callContexts) { + for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { + var callContext = _a[_i]; + callSignatures.push(getSignatureFromCallContext(callContext, checker)); + } + } + if (usageContext.constructContexts) { + for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { + var constructContext = _c[_b]; + constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + } + } + if (usageContext.stringIndexContext) { + stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + } + types.push(checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + } + return types; + function recur(innerContext) { + return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + } + function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + var types = []; + if (callContexts) { + for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { + var callContext = callContexts_2[_i]; + if (callContext.argumentTypes.length > parameterIndex) { + if (isRestParameter) { + types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + } + } + if (types.length) { + var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); + return isRestParameter ? checker.createArrayType(type) : type; + } + return undefined; + } + function getSignatureFromCallContext(callContext, checker) { + var parameters = []; + for (var i = 0; i < callContext.argumentTypes.length; i++) { + var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + parameters.push(symbol); + } + var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + // TODO: GH#18217 + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + } + function addCandidateType(context, type) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + (context.candidateTypes || (context.candidateTypes = [])).push(type); + } + } + function hasCallContext(usageContext) { + return !!usageContext && !!usageContext.callContexts; + } + })(InferFromReference || (InferFromReference = {})); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107655,12 +109683,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -107692,7 +109720,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(116 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -107715,7 +109743,7 @@ var ts; 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 === 219 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 221 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -107723,27 +109751,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 195 /* ArrowFunction */: { + case 197 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 216 /* Block */) { + if (arrowFunctionBody.kind === 218 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyComments(assignmentBinaryExpression, method, sourceFile); @@ -107764,17 +109792,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 196 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 71 /* Identifier */) { + if (node.name.kind !== 72 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107785,7 +109813,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107837,13 +109865,13 @@ var ts; var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context, setOfExpressionsToReturn, originalTypeMap, allVarNames); var constIdentifiers = getConstIdentifiers(synthNamesMap); - var returnStatements = ts.getReturnStatementsWithPromiseHandlers(functionToConvertRenamed); + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, allVarNames: allVarNames, setOfExpressionsToReturn: setOfExpressionsToReturn, constIdentifiers: constIdentifiers, originalTypeMap: originalTypeMap, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 120 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 121 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); @@ -107863,6 +109891,14 @@ var ts; _loop_19(statement); } } + function getReturnStatementsWithPromiseHandlers(body) { + var res = []; + ts.forEachReturnStatement(body, function (ret) { + if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + res.push(ret); + }); + return res; + } // Returns the identifiers that are never reassigned in the refactor function getConstIdentifiers(synthNamesMap) { var constIdentifiers = []; @@ -108124,10 +110160,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 71 /* Identifier */: // identifier includes undefined + case 72 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -108149,8 +110185,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -108161,7 +110197,7 @@ var ts; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; } - if (ts.getReturnStatementsWithPromiseHandlers(statement).length) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -108172,7 +110208,7 @@ var ts; removeReturns(refactoredStmts, prevArgName === undefined ? undefined : prevArgName.identifier, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.getReturnStatementsWithPromiseHandlers(ts.createReturn(funcBody)); + var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.createReturn(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -108315,10 +110351,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -108364,29 +110400,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 59 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 189 /* CallExpression */: { + case 191 /* 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 59 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -108426,8 +110462,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: { + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -108435,7 +110471,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: @@ -108478,16 +110514,16 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 274 /* ShorthandPropertyAssignment */: - case 275 /* SpreadAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 277 /* SpreadAssignment */: return undefined; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 154 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); + case 156 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(85 /* ExportKeyword */)], prop); default: ts.Debug.assertNever(prop); } @@ -108536,23 +110572,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.createToken(84 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(85 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* 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, 23 /* DotToken */, sourceFile), [ts.createToken(84 /* ExportKeyword */), ts.createToken(76 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(85 /* ExportKeyword */), ts.createToken(77 /* 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) { - var modifiers = [ts.createToken(84 /* ExportKeyword */)]; + var modifiers = [ts.createToken(85 /* ExportKeyword */)]; switch (exported.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -108560,10 +110596,10 @@ var ts; } } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -108581,7 +110617,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: { + case 184 /* 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 @@ -108592,7 +110628,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 183 /* ArrayBindingPattern */: { + case 185 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -108603,7 +110639,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name); @@ -108675,11 +110711,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node; - case 184 /* BindingElement */: + case 186 /* BindingElement */: return parent.propertyName !== node; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -109018,21 +111054,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 247 /* ImportDeclaration */) + if (declaration.kind !== 249 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 252 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 247 /* ImportDeclaration */) { + if (declaration.kind === 249 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 251 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -109043,7 +111079,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) + return (i.kind === 249 /* ImportDeclaration */ || i.kind === 248 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -109058,7 +111094,7 @@ var ts; }); }); // Sort to keep the shortest paths first - return choicesForEachExportingModule.sort(function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -109066,9 +111102,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 247 /* ImportDeclaration */ + var expression = declaration.kind === 249 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 259 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -109396,12 +111432,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -109456,6 +111492,9 @@ var ts; var errorCodes = [ ts.Diagnostics.Property_0_does_not_exist_on_type_1.code, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code, + ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more.code ]; var fixId = "addMissingMember"; codefix.registerCodeFix({ @@ -109589,7 +111628,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 207 /* ClassExpression */) { + if (classDeclaration.kind === 209 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -109615,13 +111654,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 202 /* BinaryExpression */) { + if (token.parent.parent.kind === 204 /* 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); } - return typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); + else { + var contextualType = checker.getContextualType(token.parent); + typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; + } + return typeNode || ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -109630,7 +111673,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -109654,7 +111697,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(137 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(138 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -109674,7 +111717,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, !ts.isInterfaceDeclaration(typeDecl)); - var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 156 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -109690,7 +111733,7 @@ var ts; */ var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 68 /* StringLike */); + return !!(type && type.flags & 132 /* StringLike */); }); var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); @@ -109939,7 +111982,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 99 /* ThisKeyword */) + if (token.kind !== 100 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -109978,7 +112021,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 124 /* ConstructorKeyword */); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -110016,17 +112059,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 86 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(109 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 85 /* ExtendsKeyword */ && - heritageClauses[1].token === 108 /* ImplementsKeyword */) { + heritageClauses[0].token === 86 /* ExtendsKeyword */ && + heritageClauses[1].token === 109 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(26 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* 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; @@ -110110,7 +112153,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 === 27 /* LessThanToken */) { + if (token.kind === 28 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -110130,7 +112173,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* 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)); @@ -110162,7 +112205,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 126 /* InferKeyword */) + if (token.kind === 127 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -110171,7 +112214,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 27 /* LessThanToken */) { + else if (token.kind === 28 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -110181,7 +112224,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -110192,7 +112235,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(142 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(143 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -110202,13 +112245,13 @@ var ts; } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 92 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { - if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) + if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 149 /* Parameter */) { + if (decl.kind === 151 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -110219,7 +112262,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -110228,7 +112271,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 === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -110237,14 +112280,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 149 /* Parameter */: - case 148 /* TypeParameter */: + case 151 /* Parameter */: + case 150 /* TypeParameter */: return true; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: return true; } } @@ -110258,9 +112301,9 @@ var ts; } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 187 /* PropertyAccessExpression */) + if (ts.isPropertyAccessExpression(ref.parent) && ref.parent.name === ref) ref = ref.parent; - if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + if (ts.isBinaryExpression(ref.parent) && ts.isExpressionStatement(ref.parent.parent) && ref.parent.left === ref) { changes.delete(sourceFile, ref.parent.parent); } }); @@ -110276,33 +112319,41 @@ var ts; } function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { if (mayDeleteParameter(p, checker, isFixAll)) { - changes.delete(sourceFile, p); - deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + if (p.modifiers && p.modifiers.length > 0 + && (!ts.isIdentifier(p.name) || ts.FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) { + p.modifiers.forEach(function (modifier) { + changes.deleteModifier(sourceFile, modifier); + }); + } + else { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + } } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: return true; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 72 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -110342,7 +112393,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 220 /* IfStatement */: + case 222 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -110353,8 +112404,8 @@ var ts; return; } // falls through - case 222 /* WhileStatement */: - case 223 /* ForStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -110403,7 +112454,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, 56 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -110427,10 +112478,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 === 284 /* JSDocNullableType */) { + if (typeNode.kind === 286 /* 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, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -110447,7 +112498,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -110464,22 +112515,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 210 /* AsExpression */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 237 /* FunctionDeclaration */: - case 156 /* GetAccessor */: - case 160 /* IndexSignature */: - case 179 /* MappedType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 192 /* TypeAssertionExpression */: - case 235 /* VariableDeclaration */: + case 212 /* AsExpression */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 239 /* FunctionDeclaration */: + case 158 /* GetAccessor */: + case 162 /* IndexSignature */: + case 181 /* MappedType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 194 /* TypeAssertionExpression */: + case 237 /* VariableDeclaration */: return true; default: return false; @@ -110533,15 +112584,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 90 /* FunctionKeyword */, sourceFile); break; - case 195 /* ArrowFunction */: - insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); + case 197 /* ArrowFunction */: + insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: return; @@ -110555,11 +112606,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 71 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 72 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 120 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 121 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -110649,17 +112700,17 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); switch (declaration.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 151 /* PropertySignature */: - case 152 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 153 /* PropertySignature */: + case 154 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 153 /* MethodSignature */: - case 154 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 156 /* 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 @@ -110677,8 +112728,8 @@ var ts; outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { - var signature = signatures_8[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var signature = signatures_7[_i]; // Need to ensure nodes are fresh each time so they can have different positions. outputMethod(signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } @@ -110699,14 +112750,14 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 156 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(55 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -110722,11 +112773,11 @@ var ts; ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); - var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(119 /* AnyKeyword */); + var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(120 /* AnyKeyword */); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(39 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -110743,8 +112794,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(120 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -110758,8 +112809,8 @@ var ts; var maxArgsSignature = signatures[0]; var minArgumentCount = signatures[0].minArgumentCount; var someSigHasRestParameter = false; - for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) { - var sig = signatures_9[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); if (sig.hasRestParameter) { someSigHasRestParameter = true; @@ -110772,11 +112823,11 @@ 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.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(120 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyArrayType, + /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -110787,7 +112838,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -110796,10 +112847,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(114 /* PublicKeyword */); + return ts.createToken(115 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(113 /* ProtectedKeyword */); + return ts.createToken(114 /* ProtectedKeyword */); } return undefined; } @@ -110807,608 +112858,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - var codefix; - (function (codefix) { - var fixId = "inferFromUsage"; - var errorCodes = [ - // Variable declarations - ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, - // Variable uses - ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, - // Parameter declarations - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, - // Get Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, - ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, - // Set Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, - // Property declarations - ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, - ]; - codefix.registerCodeFix({ - errorCodes: errorCodes, - getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; - var token = ts.getTokenAtPosition(sourceFile, start); - var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); - var name = declaration && ts.getNameOfDeclaration(declaration); - return !name || changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; - }, - fixIds: [fixId], - getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; - var markSeen = ts.nodeSeenTracker(); - return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); - }); - }, - }); - function getDiagnostic(errorCode, token) { - switch (errorCode) { - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - return ts.Diagnostics.Infer_parameter_types_from_usage; - default: - return ts.Diagnostics.Infer_type_of_0_from_usage; - } - } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 71 /* Identifier */ && token.kind !== 24 /* DotDotDotToken */ && token.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var parent = token.parent; - switch (errorCode) { - // Variable and Property declarations - case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: - case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: - if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); - return parent; - } - if (ts.isPropertyAccessExpression(parent)) { - var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); - var typeNode = type && getTypeNodeIfAccessible(type, parent, program, host); - if (typeNode) { - changes.tryInsertJSDocType(sourceFile, parent, typeNode); - } - return parent; - } - return undefined; - case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { - var symbol = program.getTypeChecker().getSymbolAtLocation(token); - if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); - return symbol.valueDeclaration; - } - return undefined; - } - } - var containingFunction = ts.getContainingFunction(token); - if (containingFunction === undefined) { - return undefined; - } - switch (errorCode) { - // Parameter declarations - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - // falls through - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - if (markSeen(containingFunction)) { - var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, param, containingFunction, sourceFile, program, host, cancellationToken); - return param; - } - return undefined; - // Get Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: - case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: - if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); - return containingFunction; - } - return undefined; - // Set Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - return undefined; - default: - return ts.Debug.fail(String(errorCode)); - } - } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { - if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); - } - } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - return true; - case 194 /* FunctionExpression */: - return !!declaration.name; - } - return false; - } - function annotateParameters(changes, parameterDeclaration, containingFunction, sourceFile, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { - return; - } - var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : undefined - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); - if (ts.isInJSFile(containingFunction)) { - annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); - } - else { - 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) { - annotate(changes, sourceFile, declaration, type, program, host); - } - } - } - } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { - var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); - if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { - var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken) || - inferTypeForVariableFromUsage(param.name, program, cancellationToken); - if (ts.isInJSFile(setAccessorDeclaration)) { - annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); - } - else { - annotate(changes, sourceFile, param, type, program, host); - } - } - } - function annotate(changes, sourceFile, declaration, type, program, host) { - var typeNode = type && getTypeNodeIfAccessible(type, declaration, program, host); - if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 151 /* PropertySignature */) { - changes.tryInsertJSDocType(sourceFile, declaration, typeNode); - } - else { - changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); - } - } - } - function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { - var result = ts.mapDefined(parameterInferences, function (inference) { - var param = inference.declaration; - var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); - return typeNode && !param.initializer && !ts.getJSDocType(param) ? __assign({}, inference, { typeNode: typeNode }) : undefined; - }); - changes.tryInsertJSDocParameters(sourceFile, result); - } - function getTypeNodeIfAccessible(type, enclosingScope, program, host) { - var checker = program.getTypeChecker(); - var typeIsAccessible = true; - var notAccessible = function () { typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { - trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; - }, - reportInaccessibleThisError: notAccessible, - reportPrivateInBaseOfClassExpression: notAccessible, - reportInaccessibleUniqueSymbolError: notAccessible, - moduleResolverHost: { - readFile: host.readFile, - fileExists: host.fileExists, - directoryExists: host.directoryExists, - getSourceFiles: program.getSourceFiles, - getCurrentDirectory: program.getCurrentDirectory, - getCommonSourceDirectory: program.getCommonSourceDirectory, - } - }); - return typeIsAccessible ? res : undefined; - } - 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; - }); - } - function inferTypeForVariableFromUsage(token, program, cancellationToken) { - return InferFromReference.inferTypeFromReferences(getReferences(token, program, cancellationToken), program.getTypeChecker(), cancellationToken); - } - function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { - switch (containingFunction.kind) { - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - var isConstructor = containingFunction.kind === 155 /* Constructor */; - var searchToken = isConstructor ? - ts.findChildOfKind(containingFunction, 123 /* ConstructorKeyword */, sourceFile) : - containingFunction.name; - if (searchToken) { - return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program.getTypeChecker(), cancellationToken); - } - } - } - var InferFromReference; - (function (InferFromReference) { - function inferTypeFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { - var reference = references_1[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return getTypeFromUsageContext(usageContext, checker); - } - InferFromReference.inferTypeFromReferences = inferTypeFromReferences; - function inferTypeForParametersFromReferences(references, declaration, checker, cancellationToken) { - if (references.length === 0) { - return undefined; - } - if (!declaration.parameters) { - return undefined; - } - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - var isConstructor = declaration.kind === 155 /* Constructor */; - var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; - return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { - var types = []; - var isRest = ts.isRestParameter(parameter); - var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { - isOptional = ts.isInJSFile(declaration); - continue; - } - if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - } - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - if (!types.length) { - return { declaration: parameter }; - } - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return { - type: isRest ? checker.createArrayType(type) : type, - isOptional: isOptional && !isRest, - declaration: parameter - }; - }); - } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeFromContext(node, checker, usageContext) { - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - switch (node.parent.kind) { - case 201 /* PostfixUnaryExpression */: - usageContext.isNumber = true; - break; - case 200 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); - break; - case 202 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); - break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); - break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); - } - else { - inferTypeFromContextualType(node, checker, usageContext); - } - break; - case 187 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); - break; - case 188 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); - break; - case 235 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); - } - break; - } - } - // falls through - default: - return inferTypeFromContextualType(node, checker, usageContext); - } - } - function inferTypeFromContextualType(node, checker, usageContext) { - if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); - } - } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { - switch (node.operator) { - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - usageContext.isNumber = true; - break; - case 37 /* PlusToken */: - usageContext.isNumberOrString = true; - break; - // case SyntaxKind.ExclamationToken: - // no inferences here; - } - } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { - switch (parent.operatorToken.kind) { - // ExponentiationOperator - case 40 /* AsteriskAsteriskToken */: - // MultiplicativeOperator - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - // ShiftOperator - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - // BitwiseOperator - case 48 /* AmpersandToken */: - case 49 /* BarToken */: - case 50 /* CaretToken */: - // CompoundAssignmentOperator - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 69 /* BarEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - // AdditiveOperator - case 38 /* MinusToken */: - // RelationalOperator - case 27 /* LessThanToken */: - case 30 /* LessThanEqualsToken */: - case 29 /* GreaterThanToken */: - case 31 /* GreaterThanEqualsToken */: - var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, operandType); - } - else { - usageContext.isNumber = true; - } - break; - case 59 /* PlusEqualsToken */: - case 37 /* PlusToken */: - var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); - } - else if (otherOperandType.flags & 168 /* NumberLike */) { - usageContext.isNumber = true; - } - else if (otherOperandType.flags & 68 /* StringLike */) { - usageContext.isString = true; - } - else { - usageContext.isNumberOrString = true; - } - break; - // AssignmentOperators - case 58 /* EqualsToken */: - case 32 /* EqualsEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); - break; - case 92 /* InKeyword */: - if (node === parent.left) { - usageContext.isString = true; - } - break; - // LogicalOperator - case 54 /* BarBarToken */: - if (node === parent.left && - (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { - // var x = x || {}; - // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); - } - break; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: - case 93 /* InstanceOfKeyword */: - // nothing to infer here - break; - } - } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); - } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { - argumentTypes: [], - returnType: {} - }; - if (parent.arguments) { - for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); - } - } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 189 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); - } - else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); - } - } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { - var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); - } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); - } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { - if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; - return; - } - else { - var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 168 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; - } - else { - usageContext.stringIndexContext = indexUsageContext; - } - } - } - function getTypeFromUsageContext(usageContext, checker) { - if (usageContext.isNumberOrString && !usageContext.isNumber && !usageContext.isString) { - return checker.getUnionType([checker.getNumberType(), checker.getStringType()]); - } - else if (usageContext.isNumber) { - return checker.getNumberType(); - } - else if (usageContext.isString) { - return checker.getStringType(); - } - else if (usageContext.candidateTypes) { - return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(function (t) { return checker.getBaseTypeOfLiteralType(t); }), 2 /* Subtype */)); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - return checker.createPromiseType(types.length ? checker.getUnionType(types, 2 /* Subtype */) : checker.getAnyType()); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - return checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker)); - } - else if (usageContext.numberIndexContext) { - return checker.createArrayType(recur(usageContext.numberIndexContext)); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_6 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_6.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 - } - else { - return undefined; - } - function recur(innerContext) { - return getTypeFromUsageContext(innerContext, checker) || checker.getAnyType(); - } - } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { - var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - } - } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; - } - return undefined; - } - function getSignatureFromCallContext(callContext, checker) { - var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - parameters.push(symbol); - } - var returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType(); - // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - } - function addCandidateType(context, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 32768 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); - } - } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); - })(codefix = ts.codefix || (ts.codefix = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var codefix; (function (codefix) { @@ -111441,7 +112890,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 191 /* CallExpression */ : 192 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; @@ -111552,7 +113001,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(51 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -111560,7 +113009,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(141 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -111581,7 +113030,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 512 /* BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.createFalse() : ts.createTrue(); } else if (type.isLiteral()) { @@ -111606,15 +113055,23 @@ var ts; } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/* @internal */ var ts; (function (ts) { function generateTypesForModule(name, moduleValue, formatSettings) { - return valueInfoToDeclarationFileText(ts.inspectValue(name, moduleValue), formatSettings); + return generateTypesForModuleOrGlobal(name, moduleValue, formatSettings, 0 /* ExportEquals */); } ts.generateTypesForModule = generateTypesForModule; - function valueInfoToDeclarationFileText(valueInfo, formatSettings) { - return ts.textChanges.getNewFileText(toStatements(valueInfo, 0 /* ExportEquals */), 3 /* TS */, "\n", ts.formatting.getFormatContext(formatSettings)); + function generateTypesForGlobal(name, globalValue, formatSettings) { + return generateTypesForModuleOrGlobal(name, globalValue, formatSettings, 3 /* Global */); + } + ts.generateTypesForGlobal = generateTypesForGlobal; + function generateTypesForModuleOrGlobal(name, globalValue, formatSettings, outputKind) { + return valueInfoToDeclarationFileText(ts.inspectValue(name, globalValue), formatSettings, outputKind); + } + /* @internal */ + function valueInfoToDeclarationFileText(valueInfo, formatSettings, outputKind) { + if (outputKind === void 0) { outputKind = 0 /* ExportEquals */; } + return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; var OutputKind; @@ -111622,6 +113079,7 @@ var ts; OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; OutputKind[OutputKind["NamedExport"] = 1] = "NamedExport"; OutputKind[OutputKind["NamespaceMember"] = 2] = "NamespaceMember"; + OutputKind[OutputKind["Global"] = 3] = "Global"; })(OutputKind || (OutputKind = {})); function toNamespaceMemberStatements(info) { return toStatements(info, 2 /* NamespaceMember */); @@ -111631,9 +113089,9 @@ var ts; var name = isDefault ? "_default" : info.name; if (!isValidIdentifier(name) || isDefault && kind !== 1 /* NamedExport */) return ts.emptyArray; - var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(84 /* ExportKeyword */), ts.createModifier(79 /* DefaultKeyword */)] - : kind === 0 /* ExportEquals */ ? [ts.createModifier(124 /* DeclareKeyword */)] - : kind === 1 /* NamedExport */ ? [ts.createModifier(84 /* ExportKeyword */)] + var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(85 /* ExportKeyword */), ts.createModifier(80 /* DefaultKeyword */)] + : kind === 3 /* Global */ || kind === 0 /* ExportEquals */ ? [ts.createModifier(125 /* DeclareKeyword */)] + : kind === 1 /* NamedExport */ ? [ts.createModifier(85 /* ExportKeyword */)] : undefined; var exportEquals = function () { return kind === 0 /* ExportEquals */ ? [exportEqualsOrDefault(info.name, /*isExportEquals*/ true)] : ts.emptyArray; }; var exportDefault = function () { return isDefault ? [exportEqualsOrDefault("_default", /*isExportEquals*/ false)] : ts.emptyArray; }; @@ -111641,13 +113099,15 @@ var ts; case 2 /* FunctionOrClass */: return exportEquals().concat(functionOrClassToStatements(modifiers, name, info)); case 3 /* Object */: - var members = info.members; - if (kind === 0 /* ExportEquals */) { - return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); - } - if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { - // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. - return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + var members = info.members, hasNontrivialPrototype = info.hasNontrivialPrototype; + if (!hasNontrivialPrototype) { + if (kind === 0 /* ExportEquals */) { + return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); + } + if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { + // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. + return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + } } // falls through case 0 /* Const */: @@ -111667,8 +113127,20 @@ var ts; var source = _a.source, prototypeMembers = _a.prototypeMembers, namespaceMembers = _a.namespaceMembers; var fnAst = parseClassOrFunctionBody(source); var _b = fnAst === undefined ? { parameters: ts.emptyArray, returnType: anyType() } : getParametersAndReturnType(fnAst), parameters = _b.parameters, returnType = _b.returnType; - var instanceProperties = typeof fnAst === "object" ? getConstructorFunctionInstanceProperties(fnAst) : ts.emptyArray; - var classStaticMembers = instanceProperties.length !== 0 || prototypeMembers.length !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */ ? [] : undefined; + var protoOrInstanceMembers = ts.createMap(); + if (typeof fnAst === "object") + getConstructorFunctionInstanceProperties(fnAst, protoOrInstanceMembers); + for (var _i = 0, prototypeMembers_1 = prototypeMembers; _i < prototypeMembers_1.length; _i++) { + var p = prototypeMembers_1[_i]; + // ignore non-functions on the prototype + if (p.kind === 2 /* FunctionOrClass */) { + var m = tryGetMethod(p); + if (m) { + protoOrInstanceMembers.set(p.name, m); + } + } + } + var classStaticMembers = protoOrInstanceMembers.size !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */ ? [] : undefined; var namespaceStatements = ts.flatMap(namespaceMembers, function (info) { if (!isValidIdentifier(info.name)) return undefined; @@ -111681,16 +113153,19 @@ var ts; // falls through case 1 /* Array */: case 0 /* Const */: - classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(115 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); + classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(116 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); return undefined; case 2 /* FunctionOrClass */: if (!info.namespaceMembers.length) { // Else, can't merge a static method with a namespace. Must make it a function on the namespace. - var sig = tryGetMethod(info, [ts.createModifier(115 /* StaticKeyword */)]); + var sig = tryGetMethod(info, [ts.createModifier(116 /* StaticKeyword */)]); if (sig) { classStaticMembers.push(sig); return undefined; } } + break; + default: + ts.Debug.assertNever(info); } } return toStatements(info, 2 /* NamespaceMember */); @@ -111699,7 +113174,7 @@ var ts; ? ts.createClassDeclaration( /*decorators*/ undefined, modifiers, name, /*typeParameters*/ undefined, - /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), instanceProperties, ts.mapDefined(prototypeMembers, function (info) { return info.kind === 2 /* FunctionOrClass */ ? tryGetMethod(info) : undefined; }))) + /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), ts.arrayFrom(protoOrInstanceMembers.values()))) : ts.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, name, /*typeParameters*/ undefined, parameters, returnType, /*body*/ undefined); return [decl].concat((namespaceStatements.length === 0 ? ts.emptyArray : [createNamespace(modifiers && modifiers.map(function (m) { return ts.getSynthesizedDeepClone(m); }), name, namespaceStatements)])); } @@ -111708,7 +113183,7 @@ var ts; if (!isValidIdentifier(name)) return undefined; var fnAst = parseClassOrFunctionBody(source); - if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */)) + if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */)) return undefined; var sig = getParametersAndReturnType(fnAst); return sig && ts.createMethod( @@ -111727,23 +113202,25 @@ var ts; case 2 /* FunctionOrClass */: return ts.createTypeReferenceNode("Function", /*typeArguments*/ undefined); // Normally we create a FunctionDeclaration, but this can happen for a function in an array. case 3 /* Object */: - return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, m.name, /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); + return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, toPropertyName(m.name), /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); default: return ts.Debug.assertNever(info); } } + function toPropertyName(name) { + return ts.isIdentifierText(name, 6 /* ESNext */) ? ts.createIdentifier(name) : ts.createStringLiteral(name); + } // Parses assignments to "this.x" in the constructor into class property declarations - function getConstructorFunctionInstanceProperties(fnAst) { - var members = []; + function getConstructorFunctionInstanceProperties(fnAst, members) { forEachOwnNodeOfFunction(fnAst, function (node) { if (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && - ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 99 /* ThisKeyword */) { - var name = node.left.name.text; - if (!ts.isJsPrivate(name)) - members.push(ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined)); + ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 100 /* ThisKeyword */) { + var name_6 = node.left.name.text; + if (!ts.isJsPrivate(name_6)) { + ts.getOrUpdate(members, name_6, function () { return ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name_6, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined); }); + } } }); - return members; } function getParametersAndReturnType(fnAst) { if (typeof fnAst === "number") { @@ -111752,16 +113229,16 @@ var ts; var usedArguments = false, hasReturn = false; forEachOwnNodeOfFunction(fnAst, function (node) { usedArguments = usedArguments || ts.isIdentifier(node) && node.text === "arguments"; - hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 198 /* VoidExpression */; + hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 200 /* VoidExpression */; }); var parameters = fnAst.parameters.map(function (p) { return makeParameter("" + p.name.getText(), inferParameterType(fnAst, p)); }).concat((usedArguments ? [makeRestParameter()] : ts.emptyArray)); - return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(105 /* VoidKeyword */) }; + return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(106 /* VoidKeyword */) }; } function makeParameter(name, type) { return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name, /*questionToken*/ undefined, type); } function makeRestParameter() { - return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); + return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); } /** Returns 'undefined' for class with no declared constructor */ function parseClassOrFunctionBody(source) { @@ -111800,7 +113277,7 @@ var ts; return node; } function anyType() { - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createNamespace(modifiers, name, statements) { return ts.createModuleDeclaration(/*decorators*/ undefined, modifiers, ts.createIdentifier(name), ts.createModuleBlock(statements), 16 /* Namespace */); @@ -111902,8 +113379,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 181 /* ImportType */); + ts.Debug.assert(token.kind === 92 /* ImportKeyword */); + ts.Debug.assert(token.parent.kind === 183 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -111955,7 +113432,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(133 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -111975,7 +113452,7 @@ var ts; getAvailableActions: function (context) { var info = getInfo(context); if (!info) - return undefined; + return ts.emptyArray; var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; @@ -112002,16 +113479,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: { + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -112034,17 +113511,17 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 80 /* DefaultKeyword */))); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 85 /* ExportKeyword */)); switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(80 /* DefaultKeyword */)); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. @@ -112052,9 +113529,9 @@ var ts; break; } // falls through - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); @@ -112081,18 +113558,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { + case 253 /* ImportSpecifier */: + case 257 /* 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 248 /* ImportClause */: { + case 250 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref); var spec = makeImportSpecifier(exportName, ref.text); @@ -112101,7 +113578,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 249 /* NamespaceImport */) { + else if (namedBindings.kind === 251 /* 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 */; @@ -112122,36 +113599,33 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { - var spec = parent; - if (spec.kind === 251 /* ImportSpecifier */) { - // `import { foo } from "./a";` --> `import foo from "./a";` - // `import { foo as bar } from "./a";` --> `import bar from "./a";` - var defaultImport = ts.createIdentifier(spec.name.text); - if (spec.parent.elements.length === 1) { - changes.replaceNode(importingSourceFile, spec.parent, defaultImport); - } - else { - changes.delete(importingSourceFile, spec); - changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); - } + case 253 /* ImportSpecifier */: { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(parent.name.text); + if (parent.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, parent.parent, defaultImport); } else { - // `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";` - // (Because `export foo from "./a";` isn't valid syntax.) - changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + changes.delete(importingSourceFile, parent); + changes.insertNodeBefore(importingSourceFile, parent.parent, defaultImport); } break; } + case 257 /* 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";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, parent, makeExportSpecifier("default", parent.name.text)); + break; + } default: - ts.Debug.failBadSyntaxKind(parent); + ts.Debug.assertNever(parent); } } function makeImportSpecifier(propertyName, name) { @@ -112174,9 +113648,9 @@ var ts; getAvailableActions: function (context) { var i = getImportToConvert(context); if (!i) - return undefined; - var description = i.kind === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 249 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return ts.emptyArray; + var description = i.kind === 251 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 251 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { @@ -112198,7 +113672,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 249 /* NamespaceImport */) { + if (toConvert.kind === 251 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -112306,12 +113780,12 @@ var ts; var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context)); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { - return undefined; + return ts.emptyArray; } var extractions = getPossibleExtractions(targetRange, context); if (extractions === undefined) { // No extractions possible - return undefined; + return ts.emptyArray; } var functionActions = []; var usedFunctionNames = ts.createMap(); @@ -112367,7 +113841,7 @@ var ts; actions: constantActions }); } - return infos.length ? infos : undefined; + return infos.length ? infos : ts.emptyArray; } extractSymbol.getAvailableActions = getAvailableActions; /* Exported for tests */ @@ -112541,20 +114015,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 152 /* PropertyDeclaration */) { + if (current.kind === 154 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 149 /* Parameter */) { + else if (current.kind === 151 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 155 /* Constructor */) { + if (ctorOrMethod.kind === 157 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 154 /* MethodDeclaration */) { + else if (current.kind === 156 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -112597,7 +114071,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 235 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 237 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* 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`! @@ -112609,13 +114083,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 97 /* SuperKeyword */: + case 98 /* 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 === 189 /* CallExpression */) { + if (node.parent.kind === 191 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -112630,8 +114104,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -112643,20 +114117,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 220 /* IfStatement */: + case 222 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 216 /* Block */: - if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { + case 218 /* Block */: + if (node.parent && node.parent.kind === 235 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -112668,11 +114142,11 @@ var ts; break; } switch (node.kind) { - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -112680,8 +114154,8 @@ var ts; seenLabels.pop(); break; } - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: { var label = node.label; if (label) { @@ -112691,20 +114165,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 229 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -112758,7 +114232,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 === 149 /* Parameter */) { + if (current.kind === 151 /* 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; } @@ -112769,7 +114243,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 277 /* SourceFile */) { + if (current.kind === 279 /* SourceFile */) { return scopes; } } @@ -112859,32 +114333,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return "arrow function"; - case 154 /* MethodDeclaration */: - return "method '" + scope.name.getText(); - case 156 /* GetAccessor */: + case 156 /* MethodDeclaration */: + return "method '" + scope.name.getText() + "'"; + case 158 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 238 /* ClassDeclaration */ + return scope.kind === 240 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 243 /* ModuleBlock */ + return scope.kind === 245 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -112950,20 +114424,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(112 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(113 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(120 /* AsyncKeyword */)); + modifiers.push(ts.createToken(121 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(121 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* 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; @@ -112980,7 +114454,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -113104,9 +114578,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 140 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 141 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(140 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(141 /* UndefinedKeyword */)]); } } /** @@ -113129,11 +114603,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(112 /* PrivateKeyword */)); + modifiers.push(ts.createToken(113 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } - modifiers.push(ts.createToken(132 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(133 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -113162,7 +114636,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 219 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 221 /* 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.createVariableStatement( @@ -113181,7 +114655,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 219 /* ExpressionStatement */) { + if (node.parent.kind === 221 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -113268,7 +114742,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 230 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -113438,7 +114912,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (4096 /* Void */ | 32768 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -113446,7 +114920,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 239 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -113762,30 +115236,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 276 /* EnumMember */: + case 278 /* EnumMember */: return false; } switch (node.kind) { - case 9 /* StringLiteral */: - return parent.kind !== 247 /* ImportDeclaration */ && - parent.kind !== 251 /* ImportSpecifier */; - case 206 /* SpreadElement */: - case 182 /* ObjectBindingPattern */: - case 184 /* BindingElement */: + case 10 /* StringLiteral */: + return parent.kind !== 249 /* ImportDeclaration */ && + parent.kind !== 253 /* ImportSpecifier */; + case 208 /* SpreadElement */: + case 184 /* ObjectBindingPattern */: + case 186 /* BindingElement */: return false; - case 71 /* Identifier */: - return parent.kind !== 184 /* BindingElement */ && - parent.kind !== 251 /* ImportSpecifier */ && - parent.kind !== 255 /* ExportSpecifier */; + case 72 /* Identifier */: + return parent.kind !== 186 /* BindingElement */ && + parent.kind !== 253 /* ImportSpecifier */ && + parent.kind !== 257 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 216 /* Block */: - case 277 /* SourceFile */: - case 243 /* ModuleBlock */: - case 269 /* CaseClause */: + case 218 /* Block */: + case 279 /* SourceFile */: + case 245 /* ModuleBlock */: + case 271 /* CaseClause */: return true; default: return false; @@ -113806,7 +115280,7 @@ var ts; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { if (!getConvertibleFieldAtPosition(context)) - return undefined; + return ts.emptyArray; return [{ name: actionName, description: actionDescription, @@ -113834,10 +115308,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 114 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 115 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 112 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 113 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -113875,7 +115349,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(115 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(116 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -113898,7 +115372,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 149 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 151 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -113980,7 +115454,7 @@ var ts; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) - return undefined; + return ts.emptyArray; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, @@ -114042,11 +115516,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return true; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -114134,12 +115608,12 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? + case 249 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 251 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -114170,20 +115644,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 249 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 248 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -114253,15 +115727,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -114274,7 +115748,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 251 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -114286,7 +115760,7 @@ var ts; if (namedBindingsUnused) { changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 250 /* NamedImports */) { + else if (namedBindings.kind === 252 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -114299,14 +115773,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: break; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); } @@ -114411,13 +115885,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: return true; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -114429,7 +115903,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -114439,9 +115913,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -114450,7 +115924,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -114460,11 +115934,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return keep(name) ? name : undefined; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return name; - case 182 /* ObjectBindingPattern */: { + case 184 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -114521,13 +115995,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -114535,17 +116009,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return cb(statement); - case 217 /* VariableStatement */: - return ts.forEach(statement.declarationList.declarations, cb); - case 219 /* ExpressionStatement */: { + case 219 /* VariableStatement */: + return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); + case 221 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -114553,11 +116027,29 @@ var ts; } } } + function forEachTopLevelDeclarationInBindingName(name, cb) { + switch (name.kind) { + case 72 /* Identifier */: + return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); + default: + return ts.Debug.assertNever(name); + } + } function nameOfTopLevelDeclaration(d) { - return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return ts.isExpressionStatement(d) ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { - return ts.isVariableDeclaration(d) ? d.parent.parent : d; + switch (d.kind) { + case 237 /* VariableDeclaration */: + return d.parent.parent; + case 186 /* BindingElement */: + return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); + default: + return d; + } } function addExportToChanges(sourceFile, decl, changes, useEs6Exports) { if (isExported(sourceFile, decl, useEs6Exports)) @@ -114584,25 +116076,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(85 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -114613,18 +116105,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -114632,7 +116124,7 @@ var ts; } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 58 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 59 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -114654,7 +116146,7 @@ var ts; var file = context.file, startPosition = context.startPosition; var info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) - return undefined; + return ts.emptyArray; return [{ name: refactorName, description: refactorDescription, @@ -114696,7 +116188,7 @@ var ts; return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { var node = ts.getTokenAtPosition(file, startPosition); @@ -114732,7 +116224,7 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 71 /* Identifier */ ? new IdentifierObject(71 /* Identifier */, pos, end) : + kind === 72 /* Identifier */ ? new IdentifierObject(72 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 12679168 /* ContextFlags */; @@ -114805,8 +116297,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 303 /* LastJSDocNode */; }); - return child.kind < 146 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -114817,7 +116309,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 146 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 148 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -114863,7 +116355,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 71 /* Identifier */) { + if (token === 72 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -114875,7 +116367,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(304 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -115007,7 +116499,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 71 /* Identifier */; + IdentifierObject.prototype.kind = 72 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -115053,25 +116545,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 262144 /* Union */); + return !!(this.flags & 1048576 /* Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 524288 /* Intersection */); + return !!(this.flags & 2097152 /* Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 786432 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 192 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 64 /* StringLiteral */); + return !!(this.flags & 128 /* StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 128 /* NumberLiteral */); + return !!(this.flags & 256 /* NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 65536 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); @@ -115208,10 +116700,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -115231,31 +116723,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 166 /* TypeLiteral */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 168 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: { + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -115266,19 +116758,19 @@ var ts; } } // falls through - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: addDeclaration(node); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -115290,7 +116782,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -115299,7 +116791,7 @@ var ts; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -115612,7 +117104,7 @@ var ts; } var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - var sourceMapper = ts.getSourceMapper(getCanonicalFileName, currentDirectory, log, host, function () { return program; }); + var sourceMapper = ts.getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, function () { return program; }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -115693,11 +117185,11 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }; + compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile); + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -115731,7 +117223,7 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -115888,15 +117380,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return !ts.isLabelName(node); - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 97 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 98 /* SuperKeyword */: return true; default: return false; @@ -115934,7 +117426,7 @@ var ts; var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return ts.Debug.assertDefined(program.getSourceFile(f)); }); + var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -115942,7 +117434,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, position); - if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) { var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); @@ -116003,16 +117495,16 @@ var ts; return undefined; } switch (node.kind) { - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: - case 9 /* StringLiteral */: - case 86 /* FalseKeyword */: - case 101 /* TrueKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 71 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: + case 10 /* StringLiteral */: + case 87 /* FalseKeyword */: + case 102 /* TrueKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 72 /* Identifier */: break; // Cant create the text span default: @@ -116028,7 +117520,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 === 242 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 244 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -116090,10 +117582,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = ts.createMapFromTemplate((_a = {}, - _a[17 /* OpenBraceToken */] = 18 /* CloseBraceToken */, - _a[19 /* OpenParenToken */] = 20 /* CloseParenToken */, - _a[21 /* OpenBracketToken */] = 22 /* CloseBracketToken */, - _a[29 /* GreaterThanToken */] = 27 /* LessThanToken */, + _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, + _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, + _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, + _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -116233,7 +117725,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 29 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -116492,7 +117984,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 257 /* ExternalModuleReference */ || + node.parent.kind === 259 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -116507,15 +117999,15 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 147 /* ComputedPropertyName */) { + if (node.parent.kind === 149 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && + (node.parent.parent.kind === 188 /* ObjectLiteralExpression */ || node.parent.parent.kind === 268 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -116557,7 +118049,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 188 /* ElementAccessExpression */ && + node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -116637,144 +118129,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return spanInVariableDeclaration(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return spanInParameterDeclaration(node); - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanInBlock(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInBlock(node.block); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return spanInForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 233 /* TryStatement */: + case 235 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 184 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 186 /* BindingElement */: // span on complete node return textSpan(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 150 /* Decorator */: + case 152 /* Decorator */: return spanInNodeArray(parent.decorators); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return spanInPreviousNode(node); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 22 /* CloseBracketToken */: + case 23 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return spanInOpenParenToken(node); - case 20 /* CloseParenToken */: + case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 56 /* ColonToken */: + case 57 /* ColonToken */: return spanInColonToken(node); - case 29 /* GreaterThanToken */: - case 27 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 28 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return spanInWhileKeyword(node); - case 82 /* ElseKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 83 /* ElseKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return spanInNextNode(node); - case 145 /* OfKeyword */: + case 147 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -116786,14 +118278,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 === 71 /* Identifier */ || - node.kind === 206 /* SpreadElement */ || - node.kind === 273 /* PropertyAssignment */ || - node.kind === 274 /* ShorthandPropertyAssignment */) && + if ((node.kind === 72 /* Identifier */ || + node.kind === 208 /* SpreadElement */ || + node.kind === 275 /* PropertyAssignment */ || + node.kind === 276 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 202 /* BinaryExpression */) { + if (node.kind === 204 /* 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 @@ -116802,35 +118294,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 58 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 59 /* 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 === 26 /* CommaToken */) { + if (operatorToken.kind === 27 /* CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 150 /* Decorator */: + case 152 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: return textSpan(node); - case 202 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 26 /* CommaToken */) { + case 204 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -116839,21 +118331,21 @@ var ts; } } switch (node.parent.kind) { - case 273 /* PropertyAssignment */: + case 275 /* 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 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: { + case 237 /* VariableDeclaration */: + case 151 /* 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)) { @@ -116861,7 +118353,7 @@ var ts; } break; } - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -116891,7 +118383,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 226 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -116903,7 +118395,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 225 /* ForOfStatement */) { + parent.parent.kind === 227 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -116944,7 +118436,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 240 /* ClassDeclaration */ && functionDeclaration.kind !== 157 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -116967,26 +118459,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 224 /* ForInStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 226 /* 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 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* 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 === 236 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 238 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -117011,21 +118503,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 184 /* BindingElement */) { + if (bindingPattern.parent.kind === 186 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); - var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 185 /* ArrayBindingPattern */ && node.kind !== 184 /* ObjectBindingPattern */); + var elements = node.kind === 187 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -117033,18 +118525,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 === 202 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 204 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -117052,25 +118544,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* EnumDeclaration */: - case 238 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -117078,7 +118570,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); @@ -117094,7 +118586,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 183 /* ArrayBindingPattern */: + case 185 /* 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); @@ -117109,12 +118601,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 189 /* CallExpression */ || - node.parent.kind === 190 /* NewExpression */) { + if (node.parent.kind === 223 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 191 /* CallExpression */ || + node.parent.kind === 192 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 193 /* ParenthesizedExpression */) { + if (node.parent.kind === 195 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -117123,21 +118615,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 193 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 195 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -117147,20 +118639,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ || - node.parent.kind === 149 /* Parameter */) { + node.parent.kind === 275 /* PropertyAssignment */ || + node.parent.kind === 151 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 192 /* TypeAssertionExpression */) { + if (node.parent.kind === 194 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 221 /* DoStatement */) { + if (node.parent.kind === 223 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -117168,7 +118660,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.kind === 227 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -117266,7 +118758,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); // TODO: GH#18217 return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; // TODO: GH#18217 + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } @@ -117276,7 +118768,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); }); // TODO: GH#18217 + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); }; } } @@ -118023,30 +119515,6 @@ var ts; } Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterConstructor: false, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - insertSpaceBeforeFunctionParenthesis: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; function toNormalizedPath(fileName) { return ts.normalizePath(fileName); } @@ -118176,28 +119644,12 @@ var ts; } } server.removeSorted = removeSorted; - function toSortedArray(arr, comparer) { - arr.sort(comparer); - return arr; - } - server.toSortedArray = toSortedArray; - function toDeduplicatedSortedArray(arr) { - arr.sort(); - ts.filterMutate(arr, isNonDuplicateInSortedArray); - return arr; - } - server.toDeduplicatedSortedArray = toDeduplicatedSortedArray; - function isNonDuplicateInSortedArray(value, index, array) { - return index === 0 || value !== array[index - 1]; - } var indentStr = "\n "; - /* @internal */ function indent(str) { return indentStr + str.replace(/\n/g, indentStr); } server.indent = indent; /** Put stringified JSON on the next line, indented. */ - /* @internal */ function stringifyIndented(json) { return indentStr + JSON.stringify(json); } @@ -118338,6 +119790,7 @@ var ts; CommandTypes["GetEditsForFileRename"] = "getEditsForFileRename"; /* @internal */ CommandTypes["GetEditsForFileRenameFull"] = "getEditsForFileRename-full"; + CommandTypes["ConfigurePlugin"] = "configurePlugin"; // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {})); var IndentStyle; @@ -118734,7 +120187,7 @@ var ts; ScriptInfo.prototype.setOptions = function (formatSettings, preferences) { if (formatSettings) { if (!this.formatSettings) { - this.formatSettings = server.getDefaultFormatCodeSettings(this.host); + this.formatSettings = ts.getDefaultFormatCodeSettings(this.host.newLine); ts.assign(this.formatSettings, formatSettings); } else { @@ -118913,7 +120366,7 @@ var ts; } }; TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { - var typings = server.toSortedArray(newTypings); + var typings = ts.sort(newTypings); this.perProjectCache.set(projectName, { compilerOptions: compilerOptions, typeAcquisition: typeAcquisition, @@ -118996,8 +120449,7 @@ var ts; server.isScriptInfo = isScriptInfo; var Project = /** @class */ (function () { /*@internal*/ - function Project( - /*@internal*/ projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, directoryStructureHost, currentDirectory) { + function Project(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, directoryStructureHost, currentDirectory) { var _this = this; this.projectName = projectName; this.projectKind = projectKind; @@ -119125,7 +120577,7 @@ var ts; return this.projectStateVersion.toString(); }; Project.prototype.getProjectReferences = function () { - return server.emptyArray; + return undefined; }; Project.prototype.getScriptFileNames = function () { var _this = this; @@ -119196,14 +120648,14 @@ var ts; var path = this.toPath(file); return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file); }; - Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames) { - return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); + Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { + return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile) { return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile); }; - Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); + Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference) { + return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }; Project.prototype.directoryExists = function (path) { return this.directoryStructureHost.directoryExists(path); // TODO: GH#18217 @@ -119338,11 +120790,11 @@ var ts; }; Project.prototype.getExternalFiles = function () { var _this = this; - return server.toSortedArray(ts.flatMap(this.plugins, function (plugin) { - if (typeof plugin.getExternalFiles !== "function") + return ts.sort(ts.flatMap(this.plugins, function (plugin) { + if (typeof plugin.module.getExternalFiles !== "function") return; try { - return plugin.getExternalFiles(_this); + return plugin.module.getExternalFiles(_this); } catch (e) { _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); @@ -119373,21 +120825,17 @@ var ts; var f = _a[_i]; this.detachScriptInfoIfNotRoot(f.fileName); } - var projectReferences = this.program.getResolvedProjectReferences(); - if (projectReferences) { - for (var _b = 0, projectReferences_2 = projectReferences; _b < projectReferences_2.length; _b++) { - var ref = projectReferences_2[_b]; - if (ref) { - this.detachScriptInfoFromProject(ref.sourceFile.fileName); - } + this.program.forEachResolvedProjectReference(function (ref) { + if (ref) { + _this.detachScriptInfoFromProject(ref.sourceFile.fileName); } - } + }); } // Release external files ts.forEach(this.externalFiles, function (externalFile) { return _this.detachScriptInfoIfNotRoot(externalFile); }); // Always remove root files from the project - for (var _c = 0, _d = this.rootFiles; _c < _d.length; _c++) { - var root = _d[_c]; + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; root.detachFromProject(this); } this.projectService.pendingEnsureProjectForOpenFiles = true; @@ -119562,38 +121010,6 @@ var ts; } }; /* @internal */ - Project.prototype.extractUnresolvedImportsFromSourceFile = function (file, ambientModules) { - var cached = this.cachedUnresolvedImportsPerFile.get(file.path); - if (cached) { - // found cached result, return - return cached; - } - var unresolvedImports; - if (file.resolvedModules) { - file.resolvedModules.forEach(function (resolvedModule, name) { - // pick unresolved non-relative names - if (!resolvedModule && !ts.isExternalModuleNameRelative(name) && !isAmbientlyDeclaredModule(name)) { - // for non-scoped names extract part up-to the first slash - // for scoped names - extract up to the second slash - var trimmed = name.trim(); - var i = trimmed.indexOf("/"); - if (i !== -1 && trimmed.charCodeAt(0) === 64 /* at */) { - i = trimmed.indexOf("/", i + 1); - } - if (i !== -1) { - trimmed = trimmed.substr(0, i); - } - (unresolvedImports || (unresolvedImports = [])).push(trimmed); - } - }); - } - this.cachedUnresolvedImportsPerFile.set(file.path, unresolvedImports || server.emptyArray); - return unresolvedImports || server.emptyArray; - function isAmbientlyDeclaredModule(name) { - return ambientModules.some(function (m) { return m === name; }); - } - }; - /* @internal */ Project.prototype.onFileAddedOrRemoved = function () { this.hasAddedorRemovedFiles = true; }; @@ -119602,7 +121018,6 @@ var ts; * @returns: true if set of files in the project stays the same and false - otherwise. */ Project.prototype.updateGraph = function () { - var _a; this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; @@ -119623,16 +121038,7 @@ var ts; // (can reuse cached imports for files that were not changed) // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch if (hasNewProgram || changedFiles.length) { - var result = void 0; - var ambientModules = this.program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); - for (var _b = 0, _c = this.program.getSourceFiles(); _b < _c.length; _b++) { - var sourceFile = _c[_b]; - var unResolved = this.extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules); - if (unResolved !== server.emptyArray) { - (_a = (result || (result = []))).push.apply(_a, unResolved); - } - } - this.lastCachedUnresolvedImportsList = result ? server.toDeduplicatedSortedArray(result) : server.emptyArray; + this.lastCachedUnresolvedImportsList = getUnresolvedImports(this.program, this.cachedUnresolvedImportsPerFile); } this.projectService.typingsCache.enqueueInstallTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasAddedorRemovedFiles); } @@ -119682,12 +121088,18 @@ var ts; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var f = _a[_i]; - if (this.program.getSourceFileByPath(f.path)) { - continue; + var newFile = this.program.getSourceFileByPath(f.resolvedPath); + if (!newFile || (f.resolvedPath === f.path && newFile.resolvedPath !== f.path)) { + // new program does not contain this file - detach it from the project + // - remove resolutions only if the new program doesnt contain source file by the path (not resolvedPath since path is used for resolution) + this.detachScriptInfoFromProject(f.fileName, !!this.program.getSourceFileByPath(f.path)); } - // new program does not contain this file - detach it from the project - this.detachScriptInfoFromProject(f.fileName); } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !_this.program.getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + _this.detachScriptInfoFromProject(resolvedProjectReference.sourceFile.fileName); + } + }); } // Update the missing file paths watcher ts.updateMissingFilePathsWatch(this.program, this.missingFilesMap || (this.missingFilesMap = ts.createMap()), @@ -119712,11 +121124,13 @@ var ts; this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + " Elapsed: " + elapsed + "ms"); return hasNewProgram; }; - Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName) { + Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { scriptInfoToDetach.detachFromProject(this); - this.resolutionCache.removeResolutionsOfFile(scriptInfoToDetach.path); + if (!noRemoveResolution) { + this.resolutionCache.removeResolutionsOfFile(scriptInfoToDetach.path); + } } }; Project.prototype.addMissingFileWatcher = function (missingFilePath) { @@ -119761,6 +121175,12 @@ var ts; } return strBuilder; }; + /*@internal*/ + Project.prototype.print = function (counter) { + this.writeLog("Project '" + this.projectName + "' (" + ProjectKind[this.projectKind] + ") " + (counter === undefined ? "" : counter)); + this.writeLog(this.filesToString(this.projectService.logger.hasLevel(server.LogLevel.verbose))); + this.writeLog("-----------------------------------------------"); + }; Project.prototype.setCompilerOptions = function (compilerOptions) { if (compilerOptions) { compilerOptions.allowNonTsExtensions = true; @@ -119834,7 +121254,7 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; - Project.prototype.enableGlobalPlugins = function (options) { + Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -119853,7 +121273,7 @@ var ts; return "continue"; // Provide global: true so plugins can detect why they can't find their config this_2.projectService.logger.info("Loading global plugin " + globalPluginName); - this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths); + this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_2 = this; // Enable global plugins with synthetic configuration entries @@ -119863,7 +121283,7 @@ var ts; } } }; - Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { + Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); var log = function (message) { @@ -119873,16 +121293,19 @@ var ts; return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log); }); if (resolvedModule) { + var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); + if (configurationOverride) { + // Preserve the name property since it's immutable + var pluginName = pluginConfigEntry.name; + pluginConfigEntry = configurationOverride; + pluginConfigEntry.name = pluginName; + } this.enableProxy(resolvedModule, pluginConfigEntry); } else { this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); } }; - /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ - Project.prototype.refreshDiagnostics = function () { - this.projectService.sendProjectsUpdatedInBackgroundEvent(); - }; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { @@ -119907,15 +121330,49 @@ var ts; } this.projectService.logger.info("Plugin validation succeded"); this.languageService = newLS; - this.plugins.push(pluginModule); + this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { this.projectService.logger.info("Plugin activation failed: " + e); } }; + /*@internal*/ + Project.prototype.onPluginConfigurationChanged = function (pluginName, configuration) { + this.plugins.filter(function (plugin) { return plugin.name === pluginName; }).forEach(function (plugin) { + if (plugin.module.onConfigurationChanged) { + plugin.module.onConfigurationChanged(configuration); + } + }); + }; + /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ + Project.prototype.refreshDiagnostics = function () { + this.projectService.sendProjectsUpdatedInBackgroundEvent(); + }; return Project; }()); server.Project = Project; + function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) { + var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); + return ts.sortAndDeduplicate(ts.flatMap(program.getSourceFiles(), function (sourceFile) { + return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile); + })); + } + function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) { + return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () { + if (!file.resolvedModules) + return server.emptyArray; + var unresolvedImports; + file.resolvedModules.forEach(function (resolvedModule, name) { + // pick unresolved non-relative names + if ((!resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) && + !ts.isExternalModuleNameRelative(name) && + !ambientModules.some(function (m) { return m === name; })) { + unresolvedImports = ts.append(unresolvedImports, ts.parsePackageName(name).packageName); + } + }); + return unresolvedImports || server.emptyArray; + }); + } /** * If a file is opened and no tsconfig (or jsconfig) is found, * the file and its imports/references are put into an InferredProject. @@ -119923,7 +121380,7 @@ var ts; var InferredProject = /** @class */ (function (_super) { __extends(InferredProject, _super); /*@internal*/ - function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory) { + function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory, pluginConfigOverrides) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, // TODO: GH#18217 /*files*/ undefined, @@ -119934,7 +121391,7 @@ var ts; if (!projectRootPath && !projectService.useSingleInferredProject) { _this.canonicalCurrentDirectory = projectService.toCanonicalFileName(_this.currentDirectory); } - _this.enableGlobalPlugins(_this.getCompilerOptions()); + _this.enableGlobalPlugins(_this.getCompilerOptions(), pluginConfigOverrides); return _this; } InferredProject.prototype.toggleJsInferredProject = function (isJsInferredProject) { @@ -119945,10 +121402,10 @@ var ts; }; InferredProject.prototype.setCompilerOptions = function (options) { // Avoid manipulating the given options directly - var newOptions = options ? ts.cloneCompilerOptions(options) : this.getCompilationSettings(); - if (!newOptions) { + if (!options && !this.getCompilationSettings()) { return; } + var newOptions = ts.cloneCompilerOptions(options || this.getCompilationSettings()); if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") { newOptions.maxNodeModuleJsDepth = 2; } @@ -120066,21 +121523,18 @@ var ts; return server.asNormalizedPath(this.getProjectName()); }; ConfiguredProject.prototype.getProjectReferences = function () { - return this.projectReferences || server.emptyArray; + return this.projectReferences; }; ConfiguredProject.prototype.updateReferences = function (refs) { this.projectReferences = refs; }; /*@internal*/ - ConfiguredProject.prototype.getResolvedProjectReferences = function () { + ConfiguredProject.prototype.forEachResolvedProjectReference = function (cb) { var program = this.getCurrentProgram(); - return program && program.getResolvedProjectReferences(); - }; - ConfiguredProject.prototype.enablePlugins = function () { - this.enablePluginsWithOptions(this.getCompilerOptions()); + return program && program.forEachResolvedProjectReference(cb); }; /*@internal*/ - ConfiguredProject.prototype.enablePluginsWithOptions = function (options) { + ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); @@ -120098,10 +121552,10 @@ var ts; if (options.plugins) { for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { var pluginConfigEntry = _a[_i]; - this.enablePlugin(pluginConfigEntry, searchPaths); + this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides); } } - this.enableGlobalPlugins(options); + this.enableGlobalPlugins(options, pluginConfigOverrides); }; /** * Get the errors that dont have any file name associated @@ -120527,7 +121981,7 @@ var ts; this.typingsInstaller.attach(this); this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { - formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + formatCodeOptions: ts.getDefaultFormatCodeSettings(this.host.newLine), preferences: ts.emptyOptions, hostInfo: "Unknown host", extraFileExtensions: [] @@ -120769,9 +122223,9 @@ var ts; }; /* @internal */ ProjectService.prototype.forEachProject = function (cb) { - this.inferredProjects.forEach(cb); - this.configuredProjects.forEach(cb); this.externalProjects.forEach(cb); + this.configuredProjects.forEach(cb); + this.inferredProjects.forEach(cb); }; /* @internal */ ProjectService.prototype.forEachEnabledProject = function (cb) { @@ -120796,7 +122250,7 @@ var ts; ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) { this.ensureProjectStructuresUptoDate(); var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - return scriptInfo ? scriptInfo.getDefaultProject() : server.Errors.ThrowNoProject(); + return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), server.Errors.ThrowNoProject()); }; ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) { this.ensureProjectStructuresUptoDate(); @@ -120841,15 +122295,20 @@ var ts; if (!info) { this.logger.msg("Error: got watch notification for unknown file: " + fileName); } - else if (eventKind === ts.FileWatcherEventKind.Deleted) { - // File was deleted - this.handleDeletedFile(info); - } - else if (!info.isScriptOpen()) { - // file has been changed which might affect the set of referenced files in projects that include - // this file and set of inferred projects - info.delayReloadNonMixedContentFile(); - this.delayUpdateProjectGraphs(info.containingProjects); + else { + if (info.containingProjects) { + info.containingProjects.forEach(function (project) { return project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(info.path); }); + } + if (eventKind === ts.FileWatcherEventKind.Deleted) { + // File was deleted + this.handleDeletedFile(info); + } + else if (!info.isScriptOpen()) { + // file has been changed which might affect the set of referenced files in projects that include + // this file and set of inferred projects + info.delayReloadNonMixedContentFile(); + this.delayUpdateProjectGraphs(info.containingProjects); + } } }; ProjectService.prototype.handleDeletedFile = function (info) { @@ -120872,6 +122331,8 @@ var ts; return this.watchFactory.watchDirectory(this.host, directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; var configFilename = project.getConfigFilePath(); // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list @@ -120932,10 +122393,12 @@ var ts; this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ false); }; ProjectService.prototype.removeProject = function (project) { - this.logger.info("remove project: " + project.getRootFiles().toString()); + var _this = this; + this.logger.info("`remove Project::"); + project.print(); project.close(); if (ts.Debug.shouldAssert(1 /* Normal */)) { - this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project)); }); + this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return project.projectName + ": ScriptInfos still attached: " + JSON.stringify(ts.mapDefined(ts.arrayFrom(_this.filenameToScriptInfo.values()), function (info) { return info.isAttached(project) ? info : undefined; })); }); }); } // Remove the project from pending project updates this.pendingProjectUpdates.delete(project.getProjectName()); @@ -121329,20 +122792,9 @@ var ts; } var writeProjectFileNames = this.logger.hasLevel(server.LogLevel.verbose); this.logger.startGroup(); - var counter = 0; - var printProjects = function (projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; - _this.logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - _this.logger.info(project.filesToString(writeProjectFileNames)); - _this.logger.info("-----------------------------------------------"); - counter++; - } - return counter; - }; - counter = printProjects(this.externalProjects, counter); - counter = printProjects(ts.arrayFrom(this.configuredProjects.values()), counter); - printProjects(this.inferredProjects, counter); + var counter = printProjectsWithCounter(this.externalProjects, 0); + counter = printProjectsWithCounter(ts.arrayFrom(this.configuredProjects.values()), counter); + printProjectsWithCounter(this.inferredProjects, counter); this.logger.info("Open files: "); this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); @@ -121544,7 +122996,7 @@ var ts; project.enableLanguageService(); project.watchWildcards(ts.createMapFromTemplate(parsedCommandLine.wildcardDirectories)); // TODO: GH#18217 } - project.enablePluginsWithOptions(compilerOptions); + project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); // TODO: GH#18217 }; @@ -121719,7 +123171,7 @@ var ts; }; ProjectService.prototype.createInferredProject = function (currentDirectory, isSingleInferredProject, projectRootPath) { var compilerOptions = projectRootPath && this.compilerOptionsForInferredProjectsPerProjectRoot.get(projectRootPath) || this.compilerOptionsForInferredProjects; - var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory); + var project = new server.InferredProject(this, this.documentRegistry, compilerOptions, projectRootPath, currentDirectory, this.currentPluginConfigOverrides); if (isSingleInferredProject) { this.inferredProjects.unshift(project); } @@ -121745,6 +123197,14 @@ var ts; var configProject = this.configuredProjects.get(uncheckedFileName); return configProject && configProject.getCompilerOptions().configFile; }; + /* @internal */ + ProjectService.prototype.logErrorForScriptInfoNotFound = function (fileName) { + var names = ts.arrayFrom(this.filenameToScriptInfo.entries()).map(function (_a) { + var path = _a[0], scriptInfo = _a[1]; + return ({ path: path, fileName: scriptInfo.fileName }); + }); + this.logger.msg("Could not find file " + JSON.stringify(fileName) + ".\nAll files are: " + JSON.stringify(names), server.Msg.Err); + }; /** * Returns the projects that contain script info through SymLink * Note that this does not return projects in info.containingProjects @@ -121813,6 +123273,8 @@ var ts; var watchDir = dir + "/node_modules"; var watcher = this.watchFactory.watchDirectory(this.host, watchDir, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; // Has extension ts.Debug.assert(result.refCount > 0); if (watchDir === fileOrDirectoryPath) { @@ -121873,7 +123335,18 @@ var ts; } }; ProjectService.prototype.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath = function (fileName, currentDirectory, scriptKind, hasMixedContent, hostToQueryFileExistsOn) { - return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); + if (ts.isRootedDiskPath(fileName) || server.isDynamicFileName(fileName)) { + return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); + } + // This is non rooted path with different current directory than project service current directory + // Only paths recognized are open relative file paths + var info = this.openFilesWithNonRootedDiskPath.get(this.toCanonicalFileName(fileName)); + if (info) { + return info; + } + // This means triple slash references wont be resolved in dynamic and unsaved files + // which is intentional since we dont know what it means to be relative to non disk files + return undefined; }; ProjectService.prototype.getOrCreateScriptInfoOpenedByClientForNormalizedPath = function (fileName, currentDirectory, fileContent, scriptKind, hasMixedContent) { return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ true, fileContent, scriptKind, hasMixedContent); @@ -121888,7 +123361,7 @@ var ts; var info = this.getScriptInfoForPath(path); if (!info) { var isDynamic = server.isDynamicFileName(fileName); - ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info"; }); + ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; }); ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; }); ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always have current directory context since containing external project name will always match the script info name."; }); // If the file is not opened by client and the file doesnot exist on the disk, return @@ -121901,7 +123374,7 @@ var ts; if (!openedByClient) { this.watchClosedScriptInfo(info); } - else if (!ts.isRootedDiskPath(fileName) && currentDirectory !== this.currentDirectory) { + else if (!ts.isRootedDiskPath(fileName) && !isDynamic) { // File that is opened by user but isn't rooted disk path this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info); } @@ -122100,7 +123573,7 @@ var ts; }; /*@internal*/ ProjectService.prototype.getOriginalLocationEnsuringConfiguredProject = function (project, location) { - var originalLocation = project.getSourceMapper().tryGetOriginalLocation(location); + var originalLocation = project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) return undefined; var fileName = originalLocation.fileName; @@ -122225,18 +123698,14 @@ var ts; } else { // If the configured project for project reference has more than zero references, keep it alive - var resolvedProjectReferences = project.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { - var ref = resolvedProjectReferences_1[_i]; - if (ref) { - var refProject = _this.configuredProjects.get(ref.sourceFile.path); - if (refProject && refProject.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); - } + project.forEachResolvedProjectReference(function (ref) { + if (ref) { + var refProject = _this.configuredProjects.get(ref.sourceFile.path); + if (refProject && refProject.hasOpenRef()) { + toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); } } - } + }); } }); // Remove all the non marked projects @@ -122352,8 +123821,8 @@ var ts; ts.forEachKey(this.externalProjectToConfiguredProjectMap, function (externalProjectName) { projectsToClose.set(externalProjectName, true); }); - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var externalProject = projects_4[_i]; + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var externalProject = projects_3[_i]; this.openExternalProject(externalProject); // delete project that is present in input list projectsToClose.delete(externalProject.projectFileName); @@ -122615,6 +124084,14 @@ var ts; } return false; }; + ProjectService.prototype.configurePlugin = function (args) { + // For any projects that already have the plugin loaded, configure the plugin + this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); }); + // Also save the current configuration to pass on to any projects that are yet to be loaded. + // If a plugin is configured twice, only the latest configuration will be remembered. + this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || ts.createMap(); + this.currentPluginConfigOverrides.set(args.pluginName, args.configuration); + }; /** Makes a filename safe to insert in a RegExp */ ProjectService.filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g; return ProjectService; @@ -122625,6 +124102,14 @@ var ts; return config.kind !== undefined; } server.isConfigFile = isConfigFile; + function printProjectsWithCounter(projects, counter) { + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var project = projects_4[_i]; + project.print(counter); + counter++; + } + return counter; + } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; @@ -122820,7 +124305,7 @@ var ts; * This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project. */ function combineProjectOutput(defaultValue, getValue, projects, action) { - var outputs = ts.flatMap(ts.isArray(projects) ? projects : projects.projects, function (project) { return action(project, defaultValue); }); + var outputs = ts.flatMapToMutable(ts.isArray(projects) ? projects : projects.projects, function (project) { return action(project, defaultValue); }); if (!ts.isArray(projects) && projects.symLinkedProjects) { projects.symLinkedProjects.forEach(function (projects, path) { var value = getValue(path); @@ -122837,10 +124322,10 @@ var ts; }); return outputs; } - function combineProjectOutputWhileOpeningReferencedProjects(projects, defaultProject, projectService, action, getLocation, resultsEqual) { + function combineProjectOutputWhileOpeningReferencedProjects(projects, defaultProject, action, getLocation, resultsEqual) { var outputs = []; combineProjectOutputWorker(projects, defaultProject, - /*initialLocation*/ undefined, projectService, function (_a, tryAddToTodo) { + /*initialLocation*/ undefined, function (_a, tryAddToTodo) { var project = _a.project; for (var _i = 0, _b = action(project); _i < _b.length; _i++) { var output = _b[_i]; @@ -122852,11 +124337,11 @@ var ts; /*getDefinition*/ undefined); return outputs; } - function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, projectService, findInStrings, findInComments) { + function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, findInStrings, findInComments) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, function (_a, tryAddToTodo) { + combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, tryAddToTodo) { var project = _a.project, location = _a.location; - for (var _i = 0, _b = project.getLanguageService().findRenameLocations(location.fileName, location.position, findInStrings, findInComments) || server.emptyArray; _i < _b.length; _i++) { + for (var _i = 0, _b = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments) || server.emptyArray; _i < _b.length; _i++) { var output = _b[_i]; if (!ts.contains(outputs, output, ts.documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) { outputs.push(output); @@ -122866,17 +124351,17 @@ var ts; return outputs; } function getDefinitionLocation(defaultProject, initialLocation) { - var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.position); + var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos); var info = infos && ts.firstOrUndefined(infos); - return info && { fileName: info.fileName, position: info.textSpan.start }; + return info && { fileName: info.fileName, pos: info.textSpan.start }; } - function combineProjectOutputForReferences(projects, defaultProject, initialLocation, projectService) { + function combineProjectOutputForReferences(projects, defaultProject, initialLocation) { var outputs = []; - combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, function (_a, getMappedLocation) { + combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, getMappedLocation) { var project = _a.project, location = _a.location; var _loop_32 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); - var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.position, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName }); + var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName }); var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); }); if (!symbolToAddTo) { symbolToAddTo = { definition: definition, references: [] }; @@ -122890,7 +124375,7 @@ var ts; } } }; - for (var _i = 0, _b = project.getLanguageService().findReferences(location.fileName, location.position) || server.emptyArray; _i < _b.length; _i++) { + for (var _i = 0, _b = project.getLanguageService().findReferences(location.fileName, location.pos) || server.emptyArray; _i < _b.length; _i++) { var outputReferencedSymbol = _b[_i]; _loop_32(outputReferencedSymbol); } @@ -122911,12 +124396,13 @@ var ts; }); } } - function combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, cb, getDefinition) { + function combineProjectOutputWorker(projects, defaultProject, initialLocation, cb, getDefinition) { + var projectService = defaultProject.projectService; var toDo; var seenProjects = ts.createMap(); forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, function (project, path) { - // TLocation shoud be either `sourcemaps.SourceMappableLocation` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid. - var location = (initialLocation ? { fileName: path, position: initialLocation.position } : undefined); + // TLocation shoud be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid. + var location = (initialLocation ? { fileName: path, pos: initialLocation.pos } : undefined); toDo = callbackProjectAndLocation({ project: project, location: location }, projectService, toDo, seenProjects, cb); }); // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. @@ -122938,7 +124424,7 @@ var ts; function getDefinitionInProject(definition, definingProject, project) { if (!definition || project.containsFile(server.toNormalizedPath(definition.fileName))) return definition; - var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedLocation(definition); + var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); return mappedDefinition && project.containsFile(server.toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; } function callbackProjectAndLocation(projectAndLocation, projectService, toDo, seenProjects, cb) { @@ -122974,10 +124460,10 @@ var ts; } function documentSpanLocation(_a) { var fileName = _a.fileName, textSpan = _a.textSpan; - return { fileName: fileName, position: textSpan.start }; + return { fileName: fileName, pos: textSpan.start }; } function getMappedLocation(location, projectService, project) { - var mapsTo = project.getSourceMapper().tryGetOriginalLocation(location); + var mapsTo = project.getSourceMapper().tryGetSourcePosition(location); return mapsTo && projectService.fileExists(server.toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined; } var Session = /** @class */ (function () { @@ -123288,6 +124774,10 @@ var ts; _a[server.CommandNames.GetEditsForFileRenameFull] = function (request) { return _this.requiredResponse(_this.getEditsForFileRename(request.arguments, /*simplifiedResult*/ false)); }, + _a[server.CommandNames.ConfigurePlugin] = function (request) { + _this.configurePlugin(request.arguments); + return _this.notRequired(); + }, _a)); this.host = opts.host; this.cancellationToken = opts.cancellationToken; @@ -123345,7 +124835,7 @@ var ts; break; case server.ProjectLoadingFinishEvent: var finishProject = event.data.project; - this.event({ projectName: finishProject.getProjectName() }, server.ProjectLoadingStartEvent); + this.event({ projectName: finishProject.getProjectName() }, server.ProjectLoadingFinishEvent); break; case server.LargeFileReferencedEvent: var _b = event.data, file = _b.file, fileSize = _b.fileSize, maxFileSize_1 = _b.maxFileSize; @@ -123447,7 +124937,27 @@ var ts; success: success, }; if (success) { - res.body = info; + var metadata = void 0; + if (ts.isArray(info)) { + res.body = info; + metadata = info.metadata; + delete info.metadata; + } + else if (typeof info === "object") { + if (info.metadata) { + var _a = info, infoMetadata = _a.metadata, body = __rest(_a, ["metadata"]); + res.body = body; + metadata = infoMetadata; + } + else { + res.body = info; + } + } + else { + res.body = info; + } + if (metadata) + res.metadata = metadata; } else { ts.Debug.assert(info === undefined); @@ -123631,7 +125141,7 @@ var ts; kind: info.kind, name: info.name, textSpan: { - start: newLoc.position, + start: newLoc.pos, length: info.textSpan.length }, originalFileName: info.fileName, @@ -123710,7 +125220,7 @@ var ts; kind: info.kind, displayParts: info.displayParts, textSpan: { - start: newLoc.position, + start: newLoc.pos, length: info.textSpan.length }, originalFileName: info.fileName, @@ -123847,7 +125357,10 @@ var ts; this.projectService.getScriptInfoEnsuringProjectsUptoDate(args.file) : this.projectService.getScriptInfo(args.file); if (!scriptInfo) { - return ignoreNoProjectError ? server.emptyArray : server.Errors.ThrowNoProject(); + if (ignoreNoProjectError) + return server.emptyArray; + this.projectService.logErrorForScriptInfoNotFound(args.file); + return server.Errors.ThrowNoProject(); } projects = scriptInfo.containingProjects; symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo); @@ -123855,6 +125368,7 @@ var ts; // filter handles case when 'projects' is undefined projects = ts.filter(projects, function (p) { return p.languageServiceEnabled && !p.isOrphan(); }); if (!ignoreNoProjectError && (!projects || !projects.length) && !symLinkedProjects) { + this.projectService.logErrorForScriptInfoNotFound(args.file); return server.Errors.ThrowNoProject(); } return symLinkedProjects ? { projects: projects, symLinkedProjects: symLinkedProjects } : projects; // TODO: GH#18217 @@ -123873,7 +125387,7 @@ var ts; var file = server.toNormalizedPath(args.file); var position = this.getPositionInFile(args, file); var projects = this.getProjects(args); - var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, position: position }, this.projectService, !!args.findInStrings, !!args.findInComments); + var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments); if (!simplifiedResult) return locations; var defaultProject = this.getDefaultProject(args); @@ -123907,7 +125421,7 @@ var ts; var file = server.toNormalizedPath(args.file); var projects = this.getProjects(args); var position = this.getPositionInFile(args, file); - var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, position: position }, this.projectService); + var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }); if (simplifiedResult) { var defaultProject = this.getDefaultProject(args); var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); @@ -124144,8 +125658,11 @@ var ts; return { name: name, kind: kind_2, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended }; } }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); - if (kind === "completions" /* Completions */) + if (kind === "completions" /* Completions */) { + if (completions.metadata) + entries.metadata = completions.metadata; return entries; + } var res = __assign({}, completions, { entries: entries }); return res; }; @@ -124354,7 +125871,7 @@ var ts; return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file); } else { - return combineProjectOutputWhileOpeningReferencedProjects(this.getProjects(args), this.getDefaultProject(args), this.projectService, function (project) { + return combineProjectOutputWhileOpeningReferencedProjects(this.getProjects(args), this.getDefaultProject(args), function (project) { return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()); }, documentSpanLocation, navigateToItemIsEqualTo); } @@ -124508,8 +126025,17 @@ var ts; var _this = this; return textChanges.map(function (change) { return _this.mapTextChangeToCodeEdit(change); }); }; - Session.prototype.mapTextChangeToCodeEdit = function (change) { - return mapTextChangesToCodeEdits(change, this.projectService.getScriptInfoOrConfig(change.fileName)); + Session.prototype.mapTextChangeToCodeEdit = function (textChanges) { + var scriptInfo = this.projectService.getScriptInfoOrConfig(textChanges.fileName); + if (!!textChanges.isNewFile === !!scriptInfo) { + if (!scriptInfo) { // and !isNewFile + this.projectService.logErrorForScriptInfoNotFound(textChanges.fileName); + } + ts.Debug.fail("Expected isNewFile for (only) new files. " + JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo })); + } + return scriptInfo + ? { fileName: textChanges.fileName, textChanges: textChanges.textChanges.map(function (textChange) { return convertTextChangeToCodeEdit(textChange, scriptInfo); }) } + : convertNewFileTextChangeToCodeEdit(textChanges); }; Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { return { @@ -124576,6 +126102,9 @@ var ts; // doesn't require the file to be opened this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); }; + Session.prototype.configurePlugin = function (args) { + this.projectService.configurePlugin(args); + }; Session.prototype.getCanonicalFileName = function (fileName) { var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); return ts.normalizePath(name); @@ -124684,12 +126213,6 @@ var ts; function toFileSpan(fileName, textSpan, scriptInfo) { return { file: fileName, start: scriptInfo.positionToLineOffset(textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)) }; } - function mapTextChangesToCodeEdits(textChanges, scriptInfo) { - ts.Debug.assert(!!textChanges.isNewFile === !scriptInfo, "Expected isNewFile for (only) new files", function () { return JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo }); }); - return scriptInfo - ? { fileName: textChanges.fileName, textChanges: textChanges.textChanges.map(function (textChange) { return convertTextChangeToCodeEdit(textChange, scriptInfo); }) } - : convertNewFileTextChangeToCodeEdit(textChanges); - } function convertTextChangeToCodeEdit(change, scriptInfo) { return { start: positionToLineOffset(scriptInfo, change.span.start), end: positionToLineOffset(scriptInfo, ts.textSpanEnd(change.span)), newText: change.newText }; } @@ -125070,7 +126593,6 @@ var ts; }; return LineIndexSnapshot; }()); - /* @internal */ var LineIndex = /** @class */ (function () { function LineIndex() { // set this to true to check each edit for accuracy diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index fdd11aa3484..83a5cab6a59 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -27,6 +27,9 @@ declare namespace ts { interface MapLike { [index: string]: T; } + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedArrayBrand": any; + } interface SortedArray extends Array { " __sortedArrayBrand": any; } @@ -70,7 +73,7 @@ declare namespace ts { end: number; } type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -82,337 +85,339 @@ declare namespace ts { ShebangTrivia = 6, ConflictMarkerTrivia = 7, NumericLiteral = 8, - StringLiteral = 9, - JsxText = 10, - JsxTextAllWhiteSpaces = 11, - RegularExpressionLiteral = 12, - NoSubstitutionTemplateLiteral = 13, - TemplateHead = 14, - TemplateMiddle = 15, - TemplateTail = 16, - OpenBraceToken = 17, - CloseBraceToken = 18, - OpenParenToken = 19, - CloseParenToken = 20, - OpenBracketToken = 21, - CloseBracketToken = 22, - DotToken = 23, - DotDotDotToken = 24, - SemicolonToken = 25, - CommaToken = 26, - LessThanToken = 27, - LessThanSlashToken = 28, - GreaterThanToken = 29, - LessThanEqualsToken = 30, - GreaterThanEqualsToken = 31, - EqualsEqualsToken = 32, - ExclamationEqualsToken = 33, - EqualsEqualsEqualsToken = 34, - ExclamationEqualsEqualsToken = 35, - EqualsGreaterThanToken = 36, - PlusToken = 37, - MinusToken = 38, - AsteriskToken = 39, - AsteriskAsteriskToken = 40, - SlashToken = 41, - PercentToken = 42, - PlusPlusToken = 43, - MinusMinusToken = 44, - LessThanLessThanToken = 45, - GreaterThanGreaterThanToken = 46, - GreaterThanGreaterThanGreaterThanToken = 47, - AmpersandToken = 48, - BarToken = 49, - CaretToken = 50, - ExclamationToken = 51, - TildeToken = 52, - AmpersandAmpersandToken = 53, - BarBarToken = 54, - QuestionToken = 55, - ColonToken = 56, - AtToken = 57, - EqualsToken = 58, - PlusEqualsToken = 59, - MinusEqualsToken = 60, - AsteriskEqualsToken = 61, - AsteriskAsteriskEqualsToken = 62, - SlashEqualsToken = 63, - PercentEqualsToken = 64, - LessThanLessThanEqualsToken = 65, - GreaterThanGreaterThanEqualsToken = 66, - GreaterThanGreaterThanGreaterThanEqualsToken = 67, - AmpersandEqualsToken = 68, - BarEqualsToken = 69, - CaretEqualsToken = 70, - Identifier = 71, - BreakKeyword = 72, - CaseKeyword = 73, - CatchKeyword = 74, - ClassKeyword = 75, - ConstKeyword = 76, - ContinueKeyword = 77, - DebuggerKeyword = 78, - DefaultKeyword = 79, - DeleteKeyword = 80, - DoKeyword = 81, - ElseKeyword = 82, - EnumKeyword = 83, - ExportKeyword = 84, - ExtendsKeyword = 85, - FalseKeyword = 86, - FinallyKeyword = 87, - ForKeyword = 88, - FunctionKeyword = 89, - IfKeyword = 90, - ImportKeyword = 91, - InKeyword = 92, - InstanceOfKeyword = 93, - NewKeyword = 94, - NullKeyword = 95, - ReturnKeyword = 96, - SuperKeyword = 97, - SwitchKeyword = 98, - ThisKeyword = 99, - ThrowKeyword = 100, - TrueKeyword = 101, - TryKeyword = 102, - TypeOfKeyword = 103, - VarKeyword = 104, - VoidKeyword = 105, - WhileKeyword = 106, - WithKeyword = 107, - ImplementsKeyword = 108, - InterfaceKeyword = 109, - LetKeyword = 110, - PackageKeyword = 111, - PrivateKeyword = 112, - ProtectedKeyword = 113, - PublicKeyword = 114, - StaticKeyword = 115, - YieldKeyword = 116, - AbstractKeyword = 117, - AsKeyword = 118, - AnyKeyword = 119, - AsyncKeyword = 120, - AwaitKeyword = 121, - BooleanKeyword = 122, - ConstructorKeyword = 123, - DeclareKeyword = 124, - GetKeyword = 125, - InferKeyword = 126, - IsKeyword = 127, - KeyOfKeyword = 128, - ModuleKeyword = 129, - NamespaceKeyword = 130, - NeverKeyword = 131, - ReadonlyKeyword = 132, - RequireKeyword = 133, - NumberKeyword = 134, - ObjectKeyword = 135, - SetKeyword = 136, - StringKeyword = 137, - SymbolKeyword = 138, - TypeKeyword = 139, - UndefinedKeyword = 140, - UniqueKeyword = 141, - UnknownKeyword = 142, - FromKeyword = 143, - GlobalKeyword = 144, - OfKeyword = 145, - QualifiedName = 146, - ComputedPropertyName = 147, - TypeParameter = 148, - Parameter = 149, - Decorator = 150, - PropertySignature = 151, - PropertyDeclaration = 152, - MethodSignature = 153, - MethodDeclaration = 154, - Constructor = 155, - GetAccessor = 156, - SetAccessor = 157, - CallSignature = 158, - ConstructSignature = 159, - IndexSignature = 160, - TypePredicate = 161, - TypeReference = 162, - FunctionType = 163, - ConstructorType = 164, - TypeQuery = 165, - TypeLiteral = 166, - ArrayType = 167, - TupleType = 168, - OptionalType = 169, - RestType = 170, - UnionType = 171, - IntersectionType = 172, - ConditionalType = 173, - InferType = 174, - ParenthesizedType = 175, - ThisType = 176, - TypeOperator = 177, - IndexedAccessType = 178, - MappedType = 179, - LiteralType = 180, - ImportType = 181, - ObjectBindingPattern = 182, - ArrayBindingPattern = 183, - BindingElement = 184, - ArrayLiteralExpression = 185, - ObjectLiteralExpression = 186, - PropertyAccessExpression = 187, - ElementAccessExpression = 188, - CallExpression = 189, - NewExpression = 190, - TaggedTemplateExpression = 191, - TypeAssertionExpression = 192, - ParenthesizedExpression = 193, - FunctionExpression = 194, - ArrowFunction = 195, - DeleteExpression = 196, - TypeOfExpression = 197, - VoidExpression = 198, - AwaitExpression = 199, - PrefixUnaryExpression = 200, - PostfixUnaryExpression = 201, - BinaryExpression = 202, - ConditionalExpression = 203, - TemplateExpression = 204, - YieldExpression = 205, - SpreadElement = 206, - ClassExpression = 207, - OmittedExpression = 208, - ExpressionWithTypeArguments = 209, - AsExpression = 210, - NonNullExpression = 211, - MetaProperty = 212, - SyntheticExpression = 213, - TemplateSpan = 214, - SemicolonClassElement = 215, - Block = 216, - VariableStatement = 217, - EmptyStatement = 218, - ExpressionStatement = 219, - IfStatement = 220, - DoStatement = 221, - WhileStatement = 222, - ForStatement = 223, - ForInStatement = 224, - ForOfStatement = 225, - ContinueStatement = 226, - BreakStatement = 227, - ReturnStatement = 228, - WithStatement = 229, - SwitchStatement = 230, - LabeledStatement = 231, - ThrowStatement = 232, - TryStatement = 233, - DebuggerStatement = 234, - VariableDeclaration = 235, - VariableDeclarationList = 236, - FunctionDeclaration = 237, - ClassDeclaration = 238, - InterfaceDeclaration = 239, - TypeAliasDeclaration = 240, - EnumDeclaration = 241, - ModuleDeclaration = 242, - ModuleBlock = 243, - CaseBlock = 244, - NamespaceExportDeclaration = 245, - ImportEqualsDeclaration = 246, - ImportDeclaration = 247, - ImportClause = 248, - NamespaceImport = 249, - NamedImports = 250, - ImportSpecifier = 251, - ExportAssignment = 252, - ExportDeclaration = 253, - NamedExports = 254, - ExportSpecifier = 255, - MissingDeclaration = 256, - ExternalModuleReference = 257, - JsxElement = 258, - JsxSelfClosingElement = 259, - JsxOpeningElement = 260, - JsxClosingElement = 261, - JsxFragment = 262, - JsxOpeningFragment = 263, - JsxClosingFragment = 264, - JsxAttribute = 265, - JsxAttributes = 266, - JsxSpreadAttribute = 267, - JsxExpression = 268, - CaseClause = 269, - DefaultClause = 270, - HeritageClause = 271, - CatchClause = 272, - PropertyAssignment = 273, - ShorthandPropertyAssignment = 274, - SpreadAssignment = 275, - EnumMember = 276, - SourceFile = 277, - Bundle = 278, - UnparsedSource = 279, - InputFiles = 280, - JSDocTypeExpression = 281, - JSDocAllType = 282, - JSDocUnknownType = 283, - JSDocNullableType = 284, - JSDocNonNullableType = 285, - JSDocOptionalType = 286, - JSDocFunctionType = 287, - JSDocVariadicType = 288, - JSDocComment = 289, - JSDocTypeLiteral = 290, - JSDocSignature = 291, - JSDocTag = 292, - JSDocAugmentsTag = 293, - JSDocClassTag = 294, - JSDocCallbackTag = 295, - JSDocEnumTag = 296, - JSDocParameterTag = 297, - JSDocReturnTag = 298, - JSDocThisTag = 299, - JSDocTypeTag = 300, - JSDocTemplateTag = 301, - JSDocTypedefTag = 302, - JSDocPropertyTag = 303, - SyntaxList = 304, - NotEmittedStatement = 305, - PartiallyEmittedExpression = 306, - CommaListExpression = 307, - MergeDeclarationMarker = 308, - EndOfDeclarationMarker = 309, - Count = 310, - FirstAssignment = 58, - LastAssignment = 70, - FirstCompoundAssignment = 59, - LastCompoundAssignment = 70, - FirstReservedWord = 72, - LastReservedWord = 107, - FirstKeyword = 72, - LastKeyword = 145, - FirstFutureReservedWord = 108, - LastFutureReservedWord = 116, - FirstTypeNode = 161, - LastTypeNode = 181, - FirstPunctuation = 17, - LastPunctuation = 70, + BigIntLiteral = 9, + StringLiteral = 10, + JsxText = 11, + JsxTextAllWhiteSpaces = 12, + RegularExpressionLiteral = 13, + NoSubstitutionTemplateLiteral = 14, + TemplateHead = 15, + TemplateMiddle = 16, + TemplateTail = 17, + OpenBraceToken = 18, + CloseBraceToken = 19, + OpenParenToken = 20, + CloseParenToken = 21, + OpenBracketToken = 22, + CloseBracketToken = 23, + DotToken = 24, + DotDotDotToken = 25, + SemicolonToken = 26, + CommaToken = 27, + LessThanToken = 28, + LessThanSlashToken = 29, + GreaterThanToken = 30, + LessThanEqualsToken = 31, + GreaterThanEqualsToken = 32, + EqualsEqualsToken = 33, + ExclamationEqualsToken = 34, + EqualsEqualsEqualsToken = 35, + ExclamationEqualsEqualsToken = 36, + EqualsGreaterThanToken = 37, + PlusToken = 38, + MinusToken = 39, + AsteriskToken = 40, + AsteriskAsteriskToken = 41, + SlashToken = 42, + PercentToken = 43, + PlusPlusToken = 44, + MinusMinusToken = 45, + LessThanLessThanToken = 46, + GreaterThanGreaterThanToken = 47, + GreaterThanGreaterThanGreaterThanToken = 48, + AmpersandToken = 49, + BarToken = 50, + CaretToken = 51, + ExclamationToken = 52, + TildeToken = 53, + AmpersandAmpersandToken = 54, + BarBarToken = 55, + QuestionToken = 56, + ColonToken = 57, + AtToken = 58, + EqualsToken = 59, + PlusEqualsToken = 60, + MinusEqualsToken = 61, + AsteriskEqualsToken = 62, + AsteriskAsteriskEqualsToken = 63, + SlashEqualsToken = 64, + PercentEqualsToken = 65, + LessThanLessThanEqualsToken = 66, + GreaterThanGreaterThanEqualsToken = 67, + GreaterThanGreaterThanGreaterThanEqualsToken = 68, + AmpersandEqualsToken = 69, + BarEqualsToken = 70, + CaretEqualsToken = 71, + Identifier = 72, + BreakKeyword = 73, + CaseKeyword = 74, + CatchKeyword = 75, + ClassKeyword = 76, + ConstKeyword = 77, + ContinueKeyword = 78, + DebuggerKeyword = 79, + DefaultKeyword = 80, + DeleteKeyword = 81, + DoKeyword = 82, + ElseKeyword = 83, + EnumKeyword = 84, + ExportKeyword = 85, + ExtendsKeyword = 86, + FalseKeyword = 87, + FinallyKeyword = 88, + ForKeyword = 89, + FunctionKeyword = 90, + IfKeyword = 91, + ImportKeyword = 92, + InKeyword = 93, + InstanceOfKeyword = 94, + NewKeyword = 95, + NullKeyword = 96, + ReturnKeyword = 97, + SuperKeyword = 98, + SwitchKeyword = 99, + ThisKeyword = 100, + ThrowKeyword = 101, + TrueKeyword = 102, + TryKeyword = 103, + TypeOfKeyword = 104, + VarKeyword = 105, + VoidKeyword = 106, + WhileKeyword = 107, + WithKeyword = 108, + ImplementsKeyword = 109, + InterfaceKeyword = 110, + LetKeyword = 111, + PackageKeyword = 112, + PrivateKeyword = 113, + ProtectedKeyword = 114, + PublicKeyword = 115, + StaticKeyword = 116, + YieldKeyword = 117, + AbstractKeyword = 118, + AsKeyword = 119, + AnyKeyword = 120, + AsyncKeyword = 121, + AwaitKeyword = 122, + BooleanKeyword = 123, + ConstructorKeyword = 124, + DeclareKeyword = 125, + GetKeyword = 126, + InferKeyword = 127, + IsKeyword = 128, + KeyOfKeyword = 129, + ModuleKeyword = 130, + NamespaceKeyword = 131, + NeverKeyword = 132, + ReadonlyKeyword = 133, + RequireKeyword = 134, + NumberKeyword = 135, + ObjectKeyword = 136, + SetKeyword = 137, + StringKeyword = 138, + SymbolKeyword = 139, + TypeKeyword = 140, + UndefinedKeyword = 141, + UniqueKeyword = 142, + UnknownKeyword = 143, + FromKeyword = 144, + GlobalKeyword = 145, + BigIntKeyword = 146, + OfKeyword = 147, + QualifiedName = 148, + ComputedPropertyName = 149, + TypeParameter = 150, + Parameter = 151, + Decorator = 152, + PropertySignature = 153, + PropertyDeclaration = 154, + MethodSignature = 155, + MethodDeclaration = 156, + Constructor = 157, + GetAccessor = 158, + SetAccessor = 159, + CallSignature = 160, + ConstructSignature = 161, + IndexSignature = 162, + TypePredicate = 163, + TypeReference = 164, + FunctionType = 165, + ConstructorType = 166, + TypeQuery = 167, + TypeLiteral = 168, + ArrayType = 169, + TupleType = 170, + OptionalType = 171, + RestType = 172, + UnionType = 173, + IntersectionType = 174, + ConditionalType = 175, + InferType = 176, + ParenthesizedType = 177, + ThisType = 178, + TypeOperator = 179, + IndexedAccessType = 180, + MappedType = 181, + LiteralType = 182, + ImportType = 183, + ObjectBindingPattern = 184, + ArrayBindingPattern = 185, + BindingElement = 186, + ArrayLiteralExpression = 187, + ObjectLiteralExpression = 188, + PropertyAccessExpression = 189, + ElementAccessExpression = 190, + CallExpression = 191, + NewExpression = 192, + TaggedTemplateExpression = 193, + TypeAssertionExpression = 194, + ParenthesizedExpression = 195, + FunctionExpression = 196, + ArrowFunction = 197, + DeleteExpression = 198, + TypeOfExpression = 199, + VoidExpression = 200, + AwaitExpression = 201, + PrefixUnaryExpression = 202, + PostfixUnaryExpression = 203, + BinaryExpression = 204, + ConditionalExpression = 205, + TemplateExpression = 206, + YieldExpression = 207, + SpreadElement = 208, + ClassExpression = 209, + OmittedExpression = 210, + ExpressionWithTypeArguments = 211, + AsExpression = 212, + NonNullExpression = 213, + MetaProperty = 214, + SyntheticExpression = 215, + TemplateSpan = 216, + SemicolonClassElement = 217, + Block = 218, + VariableStatement = 219, + EmptyStatement = 220, + ExpressionStatement = 221, + IfStatement = 222, + DoStatement = 223, + WhileStatement = 224, + ForStatement = 225, + ForInStatement = 226, + ForOfStatement = 227, + ContinueStatement = 228, + BreakStatement = 229, + ReturnStatement = 230, + WithStatement = 231, + SwitchStatement = 232, + LabeledStatement = 233, + ThrowStatement = 234, + TryStatement = 235, + DebuggerStatement = 236, + VariableDeclaration = 237, + VariableDeclarationList = 238, + FunctionDeclaration = 239, + ClassDeclaration = 240, + InterfaceDeclaration = 241, + TypeAliasDeclaration = 242, + EnumDeclaration = 243, + ModuleDeclaration = 244, + ModuleBlock = 245, + CaseBlock = 246, + NamespaceExportDeclaration = 247, + ImportEqualsDeclaration = 248, + ImportDeclaration = 249, + ImportClause = 250, + NamespaceImport = 251, + NamedImports = 252, + ImportSpecifier = 253, + ExportAssignment = 254, + ExportDeclaration = 255, + NamedExports = 256, + ExportSpecifier = 257, + MissingDeclaration = 258, + ExternalModuleReference = 259, + JsxElement = 260, + JsxSelfClosingElement = 261, + JsxOpeningElement = 262, + JsxClosingElement = 263, + JsxFragment = 264, + JsxOpeningFragment = 265, + JsxClosingFragment = 266, + JsxAttribute = 267, + JsxAttributes = 268, + JsxSpreadAttribute = 269, + JsxExpression = 270, + CaseClause = 271, + DefaultClause = 272, + HeritageClause = 273, + CatchClause = 274, + PropertyAssignment = 275, + ShorthandPropertyAssignment = 276, + SpreadAssignment = 277, + EnumMember = 278, + SourceFile = 279, + Bundle = 280, + UnparsedSource = 281, + InputFiles = 282, + JSDocTypeExpression = 283, + JSDocAllType = 284, + JSDocUnknownType = 285, + JSDocNullableType = 286, + JSDocNonNullableType = 287, + JSDocOptionalType = 288, + JSDocFunctionType = 289, + JSDocVariadicType = 290, + JSDocComment = 291, + JSDocTypeLiteral = 292, + JSDocSignature = 293, + JSDocTag = 294, + JSDocAugmentsTag = 295, + JSDocClassTag = 296, + JSDocCallbackTag = 297, + JSDocEnumTag = 298, + JSDocParameterTag = 299, + JSDocReturnTag = 300, + JSDocThisTag = 301, + JSDocTypeTag = 302, + JSDocTemplateTag = 303, + JSDocTypedefTag = 304, + JSDocPropertyTag = 305, + SyntaxList = 306, + NotEmittedStatement = 307, + PartiallyEmittedExpression = 308, + CommaListExpression = 309, + MergeDeclarationMarker = 310, + EndOfDeclarationMarker = 311, + Count = 312, + FirstAssignment = 59, + LastAssignment = 71, + FirstCompoundAssignment = 60, + LastCompoundAssignment = 71, + FirstReservedWord = 73, + LastReservedWord = 108, + FirstKeyword = 73, + LastKeyword = 147, + FirstFutureReservedWord = 109, + LastFutureReservedWord = 117, + FirstTypeNode = 163, + LastTypeNode = 183, + FirstPunctuation = 18, + LastPunctuation = 71, FirstToken = 0, - LastToken = 145, + LastToken = 147, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 13, - FirstTemplateToken = 13, - LastTemplateToken = 16, - FirstBinaryOperator = 27, - LastBinaryOperator = 70, - FirstNode = 146, - FirstJSDocNode = 281, - LastJSDocNode = 303, - FirstJSDocTagNode = 292, - LastJSDocTagNode = 303 + LastLiteralToken = 14, + FirstTemplateToken = 14, + LastTemplateToken = 17, + FirstBinaryOperator = 28, + LastBinaryOperator = 71, + FirstNode = 148, + FirstJSDocNode = 283, + LastJSDocNode = 305, + FirstJSDocTagNode = 294, + LastJSDocTagNode = 305 } enum NodeFlags { None = 0, @@ -499,7 +504,6 @@ declare namespace ts { type AsteriskToken = Token; type EqualsGreaterThanToken = Token; type EndOfFileToken = Token & JSDocContainer; - type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; type PlusToken = Token; @@ -526,7 +530,7 @@ declare namespace ts { } type EntityName = Identifier | QualifiedName; type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern; + type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; interface Declaration extends Node { _declarationBrand: any; } @@ -724,7 +728,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; @@ -996,6 +1000,9 @@ declare namespace ts { interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } + interface BigIntLiteral extends LiteralExpression { + kind: SyntaxKind.BigIntLiteral; + } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; @@ -1543,7 +1550,6 @@ declare namespace ts { } interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; - atToken: AtToken; tagName: Identifier; comment?: string; } @@ -1573,7 +1579,7 @@ declare namespace ts { } interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; - constraint: TypeNode | undefined; + constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } interface JSDocReturnTag extends JSDocTag { @@ -1755,13 +1761,14 @@ declare namespace ts { } interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; + readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. */ fileExists(path: string): boolean; readFile(path: string): string | undefined; + trace?(s: string): void; } /** * Branded string for keeping track of when we've turned an ambiguous path @@ -1813,11 +1820,12 @@ declare namespace ts { isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; + getResolvedProjectReferences(): ReadonlyArray | undefined; } interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; + references?: ReadonlyArray; } interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ @@ -1841,17 +1849,6 @@ declare namespace ts { /** .ts file (index into sources array) associated with this span */ sourceIndex: number; } - interface SourceMapData { - sourceMapFilePath: string; - jsSourceMappingURL: string; - sourceMapFile: string; - sourceMapSourceRoot: string; - sourceMapSources: string[]; - sourceMapSourcesContent?: (string | null)[]; - inputSourceFileNames: string[]; - sourceMapNames?: string[]; - sourceMapMappings: string; - } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { Success = 0, @@ -1923,7 +1920,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): Symbol[]; + getRootSymbols(symbol: Symbol): ReadonlyArray; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -1941,7 +1938,6 @@ declare namespace ts { /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined; getJsxIntrinsicTagNamesAt(location: Node): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; @@ -2160,44 +2156,47 @@ declare namespace ts { Number = 8, Boolean = 16, Enum = 32, - StringLiteral = 64, - NumberLiteral = 128, - BooleanLiteral = 256, - EnumLiteral = 512, - ESSymbol = 1024, - UniqueESSymbol = 2048, - Void = 4096, - Undefined = 8192, - Null = 16384, - Never = 32768, - TypeParameter = 65536, - Object = 131072, - Union = 262144, - Intersection = 524288, - Index = 1048576, - IndexedAccess = 2097152, - Conditional = 4194304, - Substitution = 8388608, - NonPrimitive = 16777216, - Literal = 448, - Unit = 27072, - StringOrNumberLiteral = 192, - PossiblyFalsy = 29148, - StringLike = 68, - NumberLike = 168, - BooleanLike = 272, - EnumLike = 544, - ESSymbolLike = 3072, - VoidLike = 12288, - UnionOrIntersection = 786432, - StructuredType = 917504, - TypeVariable = 2162688, - InstantiableNonPrimitive = 14745600, - InstantiablePrimitive = 1048576, - Instantiable = 15794176, - StructuredOrInstantiable = 16711680, - Narrowable = 33492479, - NotUnionOrUnit = 16909315 + BigInt = 64, + StringLiteral = 128, + NumberLiteral = 256, + BooleanLiteral = 512, + EnumLiteral = 1024, + BigIntLiteral = 2048, + ESSymbol = 4096, + UniqueESSymbol = 8192, + Void = 16384, + Undefined = 32768, + Null = 65536, + Never = 131072, + TypeParameter = 262144, + Object = 524288, + Union = 1048576, + Intersection = 2097152, + Index = 4194304, + IndexedAccess = 8388608, + Conditional = 16777216, + Substitution = 33554432, + NonPrimitive = 67108864, + Literal = 2944, + Unit = 109440, + StringOrNumberLiteral = 384, + PossiblyFalsy = 117724, + StringLike = 132, + NumberLike = 296, + BigIntLike = 2112, + BooleanLike = 528, + EnumLike = 1056, + ESSymbolLike = 12288, + VoidLike = 49152, + UnionOrIntersection = 3145728, + StructuredType = 3670016, + TypeVariable = 8650752, + InstantiableNonPrimitive = 58982400, + InstantiablePrimitive = 4194304, + Instantiable = 63176704, + StructuredOrInstantiable = 66846720, + Narrowable = 133970943, + NotUnionOrUnit = 67637251 } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2208,7 +2207,7 @@ declare namespace ts { aliasTypeArguments?: ReadonlyArray; } interface LiteralType extends Type { - value: string | number; + value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } @@ -2221,6 +2220,9 @@ declare namespace ts { interface NumberLiteralType extends LiteralType { value: number; } + interface BigIntLiteralType extends LiteralType { + value: PseudoBigInt; + } interface EnumType extends Type { } enum ObjectFlags { @@ -2239,6 +2241,7 @@ declare namespace ts { JsxAttributes = 4096, MarkerType = 8192, JSLiteral = 16384, + FreshLiteral = 32768, ClassOrInterface = 3 } interface ObjectType extends Type { @@ -2670,6 +2673,8 @@ declare namespace ts { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; + /** True if `resolvedFileName` comes from `node_modules`. */ + isExternalLibraryImport?: boolean; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; @@ -2688,11 +2693,11 @@ declare namespace ts { useCaseSensitiveFileNames(): boolean; getNewLine(): string; readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; } @@ -2747,7 +2752,8 @@ declare namespace ts { Expression = 1, IdentifierName = 2, MappedTypeParameter = 3, - Unspecified = 4 + Unspecified = 4, + EmbeddedStatement = 5 } interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ @@ -2940,60 +2946,62 @@ declare namespace ts { BarDelimited = 4, AmpersandDelimited = 8, CommaDelimited = 16, - DelimitersMask = 28, - AllowTrailingComma = 32, - Indented = 64, - SpaceBetweenBraces = 128, - SpaceBetweenSiblings = 256, - Braces = 512, - Parenthesis = 1024, - AngleBrackets = 2048, - SquareBrackets = 4096, - BracketsMask = 7680, - OptionalIfUndefined = 8192, - OptionalIfEmpty = 16384, - Optional = 24576, - PreferNewLine = 32768, - NoTrailingNewLine = 65536, - NoInterveningComments = 131072, - NoSpaceIfEmpty = 262144, - SingleElement = 524288, - Modifiers = 131328, - HeritageClauses = 256, - SingleLineTypeLiteralMembers = 384, - MultiLineTypeLiteralMembers = 16449, - TupleTypeElements = 272, - UnionTypeConstituents = 260, - IntersectionTypeConstituents = 264, - ObjectBindingPatternElements = 262576, - ArrayBindingPatternElements = 262448, - ObjectLiteralExpressionProperties = 263122, - ArrayLiteralExpressionElements = 4466, - CommaListElements = 272, - CallExpressionArguments = 1296, - NewExpressionArguments = 9488, - TemplateExpressionSpans = 131072, - SingleLineBlockStatements = 384, - MultiLineBlockStatements = 65, - VariableDeclarationList = 272, - SingleLineFunctionBodyStatements = 384, + AsteriskDelimited = 32, + DelimitersMask = 60, + AllowTrailingComma = 64, + Indented = 128, + SpaceBetweenBraces = 256, + SpaceBetweenSiblings = 512, + Braces = 1024, + Parenthesis = 2048, + AngleBrackets = 4096, + SquareBrackets = 8192, + BracketsMask = 15360, + OptionalIfUndefined = 16384, + OptionalIfEmpty = 32768, + Optional = 49152, + PreferNewLine = 65536, + NoTrailingNewLine = 131072, + NoInterveningComments = 262144, + NoSpaceIfEmpty = 524288, + SingleElement = 1048576, + Modifiers = 262656, + HeritageClauses = 512, + SingleLineTypeLiteralMembers = 768, + MultiLineTypeLiteralMembers = 32897, + TupleTypeElements = 528, + UnionTypeConstituents = 516, + IntersectionTypeConstituents = 520, + ObjectBindingPatternElements = 525136, + ArrayBindingPatternElements = 524880, + ObjectLiteralExpressionProperties = 526226, + ArrayLiteralExpressionElements = 8914, + CommaListElements = 528, + CallExpressionArguments = 2576, + NewExpressionArguments = 18960, + TemplateExpressionSpans = 262144, + SingleLineBlockStatements = 768, + MultiLineBlockStatements = 129, + VariableDeclarationList = 528, + SingleLineFunctionBodyStatements = 768, MultiLineFunctionBodyStatements = 1, ClassHeritageClauses = 0, - ClassMembers = 65, - InterfaceMembers = 65, - EnumMembers = 81, - CaseBlockClauses = 65, - NamedImportsOrExportsElements = 262576, - JsxElementOrFragmentChildren = 131072, - JsxElementAttributes = 131328, - CaseOrDefaultClauseStatements = 81985, - HeritageClauseTypes = 272, - SourceFileStatements = 65537, - Decorators = 24577, - TypeArguments = 26896, - TypeParameters = 26896, - Parameters = 1296, - IndexSignatureParameters = 4432 + ClassMembers = 129, + InterfaceMembers = 129, + EnumMembers = 145, + CaseBlockClauses = 129, + NamedImportsOrExportsElements = 525136, + JsxElementOrFragmentChildren = 262144, + JsxElementAttributes = 262656, + CaseOrDefaultClauseStatements = 163969, + HeritageClauseTypes = 528, + SourceFileStatements = 131073, + Decorators = 49153, + TypeArguments = 53776, + TypeParameters = 53776, + Parameters = 2576, + IndexSignatureParameters = 8848, + JSDocComment = 33 } interface UserPreferences { readonly disableSuggestions?: boolean; @@ -3005,6 +3013,11 @@ declare namespace ts { readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; readonly allowTextChangesInNewFiles?: boolean; } + /** Represents a bigint literal value without requiring bigint support */ + interface PseudoBigInt { + negative: boolean; + base10Value: string; + } } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -3121,7 +3134,7 @@ declare namespace ts { /** Non-internal stuff goes here */ declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): T[]; + function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3287,6 +3300,7 @@ declare namespace ts { } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; + function isBigIntLiteral(node: Node): node is BigIntLiteral; function isStringLiteral(node: Node): node is StringLiteral; function isJsxText(node: Node): node is JsxText; function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral; @@ -3606,7 +3620,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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -3621,14 +3635,14 @@ declare namespace ts { * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string): Map; + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ interface NonRelativeModuleNameResolutionCache { - getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; @@ -3636,18 +3650,19 @@ declare namespace ts { } function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; - function createLiteral(value: number): NumericLiteral; + function createLiteral(value: number | PseudoBigInt): NumericLiteral; function createLiteral(value: boolean): BooleanLiteral; - function createLiteral(value: string | number | boolean): PrimaryExpression; + function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression; function createNumericLiteral(value: string): NumericLiteral; + function createBigIntLiteral(value: string): BigIntLiteral; function createStringLiteral(text: string): StringLiteral; function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; function createIdentifier(text: string): Identifier; @@ -4148,7 +4163,7 @@ declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -4384,9 +4399,9 @@ declare namespace ts { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; } /** * Host to create watch with root files and options @@ -4452,9 +4467,6 @@ declare namespace ts.server { type EventBeginInstallTypes = "event::beginInstallTypes"; type EventEndInstallTypes = "event::endInstallTypes"; type EventInitializationFailed = "event::initializationFailed"; - interface SortedReadonlyArray extends ReadonlyArray { - " __sortedArrayBrand": any; - } interface TypingInstallerResponse { readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | ActionValueInspected | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed; } @@ -4654,9 +4666,9 @@ declare namespace ts { realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4666,6 +4678,9 @@ declare namespace ts { installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; } + type WithMetadata = T & { + metadata?: unknown; + }; interface LanguageService { cleanupSemanticCache(): void; getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; @@ -4683,7 +4698,7 @@ declare namespace ts { getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined; + getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): WithMetadata | undefined; getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; @@ -4691,16 +4706,16 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; - getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; + getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -5040,24 +5055,25 @@ declare namespace ts { insertSpaceBeforeTypeAnnotation?: boolean; } interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterConstructor?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceAfterTypeAssertion?: boolean; - insertSpaceBeforeFunctionParenthesis?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - insertSpaceBeforeTypeAnnotation?: boolean; - indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly insertSpaceAfterCommaDelimiter?: boolean; + readonly insertSpaceAfterSemicolonInForStatements?: boolean; + readonly insertSpaceBeforeAndAfterBinaryOperators?: boolean; + readonly insertSpaceAfterConstructor?: boolean; + readonly insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + readonly insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + readonly insertSpaceAfterTypeAssertion?: boolean; + readonly insertSpaceBeforeFunctionParenthesis?: boolean; + readonly placeOpenBraceOnNewLineForFunctions?: boolean; + readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; + readonly insertSpaceBeforeTypeAnnotation?: boolean; + readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; } + function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { kind: ScriptElementKind; name: string; @@ -5250,8 +5266,9 @@ declare namespace ts { Whitespace = 4, Identifier = 5, NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8 + BigIntLiteral = 7, + StringLiteral = 8, + RegExpLiteral = 9 } interface ClassificationResult { finalLexState: EndOfLineState; @@ -5363,13 +5380,20 @@ declare namespace ts { ambientModifier = "declare", staticModifier = "static", abstractModifier = "abstract", - optionalModifier = "optional" + optionalModifier = "optional", + dtsModifier = ".d.ts", + tsModifier = ".ts", + tsxModifier = ".tsx", + jsModifier = ".js", + jsxModifier = ".jsx", + jsonModifier = ".json" } enum ClassificationTypeNames { comment = "comment", identifier = "identifier", keyword = "keyword", numericLiteral = "number", + bigintLiteral = "bigint", operator = "operator", stringLiteral = "string", whiteSpace = "whitespace", @@ -5414,7 +5438,8 @@ declare namespace ts { jsxSelfClosingTagName = 21, jsxAttribute = 22, jsxText = 23, - jsxAttributeStringLiteralValue = 24 + jsxAttributeStringLiteralValue = 24, + bigintLiteral = 25 } } declare namespace ts { @@ -5506,6 +5531,10 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } +declare namespace ts { + function generateTypesForModule(name: string, moduleValue: unknown, formatSettings: FormatCodeSettings): string; + function generateTypesForGlobal(name: string, globalValue: unknown, formatSettings: FormatCodeSettings): string; +} declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; diff --git a/lib/typescript.js b/lib/typescript.js index bb0d451215a..9b296e619a2 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -478,10 +478,33 @@ var ts; return result; } ts.flatten = flatten; + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ function flatMap(array, mapfn) { var result; if (array) { - result = []; + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || ts.emptyArray; + } + ts.flatMap = flatMap; + function flatMapToMutable(array, mapfn) { + var result = []; + if (array) { for (var i = 0; i < array.length; i++) { var v = mapfn(array[i], i); if (v) { @@ -496,7 +519,7 @@ var ts; } return result; } - ts.flatMap = flatMap; + ts.flatMapToMutable = flatMapToMutable; function flatMapIterator(iter, mapfn) { var first = iter.next(); if (first.done) { @@ -735,7 +758,7 @@ var ts; */ function deduplicateSorted(array, comparer) { if (array.length === 0) - return []; + return ts.emptyArray; var last = array[0]; var deduplicated = [last]; for (var i = 1; i < array.length; i++) { @@ -766,7 +789,7 @@ var ts; } ts.insertSorted = insertSorted; function sortAndDeduplicate(array, comparer, equalityComparer) { - return deduplicateSorted(sort(array, comparer), equalityComparer || comparer); + return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive); } ts.sortAndDeduplicate = sortAndDeduplicate; function arrayIsEqualTo(array1, array2, equalityComparer) { @@ -919,7 +942,7 @@ var ts; * Returns a new sorted array. */ function sort(array, comparer) { - return array.slice().sort(comparer); + return (array.length === 0 ? array : array.slice().sort(comparer)); } ts.sort = sort; function arrayIterator(array) { @@ -1025,12 +1048,25 @@ var ts; * @param offset An offset into `array` at which to start the search. */ function binarySearch(array, value, keySelector, keyComparer, offset) { - if (!array || array.length === 0) { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); + } + ts.binarySearch = binarySearch; + /** + * Performs a binary search, finding the index at which an object with `key` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `key`. + * @param array A sorted array whose first element must be no larger than number + * @param key The key to be searched for in the array. + * @param keySelector A callback used to select the search key from each element of `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + */ + function binarySearchKey(array, key, keySelector, keyComparer, offset) { + if (!some(array)) { return -1; } var low = offset || 0; var high = array.length - 1; - var key = keySelector(value); while (low <= high) { var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle]); @@ -1047,7 +1083,7 @@ var ts; } return ~low; } - ts.binarySearch = binarySearch; + ts.binarySearchKey = binarySearchKey; function reduceLeft(array, f, initial, start, count) { if (array && array.length > 0) { var size = array.length; @@ -1971,6 +2007,33 @@ var ts; var counts; var marks; var measures; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; /** * Marks a performance event. * @@ -2425,368 +2488,370 @@ var ts; SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["BigIntLiteral"] = 9] = "BigIntLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 11] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 12] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 13] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 14] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 15] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 16] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 17] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 18] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 19] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 20] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 21] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 22] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 23] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 24] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 59] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 60] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 61] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 62] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 63] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 64] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 65] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 66] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 69] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 70] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 71] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 72] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 73] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 74] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 75] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 76] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 77] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 78] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 79] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 80] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 81] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 82] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 83] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 84] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 85] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 86] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 87] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 88] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 89] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 90] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 91] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 92] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 93] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 94] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 95] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 96] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 97] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 98] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 99] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 100] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 101] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 102] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 103] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 104] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 105] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 106] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 107] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 108] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 109] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 110] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 111] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 112] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 113] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 114] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 115] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 116] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 117] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 126] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 127] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 128] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 129] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 130] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 131] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 132] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 133] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 134] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 135] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 136] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 137] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 138] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 118] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 119] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 120] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 121] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 122] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 123] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 124] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 125] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 126] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 127] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 128] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 129] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 130] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 131] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 132] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 133] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 134] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 135] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 136] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 137] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 138] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 139] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 140] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 141] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 142] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 143] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 144] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 145] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 146] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 147] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 148] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 149] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 150] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 151] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 152] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 153] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 154] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 155] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 156] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 157] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 158] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 159] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 160] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 161] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 162] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 163] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 164] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 165] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 166] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 167] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 168] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 169] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 170] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 171] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 172] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 173] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 174] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 175] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 176] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 177] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 178] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 179] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 180] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 181] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 182] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 183] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 184] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 185] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 186] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 187] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 188] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 189] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 190] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 191] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 192] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 193] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 194] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 195] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 196] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 197] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 198] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 199] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 200] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 201] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 202] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 203] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 204] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 205] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 206] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 207] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 208] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 209] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 210] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 211] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 212] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 213] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 214] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 215] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 216] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 217] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 218] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 219] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 220] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 221] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 222] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 223] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 224] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 225] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 226] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 227] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 228] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 229] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 230] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 231] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 232] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 233] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 234] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 235] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 236] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 237] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 238] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 239] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 240] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 241] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 242] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 243] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 244] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 245] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 246] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 247] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 248] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 249] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 250] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 251] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 252] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 253] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 254] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 255] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 256] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 257] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 258] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 259] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 260] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 261] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 262] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 263] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 264] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 265] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 266] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 267] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 268] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 269] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 270] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 271] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 272] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 273] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 274] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 275] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 276] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 296] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 297] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 298] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 299] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 300] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 301] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 302] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 303] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 304] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 305] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 306] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 307] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 308] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 309] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 310] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 60] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 71] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 73] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 108] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 73] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 147] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 109] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 117] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 163] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 183] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 71] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 147] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 303] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 303] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3076,14 +3141,15 @@ var ts; // of a type, such as the global `Promise` type in lib.d.ts). TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; // with call signatures. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; (function (SymbolFlags) { @@ -3238,29 +3304,27 @@ var ts; TypeFlags[TypeFlags["Number"] = 8] = "Number"; TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 4096] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 16384] = "Null"; - TypeFlags[TypeFlags["Never"] = 32768] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 131072] = "Object"; - TypeFlags[TypeFlags["Union"] = 262144] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; - TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; - /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; - /* @internal */ - TypeFlags[TypeFlags["UnionOfPrimitiveTypes"] = 67108864] = "UnionOfPrimitiveTypes"; + TypeFlags[TypeFlags["BigInt"] = 64] = "BigInt"; + TypeFlags[TypeFlags["StringLiteral"] = 128] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 256] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 512] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 1024] = "EnumLiteral"; + TypeFlags[TypeFlags["BigIntLiteral"] = 2048] = "BigIntLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 4096] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 8192] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 16384] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32768] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 65536] = "Null"; + TypeFlags[TypeFlags["Never"] = 131072] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 262144] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 524288] = "Object"; + TypeFlags[TypeFlags["Union"] = 1048576] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 2097152] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 4194304] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 8388608] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; /* @internal */ TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ @@ -3270,40 +3334,41 @@ var ts; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 98304] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 2944] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 117724] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 67359327] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 131068] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 132] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 296] = "NumberLike"; + TypeFlags[TypeFlags["BigIntLike"] = 2112] = "BigIntLike"; + TypeFlags[TypeFlags["BooleanLike"] = 528] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 1056] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 16748579] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ @@ -3338,6 +3403,7 @@ var ts; ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ @@ -3349,6 +3415,13 @@ var ts; Variance[Variance["Bivariant"] = 3] = "Bivariant"; Variance[Variance["Independent"] = 4] = "Independent"; })(Variance = ts.Variance || (ts.Variance = {})); + /* @internal */ + var JsxReferenceKind; + (function (JsxReferenceKind) { + JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; + JsxReferenceKind[JsxReferenceKind["Function"] = 1] = "Function"; + JsxReferenceKind[JsxReferenceKind["Mixed"] = 2] = "Mixed"; + })(JsxReferenceKind = ts.JsxReferenceKind || (ts.JsxReferenceKind = {})); var SignatureKind; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; @@ -3409,6 +3482,15 @@ var ts; AssignmentDeclarationKind[AssignmentDeclarationKind["Property"] = 5] = "Property"; // F.prototype = { ... } AssignmentDeclarationKind[AssignmentDeclarationKind["Prototype"] = 6] = "Prototype"; + // Object.defineProperty(x, 'name', { value: any, writable?: boolean (false by default) }); + // Object.defineProperty(x, 'name', { get: Function, set: Function }); + // Object.defineProperty(x, 'name', { get: Function }); + // Object.defineProperty(x, 'name', { set: Function }); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyValue"] = 7] = "ObjectDefinePropertyValue"; + // Object.defineProperty(exports || module.exports, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyExports"] = 8] = "ObjectDefinePropertyExports"; + // Object.defineProperty(Foo.prototype, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePrototypeProperty"] = 9] = "ObjectDefinePrototypeProperty"; })(AssignmentDeclarationKind = ts.AssignmentDeclarationKind || (ts.AssignmentDeclarationKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -3776,6 +3858,7 @@ var ts; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; + EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); var ListFormat; (function (ListFormat) { @@ -3790,64 +3873,66 @@ var ts; ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["AsteriskDelimited"] = 32] = "AsteriskDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 60] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 64] = "AllowTrailingComma"; // Whitespace - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Indented"] = 128] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 256] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 512] = "SpaceBetweenSiblings"; // Brackets/Braces - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["Braces"] = 1024] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 2048] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 4096] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 8192] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 15360] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 16384] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 32768] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 49152] = "Optional"; // Other - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; - ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; + ListFormat[ListFormat["PreferNewLine"] = 65536] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 131072] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 262144] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 524288] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 1048576] = "SingleElement"; // Precomputed Formats - ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 384] = "SingleLineTypeLiteralMembers"; - ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 16449] = "MultiLineTypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 272] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 262576] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 262448] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["Modifiers"] = 262656] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 512] = "HeritageClauses"; + ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 768] = "SingleLineTypeLiteralMembers"; + ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 32897] = "MultiLineTypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 528] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 516] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 520] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 525136] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 524880] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 526226] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 8914] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CommaListElements"] = 528] = "CommaListElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 2576] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 18960] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 262144] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 768] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 129] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 528] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 768] = "SingleLineFunctionBodyStatements"; ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; ListFormat[ListFormat["ClassHeritageClauses"] = 0] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 262576] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 131072] = "JsxElementOrFragmentChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26896] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26896] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1296] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + ListFormat[ListFormat["ClassMembers"] = 129] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 129] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 145] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 129] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 525136] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 262144] = "JsxElementOrFragmentChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 262656] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 163969] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 528] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 131073] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 49153] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 53776] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 53776] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 2576] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 8848] = "IndexSignatureParameters"; + ListFormat[ListFormat["JSDocComment"] = 33] = "JSDocComment"; })(ListFormat = ts.ListFormat || (ts.ListFormat = {})); /* @internal */ var PragmaKindFlags; @@ -5151,6 +5236,7 @@ var ts; use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), 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."), @@ -5207,14 +5293,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number' or an enum type."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), @@ -5421,9 +5507,9 @@ var ts; No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), @@ -5521,6 +5607,13 @@ var ts; Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), It_is_highly_likely_that_you_are_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "It_is_highly_likely_that_you_are_missing_a_semicolon_2734", "It is highly likely that you are missing a semicolon."), + Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), + Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), + BigInt_literals_are_not_available_when_targeting_lower_than_ESNext: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ESNext_2737", "BigInt literals are not available when targeting lower than ESNext."), + An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, ts.DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."), + Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."), 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}'."), @@ -5837,6 +5930,9 @@ var ts; Did_you_mean_to_call_this_expression: diag(6212, ts.DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"), Did_you_mean_to_use_new_with_this_expression: diag(6213, ts.DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"), Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, ts.DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."), + Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."), + Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."), + Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5877,6 +5973,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."), Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."), Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."), + Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, ts.DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."), Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."), Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."), Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."), @@ -5904,6 +6001,14 @@ var ts; If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any_7041", "The containing arrow function captures the global value of 'this' which implicitly has type 'any'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), + Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, ts.DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, ts.DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."), + Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, ts.DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."), + _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."), 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_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -6065,6 +6170,8 @@ var ts; Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), Generate_types_for_0: diag(95067, ts.DiagnosticCategory.Message, "Generate_types_for_0_95067", "Generate types for '{0}'"), Generate_types_for_all_packages_without_types: diag(95068, ts.DiagnosticCategory.Message, "Generate_types_for_all_packages_without_types_95068", "Generate types for all packages without types"), + Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), + Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), }; })(ts || (ts = {})); var ts; @@ -6072,93 +6179,94 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 71 /* Identifier */; + return token >= 72 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 117 /* AbstractKeyword */, - any: 119 /* AnyKeyword */, - as: 118 /* AsKeyword */, - boolean: 122 /* BooleanKeyword */, - break: 72 /* BreakKeyword */, - case: 73 /* CaseKeyword */, - catch: 74 /* CatchKeyword */, - class: 75 /* ClassKeyword */, - continue: 77 /* ContinueKeyword */, - const: 76 /* ConstKeyword */ + abstract: 118 /* AbstractKeyword */, + any: 120 /* AnyKeyword */, + as: 119 /* AsKeyword */, + bigint: 146 /* BigIntKeyword */, + boolean: 123 /* BooleanKeyword */, + break: 73 /* BreakKeyword */, + case: 74 /* CaseKeyword */, + catch: 75 /* CatchKeyword */, + class: 76 /* ClassKeyword */, + continue: 78 /* ContinueKeyword */, + const: 77 /* ConstKeyword */ }, - _a["" + "constructor"] = 123 /* ConstructorKeyword */, - _a.debugger = 78 /* DebuggerKeyword */, - _a.declare = 124 /* DeclareKeyword */, - _a.default = 79 /* DefaultKeyword */, - _a.delete = 80 /* DeleteKeyword */, - _a.do = 81 /* DoKeyword */, - _a.else = 82 /* ElseKeyword */, - _a.enum = 83 /* EnumKeyword */, - _a.export = 84 /* ExportKeyword */, - _a.extends = 85 /* ExtendsKeyword */, - _a.false = 86 /* FalseKeyword */, - _a.finally = 87 /* FinallyKeyword */, - _a.for = 88 /* ForKeyword */, - _a.from = 143 /* FromKeyword */, - _a.function = 89 /* FunctionKeyword */, - _a.get = 125 /* GetKeyword */, - _a.if = 90 /* IfKeyword */, - _a.implements = 108 /* ImplementsKeyword */, - _a.import = 91 /* ImportKeyword */, - _a.in = 92 /* InKeyword */, - _a.infer = 126 /* InferKeyword */, - _a.instanceof = 93 /* InstanceOfKeyword */, - _a.interface = 109 /* InterfaceKeyword */, - _a.is = 127 /* IsKeyword */, - _a.keyof = 128 /* KeyOfKeyword */, - _a.let = 110 /* LetKeyword */, - _a.module = 129 /* ModuleKeyword */, - _a.namespace = 130 /* NamespaceKeyword */, - _a.never = 131 /* NeverKeyword */, - _a.new = 94 /* NewKeyword */, - _a.null = 95 /* NullKeyword */, - _a.number = 134 /* NumberKeyword */, - _a.object = 135 /* ObjectKeyword */, - _a.package = 111 /* PackageKeyword */, - _a.private = 112 /* PrivateKeyword */, - _a.protected = 113 /* ProtectedKeyword */, - _a.public = 114 /* PublicKeyword */, - _a.readonly = 132 /* ReadonlyKeyword */, - _a.require = 133 /* RequireKeyword */, - _a.global = 144 /* GlobalKeyword */, - _a.return = 96 /* ReturnKeyword */, - _a.set = 136 /* SetKeyword */, - _a.static = 115 /* StaticKeyword */, - _a.string = 137 /* StringKeyword */, - _a.super = 97 /* SuperKeyword */, - _a.switch = 98 /* SwitchKeyword */, - _a.symbol = 138 /* SymbolKeyword */, - _a.this = 99 /* ThisKeyword */, - _a.throw = 100 /* ThrowKeyword */, - _a.true = 101 /* TrueKeyword */, - _a.try = 102 /* TryKeyword */, - _a.type = 139 /* TypeKeyword */, - _a.typeof = 103 /* TypeOfKeyword */, - _a.undefined = 140 /* UndefinedKeyword */, - _a.unique = 141 /* UniqueKeyword */, - _a.unknown = 142 /* UnknownKeyword */, - _a.var = 104 /* VarKeyword */, - _a.void = 105 /* VoidKeyword */, - _a.while = 106 /* WhileKeyword */, - _a.with = 107 /* WithKeyword */, - _a.yield = 116 /* YieldKeyword */, - _a.async = 120 /* AsyncKeyword */, - _a.await = 121 /* AwaitKeyword */, - _a.of = 145 /* OfKeyword */, + _a["" + "constructor"] = 124 /* ConstructorKeyword */, + _a.debugger = 79 /* DebuggerKeyword */, + _a.declare = 125 /* DeclareKeyword */, + _a.default = 80 /* DefaultKeyword */, + _a.delete = 81 /* DeleteKeyword */, + _a.do = 82 /* DoKeyword */, + _a.else = 83 /* ElseKeyword */, + _a.enum = 84 /* EnumKeyword */, + _a.export = 85 /* ExportKeyword */, + _a.extends = 86 /* ExtendsKeyword */, + _a.false = 87 /* FalseKeyword */, + _a.finally = 88 /* FinallyKeyword */, + _a.for = 89 /* ForKeyword */, + _a.from = 144 /* FromKeyword */, + _a.function = 90 /* FunctionKeyword */, + _a.get = 126 /* GetKeyword */, + _a.if = 91 /* IfKeyword */, + _a.implements = 109 /* ImplementsKeyword */, + _a.import = 92 /* ImportKeyword */, + _a.in = 93 /* InKeyword */, + _a.infer = 127 /* InferKeyword */, + _a.instanceof = 94 /* InstanceOfKeyword */, + _a.interface = 110 /* InterfaceKeyword */, + _a.is = 128 /* IsKeyword */, + _a.keyof = 129 /* KeyOfKeyword */, + _a.let = 111 /* LetKeyword */, + _a.module = 130 /* ModuleKeyword */, + _a.namespace = 131 /* NamespaceKeyword */, + _a.never = 132 /* NeverKeyword */, + _a.new = 95 /* NewKeyword */, + _a.null = 96 /* NullKeyword */, + _a.number = 135 /* NumberKeyword */, + _a.object = 136 /* ObjectKeyword */, + _a.package = 112 /* PackageKeyword */, + _a.private = 113 /* PrivateKeyword */, + _a.protected = 114 /* ProtectedKeyword */, + _a.public = 115 /* PublicKeyword */, + _a.readonly = 133 /* ReadonlyKeyword */, + _a.require = 134 /* RequireKeyword */, + _a.global = 145 /* GlobalKeyword */, + _a.return = 97 /* ReturnKeyword */, + _a.set = 137 /* SetKeyword */, + _a.static = 116 /* StaticKeyword */, + _a.string = 138 /* StringKeyword */, + _a.super = 98 /* SuperKeyword */, + _a.switch = 99 /* SwitchKeyword */, + _a.symbol = 139 /* SymbolKeyword */, + _a.this = 100 /* ThisKeyword */, + _a.throw = 101 /* ThrowKeyword */, + _a.true = 102 /* TrueKeyword */, + _a.try = 103 /* TryKeyword */, + _a.type = 140 /* TypeKeyword */, + _a.typeof = 104 /* TypeOfKeyword */, + _a.undefined = 141 /* UndefinedKeyword */, + _a.unique = 142 /* UniqueKeyword */, + _a.unknown = 143 /* UnknownKeyword */, + _a.var = 105 /* VarKeyword */, + _a.void = 106 /* VoidKeyword */, + _a.while = 107 /* WhileKeyword */, + _a.with = 108 /* WithKeyword */, + _a.yield = 117 /* YieldKeyword */, + _a.async = 121 /* AsyncKeyword */, + _a.await = 122 /* AwaitKeyword */, + _a.of = 147 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 59 /* EqualsToken */, "+=": 60 /* PlusEqualsToken */, "-=": 61 /* MinusEqualsToken */, "*=": 62 /* AsteriskEqualsToken */, "**=": 63 /* AsteriskAsteriskEqualsToken */, "/=": 64 /* SlashEqualsToken */, "%=": 65 /* PercentEqualsToken */, "<<=": 66 /* LessThanLessThanEqualsToken */, ">>=": 67 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 69 /* AmpersandEqualsToken */, "|=": 70 /* BarEqualsToken */, "^=": 71 /* CaretEqualsToken */, "@": 58 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6747,8 +6855,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; }, + isIdentifier: function () { return token === 72 /* Identifier */ || token > 108 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -6842,18 +6950,29 @@ var ts; end = pos; } } + var result; if (tokenFlags & 512 /* ContainsSeparator */) { - var result = mainFragment; + result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; } if (scientificFragment) { result += scientificFragment; } - return "" + +result; } else { - return "" + +(text.substring(start, end)); // No need to use all the fragments; no _ removal needed + result = text.substring(start, end); // No need to use all the fragments; no _ removal needed + } + if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { + return { + type: 8 /* NumericLiteral */, + value: "" + +result // if value is not an integer, it can be safely coerced to a number + }; + } + else { + tokenValue = result; + var type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint + return { type: type, value: tokenValue }; } } function scanOctalDigits() { @@ -6868,21 +6987,21 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count, canHaveSeparators) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + var valueString = scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + return valueString ? parseInt(valueString, 16) : -1; } /** * Scans as many hexadecimal digits as are available in the text, - * returning -1 if the given number of digits was unavailable. + * returning "" if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count, canHaveSeparators) { return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true, canHaveSeparators); } function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) { - var digits = 0; - var value = 0; + var valueChars = []; var allowSeparator = false; var isPreviousTokenSeparator = false; - while (digits < minCount || scanAsManyAsPossible) { + while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); if (canHaveSeparators && ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; @@ -6900,29 +7019,24 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; + if (ch >= 65 /* A */ && ch <= 70 /* F */) { + ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { + else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || + (ch >= 97 /* a */ && ch <= 102 /* f */))) { break; } + valueChars.push(ch); pos++; - digits++; isPreviousTokenSeparator = false; } - if (digits < minCount) { - value = -1; + if (valueChars.length < minCount) { + valueChars = []; } if (text.charCodeAt(pos - 1) === 95 /* _ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } - return value; + return String.fromCharCode.apply(String, valueChars); } function scanString(jsxAttributeString) { if (jsxAttributeString === void 0) { jsxAttributeString = false; } @@ -6974,7 +7088,7 @@ var ts; contents += text.substring(start, pos); tokenFlags |= 4 /* Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -6982,14 +7096,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; break; } // Escape character @@ -7082,7 +7196,8 @@ var ts; } } function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; var isInvalidExtendedEscape = false; // Validate the value of the digit if (escapedValue < 0) { @@ -7170,14 +7285,12 @@ var ts; } } } - return token = 71 /* Identifier */; + return token = 72 /* Identifier */; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; + var value = ""; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. - var numberOfDigits = 0; var separatorAllowed = false; var isPreviousTokenSeparator = false; while (true) { @@ -7199,27 +7312,42 @@ var ts; continue; } separatorAllowed = true; - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { + if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { break; } - value = value * base + valueOfCh; + value += text[pos]; pos++; - numberOfDigits++; isPreviousTokenSeparator = false; } - // Invalid binaryIntegerLiteral or octalIntegerLiteral - if (numberOfDigits === 0) { - return -1; - } if (text.charCodeAt(pos - 1) === 95 /* _ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); - return value; } return value; } + function checkBigIntSuffix() { + if (text.charCodeAt(pos) === 110 /* n */) { + tokenValue += "n"; + // Use base 10 instead of base 2 or base 8 for shorter literals + if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; + } + pos++; + return 9 /* 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 */ + ? parseInt(tokenValue.slice(2), 2) // skip "0b" + : tokenFlags & 256 /* OctalSpecifier */ + ? parseInt(tokenValue.slice(2), 8) // skip "0o" + : +tokenValue; + tokenValue = "" + numericValue; + return 8 /* NumericLiteral */; + } + } function scan() { + var _a; startPos = pos; tokenFlags = 0; var asteriskSeen = false; @@ -7292,48 +7420,48 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 33 /* ExclamationEqualsToken */; + return pos += 2, token = 34 /* ExclamationEqualsToken */; } pos++; - return token = 51 /* ExclamationToken */; + return token = 52 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PercentEqualsToken */; + return pos += 2, token = 65 /* PercentEqualsToken */; } pos++; - return token = 42 /* PercentToken */; + return token = 43 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 53 /* AmpersandAmpersandToken */; + return pos += 2, token = 54 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* AmpersandEqualsToken */; + return pos += 2, token = 69 /* AmpersandEqualsToken */; } pos++; - return token = 48 /* AmpersandToken */; + return token = 49 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 19 /* OpenParenToken */; + return token = 20 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 20 /* CloseParenToken */; + return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* AsteriskEqualsToken */; + return pos += 2, token = 62 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 63 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 40 /* AsteriskAsteriskToken */; + return pos += 2, token = 41 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7341,38 +7469,38 @@ var ts; asteriskSeen = true; continue; } - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 43 /* PlusPlusToken */; + return pos += 2, token = 44 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PlusEqualsToken */; + return pos += 2, token = 60 /* PlusEqualsToken */; } pos++; - return token = 37 /* PlusToken */; + return token = 38 /* PlusToken */; case 44 /* comma */: pos++; - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 44 /* MinusMinusToken */; + return pos += 2, token = 45 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* MinusEqualsToken */; + return pos += 2, token = 61 /* MinusEqualsToken */; } pos++; - return token = 38 /* MinusToken */; + return token = 39 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); + tokenValue = scanNumber().value; return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 24 /* DotDotDotToken */; + return pos += 3, token = 25 /* DotDotDotToken */; } pos++; - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -7423,43 +7551,43 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* SlashEqualsToken */; + return pos += 2, token = 64 /* SlashEqualsToken */; } pos++; - return token = 41 /* SlashToken */; + return token = 42 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; - var value = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); - if (value < 0) { + tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); + if (!tokenValue) { error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0x" + tokenValue; tokenFlags |= 64 /* HexSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 2); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 2); + if (!tokenValue) { error(ts.Diagnostics.Binary_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0b" + tokenValue; tokenFlags |= 128 /* BinarySpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 8); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 8); + if (!tokenValue) { error(ts.Diagnostics.Octal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0o" + tokenValue; tokenFlags |= 256 /* OctalSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -7480,14 +7608,14 @@ var ts; case 55 /* _7 */: case 56 /* _8 */: case 57 /* _9 */: - tokenValue = scanNumber(); - return token = 8 /* NumericLiteral */; + (_a = scanNumber(), token = _a.type, tokenValue = _a.value); + return token; case 58 /* colon */: pos++; - return token = 56 /* ColonToken */; + return token = 57 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 25 /* SemicolonToken */; + return token = 26 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7500,20 +7628,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 66 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 45 /* LessThanLessThanToken */; + return pos += 2, token = 46 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 30 /* LessThanEqualsToken */; + return pos += 2, token = 31 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 28 /* LessThanSlashToken */; + return pos += 2, token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7526,15 +7654,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 34 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 32 /* EqualsEqualsToken */; + return pos += 2, token = 33 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 36 /* EqualsGreaterThanToken */; + return pos += 2, token = 37 /* EqualsGreaterThanToken */; } pos++; - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7546,25 +7674,25 @@ var ts; } } pos++; - return token = 29 /* GreaterThanToken */; + return token = 30 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 55 /* QuestionToken */; + return token = 56 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* CaretEqualsToken */; + return pos += 2, token = 71 /* CaretEqualsToken */; } pos++; - return token = 50 /* CaretToken */; + return token = 51 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 124 /* bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7576,22 +7704,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 54 /* BarBarToken */; + return pos += 2, token = 55 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* BarEqualsToken */; + return pos += 2, token = 70 /* BarEqualsToken */; } pos++; - return token = 49 /* BarToken */; + return token = 50 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 52 /* TildeToken */; + return token = 53 /* TildeToken */; case 64 /* at */: pos++; - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -7629,29 +7757,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* 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 = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 67 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 46 /* GreaterThanGreaterThanToken */; + return token = 47 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 31 /* GreaterThanEqualsToken */; + return token = 32 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) { + if (token === 42 /* SlashToken */ || token === 64 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -7696,7 +7824,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 12 /* RegularExpressionLiteral */; + token = 13 /* RegularExpressionLiteral */; } return token; } @@ -7704,7 +7832,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -7721,14 +7849,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 28 /* LessThanSlashToken */; + return token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -7760,7 +7888,7 @@ var ts; } pos++; } - return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -7786,7 +7914,7 @@ var ts; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -7810,36 +7938,36 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 123 /* openBrace */: - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 91 /* openBracket */: - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 44 /* comma */: - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 46 /* dot */: - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 96 /* backtick */: while (pos < end && text.charCodeAt(pos) !== 96 /* backtick */) { pos++; } tokenValue = text.substring(tokenPos + 1, pos); pos++; - return token = 13 /* NoSubstitutionTemplateLiteral */; + return token = 14 /* NoSubstitutionTemplateLiteral */; } if (isIdentifierStart(ch, 6 /* Latest */)) { while (isIdentifierPart(text.charCodeAt(pos), 6 /* Latest */) && pos < end) { @@ -7992,7 +8120,6 @@ var ts; getText: function () { return str; }, write: writeText, rawWrite: writeText, - writeTextOfNode: writeText, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -8001,7 +8128,9 @@ var ts; writeLiteral: writeText, writeParameter: writeText, writeProperty: writeText, - writeSymbol: writeText, + writeSymbol: function (s, _) { return writeText(s); }, + writeTrailingSemicolon: writeText, + writeComment: writeText, getTextPos: function () { return str.length; }, getLine: function () { return 0; }, getColumn: function () { return 0; }, @@ -8200,7 +8329,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { + while (node && node.kind !== 279 /* SourceFile */) { node = node.parent; } return node; @@ -8208,11 +8337,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return true; } return false; @@ -8346,7 +8475,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 === 304 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8365,7 +8494,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 281 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8407,32 +8536,34 @@ var ts; function getLiteralText(node, sourceFile, neverAsciiEscape) { // 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 (!nodeIsSynthesized(node) && node.parent && !(ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */)) { + if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) || + ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // 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 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.singleQuote) { return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; } else { return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return "`" + escapeText(node.text, 96 /* backtick */) + "`"; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: // tslint:disable-next-line no-invalid-template-strings return "`" + escapeText(node.text, 96 /* backtick */) + "${"; - case 15 /* TemplateMiddle */: + case 16 /* TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings return "}" + escapeText(node.text, 96 /* backtick */) + "${"; - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: + case 9 /* BigIntLiteral */: + case 13 /* RegularExpressionLiteral */: return node.text; } return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -8455,15 +8586,15 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; + return node.kind === 237 /* VariableDeclaration */ && node.parent.kind === 274 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 9 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -8487,11 +8618,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 277 /* SourceFile */ || - node.kind === 242 /* ModuleDeclaration */ || + return node.kind === 279 /* SourceFile */ || + node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8508,9 +8639,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 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node.parent); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8526,22 +8657,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 272 /* CatchClause */: - case 242 /* ModuleDeclaration */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 274 /* CatchClause */: + case 244 /* ModuleDeclaration */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 216 /* Block */: + case 218 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8551,9 +8682,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 291 /* JSDocSignature */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 293 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8563,25 +8694,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -8591,8 +8722,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8601,15 +8732,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 217 /* VariableStatement */: - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 219 /* VariableStatement */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -8639,12 +8770,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isStringOrNumericLiteralLike(name.expression) ? ts.escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: return ts.Debug.assertNever(name); @@ -8653,11 +8785,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8702,7 +8834,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 216 /* Block */) { + if (node.body && node.body.kind === 218 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8716,7 +8848,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* 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 @@ -8725,25 +8857,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: errorNode = node.name; break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8792,11 +8924,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 98 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 92 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { @@ -8804,20 +8936,20 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 219 /* ExpressionStatement */ - && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 221 /* ExpressionStatement */ + && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 149 /* Parameter */ || - node.kind === 148 /* TypeParameter */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 195 /* ArrowFunction */ || - node.kind === 193 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 151 /* Parameter */ || + node.kind === 150 /* TypeParameter */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 197 /* ArrowFunction */ || + node.kind === 195 /* ParenthesizedExpression */) ? 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 '/**/' @@ -8833,47 +8965,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= node.kind && node.kind <= 183 /* LastTypeNode */) { return true; } switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 134 /* NumberKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: return true; - case 105 /* VoidKeyword */: - return node.parent.kind !== 198 /* VoidExpression */; - case 209 /* ExpressionWithTypeArguments */: + case 106 /* VoidKeyword */: + return node.parent.kind !== 200 /* VoidExpression */; + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 148 /* TypeParameter */: - return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; + case 150 /* TypeParameter */: + return node.parent.kind === 181 /* MappedType */ || node.parent.kind === 176 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 71 /* Identifier */: + case 72 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 189 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */ || node.kind === 189 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 146 /* QualifiedName */: - case 187 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: { + case 148 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 100 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 165 /* TypeQuery */) { + if (parent.kind === 167 /* TypeQuery */) { return false; } - if (parent.kind === 181 /* ImportType */) { + if (parent.kind === 183 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8882,40 +9015,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 (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= parent.kind && parent.kind <= 183 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return node === parent.constraint; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return node === parent.constraint; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return node === parent.type; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node === parent.type; - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return node === parent.type; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return node === parent.type; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8940,23 +9073,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitor(node); - case 244 /* CaseBlock */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 246 /* CaseBlock */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8966,26 +9099,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* 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); @@ -9008,10 +9141,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 167 /* ArrayType */) { + if (node && node.kind === 169 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 162 /* TypeReference */) { + else if (node && node.kind === 164 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9021,12 +9154,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 166 /* TypeLiteral */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 168 /* TypeLiteral */: return node.members; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return node.properties; } } @@ -9034,14 +9167,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 184 /* BindingElement */: - case 276 /* EnumMember */: - case 149 /* Parameter */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 274 /* ShorthandPropertyAssignment */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 278 /* EnumMember */: + case 151 /* Parameter */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 276 /* ShorthandPropertyAssignment */: + case 237 /* VariableDeclaration */: return true; } } @@ -9053,8 +9186,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 236 /* VariableDeclarationList */ - && node.parent.parent.kind === 217 /* VariableStatement */; + return node.parent.kind === 238 /* VariableDeclarationList */ + && node.parent.parent.kind === 219 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9065,13 +9198,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return true; } return false; @@ -9082,7 +9215,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 231 /* LabeledStatement */) { + if (node.statement.kind !== 233 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9090,17 +9223,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 218 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; + return node && node.kind === 156 /* MethodDeclaration */ && node.parent.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 186 /* ObjectLiteralExpression */ || - node.parent.kind === 207 /* ClassExpression */); + return node.kind === 156 /* MethodDeclaration */ && + (node.parent.kind === 188 /* ObjectLiteralExpression */ || + node.parent.kind === 209 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9113,7 +9246,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 273 /* PropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9150,14 +9283,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 277 /* SourceFile */); + ts.Debug.assert(node.kind !== 279 /* 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 147 /* ComputedPropertyName */: + case 149 /* 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 @@ -9172,9 +9305,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9185,26 +9318,26 @@ var ts; node = node.parent; } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 242 /* ModuleDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 241 /* EnumDeclaration */: - case 277 /* SourceFile */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 244 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 243 /* EnumDeclaration */: + case 279 /* SourceFile */: return node; } } @@ -9214,9 +9347,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return container; } } @@ -9238,27 +9371,27 @@ var ts; return node; } switch (node.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: node = node.parent; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9274,14 +9407,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { + if (func.kind === 196 /* FunctionExpression */ || func.kind === 197 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 193 /* ParenthesizedExpression */) { + while (parent.kind === 195 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 191 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9292,8 +9425,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 97 /* SuperKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 98 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9301,20 +9434,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 99 /* ThisKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 100 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: return node; } return undefined; @@ -9322,10 +9455,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return node.tag; - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9334,25 +9467,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // classes are valid targets return true; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 238 /* ClassDeclaration */; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + return parent.kind === 240 /* ClassDeclaration */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* 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 === 238 /* ClassDeclaration */; - case 149 /* Parameter */: + && parent.kind === 240 /* ClassDeclaration */; + case 151 /* 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 === 155 /* Constructor */ - || parent.kind === 154 /* MethodDeclaration */ - || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 238 /* ClassDeclaration */; + && (parent.kind === 157 /* Constructor */ + || parent.kind === 156 /* MethodDeclaration */ + || parent.kind === 159 /* SetAccessor */) + && grandparent.kind === 240 /* ClassDeclaration */; } return false; } @@ -9368,10 +9501,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 154 /* MethodDeclaration */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 159 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -9380,9 +9513,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 260 /* JsxOpeningElement */ || - parent.kind === 259 /* JsxSelfClosingElement */ || - parent.kind === 261 /* JsxClosingElement */) { + if (parent.kind === 262 /* JsxOpeningElement */ || + parent.kind === 261 /* JsxSelfClosingElement */ || + parent.kind === 263 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9390,56 +9523,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 12 /* RegularExpressionLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 210 /* AsExpression */: - case 192 /* TypeAssertionExpression */: - case 211 /* NonNullExpression */: - case 193 /* ParenthesizedExpression */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 206 /* SpreadElement */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 208 /* OmittedExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 205 /* YieldExpression */: - case 199 /* AwaitExpression */: - case 212 /* MetaProperty */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 13 /* RegularExpressionLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 212 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 213 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 208 /* SpreadElement */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 210 /* OmittedExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 207 /* YieldExpression */: + case 201 /* AwaitExpression */: + case 214 /* MetaProperty */: return true; - case 146 /* QualifiedName */: - while (node.parent.kind === 146 /* QualifiedName */) { + case 148 /* QualifiedName */: + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); - case 71 /* Identifier */: - if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node); + case 72 /* Identifier */: + if (node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -9449,49 +9583,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 186 /* BindingElement */: return parent.initializer === node; - case 219 /* ExpressionStatement */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 228 /* ReturnStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 232 /* ThrowStatement */: + case 221 /* ExpressionStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 230 /* ReturnStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 234 /* ThrowStatement */: return parent.expression === node; - case 223 /* ForStatement */: + case 225 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forInStatement.expression === node; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return node === parent.expression; - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return node === parent.expression; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return node === parent.expression; - case 150 /* Decorator */: - case 268 /* JsxExpression */: - case 267 /* JsxSpreadAttribute */: - case 275 /* SpreadAssignment */: + case 152 /* Decorator */: + case 270 /* JsxExpression */: + case 269 /* JsxSpreadAttribute */: + case 277 /* SpreadAssignment */: return true; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -9499,7 +9633,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9508,7 +9642,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 259 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -9536,15 +9670,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 137 /* StringKeyword */ || node.typeArguments[0].kind === 134 /* NumberKeyword */); + (node.typeArguments[0].kind === 138 /* StringKeyword */ || node.typeArguments[0].kind === 135 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 189 /* CallExpression */) { + if (callExpression.kind !== 191 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 71 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 72 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -9575,16 +9709,16 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.right === node) { name = node.parent.left; decl = name; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { name = node.parent.parent.name; decl = node.parent.parent; } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.parent.right === node.parent) { name = node.parent.parent.left; decl = name; } @@ -9599,13 +9733,13 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl); + return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -9618,16 +9752,25 @@ var ts; return init && getExpandoInitializer(init, isPrototypeAccess(node.name)); } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; + function hasExpandoValueProperty(node, isPrototypeAssignment) { + return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); } + if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) { + var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype"); + if (result) { + return result; + } + } } ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer; /** @@ -9643,11 +9786,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 196 /* FunctionExpression */ || e.kind === 197 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 194 /* FunctionExpression */ || - initializer.kind === 207 /* ClassExpression */ || - initializer.kind === 195 /* ArrowFunction */) { + if (initializer.kind === 196 /* FunctionExpression */ || + initializer.kind === 209 /* ClassExpression */ || + initializer.kind === 197 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9664,14 +9807,14 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 54 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -9679,8 +9822,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 === 54 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 58 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 59 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -9703,7 +9846,7 @@ var ts; return name.escapedText === initializer.escapedText; } if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 99 /* ThisKeyword */ || + return (initializer.expression.kind === 100 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -9737,8 +9880,31 @@ var ts; return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; + function isBindableObjectDefinePropertyCall(expr) { + return ts.length(expr.arguments) === 3 && + ts.isPropertyAccessExpression(expr.expression) && + ts.isIdentifier(expr.expression.expression) && + ts.idText(expr.expression.expression) === "Object" && + ts.idText(expr.expression.name) === "defineProperty" && + isStringOrNumericLiteralLike(expr.arguments[1]) && + isEntityNameExpression(expr.arguments[0]); + } + ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; function getAssignmentDeclarationKindWorker(expr) { - if (expr.operatorToken.kind !== 58 /* EqualsToken */ || + if (ts.isCallExpression(expr)) { + if (!isBindableObjectDefinePropertyCall(expr)) { + return 0 /* None */; + } + var entityName = expr.arguments[0]; + if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + return 8 /* ObjectDefinePropertyExports */; + } + if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + return 9 /* ObjectDefinePrototypeProperty */; + } + return 7 /* ObjectDefinePropertyValue */; + } + if (expr.operatorToken.kind !== 59 /* EqualsToken */ || !ts.isPropertyAccessExpression(expr.left)) { return 0 /* None */; } @@ -9750,10 +9916,10 @@ var ts; return getAssignmentDeclarationPropertyAccessKind(lhs); } function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 99 /* ThisKeyword */) { + if (lhs.expression.kind === 100 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (ts.isIdentifier(lhs.expression) && lhs.expression.escapedText === "module" && lhs.name.escapedText === "exports") { + else if (isModuleExportsPropertyAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } @@ -9792,7 +9958,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 221 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9801,7 +9967,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 237 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 239 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -9810,14 +9976,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.parent; - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return node.parent.parent; - case 189 /* CallExpression */: - return node.parent; - case 180 /* LiteralType */: + case 191 /* CallExpression */: + return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; + case 182 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9827,12 +9993,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.moduleSpecifier; - case 246 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 181 /* ImportType */: + case 248 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 259 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 183 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9841,11 +10007,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9853,19 +10019,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 249 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 149 /* Parameter */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 274 /* ShorthandPropertyAssignment */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 151 /* Parameter */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 276 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -9873,14 +10039,13 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 287 /* JSDocFunctionType */ && - node.parameters.length > 0 && - node.parameters[0].name && - node.parameters[0].name.escapedText === "new"; + var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined; + var name = ts.tryCast(param && param.name, ts.isIdentifier); + return !!name && name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 302 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9890,7 +10055,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ + node.expression.operatorToken.kind === 59 /* EqualsToken */ ? node.expression.right : undefined; } @@ -9899,18 +10064,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + node.expression.right.operatorToken.kind === 55 /* BarBarToken */ ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return node.initializer; } } @@ -9920,7 +10085,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 242 /* ModuleDeclaration */ + node.body.kind === 244 /* ModuleDeclaration */ ? node.body : undefined; } @@ -9935,11 +10100,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 148 /* TypeParameter */) { + if (node.kind === 150 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -9950,11 +10115,11 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 273 /* PropertyAssignment */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + if (parent.kind === 275 /* PropertyAssignment */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 221 /* ExpressionStatement */ && node.kind === 189 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 59 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -9965,7 +10130,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -9988,7 +10153,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 71 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 72 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10023,7 +10188,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 === 288 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10036,31 +10201,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 59 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 193 /* ParenthesizedExpression */: - case 185 /* ArrayLiteralExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 187 /* ArrayLiteralExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: node = parent; break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10087,22 +10252,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 216 /* Block */: - case 217 /* VariableStatement */: - case 229 /* WithStatement */: - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 218 /* Block */: + case 219 /* VariableStatement */: + case 231 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return true; } return false; @@ -10119,33 +10284,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 175 /* ParenthesizedType */); + return walkUp(node, 177 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 193 /* ParenthesizedExpression */); + return walkUp(node, 195 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 196 /* DeleteExpression */; + return node && node.kind === 198 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10166,12 +10331,12 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10194,8 +10359,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 147 /* ComputedPropertyName */ && + return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + node.parent.kind === 149 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10203,32 +10368,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 187 /* PropertyAccessExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 189 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 146 /* QualifiedName */) { + while (parent.kind === 148 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; + return parent.kind === 167 /* TypeQuery */ || parent.kind === 164 /* TypeReference */; } return false; - case 184 /* BindingElement */: - case 251 /* ImportSpecifier */: + case 186 /* BindingElement */: + case 253 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 255 /* ExportSpecifier */: - case 265 /* JsxAttribute */: + case 257 /* ExportSpecifier */: + case 267 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10243,15 +10408,16 @@ var ts; // export { x as } from ... // export = // export default + // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 245 /* NamespaceExportDeclaration */ || - node.kind === 248 /* ImportClause */ && !!node.name || - node.kind === 249 /* NamespaceImport */ || - node.kind === 251 /* ImportSpecifier */ || - node.kind === 255 /* ExportSpecifier */ || - node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */; + return node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 247 /* NamespaceExportDeclaration */ || + node.kind === 250 /* ImportClause */ && !!node.name || + node.kind === 251 /* NamespaceImport */ || + node.kind === 253 /* ImportSpecifier */ || + node.kind === 257 /* ExportSpecifier */ || + node.kind === 254 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -10271,12 +10437,12 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 109 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; @@ -10288,7 +10454,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -10322,11 +10488,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; + return 73 /* FirstKeyword */ <= token && token <= 147 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; + return 118 /* FirstContextualKeyword */ <= token && token <= 147 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10338,6 +10504,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isIdentifierANonContextualKeyword(_a) { + var originalKeywordKind = _a.originalKeywordKind; + return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); + } + ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } @@ -10356,14 +10527,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10377,10 +10548,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10405,7 +10576,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 147 /* ComputedPropertyName */ && + return name.kind === 149 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10421,12 +10592,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10442,9 +10613,9 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: return true; default: @@ -10453,11 +10624,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 72 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 72 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -10472,7 +10643,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 72 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -10481,11 +10652,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 149 /* Parameter */; + return root.kind === 151 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 184 /* BindingElement */) { + while (node.kind === 186 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10493,15 +10664,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 194 /* FunctionExpression */ - || kind === 237 /* FunctionDeclaration */ - || kind === 195 /* ArrowFunction */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 242 /* ModuleDeclaration */ - || kind === 277 /* SourceFile */; + return kind === 157 /* Constructor */ + || kind === 196 /* FunctionExpression */ + || kind === 239 /* FunctionDeclaration */ + || kind === 197 /* ArrowFunction */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 244 /* ModuleDeclaration */ + || kind === 279 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10520,38 +10691,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: return 1 /* Right */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operator) { - case 40 /* AsteriskAsteriskToken */: - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 41 /* AsteriskAsteriskToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 1 /* Right */; } } @@ -10560,15 +10731,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 202 /* BinaryExpression */) { + if (expression.kind === 204 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { + else if (expression.kind === 202 /* PrefixUnaryExpression */ || expression.kind === 203 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10578,116 +10749,116 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return 0; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return 1; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return 2; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return 4; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operatorKind) { - case 26 /* CommaToken */: + case 27 /* CommaToken */: return 0; - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: return 16; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return 17; - case 189 /* CallExpression */: + case 191 /* CallExpression */: return 18; - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 19 : 18; - case 191 /* TaggedTemplateExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 193 /* TaggedTemplateExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 19; - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 71 /* Identifier */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 72 /* Identifier */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 193 /* ParenthesizedExpression */: - case 208 /* OmittedExpression */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 195 /* ParenthesizedExpression */: + case 210 /* OmittedExpression */: return 20; default: return -1; } } ts.getOperatorPrecedence = getOperatorPrecedence; - /* @internal */ function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: return 5; - case 53 /* AmpersandAmpersandToken */: + case 54 /* AmpersandAmpersandToken */: return 6; - case 49 /* BarToken */: + case 50 /* BarToken */: return 7; - case 50 /* CaretToken */: + case 51 /* CaretToken */: return 8; - case 48 /* AmpersandToken */: + case 49 /* AmpersandToken */: return 9; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return 10; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: return 11; - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 37 /* PlusToken */: - case 38 /* MinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: return 13; - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: return 14; - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -10755,7 +10926,7 @@ var ts; if (fileName) { return fileDiagnostics.get(fileName) || []; } - var fileDiags = ts.flatMap(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); + var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); if (!nonFileDiagnostics.length) { return fileDiags; } @@ -10813,7 +10984,7 @@ var ts; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || name.indexOf("-") > -1; + return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { @@ -10896,16 +11067,10 @@ var ts; lineStart = true; } } - function writeTextOfNode(text, node) { - var s = getTextOfNodeFromSourceText(text, node); - write(s); - updateLineCountAndPosFor(s); - } reset(); return { write: write, rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, writeLiteral: writeLiteral, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -10928,10 +11093,77 @@ var ts; writePunctuation: write, writeSpace: write, writeStringLiteral: write, - writeSymbol: write + writeSymbol: function (s, _) { return write(s); }, + writeTrailingSemicolon: write, + writeComment: write }; } ts.createTextWriter = createTextWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var pendingTrailingSemicolon = false; + function commitPendingTrailingSemicolon() { + if (pendingTrailingSemicolon) { + writer.writeTrailingSemicolon(";"); + pendingTrailingSemicolon = false; + } + } + return __assign({}, writer, { writeTrailingSemicolon: function () { + pendingTrailingSemicolon = true; + }, + writeLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeLiteral(s); + }, + writeStringLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeStringLiteral(s); + }, + writeSymbol: function (s, sym) { + commitPendingTrailingSemicolon(); + writer.writeSymbol(s, sym); + }, + writePunctuation: function (s) { + commitPendingTrailingSemicolon(); + writer.writePunctuation(s); + }, + writeKeyword: function (s) { + commitPendingTrailingSemicolon(); + writer.writeKeyword(s); + }, + writeOperator: function (s) { + commitPendingTrailingSemicolon(); + writer.writeOperator(s); + }, + writeParameter: function (s) { + commitPendingTrailingSemicolon(); + writer.writeParameter(s); + }, + writeSpace: function (s) { + commitPendingTrailingSemicolon(); + writer.writeSpace(s); + }, + writeProperty: function (s) { + commitPendingTrailingSemicolon(); + writer.writeProperty(s); + }, + writeComment: function (s) { + commitPendingTrailingSemicolon(); + writer.writeComment(s); + }, + writeLine: function () { + commitPendingTrailingSemicolon(); + writer.writeLine(); + }, + increaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.increaseIndent(); + }, + decreaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.decreaseIndent(); + } }); + } + ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11067,11 +11299,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 72 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 99 /* ThisKeyword */; + return id.originalKeywordKind === 100 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11082,10 +11314,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 157 /* SetAccessor */) { + else if (accessor.kind === 159 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11105,10 +11337,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 156 /* GetAccessor */ && !getAccessor) { + if (member.kind === 158 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 157 /* SetAccessor */ && !setAccessor) { + if (member.kind === 159 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11154,7 +11386,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 === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -11188,13 +11420,13 @@ var ts; function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { if (comments && comments.length > 0) { if (leadingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } var emitInterveningSeparator = false; for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var comment = comments_1[_i]; if (emitInterveningSeparator) { - writer.write(" "); + writer.writeSpace(" "); emitInterveningSeparator = false; } writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); @@ -11206,7 +11438,7 @@ var ts; } } if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } } } @@ -11324,7 +11556,7 @@ var ts; } else { // Single line comment of style //.... - writer.write(text.substring(commentPos, commentEnd)); + writer.writeComment(text.substring(commentPos, commentEnd)); } } ts.writeCommentRange = writeCommentRange; @@ -11333,14 +11565,14 @@ var ts; var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text - writer.write(currentLineText); + writer.writeComment(currentLineText); if (end !== commentEnd) { writer.writeLine(); } } else { // Empty string - make sure we write empty line - writer.writeLiteral(newLine); + writer.rawWrite(newLine); } } function calculateIndent(text, pos, end) { @@ -11394,7 +11626,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 72 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -11402,29 +11634,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 115 /* StaticKeyword */: return 32 /* Static */; - case 114 /* PublicKeyword */: return 4 /* Public */; - case 113 /* ProtectedKeyword */: return 16 /* Protected */; - case 112 /* PrivateKeyword */: return 8 /* Private */; - case 117 /* AbstractKeyword */: return 128 /* Abstract */; - case 84 /* ExportKeyword */: return 1 /* Export */; - case 124 /* DeclareKeyword */: return 2 /* Ambient */; - case 76 /* ConstKeyword */: return 2048 /* Const */; - case 79 /* DefaultKeyword */: return 512 /* Default */; - case 120 /* AsyncKeyword */: return 256 /* Async */; - case 132 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 116 /* StaticKeyword */: return 32 /* Static */; + case 115 /* PublicKeyword */: return 4 /* Public */; + case 114 /* ProtectedKeyword */: return 16 /* Protected */; + case 113 /* PrivateKeyword */: return 8 /* Private */; + case 118 /* AbstractKeyword */: return 128 /* Abstract */; + case 85 /* ExportKeyword */: return 1 /* Export */; + case 125 /* DeclareKeyword */: return 2 /* Ambient */; + case 77 /* ConstKeyword */: return 2048 /* Const */; + case 80 /* DefaultKeyword */: return 512 /* Default */; + case 121 /* AsyncKeyword */: return 256 /* Async */; + case 133 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 54 /* BarBarToken */ - || token === 53 /* AmpersandAmpersandToken */ - || token === 51 /* ExclamationToken */; + return token === 55 /* BarBarToken */ + || token === 54 /* AmpersandAmpersandToken */ + || token === 52 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */; + return token >= 59 /* FirstAssignment */ && token <= 71 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -11437,14 +11669,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 108 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 109 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 58 /* EqualsToken */ + ? node.operatorToken.kind === 59 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -11452,8 +11684,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 186 /* ObjectLiteralExpression */ - || kind === 185 /* ArrayLiteralExpression */; + return kind === 188 /* ObjectLiteralExpression */ + || kind === 187 /* ArrayLiteralExpression */; } return false; } @@ -11463,7 +11695,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 71 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 72 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function isPropertyAccessEntityNameExpression(node) { @@ -11475,17 +11707,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 186 /* ObjectLiteralExpression */ && + return expression.kind === 188 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 185 /* ArrayLiteralExpression */ && + return expression.kind === 187 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11850,8 +12082,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11928,35 +12160,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return accessKind(parent); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 202 /* BinaryExpression */: + return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 204 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 58 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 59 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 273 /* PropertyAssignment */: { + case 275 /* 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 274 /* ShorthandPropertyAssignment */: + case 276 /* 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 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 221 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12059,7 +12291,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 131072 /* Object */ ? type.objectFlags : 0; + return type.flags & 524288 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12330,9 +12562,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 148 /* TypeParameter */) { + if (d && d.kind === 150 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 241 /* InterfaceDeclaration */) { return current; } } @@ -12340,7 +12572,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 157 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12370,14 +12602,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 235 /* VariableDeclaration */) { + if (node.kind === 237 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 236 /* VariableDeclarationList */) { + if (node && node.kind === 238 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 217 /* VariableStatement */) { + if (node && node.kind === 219 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12523,27 +12755,27 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return expr.name; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 193 /* ParenthesizedExpression */: { + case 195 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 231 /* LabeledStatement */: { + case 233 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12567,17 +12799,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return declaration; - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: { + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 146 /* QualifiedName */) { + if (name.kind === 148 /* QualifiedName */) { return name.right; } break; } - case 202 /* BinaryExpression */: { + case 191 /* CallExpression */: + case 204 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -12585,13 +12818,17 @@ var ts; case 5 /* Property */: case 3 /* PrototypeProperty */: return expr.left.name; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return expr.arguments[1]; default: return undefined; } } - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 252 /* ExportAssignment */: { + case 254 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -12793,7 +13030,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12827,684 +13064,688 @@ var ts; return node.kind === 8 /* NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; + function isBigIntLiteral(node) { + return node.kind === 9 /* BigIntLiteral */; + } + ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 9 /* StringLiteral */; + return node.kind === 10 /* StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 12 /* RegularExpressionLiteral */; + return node.kind === 13 /* RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 14 /* TemplateHead */; + return node.kind === 15 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 15 /* TemplateMiddle */; + return node.kind === 16 /* TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 16 /* TemplateTail */; + return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 71 /* Identifier */; + return node.kind === 72 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 146 /* QualifiedName */; + return node.kind === 148 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 147 /* ComputedPropertyName */; + return node.kind === 149 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 148 /* TypeParameter */; + return node.kind === 150 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 149 /* Parameter */; + return node.kind === 151 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 151 /* PropertySignature */; + return node.kind === 153 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 152 /* PropertyDeclaration */; + return node.kind === 154 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 153 /* MethodSignature */; + return node.kind === 155 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 155 /* Constructor */; + return node.kind === 157 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 158 /* CallSignature */; + return node.kind === 160 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 159 /* ConstructSignature */; + return node.kind === 161 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 160 /* IndexSignature */; + return node.kind === 162 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; + return node.kind === 159 /* SetAccessor */ || node.kind === 158 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 161 /* TypePredicate */; + return node.kind === 163 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 162 /* TypeReference */; + return node.kind === 164 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 163 /* FunctionType */; + return node.kind === 165 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 164 /* ConstructorType */; + return node.kind === 166 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 165 /* TypeQuery */; + return node.kind === 167 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 166 /* TypeLiteral */; + return node.kind === 168 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 167 /* ArrayType */; + return node.kind === 169 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 168 /* TupleType */; + return node.kind === 170 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 171 /* UnionType */; + return node.kind === 173 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 172 /* IntersectionType */; + return node.kind === 174 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 173 /* ConditionalType */; + return node.kind === 175 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 174 /* InferType */; + return node.kind === 176 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 175 /* ParenthesizedType */; + return node.kind === 177 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 176 /* ThisType */; + return node.kind === 178 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 177 /* TypeOperator */; + return node.kind === 179 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 178 /* IndexedAccessType */; + return node.kind === 180 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 179 /* MappedType */; + return node.kind === 181 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 180 /* LiteralType */; + return node.kind === 182 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 181 /* ImportType */; + return node.kind === 183 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 182 /* ObjectBindingPattern */; + return node.kind === 184 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 183 /* ArrayBindingPattern */; + return node.kind === 185 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 184 /* BindingElement */; + return node.kind === 186 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 185 /* ArrayLiteralExpression */; + return node.kind === 187 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 186 /* ObjectLiteralExpression */; + return node.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 187 /* PropertyAccessExpression */; + return node.kind === 189 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 188 /* ElementAccessExpression */; + return node.kind === 190 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 189 /* CallExpression */; + return node.kind === 191 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 190 /* NewExpression */; + return node.kind === 192 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 191 /* TaggedTemplateExpression */; + return node.kind === 193 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 192 /* TypeAssertionExpression */; + return node.kind === 194 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 193 /* ParenthesizedExpression */; + return node.kind === 195 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 306 /* PartiallyEmittedExpression */) { + while (node.kind === 308 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 194 /* FunctionExpression */; + return node.kind === 196 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 195 /* ArrowFunction */; + return node.kind === 197 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 196 /* DeleteExpression */; + return node.kind === 198 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 197 /* TypeOfExpression */; + return node.kind === 199 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 198 /* VoidExpression */; + return node.kind === 200 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 199 /* AwaitExpression */; + return node.kind === 201 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 200 /* PrefixUnaryExpression */; + return node.kind === 202 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 201 /* PostfixUnaryExpression */; + return node.kind === 203 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 202 /* BinaryExpression */; + return node.kind === 204 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 203 /* ConditionalExpression */; + return node.kind === 205 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 204 /* TemplateExpression */; + return node.kind === 206 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 205 /* YieldExpression */; + return node.kind === 207 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 206 /* SpreadElement */; + return node.kind === 208 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 207 /* ClassExpression */; + return node.kind === 209 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 208 /* OmittedExpression */; + return node.kind === 210 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 210 /* AsExpression */; + return node.kind === 212 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 211 /* NonNullExpression */; + return node.kind === 213 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 212 /* MetaProperty */; + return node.kind === 214 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 214 /* TemplateSpan */; + return node.kind === 216 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 215 /* SemicolonClassElement */; + return node.kind === 217 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 216 /* Block */; + return node.kind === 218 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 217 /* VariableStatement */; + return node.kind === 219 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 218 /* EmptyStatement */; + return node.kind === 220 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 219 /* ExpressionStatement */; + return node.kind === 221 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 220 /* IfStatement */; + return node.kind === 222 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 221 /* DoStatement */; + return node.kind === 223 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 222 /* WhileStatement */; + return node.kind === 224 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 223 /* ForStatement */; + return node.kind === 225 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 224 /* ForInStatement */; + return node.kind === 226 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 225 /* ForOfStatement */; + return node.kind === 227 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 226 /* ContinueStatement */; + return node.kind === 228 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 227 /* BreakStatement */; + return node.kind === 229 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; + return node.kind === 229 /* BreakStatement */ || node.kind === 228 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 228 /* ReturnStatement */; + return node.kind === 230 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 229 /* WithStatement */; + return node.kind === 231 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 230 /* SwitchStatement */; + return node.kind === 232 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 231 /* LabeledStatement */; + return node.kind === 233 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 232 /* ThrowStatement */; + return node.kind === 234 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 233 /* TryStatement */; + return node.kind === 235 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 234 /* DebuggerStatement */; + return node.kind === 236 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 235 /* VariableDeclaration */; + return node.kind === 237 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 236 /* VariableDeclarationList */; + return node.kind === 238 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 237 /* FunctionDeclaration */; + return node.kind === 239 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 238 /* ClassDeclaration */; + return node.kind === 240 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 239 /* InterfaceDeclaration */; + return node.kind === 241 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 240 /* TypeAliasDeclaration */; + return node.kind === 242 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 241 /* EnumDeclaration */; + return node.kind === 243 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */; + return node.kind === 244 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 243 /* ModuleBlock */; + return node.kind === 245 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 244 /* CaseBlock */; + return node.kind === 246 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 245 /* NamespaceExportDeclaration */; + return node.kind === 247 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */; + return node.kind === 248 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 247 /* ImportDeclaration */; + return node.kind === 249 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 248 /* ImportClause */; + return node.kind === 250 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 249 /* NamespaceImport */; + return node.kind === 251 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 250 /* NamedImports */; + return node.kind === 252 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 251 /* ImportSpecifier */; + return node.kind === 253 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 252 /* ExportAssignment */; + return node.kind === 254 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 253 /* ExportDeclaration */; + return node.kind === 255 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 254 /* NamedExports */; + return node.kind === 256 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 255 /* ExportSpecifier */; + return node.kind === 257 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 256 /* MissingDeclaration */; + return node.kind === 258 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 257 /* ExternalModuleReference */; + return node.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 258 /* JsxElement */; + return node.kind === 260 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 259 /* JsxSelfClosingElement */; + return node.kind === 261 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 260 /* JsxOpeningElement */; + return node.kind === 262 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 261 /* JsxClosingElement */; + return node.kind === 263 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 262 /* JsxFragment */; + return node.kind === 264 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 263 /* JsxOpeningFragment */; + return node.kind === 265 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 264 /* JsxClosingFragment */; + return node.kind === 266 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 265 /* JsxAttribute */; + return node.kind === 267 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 266 /* JsxAttributes */; + return node.kind === 268 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 267 /* JsxSpreadAttribute */; + return node.kind === 269 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 268 /* JsxExpression */; + return node.kind === 270 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 269 /* CaseClause */; + return node.kind === 271 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 270 /* DefaultClause */; + return node.kind === 272 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 271 /* HeritageClause */; + return node.kind === 273 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 272 /* CatchClause */; + return node.kind === 274 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 273 /* PropertyAssignment */; + return node.kind === 275 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 274 /* ShorthandPropertyAssignment */; + return node.kind === 276 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 275 /* SpreadAssignment */; + return node.kind === 277 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 277 /* SourceFile */; + return node.kind === 279 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 278 /* Bundle */; + return node.kind === 280 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 279 /* UnparsedSource */; + return node.kind === 281 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 281 /* JSDocTypeExpression */; + return node.kind === 283 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 282 /* JSDocAllType */; + return node.kind === 284 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 283 /* JSDocUnknownType */; + return node.kind === 285 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 284 /* JSDocNullableType */; + return node.kind === 286 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 285 /* JSDocNonNullableType */; + return node.kind === 287 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 286 /* JSDocOptionalType */; + return node.kind === 288 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 287 /* JSDocFunctionType */; + return node.kind === 289 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 288 /* JSDocVariadicType */; + return node.kind === 290 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 289 /* JSDocComment */; + return node.kind === 291 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 293 /* JSDocAugmentsTag */; + return node.kind === 295 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 294 /* JSDocClassTag */; + return node.kind === 296 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 296 /* JSDocEnumTag */; + return node.kind === 298 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 299 /* JSDocThisTag */; + return node.kind === 301 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 297 /* JSDocParameterTag */; + return node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 298 /* JSDocReturnTag */; + return node.kind === 300 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 300 /* JSDocTypeTag */; + return node.kind === 302 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 301 /* JSDocTemplateTag */; + return node.kind === 303 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 302 /* JSDocTypedefTag */; + return node.kind === 304 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 303 /* JSDocPropertyTag */; + return node.kind === 305 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 303 /* JSDocPropertyTag */ || node.kind === 297 /* JSDocParameterTag */; + return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 290 /* JSDocTypeLiteral */; + return node.kind === 292 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 291 /* JSDocSignature */; + return node.kind === 293 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13515,7 +13756,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 304 /* SyntaxList */; + return n.kind === 306 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13525,7 +13766,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 146 /* FirstNode */; + return kind >= 148 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13534,7 +13775,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 147 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13546,7 +13787,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13556,7 +13797,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; + return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13565,12 +13806,12 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 15 /* TemplateMiddle */ - || kind === 16 /* TemplateTail */; + return kind === 16 /* TemplateMiddle */ + || kind === 17 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isStringTextContainingNode(node) { - return node.kind === 9 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers @@ -13583,17 +13824,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 79 /* DefaultKeyword */: - case 84 /* ExportKeyword */: - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 115 /* StaticKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 80 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 116 /* StaticKeyword */: return true; } return false; @@ -13606,7 +13847,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 115 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 116 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13615,23 +13856,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 9 /* StringLiteral */ + return kind === 72 /* Identifier */ + || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 147 /* ComputedPropertyName */; + || kind === 149 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 182 /* ObjectBindingPattern */ - || kind === 183 /* ArrayBindingPattern */; + return kind === 72 /* Identifier */ + || kind === 184 /* ObjectBindingPattern */ + || kind === 185 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13646,13 +13887,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -13661,14 +13902,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 164 /* ConstructorType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 166 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13683,29 +13924,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 152 /* PropertyDeclaration */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 160 /* IndexSignature */ - || kind === 215 /* SemicolonClassElement */; + return kind === 157 /* Constructor */ + || kind === 154 /* PropertyDeclaration */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 162 /* IndexSignature */ + || kind === 217 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); + return node && (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); + return node && (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; default: return false; @@ -13715,11 +13956,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 159 /* ConstructSignature */ - || kind === 158 /* CallSignature */ - || kind === 151 /* PropertySignature */ - || kind === 153 /* MethodSignature */ - || kind === 160 /* IndexSignature */; + return kind === 161 /* ConstructSignature */ + || kind === 160 /* CallSignature */ + || kind === 153 /* PropertySignature */ + || kind === 155 /* MethodSignature */ + || kind === 162 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13728,37 +13969,38 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 273 /* PropertyAssignment */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 275 /* SpreadAssignment */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 275 /* PropertyAssignment */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 277 /* SpreadAssignment */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) - || kind === 119 /* AnyKeyword */ - || kind === 142 /* UnknownKeyword */ - || kind === 134 /* NumberKeyword */ - || kind === 135 /* ObjectKeyword */ - || kind === 122 /* BooleanKeyword */ - || kind === 137 /* StringKeyword */ - || kind === 138 /* SymbolKeyword */ - || kind === 99 /* ThisKeyword */ - || kind === 105 /* VoidKeyword */ - || kind === 140 /* UndefinedKeyword */ - || kind === 95 /* NullKeyword */ - || kind === 131 /* NeverKeyword */ - || kind === 209 /* ExpressionWithTypeArguments */ - || kind === 282 /* JSDocAllType */ - || kind === 283 /* JSDocUnknownType */ - || kind === 284 /* JSDocNullableType */ - || kind === 285 /* JSDocNonNullableType */ - || kind === 286 /* JSDocOptionalType */ - || kind === 287 /* JSDocFunctionType */ - || kind === 288 /* JSDocVariadicType */; + return (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) + || kind === 120 /* AnyKeyword */ + || kind === 143 /* UnknownKeyword */ + || kind === 135 /* NumberKeyword */ + || kind === 146 /* BigIntKeyword */ + || kind === 136 /* ObjectKeyword */ + || kind === 123 /* BooleanKeyword */ + || kind === 138 /* StringKeyword */ + || kind === 139 /* SymbolKeyword */ + || kind === 100 /* ThisKeyword */ + || kind === 106 /* VoidKeyword */ + || kind === 141 /* UndefinedKeyword */ + || kind === 96 /* NullKeyword */ + || kind === 132 /* NeverKeyword */ + || kind === 211 /* ExpressionWithTypeArguments */ + || kind === 284 /* JSDocAllType */ + || kind === 285 /* JSDocUnknownType */ + || kind === 286 /* JSDocNullableType */ + || kind === 287 /* JSDocNonNullableType */ + || kind === 288 /* JSDocOptionalType */ + || kind === 289 /* JSDocFunctionType */ + || kind === 290 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13771,8 +14013,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return true; } return false; @@ -13783,8 +14025,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 183 /* ArrayBindingPattern */ - || kind === 182 /* ObjectBindingPattern */; + return kind === 185 /* ArrayBindingPattern */ + || kind === 184 /* ObjectBindingPattern */; } return false; } @@ -13792,15 +14034,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 185 /* ArrayLiteralExpression */ - || kind === 186 /* ObjectLiteralExpression */; + return kind === 187 /* ArrayLiteralExpression */ + || kind === 188 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 184 /* BindingElement */ - || kind === 208 /* OmittedExpression */; + return kind === 186 /* BindingElement */ + || kind === 210 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13809,9 +14051,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: return true; } return false; @@ -13832,8 +14074,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return true; } return false; @@ -13845,8 +14087,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return true; } return false; @@ -13855,26 +14097,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */ - || kind === 181 /* ImportType */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */ + || kind === 183 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 150 /* Decorator */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 152 /* Decorator */: return true; default: return false; @@ -13882,13 +14124,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; + return node.kind === 191 /* CallExpression */ || node.kind === 192 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 204 /* TemplateExpression */ - || kind === 13 /* NoSubstitutionTemplateLiteral */; + return kind === 206 /* TemplateExpression */ + || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13898,33 +14140,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 190 /* NewExpression */: - case 189 /* CallExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 191 /* TaggedTemplateExpression */: - case 185 /* ArrayLiteralExpression */: - case 193 /* ParenthesizedExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 71 /* Identifier */: - case 12 /* RegularExpressionLiteral */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 192 /* NewExpression */: + case 191 /* CallExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 193 /* TaggedTemplateExpression */: + case 187 /* ArrayLiteralExpression */: + case 195 /* ParenthesizedExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 72 /* Identifier */: + case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 101 /* TrueKeyword */: - case 97 /* SuperKeyword */: - case 211 /* NonNullExpression */: - case 212 /* MetaProperty */: - case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 102 /* TrueKeyword */: + case 98 /* SuperKeyword */: + case 213 /* NonNullExpression */: + case 214 /* MetaProperty */: + case 92 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13937,13 +14180,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 192 /* TypeAssertionExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 194 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13952,11 +14195,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 43 /* PlusPlusToken */ || - expr.operator === 44 /* MinusMinusToken */; + case 202 /* PrefixUnaryExpression */: + return expr.operator === 44 /* PlusPlusToken */ || + expr.operator === 45 /* MinusMinusToken */; default: return false; } @@ -13973,15 +14216,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: - case 195 /* ArrowFunction */: - case 202 /* BinaryExpression */: - case 206 /* SpreadElement */: - case 210 /* AsExpression */: - case 208 /* OmittedExpression */: - case 307 /* CommaListExpression */: - case 306 /* PartiallyEmittedExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: + case 197 /* ArrowFunction */: + case 204 /* BinaryExpression */: + case 208 /* SpreadElement */: + case 212 /* AsExpression */: + case 210 /* OmittedExpression */: + case 309 /* CommaListExpression */: + case 308 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13989,18 +14232,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 192 /* TypeAssertionExpression */ - || kind === 210 /* AsExpression */; + return kind === 194 /* TypeAssertionExpression */ + || kind === 212 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 306 /* PartiallyEmittedExpression */; + return node.kind === 308 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 305 /* NotEmittedStatement */; + return node.kind === 307 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14011,13 +14254,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return true; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14025,7 +14268,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; + return node.kind === 226 /* ForInStatement */ || node.kind === 227 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14049,113 +14292,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */ - || kind === 71 /* Identifier */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */ + || kind === 72 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 242 /* ModuleDeclaration */; + return kind === 72 /* Identifier */ + || kind === 244 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 250 /* NamedImports */ - || kind === 249 /* NamespaceImport */; + return kind === 252 /* NamedImports */ + || kind === 251 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; + return node.kind === 244 /* ModuleDeclaration */ || node.kind === 243 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 195 /* ArrowFunction */ - || kind === 184 /* BindingElement */ - || kind === 238 /* ClassDeclaration */ - || kind === 207 /* ClassExpression */ - || kind === 155 /* Constructor */ - || kind === 241 /* EnumDeclaration */ - || kind === 276 /* EnumMember */ - || kind === 255 /* ExportSpecifier */ - || kind === 237 /* FunctionDeclaration */ - || kind === 194 /* FunctionExpression */ - || kind === 156 /* GetAccessor */ - || kind === 248 /* ImportClause */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 251 /* ImportSpecifier */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 265 /* JsxAttribute */ - || kind === 154 /* MethodDeclaration */ - || kind === 153 /* MethodSignature */ - || kind === 242 /* ModuleDeclaration */ - || kind === 245 /* NamespaceExportDeclaration */ - || kind === 249 /* NamespaceImport */ - || kind === 149 /* Parameter */ - || kind === 273 /* PropertyAssignment */ - || kind === 152 /* PropertyDeclaration */ - || kind === 151 /* PropertySignature */ - || kind === 157 /* SetAccessor */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 148 /* TypeParameter */ - || kind === 235 /* VariableDeclaration */ - || kind === 302 /* JSDocTypedefTag */ - || kind === 295 /* JSDocCallbackTag */ - || kind === 303 /* JSDocPropertyTag */; + return kind === 197 /* ArrowFunction */ + || kind === 186 /* BindingElement */ + || kind === 240 /* ClassDeclaration */ + || kind === 209 /* ClassExpression */ + || kind === 157 /* Constructor */ + || kind === 243 /* EnumDeclaration */ + || kind === 278 /* EnumMember */ + || kind === 257 /* ExportSpecifier */ + || kind === 239 /* FunctionDeclaration */ + || kind === 196 /* FunctionExpression */ + || kind === 158 /* GetAccessor */ + || kind === 250 /* ImportClause */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 253 /* ImportSpecifier */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 267 /* JsxAttribute */ + || kind === 156 /* MethodDeclaration */ + || kind === 155 /* MethodSignature */ + || kind === 244 /* ModuleDeclaration */ + || kind === 247 /* NamespaceExportDeclaration */ + || kind === 251 /* NamespaceImport */ + || kind === 151 /* Parameter */ + || kind === 275 /* PropertyAssignment */ + || kind === 154 /* PropertyDeclaration */ + || kind === 153 /* PropertySignature */ + || kind === 159 /* SetAccessor */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 150 /* TypeParameter */ + || kind === 237 /* VariableDeclaration */ + || kind === 304 /* JSDocTypedefTag */ + || kind === 297 /* JSDocCallbackTag */ + || kind === 305 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 237 /* FunctionDeclaration */ - || kind === 256 /* MissingDeclaration */ - || kind === 238 /* ClassDeclaration */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 241 /* EnumDeclaration */ - || kind === 242 /* ModuleDeclaration */ - || kind === 247 /* ImportDeclaration */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 253 /* ExportDeclaration */ - || kind === 252 /* ExportAssignment */ - || kind === 245 /* NamespaceExportDeclaration */; + return kind === 239 /* FunctionDeclaration */ + || kind === 258 /* MissingDeclaration */ + || kind === 240 /* ClassDeclaration */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 243 /* EnumDeclaration */ + || kind === 244 /* ModuleDeclaration */ + || kind === 249 /* ImportDeclaration */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 255 /* ExportDeclaration */ + || kind === 254 /* ExportAssignment */ + || kind === 247 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 227 /* BreakStatement */ - || kind === 226 /* ContinueStatement */ - || kind === 234 /* DebuggerStatement */ - || kind === 221 /* DoStatement */ - || kind === 219 /* ExpressionStatement */ - || kind === 218 /* EmptyStatement */ - || kind === 224 /* ForInStatement */ - || kind === 225 /* ForOfStatement */ - || kind === 223 /* ForStatement */ - || kind === 220 /* IfStatement */ - || kind === 231 /* LabeledStatement */ - || kind === 228 /* ReturnStatement */ - || kind === 230 /* SwitchStatement */ - || kind === 232 /* ThrowStatement */ - || kind === 233 /* TryStatement */ - || kind === 217 /* VariableStatement */ - || kind === 222 /* WhileStatement */ - || kind === 229 /* WithStatement */ - || kind === 305 /* NotEmittedStatement */ - || kind === 309 /* EndOfDeclarationMarker */ - || kind === 308 /* MergeDeclarationMarker */; + return kind === 229 /* BreakStatement */ + || kind === 228 /* ContinueStatement */ + || kind === 236 /* DebuggerStatement */ + || kind === 223 /* DoStatement */ + || kind === 221 /* ExpressionStatement */ + || kind === 220 /* EmptyStatement */ + || kind === 226 /* ForInStatement */ + || kind === 227 /* ForOfStatement */ + || kind === 225 /* ForStatement */ + || kind === 222 /* IfStatement */ + || kind === 233 /* LabeledStatement */ + || kind === 230 /* ReturnStatement */ + || kind === 232 /* SwitchStatement */ + || kind === 234 /* ThrowStatement */ + || kind === 235 /* TryStatement */ + || kind === 219 /* VariableStatement */ + || kind === 224 /* WhileStatement */ + || kind === 231 /* WithStatement */ + || kind === 307 /* NotEmittedStatement */ + || kind === 311 /* EndOfDeclarationMarker */ + || kind === 310 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 301 /* JSDocTemplateTag */ || ts.isInJSFile(node); + if (node.kind === 150 /* TypeParameter */) { + return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14182,10 +14425,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 216 /* Block */) + if (node.kind !== 218 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { + if (node.parent.kind === 235 /* TryStatement */ || node.parent.kind === 274 /* CatchClause */) { return false; } } @@ -14195,81 +14438,81 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 257 /* ExternalModuleReference */ - || kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 259 /* ExternalModuleReference */ + || kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 99 /* ThisKeyword */ - || kind === 71 /* Identifier */ - || kind === 187 /* PropertyAccessExpression */; + return kind === 100 /* ThisKeyword */ + || kind === 72 /* Identifier */ + || kind === 189 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 258 /* JsxElement */ - || kind === 268 /* JsxExpression */ - || kind === 259 /* JsxSelfClosingElement */ - || kind === 10 /* JsxText */ - || kind === 262 /* JsxFragment */; + return kind === 260 /* JsxElement */ + || kind === 270 /* JsxExpression */ + || kind === 261 /* JsxSelfClosingElement */ + || kind === 11 /* JsxText */ + || kind === 264 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 265 /* JsxAttribute */ - || kind === 267 /* JsxSpreadAttribute */; + return kind === 267 /* JsxAttribute */ + || kind === 269 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ - || kind === 268 /* JsxExpression */; + return kind === 10 /* StringLiteral */ + || kind === 270 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 260 /* JsxOpeningElement */ - || kind === 259 /* JsxSelfClosingElement */; + return kind === 262 /* JsxOpeningElement */ + || kind === 261 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 269 /* CaseClause */ - || kind === 270 /* DefaultClause */; + return kind === 271 /* CaseClause */ + || kind === 272 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 303 /* LastJSDocNode */; + return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 303 /* LastJSDocTagNode */; + return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14299,12 +14542,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 265 /* JsxAttribute */ || node.kind === 267 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 267 /* JsxAttribute */ || node.kind === 269 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 164 /* TypeReference */ || node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14333,15 +14576,14 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 9 /* StringLiteral */ || node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; })(ts || (ts = {})); /* @internal */ (function (ts) { - /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; + return node.kind === 252 /* NamedImports */ || node.kind === 256 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -14386,10 +14628,9 @@ var ts; getSignatureConstructor: function () { return Signature; }, getSourceMapSourceConstructor: function () { return SourceMapSource; }, }; - /* @internal */ function formatStringFromArgs(text, args, baseIndex) { if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return ts.Debug.assertDefined(args[+index + baseIndex]); }); + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; function getLocaleSpecificMessage(message) { @@ -14418,7 +14659,6 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; - /* @internal */ function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -14443,7 +14683,6 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; - /* @internal */ function createCompilerDiagnosticFromMessageChain(chain) { return { file: undefined, @@ -14480,14 +14719,12 @@ var ts; function getDiagnosticFilePath(diagnostic) { return diagnostic.file ? diagnostic.file.path : undefined; } - /* @internal */ function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; - /* @internal */ function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || @@ -14791,7 +15028,6 @@ var ts; return rootLength > 0 && rootLength === path.length; } ts.isDiskPathRoot = isDiskPathRoot; - /* @internal */ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { return !isRootedDiskPath(absoluteOrRelativePath) ? absoluteOrRelativePath @@ -15756,6 +15992,82 @@ var ts; } } ts.getOrUpdate = getOrUpdate; + /** + * Converts a bigint literal string, e.g. `0x1234n`, + * to its decimal string representation, e.g. `4660`. + */ + function parsePseudoBigInt(stringValue) { + var log2Base; + switch (stringValue.charCodeAt(1)) { // "x" in "0x123" + case 98 /* b */: + case 66 /* B */: // 0b or 0B + log2Base = 1; + break; + case 111 /* o */: + case 79 /* O */: // 0o or 0O + log2Base = 3; + break; + case 120 /* x */: + case 88 /* 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 */) { + nonZeroStart++; + } + return stringValue.slice(nonZeroStart, nIndex) || "0"; + } + // Omit leading "0b", "0o", or "0x", and trailing "n" + var startIndex = 2, endIndex = stringValue.length - 1; + var bitsNeeded = (endIndex - startIndex) * log2Base; + // Stores the value specified by the string as a LE array of 16-bit integers + // using Uint16 instead of Uint32 so combining steps can use bitwise operators + var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0)); + // Add the digits, one at a time + for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) { + 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 */ + : 10 + digitChar - + (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + var shiftedDigit = digit << (bitOffset & 15); + segments[segment] |= shiftedDigit; + var residual = shiftedDigit >>> 16; + if (residual) + segments[segment + 1] |= residual; // overflows segment + } + // Repeatedly divide segments by 10 and add remainder to base10Value + var base10Value = ""; + var firstNonzeroSegment = segments.length - 1; + var segmentsRemaining = true; + while (segmentsRemaining) { + var mod10 = 0; + segmentsRemaining = false; + for (var segment = firstNonzeroSegment; segment >= 0; segment--) { + var newSegment = mod10 << 16 | segments[segment]; + var segmentValue = (newSegment / 10) | 0; + segments[segment] = segmentValue; + mod10 = newSegment - segmentValue * 10; + if (segmentValue && !segmentsRemaining) { + firstNonzeroSegment = segment; + segmentsRemaining = true; + } + } + base10Value = mod10 + base10Value; + } + return base10Value; + } + ts.parsePseudoBigInt = parsePseudoBigInt; + function pseudoBigIntToString(_a) { + var negative = _a.negative, base10Value = _a.base10Value; + return (negative && base10Value !== "0" ? "-" : "") + base10Value; + } + ts.pseudoBigIntToString = pseudoBigIntToString; })(ts || (ts = {})); var ts; (function (ts) { @@ -15775,10 +16087,10 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 277 /* SourceFile */) { + if (kind === 279 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 71 /* Identifier */) { + else if (kind === 72 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -15827,19 +16139,19 @@ 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 <= 145 /* LastToken */) { + if (!node || node.kind <= 147 /* LastToken */) { return; } switch (node.kind) { - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15847,9 +16159,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15857,7 +16169,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15865,51 +16177,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertySignature */: + case 153 /* 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 273 /* PropertyAssignment */: + case 275 /* 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 235 /* VariableDeclaration */: + case 237 /* 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 184 /* BindingElement */: + case 186 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15921,302 +16233,302 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 168 /* TupleType */: + case 170 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 174 /* InferType */: + case 176 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 181 /* ImportType */: + case 183 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 175 /* ParenthesizedType */: - case 177 /* TypeOperator */: + case 177 /* ParenthesizedType */: + case 179 /* TypeOperator */: return visitNode(cbNode, node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 179 /* MappedType */: + case 181 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return visitNode(cbNode, node.literal); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitNode(cbNode, node.name); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return visitNode(cbNode, node.label); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 150 /* Decorator */: + case 152 /* Decorator */: return visitNode(cbNode, node.expression); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 239 /* InterfaceDeclaration */: + case 241 /* 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 240 /* TypeAliasDeclaration */: + case 242 /* 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 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 169 /* OptionalType */: - case 170 /* RestType */: - case 281 /* JSDocTypeExpression */: - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 286 /* JSDocOptionalType */: - case 288 /* JSDocVariadicType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 283 /* JSDocTypeExpression */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 288 /* JSDocOptionalType */: + case 290 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 289 /* JSDocComment */: + case 291 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -16225,17 +16537,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 281 /* JSDocTypeExpression */) { + node.typeExpression.kind === 283 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -16243,20 +16555,20 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 295 /* JSDocCallbackTag */: + case 297 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocThisTag */: + case 301 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocEnumTag */: + case 298 /* JSDocEnumTag */: return visitNode(cbNode, node.typeExpression); - case 291 /* JSDocSignature */: + case 293 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 290 /* JSDocTypeLiteral */: + case 292 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -16264,7 +16576,7 @@ var ts; } } return; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -16482,18 +16794,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(219 /* ExpressionStatement */); + var statement = createNode(221 /* ExpressionStatement */); switch (token()) { - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 38 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 56 /* ColonToken */; })) { + case 39 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -16501,8 +16813,8 @@ var ts; } break; case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 56 /* ColonToken */; })) { + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -16638,7 +16950,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16843,20 +17155,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 71 /* Identifier */) { + if (token() === 72 /* 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() === 116 /* YieldKeyword */ && inYieldContext()) { + if (token() === 117 /* 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() === 121 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 122 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 107 /* LastReservedWord */; + return token() > 108 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -16899,29 +17211,29 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(25 /* SemicolonToken */); + return parseExpected(26 /* SemicolonToken */); } } function createNode(kind, pos) { nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 72 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -16963,7 +17275,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 71 /* Identifier */) { + if (kind === 72 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -16984,9 +17296,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(71 /* Identifier */); + var node = createNode(72 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 71 /* Identifier */) { + if (token() !== 72 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -16995,7 +17307,7 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17005,16 +17317,16 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -17026,13 +17338,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(147 /* ComputedPropertyName */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(149 /* ComputedPropertyName */); + parseExpected(22 /* 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. node.expression = allowInAnd(parseExpression); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -17047,20 +17359,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 83 /* EnumKeyword */; - case 84 /* ExportKeyword */: + return nextToken() === 84 /* EnumKeyword */; + case 85 /* ExportKeyword */: nextToken(); - if (token() === 79 /* DefaultKeyword */) { + if (token() === 80 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier(); - case 79 /* DefaultKeyword */: + return token() !== 40 /* AsteriskToken */ && token() !== 119 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 80 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 115 /* StaticKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -17071,18 +17383,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 21 /* OpenBracketToken */ - || token() === 17 /* OpenBraceToken */ - || token() === 39 /* AsteriskToken */ - || token() === 24 /* DotDotDotToken */ + return token() === 22 /* OpenBracketToken */ + || token() === 18 /* OpenBraceToken */ + || token() === 40 /* AsteriskToken */ + || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ || - token() === 109 /* InterfaceKeyword */ || - (token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 76 /* ClassKeyword */ || token() === 90 /* FunctionKeyword */ || + token() === 110 /* InterfaceKeyword */ || + (token() === 118 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 121 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -17100,9 +17412,9 @@ var ts; // 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() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -17110,17 +17422,17 @@ var ts; // 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() === 25 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: switch (token()) { - case 21 /* OpenBracketToken */: - case 39 /* AsteriskToken */: - case 24 /* DotDotDotToken */: - case 23 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* OpenBracketToken */: + case 40 /* 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`) return true; default: return isLiteralPropertyName(); @@ -17128,11 +17440,11 @@ var ts; case 18 /* RestProperties */: return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* 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() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -17147,37 +17459,39 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern(); case 19 /* TypeParameters */: return isIdentifier(); case 15 /* ArrayLiteralMembers */: - if (token() === 26 /* CommaToken */) { - return true; + 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`) + return true; } // falls through case 11 /* ArgumentExpressions */: - return token() === 24 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); case 17 /* JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); case 20 /* TypeArguments */: case 21 /* TupleElementTypes */: - return token() === 26 /* CommaToken */ || isStartOfType(); + return token() === 27 /* CommaToken */ || isStartOfType(); case 22 /* HeritageClauses */: return isHeritageClause(); case 23 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 17 /* OpenBraceToken */); - if (nextToken() === 18 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* OpenBraceToken */); + if (nextToken() === 19 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -17186,7 +17500,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 86 /* ExtendsKeyword */ || next === 109 /* ImplementsKeyword */; } return true; } @@ -17203,8 +17517,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 108 /* ImplementsKeyword */ || - token() === 85 /* ExtendsKeyword */) { + if (token() === 109 /* ImplementsKeyword */ || + token() === 86 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -17232,37 +17546,37 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 23 /* ImportOrExportSpecifiers */: - return token() === 18 /* CloseBraceToken */; + return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */; + return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 21 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 22 /* CloseBracketToken */; + return token() === 23 /* CloseBracketToken */; case 17 /* JSDocParameters */: case 16 /* Parameters */: case 18 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 20 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 26 /* CommaToken */; + return token() !== 27 /* CommaToken */; case 22 /* HeritageClauses */: - return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */; + return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; + return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -17282,7 +17596,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() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -17452,20 +17766,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 155 /* Constructor */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 215 /* SemicolonClassElement */: + case 157 /* Constructor */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 217 /* SemicolonClassElement */: return true; - case 154 /* MethodDeclaration */: + case 156 /* 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 === 71 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 72 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 124 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -17474,8 +17788,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: return true; } } @@ -17484,58 +17798,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 217 /* VariableStatement */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 219 /* ExpressionStatement */: - case 232 /* ThrowStatement */: - case 228 /* ReturnStatement */: - case 230 /* SwitchStatement */: - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 218 /* EmptyStatement */: - case 233 /* TryStatement */: - case 231 /* LabeledStatement */: - case 221 /* DoStatement */: - case 234 /* DebuggerStatement */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 219 /* VariableStatement */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 221 /* ExpressionStatement */: + case 234 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 232 /* SwitchStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 220 /* EmptyStatement */: + case 235 /* TryStatement */: + case 233 /* LabeledStatement */: + case 223 /* DoStatement */: + case 236 /* DebuggerStatement */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 151 /* PropertySignature */: - case 158 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 153 /* PropertySignature */: + case 160 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 235 /* VariableDeclaration */) { + if (node.kind !== 237 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -17556,7 +17870,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 149 /* Parameter */) { + if (node.kind !== 151 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -17613,7 +17927,7 @@ var ts; var startPos = scanner.getStartPos(); list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -17623,13 +17937,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(26 /* CommaToken */); + parseExpected(27 /* CommaToken */); // 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() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -17680,8 +17994,8 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); - while (parseOptional(23 /* DotToken */)) { - if (token() === 27 /* LessThanToken */) { + while (parseOptional(24 /* DotToken */)) { + if (token() === 28 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -17692,7 +18006,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(146 /* QualifiedName */, entity.pos); + var node = createNode(148 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -17723,33 +18037,33 @@ 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(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(204 /* TemplateExpression */); + var template = createNode(206 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 16 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(214 /* TemplateSpan */); + var span = createNode(216 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 18 /* CloseBraceToken */) { + if (token() === 19 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(16 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */)); + literal = parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -17759,18 +18073,17 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind) { var node = createNode(kind); - var text = scanner.getTokenValue(); - node.text = text; + node.text = scanner.getTokenValue(); if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -17792,24 +18105,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 28 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: { + case 165 /* FunctionType */: + case 166 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17817,20 +18130,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(161 /* TypePredicate */, lhs.pos); + var node = createNode(163 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(176 /* ThisType */); + var node = createNode(178 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(282 /* JSDocAllType */); + var result = createNode(284 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(286 /* JSDocOptionalType */, result); + return createPostfixType(288 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17838,7 +18151,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(285 /* JSDocNonNullableType */); + var result = createNode(287 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17856,66 +18169,66 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 26 /* CommaToken */ || - token() === 18 /* CloseBraceToken */ || - token() === 20 /* CloseParenToken */ || - token() === 29 /* GreaterThanToken */ || - token() === 58 /* EqualsToken */ || - token() === 49 /* BarToken */) { - var result = createNode(283 /* JSDocUnknownType */, pos); + if (token() === 27 /* CommaToken */ || + token() === 19 /* CloseBraceToken */ || + token() === 21 /* CloseParenToken */ || + token() === 30 /* GreaterThanToken */ || + token() === 59 /* EqualsToken */ || + token() === 50 /* BarToken */) { + var result = createNode(285 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(284 /* JSDocNullableType */, pos); + var result = createNode(286 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); nextToken(); - fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { + var parameter = createNode(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */ || token() === 95 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); + var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 58 /* EqualsToken */) { - return createPostfixType(286 /* JSDocOptionalType */, type); + if (token() === 59 /* EqualsToken */) { + return createPostfixType(288 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(165 /* TypeQuery */); - parseExpected(103 /* TypeOfKeyword */); + var node = createNode(167 /* TypeQuery */); + parseExpected(104 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(85 /* ExtendsKeyword */)) { + if (parseOptional(86 /* 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 @@ -17934,39 +18247,39 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(58 /* EqualsToken */)) { + if (parseOptional(59 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 27 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (token() === 28 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(56 /* ColonToken */)) { + if (parseOptional(57 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter(isJSDocParameter) { - return token() === 24 /* DotDotDotToken */ || + return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 /* AtToken */ || + token() === 58 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */) { + var node = createNodeWithJSDoc(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -17981,7 +18294,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(55 /* QuestionToken */); + node.questionToken = parseOptionalToken(56 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18003,16 +18316,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 36 /* EqualsGreaterThanToken */) { + if (returnToken === 37 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(56 /* ColonToken */)) { + else if (parseOptional(57 /* ColonToken */)) { return true; } - else if (isType && token() === 36 /* EqualsGreaterThanToken */) { + else if (isType && token() === 37 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); nextToken(); return true; } @@ -18033,7 +18346,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(19 /* OpenParenToken */)) { + if (!parseExpected(20 /* OpenParenToken */)) { signature.parameters = createMissingList(); return false; } @@ -18046,12 +18359,12 @@ var ts; parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - return parseExpected(20 /* CloseParenToken */); + return parseExpected(21 /* CloseParenToken */); } 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(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -18059,15 +18372,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 159 /* ConstructSignature */) { - parseExpected(94 /* NewKeyword */); + if (kind === 161 /* ConstructSignature */) { + parseExpected(95 /* NewKeyword */); } - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - return token() === 21 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -18087,7 +18400,7 @@ var ts; // [] // nextToken(); - if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) { + if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -18106,39 +18419,39 @@ 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* 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() !== 55 /* QuestionToken */) { + if (token() !== 56 /* 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; + return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 160 /* IndexSignature */; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.kind = 162 /* IndexSignature */; + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 153 /* MethodSignature */; + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.kind = 155 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 151 /* PropertySignature */; + node.kind = 153 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { // 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. @@ -18150,7 +18463,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return true; } var idToken = false; @@ -18160,7 +18473,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -18171,21 +18484,21 @@ 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() === 19 /* OpenParenToken */ || - token() === 27 /* LessThanToken */ || - token() === 55 /* QuestionToken */ || - token() === 56 /* ColonToken */ || - token() === 26 /* CommaToken */ || + return token() === 20 /* OpenParenToken */ || + token() === 28 /* LessThanToken */ || + token() === 56 /* QuestionToken */ || + token() === 57 /* ColonToken */ || + token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(158 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + return parseSignatureMember(160 /* CallSignature */); } - if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(159 /* ConstructSignature */); + if (token() === 95 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(161 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -18196,30 +18509,30 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 23 /* DotToken */; + return nextToken() === 24 /* DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 19 /* OpenParenToken */: - case 27 /* LessThanToken */: - case 23 /* DotToken */: + case 20 /* OpenParenToken */: + case 28 /* LessThanToken */: + case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(166 /* TypeLiteral */); + var node = createNode(168 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { members = createMissingList(); @@ -18228,89 +18541,89 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { - return nextToken() === 132 /* ReadonlyKeyword */; + if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + return nextToken() === 133 /* ReadonlyKeyword */; } - if (token() === 132 /* ReadonlyKeyword */) { + if (token() === 133 /* ReadonlyKeyword */) { nextToken(); } - return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 93 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(92 /* InKeyword */); + parseExpected(93 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(179 /* MappedType */); - parseExpected(17 /* OpenBraceToken */); - if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + var node = createNode(181 /* MappedType */); + parseExpected(18 /* OpenBraceToken */); + if (token() === 133 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { - parseExpectedToken(132 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { + parseExpectedToken(133 /* ReadonlyKeyword */); } } - parseExpected(21 /* OpenBracketToken */); + parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); - parseExpected(22 /* CloseBracketToken */); - if (token() === 55 /* QuestionToken */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + parseExpected(23 /* CloseBracketToken */); + if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 55 /* QuestionToken */) { - parseExpectedToken(55 /* QuestionToken */); + if (node.questionToken.kind !== 56 /* QuestionToken */) { + parseExpectedToken(56 /* QuestionToken */); } } node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(24 /* DotDotDotToken */)) { - var node = createNode(170 /* RestType */, pos); + if (parseOptional(25 /* DotDotDotToken */)) { + var node = createNode(172 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 169 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 171 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + var node = createNode(170 /* TupleType */); + node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(175 /* ParenthesizedType */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(177 /* ParenthesizedType */); + parseExpected(20 /* OpenParenToken */); node.type = parseType(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(94 /* NewKeyword */) ? 164 /* ConstructorType */ : 163 /* FunctionType */; + var kind = parseOptional(95 /* NewKeyword */) ? 166 /* ConstructorType */ : 165 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 23 /* DotToken */ ? undefined : node; + return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(180 /* LiteralType */); + var node = createNode(182 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 38 /* MinusToken */; + unaryMinusExpression = createNode(202 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } - var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */ + var expression = token() === 102 /* TrueKeyword */ || token() === 87 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -18323,79 +18636,82 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 91 /* ImportKeyword */; + return token() === 92 /* ImportKeyword */; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(181 /* ImportType */); - if (parseOptional(103 /* TypeOfKeyword */)) { + var node = createNode(183 /* ImportType */); + if (parseOptional(104 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(91 /* ImportKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(92 /* ImportKeyword */); + parseExpected(20 /* OpenParenToken */); node.argument = parseType(); - parseExpected(20 /* CloseParenToken */); - if (parseOptional(23 /* DotToken */)) { + parseExpected(21 /* CloseParenToken */); + if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } node.typeArguments = tryParseTypeArguments(); return finishNode(node); } - function nextTokenIsNumericLiteral() { - return nextToken() === 8 /* NumericLiteral */; + function nextTokenIsNumericOrBigIntLiteral() { + nextToken(); + return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 138 /* SymbolKeyword */: - case 122 /* BooleanKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 139 /* SymbolKeyword */: + case 123 /* BooleanKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 61 /* AsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 51 /* ExclamationToken */: + case 52 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseLiteralTypeNode(); - case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 105 /* VoidKeyword */: - case 95 /* NullKeyword */: + case 39 /* MinusToken */: + return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); + case 106 /* VoidKeyword */: + case 96 /* NullKeyword */: return parseTokenNode(); - case 99 /* ThisKeyword */: { + case 100 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseTupleType(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportType(); default: return parseTypeReference(); @@ -18403,42 +18719,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 141 /* UniqueKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 103 /* TypeOfKeyword */: - case 131 /* NeverKeyword */: - case 17 /* OpenBraceToken */: - case 21 /* OpenBracketToken */: - case 27 /* LessThanToken */: - case 49 /* BarToken */: - case 48 /* AmpersandToken */: - case 94 /* NewKeyword */: - case 9 /* StringLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 142 /* UniqueKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 104 /* TypeOfKeyword */: + case 132 /* NeverKeyword */: + case 18 /* OpenBraceToken */: + case 22 /* OpenBracketToken */: + case 28 /* LessThanToken */: + case 50 /* BarToken */: + case 49 /* AmpersandToken */: + case 95 /* NewKeyword */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 135 /* ObjectKeyword */: - case 39 /* AsteriskToken */: - case 55 /* QuestionToken */: - case 51 /* ExclamationToken */: - case 24 /* DotDotDotToken */: - case 126 /* InferKeyword */: - case 91 /* ImportKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 136 /* ObjectKeyword */: + case 40 /* AsteriskToken */: + case 56 /* QuestionToken */: + case 52 /* ExclamationToken */: + case 25 /* DotDotDotToken */: + case 127 /* InferKeyword */: + case 92 /* ImportKeyword */: return true; - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return !inStartOfParameter; - case 38 /* MinusToken */: - return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); - case 19 /* OpenParenToken */: + case 39 /* MinusToken */: + return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); + case 20 /* 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); @@ -18448,35 +18766,35 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 20 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 51 /* ExclamationToken */: - type = createPostfixType(285 /* JSDocNonNullableType */, type); + case 52 /* ExclamationToken */: + type = createPostfixType(287 /* JSDocNonNullableType */, type); break; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(284 /* JSDocNullableType */, type); + type = createPostfixType(286 /* JSDocNullableType */, type); break; - case 21 /* OpenBracketToken */: - parseExpected(21 /* OpenBracketToken */); + case 22 /* OpenBracketToken */: + parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(178 /* IndexedAccessType */, type.pos); + var node = createNode(180 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(167 /* ArrayType */, type.pos); + var node = createNode(169 /* ArrayType */, type.pos); node.elementType = type; - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } break; @@ -18493,16 +18811,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(177 /* TypeOperator */); + var node = createNode(179 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(174 /* InferType */); - parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(148 /* TypeParameter */); + var node = createNode(176 /* InferType */); + parseExpected(127 /* InferKeyword */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -18510,10 +18828,10 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 128 /* KeyOfKeyword */: - case 141 /* UniqueKeyword */: + case 129 /* KeyOfKeyword */: + case 142 /* UniqueKeyword */: return parseTypeOperator(operator); - case 126 /* InferKeyword */: + case 127 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -18533,27 +18851,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(174 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(173 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { return true; } - return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 99 /* ThisKeyword */) { + if (isIdentifier() || token() === 100 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) { + if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -18563,7 +18881,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) { + if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -18571,17 +18889,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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || - token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 56 /* QuestionToken */ || token() === 59 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 20 /* CloseParenToken */) { + if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -18593,7 +18911,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(163 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -18604,7 +18922,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -18615,49 +18933,50 @@ var ts; return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 94 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 95 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(173 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(86 /* ExtendsKeyword */)) { + var node = createNode(175 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(55 /* QuestionToken */); + parseExpected(56 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(56 /* ColonToken */) ? parseType() : undefined; + return parseOptional(57 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 19 /* OpenParenToken */: - case 21 /* OpenBracketToken */: - case 17 /* OpenBraceToken */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 94 /* NewKeyword */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 71 /* Identifier */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 20 /* OpenParenToken */: + case 22 /* OpenBracketToken */: + case 18 /* OpenBraceToken */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 95 /* NewKeyword */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 72 /* Identifier */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -18668,18 +18987,18 @@ var ts; return true; } switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 27 /* LessThanToken */: - case 121 /* AwaitKeyword */: - case 116 /* YieldKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 28 /* LessThanToken */: + case 122 /* AwaitKeyword */: + case 117 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -18697,10 +19016,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 17 /* OpenBraceToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && - token() !== 57 /* AtToken */ && + return token() !== 18 /* OpenBraceToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && + token() !== 58 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -18714,7 +19033,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -18723,7 +19042,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(58 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(59 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -18768,7 +19087,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -18784,7 +19103,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 116 /* YieldKeyword */) { + if (token() === 117 /* 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()) { @@ -18813,15 +19132,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(205 /* YieldExpression */); + var node = createNode(207 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 39 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -18832,20 +19151,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(195 /* ArrowFunction */, asyncModifier.pos); + node = createNode(197 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(195 /* ArrowFunction */, identifier.pos); + node = createNode(197 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(149 /* Parameter */, identifier.pos); + var parameter = createNode(151 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -18870,8 +19189,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -18881,10 +19200,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 121 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* 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. @@ -18894,28 +19213,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 19 /* OpenParenToken */) { - if (second === 20 /* CloseParenToken */) { + if (first === 20 /* OpenParenToken */) { + if (second === 21 /* 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 36 /* EqualsGreaterThanToken */: - case 56 /* ColonToken */: - case 17 /* OpenBraceToken */: + case 37 /* EqualsGreaterThanToken */: + case 57 /* ColonToken */: + case 18 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -18927,42 +19246,42 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) { + if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 24 /* DotDotDotToken */) { + if (second === 25 /* DotDotDotToken */) { return 1 /* 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 !== 120 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 121 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 99 /* ThisKeyword */) { + if (!isIdentifier() && second !== 100 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 56 /* ColonToken */: + case 57 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 58 /* EqualsToken */ || token() === 20 /* CloseParenToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 59 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; - case 26 /* CommaToken */: - case 58 /* EqualsToken */: - case 20 /* CloseParenToken */: + case 27 /* CommaToken */: + case 59 /* EqualsToken */: + case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; } @@ -18970,7 +19289,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 27 /* LessThanToken */); + ts.Debug.assert(first === 28 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -18980,17 +19299,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 85 /* ExtendsKeyword */) { + if (third === 86 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 58 /* EqualsToken */: - case 29 /* GreaterThanToken */: + case 59 /* EqualsToken */: + case 30 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 26 /* CommaToken */) { + else if (third === 27 /* CommaToken */) { return true; } return false; @@ -19009,7 +19328,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19022,23 +19341,23 @@ 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() === 120 /* AsyncKeyword */) { + if (token() === 121 /* 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() === 36 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(195 /* ArrowFunction */); + var node = createNodeWithJSDoc(197 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19048,7 +19367,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(56 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -19059,19 +19378,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && token() !== 18 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } - if (token() !== 25 /* SemicolonToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && + if (token() !== 26 /* SemicolonToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -19096,20 +19415,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(55 /* QuestionToken */); + var questionToken = parseOptionalToken(56 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(205 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(56 /* ColonToken */); + node.colonToken = parseExpectedToken(57 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + : createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -19117,7 +19436,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; + return t === 93 /* InKeyword */ || t === 147 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -19146,16 +19465,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() === 40 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 92 /* InKeyword */ && inDisallowInContext()) { + if (token() === 93 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -19176,51 +19495,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 92 /* InKeyword */) { + if (inDisallowInContext() && token() === 93 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(202 /* BinaryExpression */, left.pos); + var node = createNode(204 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(210 /* AsExpression */, left.pos); + var node = createNode(212 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(200 /* PrefixUnaryExpression */); + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(196 /* DeleteExpression */); + var node = createNode(198 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(197 /* TypeOfExpression */); + var node = createNode(199 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(198 /* VoidExpression */); + var node = createNode(200 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 121 /* AwaitKeyword */) { + if (token() === 122 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -19230,7 +19549,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(199 /* AwaitExpression */); + var node = createNode(201 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -19254,7 +19573,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 40 /* AsteriskAsteriskToken */ ? + return token() === 41 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -19271,10 +19590,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 40 /* AsteriskAsteriskToken */) { + if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 194 /* 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 { @@ -19299,23 +19618,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 80 /* DeleteKeyword */: + case 81 /* DeleteKeyword */: return parseDeleteExpression(); - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return parseVoidExpression(); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 121 /* AwaitKeyword */: + case 122 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -19338,16 +19657,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 121 /* AwaitKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 122 /* AwaitKeyword */: return false; - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -19370,21 +19689,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(200 /* PrefixUnaryExpression */); + if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(203 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -19425,7 +19744,7 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 91 /* ImportKeyword */) { + if (token() === 92 /* 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: @@ -19440,8 +19759,8 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(212 /* MetaProperty */, fullStart); - node.keywordToken = 91 /* ImportKeyword */; + var node = createNode(214 /* MetaProperty */, fullStart); + node.keywordToken = 92 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; @@ -19451,7 +19770,7 @@ var ts; } } else { - expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 98 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression. As such, we need to consume the rest of it here to be complete. @@ -19510,22 +19829,22 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* 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. - var node = createNode(187 /* PropertyAccessExpression */, expression.pos); + var node = createNode(189 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 260 /* JsxOpeningElement */) { - var node = createNode(258 /* JsxElement */, opening.pos); + if (opening.kind === 262 /* JsxOpeningElement */) { + var node = createNode(260 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -19534,15 +19853,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 263 /* JsxOpeningFragment */) { - var node = createNode(262 /* JsxFragment */, opening.pos); + else if (opening.kind === 265 /* JsxOpeningFragment */) { + var node = createNode(264 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 261 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -19553,15 +19872,15 @@ 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() === 27 /* LessThanToken */) { + if (inExpressionContext && token() === 28 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(202 /* BinaryExpression */, result.pos); + var badNode = createNode(204 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 + badNode.operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -19569,8 +19888,8 @@ var ts; return result; } function parseJsxText() { - var node = createNode(10 /* JsxText */); - node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */; + var node = createNode(11 /* JsxText */); + node.containsOnlyWhiteSpaces = currentToken === 12 /* JsxTextAllWhiteSpaces */; currentToken = scanner.scanJsxToken(); return finishNode(node); } @@ -19586,15 +19905,15 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 28 /* LessThanSlashToken */: + case 29 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; - case 10 /* JsxText */: - case 11 /* JsxTextAllWhiteSpaces */: + case 11 /* JsxText */: + case 12 /* JsxTextAllWhiteSpaces */: return parseJsxText(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -19615,16 +19934,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(266 /* JsxAttributes */); + var jsxAttributes = createNode(268 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(27 /* LessThanToken */); - if (token() === 29 /* GreaterThanToken */) { + parseExpected(28 /* LessThanToken */); + if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(265 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -19632,23 +19951,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 29 /* GreaterThanToken */) { + if (token() === 30 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(260 /* JsxOpeningElement */, fullStart); + node = createNode(262 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(41 /* SlashToken */); + parseExpected(42 /* SlashToken */); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(259 /* JsxSelfClosingElement */, fullStart); + node = createNode(261 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -19662,10 +19981,10 @@ 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() === 99 /* ThisKeyword */ ? + var expression = token() === 100 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(24 /* DotToken */)) { + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -19673,33 +19992,33 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(268 /* JsxExpression */); - if (!parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(270 /* JsxExpression */); + if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } - if (token() !== 18 /* CloseBraceToken */) { - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + if (token() !== 19 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { - parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(265 /* JsxAttribute */); + var node = createNode(267 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { switch (scanJsxAttributeValue()) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: @@ -19710,72 +20029,72 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(267 /* JsxSpreadAttribute */); - parseExpected(17 /* OpenBraceToken */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(269 /* JsxSpreadAttribute */); + parseExpected(18 /* OpenBraceToken */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(261 /* JsxClosingElement */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(263 /* JsxClosingElement */); + parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(264 /* JsxClosingFragment */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(266 /* JsxClosingFragment */); + parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(192 /* TypeAssertionExpression */); - parseExpected(27 /* LessThanToken */); + var node = createNode(194 /* TypeAssertionExpression */); + parseExpected(28 /* LessThanToken */); node.type = parseType(); - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(23 /* DotToken */); + var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(211 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(213 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { + var indexedAccess = createNode(190 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; - if (token() === 22 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -19784,7 +20103,7 @@ var ts; } indexedAccess.argumentExpression = argument; } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } @@ -19796,13 +20115,13 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; + return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(193 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; - tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); return finishNode(tagExpression); @@ -19810,7 +20129,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { // 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 @@ -19823,15 +20142,15 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(189 /* CallExpression */, expression.pos); + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(189 /* CallExpression */, expression.pos); + else if (token() === 20 /* OpenParenToken */) { + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19841,17 +20160,17 @@ var ts; } } function parseArgumentList() { - parseExpected(19 /* OpenParenToken */); + parseExpected(20 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(27 /* LessThanToken */)) { + if (!parseOptional(28 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(29 /* GreaterThanToken */)) { + if (!parseExpected(30 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -19863,34 +20182,34 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 19 /* OpenParenToken */: // foo( - case 13 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 14 /* TemplateHead */: // foo `...${100}...` + case 20 /* OpenParenToken */: // foo( + case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. - case 23 /* DotToken */: // foo. - case 20 /* CloseParenToken */: // foo) - case 22 /* CloseBracketToken */: // foo] - case 56 /* ColonToken */: // foo: - case 25 /* SemicolonToken */: // foo; - case 55 /* QuestionToken */: // foo? - case 32 /* EqualsEqualsToken */: // foo == - case 34 /* EqualsEqualsEqualsToken */: // foo === - case 33 /* ExclamationEqualsToken */: // foo != - case 35 /* ExclamationEqualsEqualsToken */: // foo !== - case 53 /* AmpersandAmpersandToken */: // foo && - case 54 /* BarBarToken */: // foo || - case 50 /* CaretToken */: // foo ^ - case 48 /* AmpersandToken */: // foo & - case 49 /* BarToken */: // foo | - case 18 /* CloseBraceToken */: // foo } + case 24 /* DotToken */: // foo. + case 21 /* CloseParenToken */: // foo) + case 23 /* CloseBracketToken */: // foo] + case 57 /* ColonToken */: // foo: + case 26 /* SemicolonToken */: // foo; + case 56 /* QuestionToken */: // foo? + case 33 /* EqualsEqualsToken */: // foo == + case 35 /* EqualsEqualsEqualsToken */: // foo === + case 34 /* ExclamationEqualsToken */: // foo != + case 36 /* ExclamationEqualsEqualsToken */: // foo !== + case 54 /* AmpersandAmpersandToken */: // foo && + case 55 /* BarBarToken */: // foo || + case 51 /* CaretToken */: // foo ^ + case 49 /* AmpersandToken */: // foo & + case 50 /* BarToken */: // foo | + case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // 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. return true; - case 26 /* CommaToken */: // foo, - case 17 /* OpenBraceToken */: // foo { + case 27 /* CommaToken */: // foo, + case 18 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -19902,22 +20221,23 @@ var ts; function parsePrimaryExpression() { switch (token()) { case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseTokenNode(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedExpression(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 120 /* AsyncKeyword */: + case 121 /* 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. @@ -19925,76 +20245,76 @@ var ts; break; } return parseFunctionExpression(); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassExpression(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionExpression(); - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) { + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); - parseExpected(19 /* OpenParenToken */); + var node = createNodeWithJSDoc(195 /* ParenthesizedExpression */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(206 /* SpreadElement */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(208 /* SpreadElement */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : + return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* CommaToken */ ? createNode(210 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(185 /* ArrayLiteralExpression */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(187 /* ArrayLiteralExpression */); + parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); - if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 275 /* SpreadAssignment */; + if (parseOptionalToken(25 /* DotDotDotToken */)) { + node.kind = 277 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(51 /* ExclamationToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20002,30 +20322,30 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 274 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(58 /* EqualsToken */); + node.kind = 276 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(59 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 273 /* PropertyAssignment */; - parseExpected(56 /* ColonToken */); + node.kind = 275 /* PropertyAssignment */; + parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(186 /* ObjectLiteralExpression */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(188 /* ObjectLiteralExpression */); + parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -20038,10 +20358,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(194 /* FunctionExpression */); + var node = createNodeWithJSDoc(196 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -20049,7 +20369,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -20061,10 +20381,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(94 /* NewKeyword */); - if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(212 /* MetaProperty */, fullStart); - node_2.keywordToken = 94 /* NewKeyword */; + parseExpected(95 /* NewKeyword */); + if (parseOptional(24 /* DotToken */)) { + var node_2 = createNode(214 /* MetaProperty */, fullStart); + node_2.keywordToken = 95 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } @@ -20080,23 +20400,23 @@ var ts; } break; } - var node = createNode(190 /* NewExpression */, fullStart); + var node = createNode(192 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; - if (node.typeArguments || token() === 19 /* OpenParenToken */) { + if (node.typeArguments || token() === 20 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(216 /* Block */); - if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(218 /* Block */); + if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -20123,52 +20443,52 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(218 /* EmptyStatement */); - parseExpected(25 /* SemicolonToken */); + var node = createNode(220 /* EmptyStatement */); + parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(220 /* IfStatement */); - parseExpected(90 /* IfKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(222 /* IfStatement */); + parseExpected(91 /* IfKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(83 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(221 /* DoStatement */); - parseExpected(81 /* DoKeyword */); + var node = createNode(223 /* DoStatement */); + parseExpected(82 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); // 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(25 /* SemicolonToken */); + parseOptional(26 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(222 /* WhileStatement */); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(224 /* WhileStatement */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(88 /* ForKeyword */); - var awaitToken = parseOptionalToken(121 /* AwaitKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(89 /* ForKeyword */); + var awaitToken = parseOptionalToken(122 /* AwaitKeyword */); + parseExpected(20 /* OpenParenToken */); var initializer; - if (token() !== 25 /* SemicolonToken */) { - if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) { + if (token() !== 26 /* SemicolonToken */) { + if (token() === 105 /* VarKeyword */ || token() === 111 /* LetKeyword */ || token() === 77 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -20176,33 +20496,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(225 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(147 /* OfKeyword */) : parseOptional(147 /* OfKeyword */)) { + var forOfStatement = createNode(227 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(224 /* ForInStatement */, pos); + else if (parseOptional(93 /* InKeyword */)) { + var forInStatement = createNode(226 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(223 /* ForStatement */, pos); + var forStatement = createNode(225 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(25 /* SemicolonToken */); - if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(25 /* SemicolonToken */); - if (token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 21 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -20210,7 +20530,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 229 /* BreakStatement */ ? 73 /* BreakKeyword */ : 78 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -20218,8 +20538,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(228 /* ReturnStatement */); - parseExpected(96 /* ReturnKeyword */); + var node = createNode(230 /* ReturnStatement */); + parseExpected(97 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -20227,42 +20547,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(229 /* WithStatement */); - parseExpected(107 /* WithKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(231 /* WithStatement */); + parseExpected(108 /* WithKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(269 /* CaseClause */); - parseExpected(73 /* CaseKeyword */); + var node = createNode(271 /* CaseClause */); + parseExpected(74 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(270 /* DefaultClause */); - parseExpected(79 /* DefaultKeyword */); - parseExpected(56 /* ColonToken */); + var node = createNode(272 /* DefaultClause */); + parseExpected(80 /* DefaultKeyword */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 74 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(230 /* SwitchStatement */); - parseExpected(98 /* SwitchKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(232 /* SwitchStatement */); + parseExpected(99 /* SwitchKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(244 /* CaseBlock */); - parseExpected(17 /* OpenBraceToken */); + parseExpected(21 /* CloseParenToken */); + var caseBlock = createNode(246 /* CaseBlock */); + parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -20274,32 +20594,32 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(232 /* ThrowStatement */); - parseExpected(100 /* ThrowKeyword */); + var node = createNode(234 /* ThrowStatement */); + parseExpected(101 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(233 /* TryStatement */); - parseExpected(102 /* TryKeyword */); + var node = createNode(235 /* TryStatement */); + parseExpected(103 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 75 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 87 /* FinallyKeyword */) { - parseExpected(87 /* FinallyKeyword */); + if (!node.catchClause || token() === 88 /* FinallyKeyword */) { + parseExpected(88 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(272 /* CatchClause */); - parseExpected(74 /* CatchKeyword */); - if (parseOptional(19 /* OpenParenToken */)) { + var result = createNode(274 /* CatchClause */); + parseExpected(75 /* CatchKeyword */); + if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -20309,8 +20629,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(234 /* DebuggerStatement */); - parseExpected(78 /* DebuggerKeyword */); + var node = createNode(236 /* DebuggerStatement */); + parseExpected(79 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -20320,13 +20640,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 231 /* LabeledStatement */; + if (expression.kind === 72 /* Identifier */ && parseOptional(57 /* ColonToken */)) { + node.kind = 233 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 219 /* ExpressionStatement */; + node.kind = 221 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -20338,25 +20658,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 76 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 90 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* 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 @@ -20379,41 +20699,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 132 /* ReadonlyKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 133 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 144 /* GlobalKeyword */: + case 145 /* GlobalKeyword */: nextToken(); - return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; - case 91 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 72 /* Identifier */ || token() === 85 /* ExportKeyword */; + case 92 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 84 /* ExportKeyword */: + return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 85 /* ExportKeyword */: nextToken(); - if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ || - token() === 118 /* AsKeyword */) { + if (token() === 59 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 80 /* DefaultKeyword */ || + token() === 119 /* AsKeyword */) { return true; } continue; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: nextToken(); continue; default: @@ -20426,50 +20746,50 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 57 /* AtToken */: - case 25 /* SemicolonToken */: - case 17 /* OpenBraceToken */: - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 90 /* IfKeyword */: - case 81 /* DoKeyword */: - case 106 /* WhileKeyword */: - case 88 /* ForKeyword */: - case 77 /* ContinueKeyword */: - case 72 /* BreakKeyword */: - case 96 /* ReturnKeyword */: - case 107 /* WithKeyword */: - case 98 /* SwitchKeyword */: - case 100 /* ThrowKeyword */: - case 102 /* TryKeyword */: - case 78 /* DebuggerKeyword */: + case 58 /* AtToken */: + case 26 /* SemicolonToken */: + case 18 /* OpenBraceToken */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 91 /* IfKeyword */: + case 82 /* DoKeyword */: + case 107 /* WhileKeyword */: + case 89 /* ForKeyword */: + case 78 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 97 /* ReturnKeyword */: + case 108 /* WithKeyword */: + case 99 /* SwitchKeyword */: + case 101 /* ThrowKeyword */: + case 103 /* TryKeyword */: + case 79 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 76 /* ConstKeyword */: - case 84 /* ExportKeyword */: + case 77 /* ConstKeyword */: + case 85 /* ExportKeyword */: return isStartOfDeclaration(); - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 109 /* InterfaceKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 139 /* TypeKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 110 /* InterfaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 140 /* TypeKeyword */: + case 145 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 116 /* StaticKeyword */: + case 133 /* 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); @@ -20479,7 +20799,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */; + return isIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -20488,67 +20808,67 @@ var ts; } function parseStatement() { switch (token()) { - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: return parseEmptyStatement(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); - case 110 /* LetKeyword */: + case 105 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); + case 111 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); } break; - case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); - case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); - case 90 /* IfKeyword */: + case 90 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(239 /* FunctionDeclaration */)); + case 76 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(240 /* ClassDeclaration */)); + case 91 /* IfKeyword */: return parseIfStatement(); - case 81 /* DoKeyword */: + case 82 /* DoKeyword */: return parseDoStatement(); - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return parseWhileStatement(); - case 88 /* ForKeyword */: + case 89 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(226 /* ContinueStatement */); - case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(227 /* BreakStatement */); - case 96 /* ReturnKeyword */: + case 78 /* ContinueKeyword */: + return parseBreakOrContinueStatement(228 /* ContinueStatement */); + case 73 /* BreakKeyword */: + return parseBreakOrContinueStatement(229 /* BreakStatement */); + case 97 /* ReturnKeyword */: return parseReturnStatement(); - case 107 /* WithKeyword */: + case 108 /* WithKeyword */: return parseWithStatement(); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return parseSwitchStatement(); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return parseThrowStatement(); - case 102 /* TryKeyword */: + case 103 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return parseTryStatement(); - case 78 /* DebuggerKeyword */: + case 79 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 57 /* AtToken */: + case 58 /* AtToken */: return parseDeclaration(); - case 120 /* AsyncKeyword */: - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 83 /* EnumKeyword */: - case 84 /* ExportKeyword */: - case 91 /* ImportKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 117 /* AbstractKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 84 /* EnumKeyword */: + case 85 /* ExportKeyword */: + case 92 /* ImportKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 118 /* AbstractKeyword */: + case 116 /* StaticKeyword */: + case 133 /* ReadonlyKeyword */: + case 145 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -20557,7 +20877,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 124 /* DeclareKeyword */; + return modifier.kind === 125 /* DeclareKeyword */; } function parseDeclaration() { var node = createNodeWithJSDoc(0 /* Unknown */); @@ -20576,33 +20896,33 @@ var ts; } function parseDeclarationWorker(node) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: return parseVariableStatement(node); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassDeclaration(node); - case 109 /* InterfaceKeyword */: + case 110 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 139 /* TypeKeyword */: + case 140 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 83 /* EnumKeyword */: + case 84 /* EnumKeyword */: return parseEnumDeclaration(node); - case 144 /* GlobalKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 145 /* GlobalKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: nextToken(); switch (token()) { - case 79 /* DefaultKeyword */: - case 58 /* EqualsToken */: + case 80 /* DefaultKeyword */: + case 59 /* EqualsToken */: return parseExportAssignment(node); - case 118 /* AsKeyword */: + case 119 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -20611,7 +20931,7 @@ var ts; if (node.decorators || node.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(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(258 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -20622,10 +20942,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -20633,25 +20953,25 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 26 /* CommaToken */) { - return createNode(208 /* OmittedExpression */); + if (token() === 27 /* CommaToken */) { + return createNode(210 /* OmittedExpression */); } - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 56 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -20659,27 +20979,27 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(182 /* ObjectBindingPattern */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(184 /* ObjectBindingPattern */); + parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(183 /* ArrayBindingPattern */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(185 /* ArrayBindingPattern */); + parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier(); + return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); @@ -20688,10 +21008,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(235 /* VariableDeclaration */); + var node = createNode(237 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 71 /* Identifier */ && - token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 72 /* Identifier */ && + token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20701,14 +21021,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(236 /* VariableDeclarationList */); + var node = createNode(238 /* VariableDeclarationList */); switch (token()) { - case 104 /* VarKeyword */: + case 105 /* VarKeyword */: break; - case 110 /* LetKeyword */: + case 111 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -20724,7 +21044,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 147 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -20736,44 +21056,44 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 217 /* VariableStatement */; + node.kind = 219 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 237 /* FunctionDeclaration */; - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + node.kind = 239 /* FunctionDeclaration */; + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 155 /* Constructor */; - parseExpected(123 /* ConstructorKeyword */); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + node.kind = 157 /* Constructor */; + parseExpected(124 /* ConstructorKeyword */); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 154 /* MethodDeclaration */; + node.kind = 156 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 152 /* PropertyDeclaration */; - if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 154 /* PropertyDeclaration */; + if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20793,12 +21113,12 @@ var ts; return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.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. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -20806,13 +21126,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 57 /* AtToken */) { + if (token() === 58 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -20829,7 +21149,7 @@ var ts; } nextToken(); } - if (token() === 39 /* AsteriskToken */) { + if (token() === 40 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -20839,24 +21159,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* 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 === 136 /* SetKeyword */ || idToken === 125 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 137 /* SetKeyword */ || idToken === 126 /* 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 19 /* OpenParenToken */: // Method declaration - case 27 /* LessThanToken */: // Generic Method declaration - case 51 /* ExclamationToken */: // Non-null assertion on property name - case 56 /* ColonToken */: // Type Annotation for declaration - case 58 /* EqualsToken */: // Initializer for declaration - case 55 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* OpenParenToken */: // Method declaration + case 28 /* LessThanToken */: // Generic Method declaration + case 52 /* ExclamationToken */: // Non-null assertion on property name + case 57 /* ColonToken */: // Type Annotation for declaration + case 59 /* EqualsToken */: // Initializer for declaration + case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -20874,10 +21194,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(57 /* AtToken */)) { + if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(150 /* Decorator */, decoratorStart); + var decorator = createNode(152 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -20897,7 +21217,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 77 /* 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)) { @@ -20916,7 +21236,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -20926,21 +21246,21 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 25 /* SemicolonToken */) { - var result = createNode(215 /* SemicolonClassElement */); + if (token() === 26 /* SemicolonToken */) { + var result = createNode(217 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - if (token() === 123 /* ConstructorKeyword */) { + if (token() === 124 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); } if (isIndexSignature()) { @@ -20949,37 +21269,37 @@ 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() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 39 /* AsteriskToken */ || - token() === 21 /* OpenBracketToken */) { + token() === 40 /* AsteriskToken */ || + token() === 22 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(node); } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // '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(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 209 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 240 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(75 /* ClassKeyword */); + parseExpected(76 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -20997,7 +21317,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 109 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21009,33 +21329,33 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(271 /* HeritageClause */); + ts.Debug.assert(tok === 86 /* ExtendsKeyword */ || tok === 109 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(273 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(209 /* ExpressionWithTypeArguments */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 27 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */) + return token() === 28 /* LessThanToken */ + ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 239 /* InterfaceDeclaration */; - parseExpected(109 /* InterfaceKeyword */); + node.kind = 241 /* InterfaceDeclaration */; + parseExpected(110 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21043,11 +21363,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 240 /* TypeAliasDeclaration */; - parseExpected(139 /* TypeKeyword */); + node.kind = 242 /* TypeAliasDeclaration */; + parseExpected(140 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -21057,18 +21377,18 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(276 /* EnumMember */); + var node = createNodeWithJSDoc(278 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 241 /* EnumDeclaration */; - parseExpected(83 /* EnumKeyword */); + node.kind = 243 /* EnumDeclaration */; + parseExpected(84 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21076,10 +21396,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(243 /* ModuleBlock */); - if (parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(245 /* ModuleBlock */); + if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -21087,20 +21407,20 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 242 /* ModuleDeclaration */; + node.kind = 244 /* ModuleDeclaration */; // 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 */; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(23 /* DotToken */) + node.body = parseOptional(24 /* DotToken */) ? parseModuleOrNamespaceDeclaration(createNode(0 /* Unknown */), 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 242 /* ModuleDeclaration */; - if (token() === 144 /* GlobalKeyword */) { + node.kind = 244 /* ModuleDeclaration */; + if (token() === 145 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -21109,7 +21429,7 @@ var ts; node.name = parseLiteralNode(); node.name.text = internIdentifier(node.name.text); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -21119,68 +21439,68 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 144 /* GlobalKeyword */) { + if (token() === 145 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(130 /* NamespaceKeyword */)) { + else if (parseOptional(131 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(129 /* ModuleKeyword */); - if (token() === 9 /* StringLiteral */) { + parseExpected(130 /* ModuleKeyword */); + if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } } return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 133 /* RequireKeyword */ && + return token() === 134 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 19 /* OpenParenToken */; + return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 41 /* SlashToken */; + return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 245 /* NamespaceExportDeclaration */; - parseExpected(118 /* AsKeyword */); - parseExpected(130 /* NamespaceKeyword */); + node.kind = 247 /* NamespaceExportDeclaration */; + parseExpected(119 /* AsKeyword */); + parseExpected(131 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(91 /* ImportKeyword */); + parseExpected(92 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 144 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 247 /* ImportDeclaration */; + node.kind = 249 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 39 /* AsteriskToken */ || // import * - token() === 17 /* OpenBraceToken */) { // import { + token() === 40 /* AsteriskToken */ || // import * + token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(143 /* FromKeyword */); + parseExpected(144 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 246 /* ImportEqualsDeclaration */; + node.kind = 248 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -21192,7 +21512,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(248 /* ImportClause */, fullStart); + var importClause = createNode(250 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -21201,8 +21521,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); + parseOptional(27 /* CommaToken */)) { + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(252 /* NamedImports */); } return finishNode(importClause); } @@ -21212,15 +21532,15 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(257 /* ExternalModuleReference */); - parseExpected(133 /* RequireKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(259 /* ExternalModuleReference */); + parseExpected(134 /* RequireKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { - if (token() === 9 /* StringLiteral */) { + if (token() === 10 /* StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -21235,9 +21555,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(249 /* NamespaceImport */); - parseExpected(39 /* AsteriskToken */); - parseExpected(118 /* AsKeyword */); + var namespaceImport = createNode(251 /* NamespaceImport */); + parseExpected(40 /* AsteriskToken */); + parseExpected(119 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -21250,14 +21570,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 252 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(255 /* ExportSpecifier */); + return parseImportOrExportSpecifier(257 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(251 /* ImportSpecifier */); + return parseImportOrExportSpecifier(253 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -21271,9 +21591,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(118 /* AsKeyword */); + parseExpected(119 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -21282,24 +21602,24 @@ var ts; else { node.name = identifierName; } - if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 253 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 253 /* ExportDeclaration */; - if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(143 /* FromKeyword */); + node.kind = 255 /* ExportDeclaration */; + if (parseOptional(40 /* AsteriskToken */)) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(254 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(256 /* 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() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(143 /* FromKeyword */); + if (token() === 144 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -21307,12 +21627,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 252 /* ExportAssignment */; - if (parseOptional(58 /* EqualsToken */)) { + node.kind = 254 /* ExportAssignment */; + if (parseOptional(59 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(79 /* DefaultKeyword */); + parseExpected(80 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -21327,10 +21647,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ - || node.kind === 247 /* ImportDeclaration */ - || node.kind === 252 /* ExportAssignment */ - || node.kind === 253 /* ExportDeclaration */ + || node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */ + || node.kind === 249 /* ImportDeclaration */ + || node.kind === 254 /* ExportAssignment */ + || node.kind === 255 /* ExportDeclaration */ ? node : undefined; } @@ -21343,7 +21663,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 91 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 92 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -21394,11 +21714,11 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); + var result = createNode(283 /* JSDocTypeExpression */); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } fixupParentReferences(result); return finishNode(result); @@ -21486,7 +21806,7 @@ var ts; } loop: while (true) { switch (token()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -21506,7 +21826,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -21557,7 +21877,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(289 /* JSDocComment */, start); + var result = createNode(291 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -21591,20 +21911,19 @@ var ts; } } var precedingLineBreak = scanner.hasPrecedingLineBreak(); - while ((precedingLineBreak && token() === 39 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; } - else if (token() === 39 /* AsteriskToken */) { + else if (token() === 40 /* AsteriskToken */) { precedingLineBreak = false; } nextJSDocToken(); } } function parseTag(indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getTokenPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); skipWhitespaceOrAsterisk(); @@ -21612,40 +21931,40 @@ var ts; switch (tagName.escapedText) { case "augments": case "extends": - tag = parseAugmentsTag(atToken, tagName); + tag = parseAugmentsTag(start, tagName); break; case "class": case "constructor": - tag = parseClassTag(atToken, tagName); + tag = parseClassTag(start, tagName); break; case "this": - tag = parseThisTag(atToken, tagName); + tag = parseThisTag(start, tagName); break; case "enum": - tag = parseEnumTag(atToken, tagName); + tag = parseEnumTag(start, tagName); break; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent); + return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, indent); case "return": case "returns": - tag = parseReturnTag(atToken, tagName); + tag = parseReturnTag(start, tagName); break; case "template": - tag = parseTemplateTag(atToken, tagName); + tag = parseTemplateTag(start, tagName); break; case "type": - tag = parseTypeTag(atToken, tagName); + tag = parseTypeTag(start, tagName); break; case "typedef": - tag = parseTypedefTag(atToken, tagName, indent); + tag = parseTypedefTag(start, tagName, indent); break; case "callback": - tag = parseCallbackTag(atToken, tagName, indent); + tag = parseCallbackTag(start, tagName, indent); break; default: - tag = parseUnknownTag(atToken, tagName); + tag = parseUnknownTag(start, tagName); break; } if (!tag.comment) { @@ -21675,7 +21994,7 @@ var ts; } indent = 0; break; - case 57 /* AtToken */: + case 58 /* AtToken */: scanner.setTextPos(scanner.getTextPos() - 1); // falls through case 1 /* EndOfFileToken */: @@ -21694,9 +22013,9 @@ var ts; indent += whitespace.length; } break; - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextJSDocToken() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextJSDocToken(); pushComment(scanner.getTokenText()); @@ -21704,7 +22023,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -21724,9 +22043,8 @@ var ts; removeTrailingWhitespace(comments); return comments.length === 0 ? undefined : comments.join(""); } - function parseUnknownTag(atToken, tagName) { - var result = createNode(292 /* JSDocTag */, atToken.pos); - result.atToken = atToken; + function parseUnknownTag(start, tagName) { + var result = createNode(294 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -21745,37 +22063,37 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { - if (token() === 13 /* NoSubstitutionTemplateLiteral */) { + if (token() === 14 /* NoSubstitutionTemplateLiteral */) { // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild return { name: createIdentifier(/*isIdentifier*/ true), isBracketed: false }; } // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptional(21 /* OpenBracketToken */); + var isBracketed = parseOptional(22 /* OpenBracketToken */); var name = parseJSDocEntityName(); if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(58 /* EqualsToken */)) { + if (parseOptionalToken(59 /* EqualsToken */)) { parseExpression(); } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; } } - function parseParameterOrPropertyTag(atToken, tagName, target, indent) { + function parseParameterOrPropertyTag(start, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); @@ -21785,15 +22103,14 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(303 /* JSDocPropertyTag */, atToken.pos) : - createNode(297 /* JSDocParameterTag */, atToken.pos); - var comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); + createNode(305 /* JSDocPropertyTag */, start) : + createNode(299 /* JSDocParameterTag */, start); + var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; result.name = name; @@ -21804,20 +22121,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) { + if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -21825,81 +22142,74 @@ var ts; } } } - function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 298 /* JSDocReturnTag */; })) { + function parseReturnTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(298 /* JSDocReturnTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(300 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } - function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocTypeTag */; })) { + function parseTypeTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocTypeTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(302 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } - function parseAugmentsTag(atToken, tagName) { - var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); - result.atToken = atToken; + function parseAugmentsTag(start, tagName) { + var result = createNode(295 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(209 /* ExpressionWithTypeArguments */); + var usedBrace = parseOptional(18 /* OpenBraceToken */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); if (usedBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var prop = createNode(187 /* PropertyAccessExpression */, node.pos); + while (parseOptional(24 /* DotToken */)) { + var prop = createNode(189 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); } return node; } - function parseClassTag(atToken, tagName) { - var tag = createNode(294 /* JSDocClassTag */, atToken.pos); - tag.atToken = atToken; + function parseClassTag(start, tagName) { + var tag = createNode(296 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } - function parseThisTag(atToken, tagName) { - var tag = createNode(299 /* JSDocThisTag */, atToken.pos); - tag.atToken = atToken; + function parseThisTag(start, tagName) { + var tag = createNode(301 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseEnumTag(atToken, tagName) { - var tag = createNode(296 /* JSDocEnumTag */, atToken.pos); - tag.atToken = atToken; + function parseEnumTag(start, tagName) { + var tag = createNode(298 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseTypedefTag(atToken, tagName, indent) { + function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); - typedefTag.atToken = atToken; + var typedefTag = createNode(304 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -21911,12 +22221,11 @@ var ts; var child = void 0; var jsdocTypeLiteral = void 0; var childTypeTag = void 0; - var start_3 = atToken.pos; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); } - if (child.kind === 300 /* JSDocTypeTag */) { + if (child.kind === 302 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21929,7 +22238,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -21947,8 +22256,8 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); + if (parseOptional(24 /* DotToken */)) { + var jsDocNamespaceNode = createNode(244 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21961,25 +22270,23 @@ var ts; } return typeNameOrNamespaceName; } - function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); - callbackTag.atToken = atToken; + function parseCallbackTag(start, tagName, indent) { + var callbackTag = createNode(297 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var start = scanner.getStartPos(); - var jsdocSignature = createNode(291 /* JSDocSignature */, start); + var jsdocSignature = createNode(293 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(57 /* AtToken */)) { + if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 298 /* JSDocReturnTag */) { + if (tag && tag.kind === 300 /* JSDocReturnTag */) { return tag; } } @@ -22021,10 +22328,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextJSDocToken()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) && + if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22037,13 +22344,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -22052,16 +22359,15 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getStartPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); skipWhitespace(); var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(atToken, tagName); + return target === 1 /* Property */ && parseTypeTag(start, tagName); case "prop": case "property": t = 1 /* Property */; @@ -22077,26 +22383,25 @@ var ts; if (!(target & t)) { return false; } - return parseParameterOrPropertyTag(atToken, tagName, target, indent); + return parseParameterOrPropertyTag(start, tagName, target, indent); } - function parseTemplateTag(atToken, tagName) { + function parseTemplateTag(start, tagName) { // the template tag looks like '@template {Constraint} T,U,V' var constraint; - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(148 /* TypeParameter */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); - } while (parseOptionalJsdoc(26 /* CommaToken */)); - var result = createNode(301 /* JSDocTemplateTag */, atToken.pos); - result.atToken = atToken; + } while (parseOptionalJsdoc(27 /* CommaToken */)); + var result = createNode(303 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22115,16 +22420,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* 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(23 /* DotToken */)) { + while (parseOptional(24 /* DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -22132,11 +22437,11 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(71 /* Identifier */, pos); + var result = createNode(72 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); nextJSDocToken(); @@ -22262,9 +22567,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 71 /* Identifier */: + case 72 /* Identifier */: return true; } return false; @@ -22842,10 +23147,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 71 /* Identifier */) { + if (lhs.kind === 72 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 99 /* ThisKeyword */) { + if (lhs.kind === 100 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -22902,7 +23207,8 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], - ["esnext.intl", "lib.esnext.intl.d.ts"] + ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.bigint", "lib.esnext.bigint.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -22959,6 +23265,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, { name: "traceResolution", type: "boolean", @@ -23009,11 +23322,11 @@ var ts; description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date }, { - name: "pretty", + name: "showConfig", type: "boolean", - showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + isCommandLineOnly: true, + description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, // Basic { @@ -23606,7 +23919,7 @@ var ts; { name: "maxNodeModuleJsDepth", type: "number", - // TODO: GH#27108 affectsModuleResolution: true, + affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, @@ -24062,6 +24375,9 @@ var ts; } var result = ts.parseJsonText(configFileName, configFileText); var cwd = host.getCurrentDirectory(); + result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd)); } ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile; @@ -24201,7 +24517,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 273 /* PropertyAssignment */) { + if (element.kind !== 275 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -24257,16 +24573,16 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 101 /* TrueKeyword */: + case 102 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -24283,13 +24599,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 200 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 202 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -24306,7 +24622,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -24346,6 +24662,115 @@ var ts; } return false; } + /** + * Generate an uncommented, complete tsconfig for use with "--showConfig" + * @param configParseResult options to be generated into tsconfig.json + * @param configFileName name of the parsed config file - output paths will be generated relative to this + * @param host provides current directory and case sensitivity services + */ + /** @internal */ + function convertToTSConfig(configParseResult, configFileName, host) { + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var files = ts.map(ts.filter(configParseResult.fileNames, !configParseResult.configFileSpecs ? function (_) { return false; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), f, getCanonicalFileName); }); + var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); + var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var _a; + return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), + exclude: configParseResult.configFileSpecs.validatedExcludeSpecs + } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + return config; + } + ts.convertToTSConfig = convertToTSConfig; + function filterSameAsDefaultInclude(specs) { + if (!ts.length(specs)) + return undefined; + if (ts.length(specs) !== 1) + return specs; + if (specs[0] === "**/*") + return undefined; + return specs; + } + function matchesSpecs(path, includeSpecs, excludeSpecs) { + if (!includeSpecs) + return function (_) { return false; }; + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + if (includeRe) { + if (excludeRe) { + return function (path) { return includeRe.test(path) && !excludeRe.test(path); }; + } + return function (path) { return includeRe.test(path); }; + } + if (excludeRe) { + return function (path) { return !excludeRe.test(path); }; + } + return function (_) { return false; }; + } + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + // this is of a type CommandLineOptionOfPrimitiveType + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + // There is a typeMap associated with this command-line option so use it to map value back to its name + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options, pathOptions) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); + var _loop_3 = function (name) { + if (ts.hasProperty(options, name)) { + // tsconfig only options cannot be specified via command line, + // so we can assume that only types that can appear here string | number | boolean + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + return "continue"; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap_1) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + if (pathOptions && optionDefinition.isFilePath) { + result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)); + } + else { + result.set(name, value); + } + } + else { + if (optionDefinition.type === "list") { + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 + } + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); + } + } + } + } + }; + for (var name in options) { + _loop_3(name); + } + return result; + } /** * Generate tsconfig configuration when running command line "--init" * @param options commandlineOptions to be generated into tsconfig.json @@ -24356,62 +24781,6 @@ var ts; var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var compilerOptionsMap = serializeCompilerOptions(compilerOptions); return writeConfigurations(); - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - // this is of a type CommandLineOptionOfPrimitiveType - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - // There is a typeMap associated with this command-line option so use it to map value back to its name - return ts.forEachEntry(customTypeMap, function (mapValue, key) { - if (mapValue === value) { - return key; - } - }); - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - var _loop_3 = function (name) { - if (ts.hasProperty(options, name)) { - // tsconfig only options cannot be specified via command line, - // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { - return "continue"; - } - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap_1) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result.set(name, value); - } - else { - if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); - } - } - } - } - }; - for (var name in options) { - _loop_3(name); - } - return result; - } function getDefaultValueForOption(option) { switch (option.type) { case "number": @@ -24800,20 +25169,24 @@ var ts; } function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) { extendedConfig = ts.normalizeSlashes(extendedConfig); - // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../"))) { - errors.push(createDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return undefined; - } - var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return undefined; + 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 */)) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; + } } + return extendedConfigPath; } - return extendedConfigPath; + // If the path isn't a rooted or relative path, resolve like a module + var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, /*cache*/ undefined, /*projectRefs*/ undefined, /*lookupConfig*/ true); + if (resolved.resolvedModule) { + return resolved.resolvedModule.resolvedFileName; + } + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; } function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors) { var _a; @@ -25263,7 +25636,7 @@ var ts; } } /** - * Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed. + * Produces a cleaned version of compiler options with personally identifying info (aka, paths) removed. * Also converts enum values back to strings. */ /* @internal */ @@ -25334,7 +25707,8 @@ var ts; Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; - Extensions[Extensions["DtsOnly"] = 3] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -25380,6 +25754,9 @@ var ts; return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state) || readPackageJsonPathField(jsonContent, "types", baseDirectory, state); } + function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) { + return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state); + } function readPackageJsonMainField(jsonContent, baseDirectory, state) { return readPackageJsonPathField(jsonContent, "main", baseDirectory, state); } @@ -25479,8 +25856,11 @@ var 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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { var traceEnabled = isTraceEnabled(options, host); + if (redirectedReference) { + options = redirectedReference.commandLine.options; + } var failedLookupLocations = []; var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -25501,6 +25881,9 @@ var ts; trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); } } + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var resolved = primaryLookup(); var primary = true; @@ -25510,13 +25893,12 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - if (!options.preserveSymlinks) { - resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); - } + var fileName = resolved.fileName, packageId = resolved.packageId; + var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -25525,7 +25907,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - return ts.forEach(typeRoots, function (typeRoot) { + return ts.firstDefined(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); var directoryExists = ts.directoryProbablyExists(candidateDirectory, host); @@ -25550,13 +25932,14 @@ var ts; } var result = void 0; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { - result = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined); + var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); + result = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = toSearchResult(nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true)); + result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - var resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25616,29 +25999,56 @@ var ts; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { - return createModuleResolutionCacheWithMaps(ts.createMap(), ts.createMap(), currentDirectory, getCanonicalFileName); + return createModuleResolutionCacheWithMaps(createCacheWithRedirects(), createCacheWithRedirects(), currentDirectory, getCanonicalFileName); } ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ + function createCacheWithRedirects() { + var ownMap = ts.createMap(); + var redirectsMap = ts.createMap(); + return { + ownMap: ownMap, + redirectsMap: redirectsMap, + getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, + clear: clear + }; + function getOrCreateMapOfCacheRedirects(redirectedReference) { + if (!redirectedReference) { + return ownMap; + } + var path = redirectedReference.sourceFile.path; + var redirects = redirectsMap.get(path); + if (!redirects) { + redirects = ts.createMap(); + redirectsMap.set(path, redirects); + } + return redirects; + } + function clear() { + ownMap.clear(); + redirectsMap.clear(); + } + } + ts.createCacheWithRedirects = createCacheWithRedirects; + /*@internal*/ function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; - function getOrCreateCacheForDirectory(directoryName) { + function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - var perFolderCache = directoryToModuleNameMap.get(path); - if (!perFolderCache) { - perFolderCache = ts.createMap(); - directoryToModuleNameMap.set(path, perFolderCache); - } - return perFolderCache; + return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap); } - function getOrCreateCacheForModuleName(nonRelativeModuleName) { + function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); - if (!perModuleNameCache) { - perModuleNameCache = createPerModuleNameCache(); - moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); } - return perModuleNameCache; + return result; } function createPerModuleNameCache() { var directoryPathMap = ts.createMap(); @@ -25713,13 +26123,19 @@ var ts; return perFolderCache && perFolderCache.get(moduleName); } ts.resolveModuleNameFromCache = resolveModuleNameFromCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); + if (redirectedReference) { + compilerOptions = redirectedReference.commandLine.options; + } if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var containingDirectory = ts.getDirectoryPath(containingFile); - var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference); var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -25741,10 +26157,10 @@ var ts; } switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); @@ -25753,7 +26169,7 @@ var ts; perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { // put result in per-module name cache - cache.getOrCreateCacheForModuleName(moduleName).set(containingDirectory, result); + cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result); } } } @@ -25829,6 +26245,9 @@ var ts; * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. */ function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) { + var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state); + if (resolved) + return resolved.value; if (!ts.isExternalModuleNameRelative(moduleName)) { return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state); } @@ -25836,6 +26255,16 @@ var ts; return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state); } } + function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { + var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + if (baseUrl && paths && !ts.pathIsRelative(moduleName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); + } + } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { if (!state.compilerOptions.rootDirs) { return undefined; @@ -25905,22 +26334,13 @@ var ts; return undefined; } function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var baseUrl = state.compilerOptions.baseUrl; if (!baseUrl) { return undefined; } if (state.traceEnabled) { trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); } - if (paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - var resolved = tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); - if (resolved) { - return resolved.value; - } - } var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName)); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate); @@ -25947,22 +26367,22 @@ var ts; return resolvedModule && resolvedModule.resolvedFileName; } ts.tryResolveJSModule = tryResolveJSModule; + var jsOnlyExtensions = [Extensions.JavaScript]; + var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; + var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { - return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true); + return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false); + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { + return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, jsOnly) { + function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; - var result = jsOnly ? - tryResolve(Extensions.JavaScript) : - (tryResolve(Extensions.TypeScript) || - tryResolve(Extensions.JavaScript) || - (compilerOptions.resolveJsonModule ? tryResolve(Extensions.Json) : undefined)); + var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); @@ -25972,13 +26392,13 @@ var ts; var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); if (resolved) { - return toSearchResult({ resolved: resolved, isExternalLibraryImport: ts.stringContains(resolved.path, ts.nodeModulesPathPart) }); + return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) }); } if (!ts.isExternalModuleNameRelative(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache); + var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved_1) return undefined; var resolvedValue = resolved_1.value; @@ -26044,6 +26464,11 @@ var ts; } /*@internal*/ ts.nodeModulesPathPart = "/node_modules/"; + /*@internal*/ + function pathContainsNodeModules(path) { + return ts.stringContains(path, ts.nodeModulesPathPart); + } + ts.pathContainsNodeModules = pathContainsNodeModules; /** * This will be called on the successfully resolved path from `loadModuleFromFile`. * (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.) @@ -26094,9 +26519,9 @@ var ts; * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { - if (extensions === Extensions.Json) { + if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, onlyRecordFailures, state); + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); @@ -26130,6 +26555,7 @@ var ts; return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); case Extensions.JavaScript: return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + case Extensions.TSConfig: case Extensions.Json: return tryExtension(".json" /* Json */); } @@ -26214,11 +26640,27 @@ var ts; } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { - var packageFile = jsonContent && (extensions !== Extensions.JavaScript && extensions !== Extensions.Json - ? readPackageJsonTypesFields(jsonContent, candidate, state) || - // When resolving typescript modules, try resolving using main field as well - (extensions === Extensions.TypeScript ? readPackageJsonMainField(jsonContent, candidate, state) : undefined) - : readPackageJsonMainField(jsonContent, candidate, state)); + var packageFile; + if (jsonContent) { + switch (extensions) { + case Extensions.JavaScript: + case Extensions.Json: + packageFile = readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.TypeScript: + // When resolving typescript modules, try resolving using main field as well + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.DtsOnly: + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state); + break; + case Extensions.TSConfig: + packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state); + break; + default: + return ts.Debug.assertNever(extensions); + } + } var loader = function (extensions, candidate, onlyRecordFailures, state) { var fromFile = tryFile(candidate, onlyRecordFailures, state); if (fromFile) { @@ -26237,7 +26679,7 @@ var ts; }; var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined; var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host); - var indexPath = ts.combinePaths(candidate, "index"); + var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index"); if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) { var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, /*ignoreCase*/ false); if (state.traceEnabled) { @@ -26264,6 +26706,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + case Extensions.TSConfig: case Extensions.Json: return extension === ".json" /* Json */; case Extensions.TypeScript: @@ -26281,15 +26724,15 @@ var ts; return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } ts.parsePackageName = parsePackageName; - function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache) { - return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache); + function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) { + return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference); } function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined); + return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined); } - function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state); @@ -26310,7 +26753,7 @@ var ts; if (packageResult) { return packageResult; } - if (extensions !== Extensions.JavaScript && extensions !== Extensions.Json) { + if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) { var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); var nodeModulesAtTypesExists = nodeModulesFolderExists; if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { @@ -26443,7 +26886,7 @@ var ts; return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + 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 }; @@ -26457,7 +26900,7 @@ var ts; return { value: resolvedUsingSettings }; } if (!ts.isExternalModuleNameRelative(moduleName)) { - var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName); + var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); // Climb up parent directories looking for a module. var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); @@ -26523,24 +26966,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 243 /* ModuleBlock */: { + case 245 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -26562,9 +27005,9 @@ var ts; }); return state_1; } - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(node); - case 71 /* Identifier */: + case 72 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -26725,7 +27168,7 @@ var ts; // 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 === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -26734,7 +27177,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -26746,36 +27189,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "__constructor" /* Constructor */; - case 163 /* FunctionType */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: return "__call" /* Call */; - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return "__new" /* New */; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "__index" /* Index */; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 149 /* Parameter */: + case 151 /* 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 === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (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; @@ -26873,7 +27316,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 === 252 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 254 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; } @@ -26900,7 +27343,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 257 /* ExportSpecifier */ || (node.kind === 248 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -26967,7 +27410,7 @@ var ts; // 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 !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -26999,7 +27442,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property intialization checks. - currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 157 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -27012,13 +27455,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -27061,8 +27504,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -27095,78 +27538,78 @@ var ts; return; } switch (node.kind) { - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: bindWhileStatement(node); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: bindDoStatement(node); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: bindForStatement(node); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: bindIfStatement(node); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: bindTryStatement(node); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: bindSwitchStatement(node); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: bindCaseBlock(node); break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: bindCaseClause(node); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: bindLabeledStatement(node); break; - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 277 /* SourceFile */: { + case 279 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -27177,26 +27620,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return hasNarrowableArgument(expr); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 200 /* PrefixUnaryExpression */: - return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 197 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 199 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || + return expr.kind === 72 /* Identifier */ || expr.kind === 100 /* ThisKeyword */ || expr.kind === 98 /* SuperKeyword */ || ts.isPropertyAccessExpression(expr) && isNarrowableReference(expr.expression) || ts.isElementAccessExpression(expr) && expr.argumentExpression && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && @@ -27211,7 +27654,7 @@ var ts; } } } - if (expr.expression.kind === 187 /* PropertyAccessExpression */ && + if (expr.expression.kind === 189 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -27225,32 +27668,32 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableReference(expr.left); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -27285,8 +27728,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 101 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 86 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 102 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 87 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -27324,34 +27767,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return parent.expression === node; - case 223 /* ForStatement */: - case 203 /* ConditionalExpression */: + case 225 /* ForStatement */: + case 205 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 193 /* ParenthesizedExpression */) { + if (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 202 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 54 /* BarBarToken */); + return node.kind === 204 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 193 /* ParenthesizedExpression */ || - node.parent.kind === 200 /* PrefixUnaryExpression */ && - node.parent.operator === 51 /* ExclamationToken */) { + while (node.parent.kind === 195 /* ParenthesizedExpression */ || + node.parent.kind === 202 /* PrefixUnaryExpression */ && + node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -27392,7 +27835,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 233 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -27426,13 +27869,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 225 /* ForOfStatement */) { + if (node.kind === 227 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 236 /* VariableDeclarationList */) { + if (node.initializer.kind !== 238 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -27454,7 +27897,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 228 /* ReturnStatement */) { + if (node.kind === 230 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -27474,7 +27917,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 229 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -27570,7 +28013,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 272 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -27637,14 +28080,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 223 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -27655,10 +28098,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 185 /* ArrayLiteralExpression */) { + else if (node.kind === 187 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 206 /* SpreadElement */) { + if (e.kind === 208 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -27666,16 +28109,16 @@ var ts; } } } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 273 /* PropertyAssignment */) { + if (p.kind === 275 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 274 /* ShorthandPropertyAssignment */) { + else if (p.kind === 276 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 275 /* SpreadAssignment */) { + else if (p.kind === 277 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -27683,7 +28126,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -27694,7 +28137,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 51 /* ExclamationToken */) { + if (node.operator === 52 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -27704,20 +28147,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -27731,7 +28174,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { + if (operator === 59 /* EqualsToken */ && node.left.kind === 190 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27742,7 +28185,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -27789,10 +28232,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 193 /* ParenthesizedExpression */) { + while (expr.kind === 195 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { + if (expr.kind === 196 /* FunctionExpression */ || expr.kind === 197 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -27800,7 +28243,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27809,54 +28252,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 266 /* JsxAttributes */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 268 /* JsxAttributes */: return 1 /* IsContainer */; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 287 /* JSDocFunctionType */: - case 163 /* FunctionType */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 164 /* ConstructorType */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 289 /* JSDocFunctionType */: + case 165 /* FunctionType */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 166 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 272 /* CatchClause */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 244 /* CaseBlock */: + case 274 /* CatchClause */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 246 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 216 /* Block */: + case 218 /* 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 @@ -27889,45 +28332,45 @@ 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 186 /* ObjectLiteralExpression */: - case 239 /* InterfaceDeclaration */: - case 266 /* JsxAttributes */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 188 /* ObjectLiteralExpression */: + case 241 /* InterfaceDeclaration */: + case 268 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 291 /* JSDocSignature */: - case 160 /* IndexSignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 287 /* JSDocFunctionType */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 293 /* JSDocSignature */: + case 162 /* IndexSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 242 /* TypeAliasDeclaration */: + case 181 /* 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 @@ -27948,11 +28391,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 277 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { + var body = node.kind === 279 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { + if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { return true; } } @@ -27980,7 +28423,7 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 9 /* StringLiteral */) { + if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; if (ts.hasZeroOrOneAsteriskCharacter(text)) { pattern = ts.tryParsePattern(text); @@ -28036,7 +28479,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 277 /* SpreadAssignment */ || prop.name.kind !== 72 /* Identifier */) { continue; } var identifier = prop.name; @@ -28048,7 +28491,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 275 /* PropertyAssignment */ || prop.kind === 276 /* ShorthandPropertyAssignment */ || prop.kind === 156 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -28080,10 +28523,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28114,7 +28557,7 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) { + if (!typeAlias.fullName || typeAlias.fullName.kind === 72 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); } @@ -28132,8 +28575,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 108 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 116 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 109 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 117 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !(node.flags & 4194304 /* Ambient */)) { // Report error only if there are no parse errors in file @@ -28169,7 +28612,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 71 /* Identifier */) { + if (inStrictMode && node.expression.kind === 72 /* 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); @@ -28180,7 +28623,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 71 /* Identifier */) { + if (name && name.kind === 72 /* 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 @@ -28221,8 +28664,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 277 /* SourceFile */ && - blockScopeContainer.kind !== 242 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 279 /* SourceFile */ && + blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -28248,7 +28691,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -28317,7 +28760,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 145 /* LastToken */) { + if (node.kind > 147 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -28379,7 +28822,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 71 /* Identifier */: + case 72 /* 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. @@ -28392,13 +28835,13 @@ var ts; break; } // falls through - case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { + case 100 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 276 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -28412,7 +28855,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -28437,142 +28880,155 @@ var ts; // Nothing to do break; default: - ts.Debug.fail("Unknown special property assignment kind"); + ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return checkStrictModeCatchClause(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkStrictModeWithStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 176 /* ThisType */: + case 178 /* ThisType */: seenThisKeyword = true; return; - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: break; // Binding the children will handle everything - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return bindTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return bindParameter(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return bindPropertyWorker(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* 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 */ : 67212223 /* MethodExcludes */); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: + case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 179 /* MappedType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 181 /* MappedType */: return bindAnonymousTypeWorker(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return bindFunctionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: + var assignmentKind = ts.getAssignmentDeclarationKind(node); + switch (assignmentKind) { + case 7 /* ObjectDefinePropertyValue */: + return bindObjectDefinePropertyAssignment(node); + case 8 /* ObjectDefinePropertyExports */: + return bindObjectDefinePropertyExport(node); + case 9 /* ObjectDefinePrototypeProperty */: + return bindObjectDefinePrototypeProperty(node); + case 0 /* None */: + break; // Nothing to do + default: + return ts.Debug.fail("Unknown call expression assignment declaration kind"); + } if (ts.isInJSFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return bindJsxAttributes(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return bindImportClause(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return bindExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 277 /* SourceFile */: + case 279 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 216 /* Block */: + case 218 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 297 /* JSDocParameterTag */: - if (node.parent.kind === 291 /* JSDocSignature */) { + case 299 /* JSDocParameterTag */: + if (node.parent.kind === 293 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { break; } // falls through - case 303 /* JSDocPropertyTag */: + case 305 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -28659,6 +29115,21 @@ var ts; } return true; } + function bindObjectDefinePropertyExport(node) { + if (!setCommonJsModuleIndicator(node)) { + return; + } + var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + } + return symbol; + }); + if (symbol) { + var flags = 4 /* Property */ | 1048576 /* ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + } + } function bindExportsPropertyAssignment(node) { // When we create a property via 'exports.foo = bar', the 'exports.foo' property access // expression is the declaration @@ -28695,17 +29166,17 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 58 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 59 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -28718,18 +29189,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -28738,10 +29209,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 99 /* ThisKeyword */) { + if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -28757,6 +29228,10 @@ var ts; var lhs = node.left; bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); } + function bindObjectDefinePrototypeProperty(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); + } /** * For `x.prototype.y = z`, declare a member `y` on `x` if `x` is a function or class, or not declared. * Note that jsdoc preceding an ExpressionStatement like `x.prototype.y;` is also treated as a declaration. @@ -28772,6 +29247,12 @@ var ts; classPrototype.parent = lhs; bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); } + function bindObjectDefinePropertyAssignment(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); + var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); + } function bindSpecialPropertyAssignment(node) { var lhs = node.left; // Class declarations in Typescript do not allow property declarations @@ -28800,16 +29281,12 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ - : propertyAccess.parent.parent.kind === 277 /* SourceFile */; + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; - namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_1); return symbol; @@ -28821,6 +29298,9 @@ var ts; } }); } + return namespaceSymbol; + } + function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) { return; } @@ -28828,10 +29308,18 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(propertyAccess)); + var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var isToplevel = ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ + : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** * Javascript expando values are: @@ -28848,6 +29336,9 @@ var ts; return true; } var node = symbol.valueDeclaration; + if (ts.isCallExpression(node)) { + return !!ts.getAssignedExpandoInitializer(node); + } var init = !node ? undefined : ts.isVariableDeclaration(node) ? node.initializer : ts.isBinaryExpression(node) ? node.right : @@ -28856,7 +29347,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 === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); } return false; } @@ -28898,7 +29389,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 238 /* ClassDeclaration */) { + if (node.kind === 240 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -28964,7 +29455,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 297 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { + if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -29041,7 +29532,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 174 /* InferType */) { + else if (node.parent.kind === 176 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -29069,11 +29560,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 220 /* EmptyStatement */) || // report error on class declarations - node.kind === 238 /* ClassDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 244 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -29117,18 +29608,17 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; } } - /* @internal */ function isExportsOrModuleExportsOrAlias(sourceFile, node) { return ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node) || @@ -29163,58 +29653,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 149 /* Parameter */: + case 151 /* Parameter */: return computeParameter(node, subtreeFlags); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 155 /* Constructor */: + case 157 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -29238,7 +29728,7 @@ var ts; transformFlags |= 8192 /* ContainsLexicalThis */; } } - if (expression.kind === 91 /* ImportKeyword */) { + if (expression.kind === 92 /* ImportKeyword */) { transformFlags |= 16777216 /* ContainsDynamicImport */; // A dynamic 'import()' call that contains a lexical 'this' will // require a captured 'this' when emitting down-level. @@ -29266,17 +29756,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 188 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 187 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 40 /* AsteriskAsteriskToken */ - || operatorTokenKind === 62 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ + || operatorTokenKind === 63 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 32 /* AssertES2016 */; } @@ -29320,8 +29810,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 210 /* AsExpression */ - || expressionKind === 192 /* TypeAssertionExpression */) { + if (expressionKind === 212 /* AsExpression */ + || expressionKind === 194 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -29378,11 +29868,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 85 /* ExtendsKeyword */: + case 86 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 108 /* ImplementsKeyword */: + case 109 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -29701,59 +30191,59 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 637535553 /* NodeExcludes */; switch (kind) { - case 120 /* AsyncKeyword */: - case 199 /* AwaitExpression */: + case 121 /* AsyncKeyword */: + case 201 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; break; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 211 /* NonNullExpression */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 213 /* NonNullExpression */: + case 133 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: - case 10 /* JsxText */: - case 261 /* JsxClosingElement */: - case 262 /* JsxFragment */: - case 263 /* JsxOpeningFragment */: - case 264 /* JsxClosingFragment */: - case 265 /* JsxAttribute */: - case 266 /* JsxAttributes */: - case 267 /* JsxSpreadAttribute */: - case 268 /* JsxExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 11 /* JsxText */: + case 263 /* JsxClosingElement */: + case 264 /* JsxFragment */: + case 265 /* JsxOpeningFragment */: + case 266 /* JsxClosingFragment */: + case 267 /* JsxAttribute */: + case 268 /* JsxAttributes */: + case 269 /* JsxSpreadAttribute */: + case 270 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - case 274 /* ShorthandPropertyAssignment */: - case 115 /* StaticKeyword */: - case 212 /* MetaProperty */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + case 276 /* ShorthandPropertyAssignment */: + case 116 /* StaticKeyword */: + case 214 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.hasExtendedUnicodeEscape) { transformFlags |= 192 /* AssertES2015 */; } @@ -29763,60 +30253,64 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ForOfStatement */: + case 9 /* BigIntLiteral */: + transformFlags |= 8 /* AssertESNext */; + break; + case 227 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 4194304 /* ContainsYield */; break; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 161 /* TypePredicate */: - case 162 /* TypeReference */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 165 /* TypeQuery */: - case 166 /* TypeLiteral */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 174 /* InferType */: - case 175 /* ParenthesizedType */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: - case 245 /* NamespaceExportDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 163 /* TypePredicate */: + case 164 /* TypeReference */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 167 /* TypeQuery */: + case 168 /* TypeLiteral */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 176 /* InferType */: + case 177 /* ParenthesizedType */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: + case 247 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -29833,43 +30327,43 @@ var ts; transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 131072 /* ContainsRestOrSpread */; break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; break; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 33554432 /* Super */; excludeFlags = 536872257 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 8192 /* ContainsLexicalThis */; break; - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; } excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 131072 /* ContainsRestOrSpread */; } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: excludeFlags = 638358849 /* ObjectLiteralExcludes */; if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -29887,8 +30381,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 185 /* ArrayLiteralExpression */: - case 190 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: + case 192 /* NewExpression */: excludeFlags = 637666625 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -29896,26 +30390,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -29929,68 +30423,68 @@ var ts; * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather * than calling this function. */ - /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { + if (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 185 /* ArrayLiteralExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: return 637666625 /* ArrayLiteralOrCallOrNewExcludes */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return 647001409 /* ModuleExcludes */; - case 149 /* Parameter */: + case 151 /* Parameter */: return 637535553 /* ParameterExcludes */; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return 653604161 /* ArrowFunctionExcludes */; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return 653620545 /* FunctionExcludes */; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return 639894849 /* VariableDeclarationListExcludes */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 638121281 /* ClassExcludes */; - case 155 /* Constructor */: + case 157 /* Constructor */: return 653616449 /* ConstructorExcludes */; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return 653616449 /* MethodOrAccessorExcludes */; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 137 /* StringKeyword */: - case 135 /* ObjectKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 138 /* StringKeyword */: + case 136 /* ObjectKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return 638358849 /* ObjectLiteralExcludes */; - case 272 /* CatchClause */: + case 274 /* CatchClause */: return 637797697 /* CatchClauseExcludes */; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return 637666625 /* BindingPatternExcludes */; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: - case 193 /* ParenthesizedExpression */: - case 97 /* SuperKeyword */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: + case 195 /* ParenthesizedExpression */: + case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 570426689 /* PropertyAccessExcludes */; default: return 637535553 /* NodeExcludes */; @@ -30051,7 +30545,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -30067,16 +30561,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { visitIndexType(type); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -30165,7 +30659,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 === 165 /* TypeQuery */) { + if (d.type && d.type.kind === 167 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -30255,6 +30749,7 @@ var ts; var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); @@ -30430,10 +30925,6 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { - var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); - return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; - }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isParameter); @@ -30466,6 +30957,7 @@ var ts; getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, + getObjectFlags: ts.getObjectFlags, isArrayLikeType: isArrayLikeType, isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, @@ -30473,7 +30965,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentExport: function (node, target) { return getSuggestionForNonexistentExport(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -30551,21 +31043,24 @@ var ts; var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(16384 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(65536 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */ | 134217728 /* ContainsWideningType */, "null"); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); - var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - falseType.flags |= 33554432 /* FreshLiteral */; - trueType.flags |= 33554432 /* FreshLiteral */; + 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"); trueType.regularType = regularTrueType; + trueType.freshType = trueType; + regularTrueType.regularType = regularTrueType; regularTrueType.freshType = trueType; falseType.regularType = regularFalseType; + falseType.freshType = falseType; + regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = createBooleanType([regularFalseType, regularTrueType]); // Also mark all combinations of fresh/regular booleans as "Boolean" so they print as `boolean` instead of `true | false` @@ -30573,15 +31068,18 @@ var ts; createBooleanType([regularFalseType, trueType]); createBooleanType([falseType, regularTrueType]); createBooleanType([falseType, trueType]); - var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(4096 /* Void */, "void"); - var neverType = createIntrinsicType(32768 /* Never */, "never"); - var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); + 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 implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; + var numberOrBigIntType = getUnionType([numberType, bigintType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -30594,16 +31092,15 @@ var ts; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var markerSuperType = createType(65536 /* TypeParameter */); - var markerSubType = createType(65536 /* TypeParameter */); + var markerSuperType = createType(262144 /* TypeParameter */); + var markerSubType = createType(262144 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(65536 /* TypeParameter */); + var markerOtherType = createType(262144 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignaturesArray = [resolvingSignature]; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var globals = ts.createSymbolTable(); /** Key is "/path/to/a.ts|/path/to/b.ts". */ @@ -30650,6 +31147,9 @@ var ts; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; var deferredGlobalExtractSymbol; + var deferredGlobalExcludeSymbol; + var deferredGlobalPickSymbol; + var deferredGlobalBigIntType; var allPotentiallyUnusedIdentifiers = ts.createMap(); // key is file name var flowLoopStart = 0; var flowLoopCount = 0; @@ -30657,6 +31157,7 @@ var ts; var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); + var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -30682,86 +31183,99 @@ var ts; TypeFacts[TypeFacts["None"] = 0] = "None"; TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["All"] = 4194303] = "All"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; // The following members encode facts about particular kinds of types for use in the getTypeFacts function. // The presence of a particular fact means that the given test is true for some (and possibly all) values // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 1972176] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 4184016] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 1970144] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 4181984] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 4079615] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 4194303] = "EmptyObjectFacts"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMapFromTemplate({ string: 1 /* TypeofEQString */, number: 2 /* TypeofEQNumber */, - boolean: 4 /* TypeofEQBoolean */, - symbol: 8 /* TypeofEQSymbol */, - undefined: 16384 /* EQUndefined */, - object: 16 /* TypeofEQObject */, - function: 32 /* TypeofEQFunction */ + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ }); var typeofNEFacts = ts.createMapFromTemplate({ - string: 128 /* TypeofNEString */, - number: 256 /* TypeofNENumber */, - boolean: 512 /* TypeofNEBoolean */, - symbol: 1024 /* TypeofNESymbol */, - undefined: 131072 /* NEUndefined */, - object: 2048 /* TypeofNEObject */, - function: 4096 /* TypeofNEFunction */ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ }); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, + bigint: bigintType, boolean: booleanType, symbol: esSymbolType, undefined: undefinedType @@ -30983,7 +31497,7 @@ var ts; (source.flags | target.flags) & 67108864 /* Assignment */) { ts.Debug.assert(source !== target); if (!(target.flags & 33554432 /* Transient */)) { - target = cloneSymbol(target); + target = cloneSymbol(resolveSymbol(target)); } // 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) { @@ -31014,7 +31528,7 @@ var ts; else if (target.flags & 1024 /* NamespaceModule */) { error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } - else { + else { // error var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); var message = isEitherEnum @@ -31079,7 +31593,8 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); + var targetSymbol = target.get(id); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -31141,7 +31656,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -31199,17 +31714,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 184 /* BindingElement */) { + if (declaration.kind === 186 /* 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, 184 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 186 /* 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, 235 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 237 /* VariableDeclaration */), usage); } - else if (declaration.kind === 235 /* VariableDeclaration */) { + else if (declaration.kind === 237 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -31228,12 +31743,12 @@ 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 === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 257 /* ExportSpecifier */ || (usage.parent.kind === 254 /* 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 === 252 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 254 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -31241,9 +31756,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 217 /* VariableStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 219 /* VariableStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -31264,16 +31779,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 152 /* PropertyDeclaration */ && + current.parent.kind === 154 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 154 /* MethodDeclaration */) { + if (declaration.kind === 156 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -31315,12 +31830,12 @@ 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 & 67897832 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 149 /* Parameter */ || - lastLocation.kind === 148 /* TypeParameter */ + lastLocation.kind === 151 /* Parameter */ || + lastLocation.kind === 150 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -31337,13 +31852,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 151 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 173 /* ConditionalType */) { + else if (location.kind === 175 /* 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; @@ -31357,14 +31872,14 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -31388,7 +31903,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 257 /* ExportSpecifier */)) { break; } } @@ -31402,13 +31917,13 @@ var ts; } } break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -31425,9 +31940,9 @@ var ts; } } break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* 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! @@ -31446,7 +31961,7 @@ var ts; } break loop; } - if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 209 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -31454,9 +31969,9 @@ var ts; } } break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 86 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { if (nameNotFoundMessage) { @@ -31474,9 +31989,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 241 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -31484,19 +31999,19 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -31509,7 +32024,7 @@ var ts; } } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -31518,7 +32033,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 === 149 /* Parameter */) { + if (location.parent && location.parent.kind === 151 /* Parameter */) { location = location.parent; } // @@ -31531,8 +32046,8 @@ var ts; location = location.parent; } break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -31551,7 +32066,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -31624,8 +32139,7 @@ var ts; } // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { - var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { + if (ts.some(result.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -31634,12 +32148,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: // For `namespace N { N; }` + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -31651,7 +32165,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 148 /* TypeParameter */) { + if (decl.kind === 150 /* 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 @@ -31706,10 +32220,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -31776,7 +32290,7 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 243 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -31811,13 +32325,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 248 /* ImportClause */: + case 250 /* ImportClause */: return node.parent; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -31827,7 +32341,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -32019,20 +32533,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 252 /* ExportAssignment */: - case 202 /* BinaryExpression */: + case 254 /* ExportAssignment */: + case 204 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -32093,11 +32607,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 255 /* ExportSpecifier */) { + else if (node.kind === 257 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -32115,17 +32629,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 71 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 72 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* QualifiedName */) { + if (entityName.kind === 72 /* Identifier */ || entityName.parent.kind === 148 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 248 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -32141,7 +32655,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); var symbol; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name).escapedText); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -32149,9 +32663,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { - var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 148 /* QualifiedName */ || name.kind === 189 /* PropertyAccessExpression */) { + var left = name.kind === 148 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 148 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -32234,6 +32748,9 @@ var ts; } function getDeclarationOfJSPrototypeContainer(symbol) { var decl = symbol.parent.valueDeclaration; + if (!decl) { + return undefined; + } var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) : ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) : undefined; @@ -32352,10 +32869,15 @@ var ts; return getPackagesSet().has(ts.getTypesPackageName(packageName)); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; + if (moduleSymbol) { + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + return getMergedSymbol(exported) || moduleSymbol; + } + return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || moduleSymbol.exports.size === 1) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } var merged = cloneSymbol(exported); @@ -32376,7 +32898,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -32444,7 +32966,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -32589,7 +33111,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 157 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -32612,7 +33134,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(131072 /* Object */); + var type = createType(524288 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -32667,12 +33189,12 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -32736,7 +33258,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 255 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -32772,7 +33294,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, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -32787,10 +33309,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: continue; default: return false; @@ -32907,10 +33429,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -32957,14 +33479,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 165 /* TypeQuery */ || + if (entityName.parent.kind === 167 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 147 /* ComputedPropertyName */) { + entityName.parent.kind === 149 /* ComputedPropertyName */) { // Typeof value meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || - entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 148 /* QualifiedName */ || entityName.kind === 189 /* PropertyAccessExpression */ || + entityName.parent.kind === 248 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -33013,15 +33535,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 166 /* ConstructorType */ : 165 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 161 /* ConstructSignature */ : 160 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 return writer; } } @@ -33086,7 +33608,8 @@ var ts; getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) } : undefined }, encounteredError: false, - visitedSymbols: undefined, + visitedTypes: undefined, + symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; @@ -33110,48 +33633,55 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + return ts.createKeywordTypeNode(143 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* StringKeyword */); + return ts.createKeywordTypeNode(138 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(134 /* NumberKeyword */); + return ts.createKeywordTypeNode(135 /* NumberKeyword */); + } + if (type.flags & 64 /* BigInt */) { + context.approximateLength += 6; + return ts.createKeywordTypeNode(146 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(122 /* BooleanKeyword */); + return ts.createKeywordTypeNode(123 /* BooleanKeyword */); } - if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { + if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToName(parentSymbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); + var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type + ? parentName + : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); + return enumLiteralName; } - if (type.flags & 544 /* EnumLike */) { - var name = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + if (type.flags & 1056 /* EnumLike */) { + return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); } - if (type.flags & 64 /* StringLiteral */) { + if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & 128 /* NumberLiteral */) { + if (type.flags & 256 /* NumberLiteral */) { context.approximateLength += (("" + type.value).length); return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 2048 /* BigIntLiteral */) { + context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; + return ts.createLiteralTypeNode((ts.createLiteral(type.value))); + } + if (type.flags & 512 /* BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; @@ -33162,33 +33692,33 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(142 /* UniqueKeyword */, ts.createKeywordTypeNode(139 /* SymbolKeyword */)); } - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(105 /* VoidKeyword */); + return ts.createKeywordTypeNode(106 /* VoidKeyword */); } - if (type.flags & 8192 /* Undefined */) { + if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(141 /* UndefinedKeyword */); } - if (type.flags & 16384 /* Null */) { + if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(95 /* NullKeyword */); + return ts.createKeywordTypeNode(96 /* NullKeyword */); } - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(131 /* NeverKeyword */); + return ts.createKeywordTypeNode(132 /* NeverKeyword */); } - if (type.flags & 1024 /* ESSymbol */) { + if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(138 /* SymbolKeyword */); + return ts.createKeywordTypeNode(139 /* SymbolKeyword */); } - if (type.flags & 16777216 /* NonPrimitive */) { + if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(135 /* ObjectKeyword */); + return ts.createKeywordTypeNode(136 /* ObjectKeyword */); } - if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { + if (type.flags & 262144 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -33202,16 +33732,16 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 65536 /* TypeParameter */ && + type.flags & 262144 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && @@ -33231,14 +33761,14 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); } - if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { - var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { + var types = type.flags & 1048576 /* 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) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 173 /* UnionType */ : 174 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -33249,23 +33779,23 @@ var ts; } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 4194304 /* Conditional */) { + if (type.flags & 16777216 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -33276,12 +33806,12 @@ var ts; context.approximateLength += 15; return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 8388608 /* Substitution */) { + if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -33300,6 +33830,7 @@ var ts; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); } function createAnonymousTypeNode(type) { + var typeId = "" + type.id; var symbol = type.symbol; var id; if (symbol) { @@ -33311,12 +33842,12 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 209 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67220415 /* Value */); } - else if (context.visitedSymbols && context.visitedSymbols.has(id)) { + else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { @@ -33325,18 +33856,34 @@ var ts; } else { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } } else { // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedSymbols) { - context.visitedSymbols = ts.createMap(); + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); } - context.visitedSymbols.set(id, true); + if (!context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + context.approximateLength += 3; + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); + } + context.symbolDepth.set(id, depth + 1); + context.visitedTypes.set(typeId, true); var result = createTypeNodeFromObjectType(type); - context.visitedSymbols.delete(id); + context.visitedTypes.delete(typeId); + context.symbolDepth.set(id, depth); return result; } } @@ -33350,11 +33897,11 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; + return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively + return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } @@ -33371,12 +33918,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 165 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* ConstructorType */, context); return signatureNode; } } @@ -33508,11 +34055,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 160 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -33563,12 +34110,12 @@ var ts; var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(55 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length) { var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 155 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -33581,9 +34128,9 @@ var ts; else { var savedFlags = context.flags; context.flags |= !!(ts.getCheckFlags(propertySymbol) & 2048 /* ReverseMapped */) ? 33554432 /* InReverseMappedType */ : 0; - var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(120 /* AnyKeyword */); context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -33634,7 +34181,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 137 /* StringKeyword */ : 134 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 138 /* StringKeyword */ : 135 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -33647,7 +34194,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -33658,7 +34205,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 157 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -33677,12 +34224,12 @@ var ts; returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 119 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 120 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(119 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(120 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -33711,9 +34258,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 297 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -33722,16 +34269,16 @@ var ts; var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; - var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; + var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 72 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 148 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -33745,7 +34292,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 184 /* BindingElement */) { + if (clone.kind === 186 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -33844,7 +34391,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -34044,10 +34591,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 24576 /* Nullable */)) { - if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { - var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 262144 /* Union */) { + 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 */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -34059,9 +34606,9 @@ var ts; result.push(t); } } - if (flags & 16384 /* Null */) + if (flags & 65536 /* Null */) result.push(nullType); - if (flags & 8192 /* Undefined */) + if (flags & 32768 /* Undefined */) result.push(undefinedType); return result || types; } @@ -34076,8 +34623,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); - if (node.kind === 240 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 177 /* ParenthesizedType */; }); + if (node.kind === 242 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -34085,11 +34632,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 243 /* ModuleBlock */ && + node.parent.kind === 245 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -34112,27 +34659,30 @@ var ts; var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { + if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + return ts.symbolName(symbol); + } return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 237 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 209 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 128 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 8192 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -34149,27 +34699,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: // 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 184 /* BindingElement */: + case 186 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 235 /* VariableDeclaration */: + case 237 /* 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 237 /* FunctionDeclaration */: - case 241 /* EnumDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 243 /* EnumDeclaration */: + case 248 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -34177,53 +34727,53 @@ var ts; 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 !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 155 /* Constructor */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 149 /* Parameter */: - case 243 /* ModuleBlock */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 162 /* TypeReference */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 175 /* ParenthesizedType */: + case 157 /* Constructor */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 151 /* Parameter */: + case 245 /* ModuleBlock */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 164 /* TypeReference */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 177 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: return false; // Type parameters are always visible - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 277 /* SourceFile */: - case 245 /* NamespaceExportDeclaration */: + case 279 /* SourceFile */: + case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return false; default: return false; @@ -34232,10 +34782,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 254 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 255 /* ExportSpecifier */) { + else if (node.parent.kind === 257 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -34331,12 +34881,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 235 /* VariableDeclaration */: - case 236 /* VariableDeclarationList */: - case 251 /* ImportSpecifier */: - case 250 /* NamedImports */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 237 /* VariableDeclaration */: + case 238 /* VariableDeclarationList */: + case 253 /* ImportSpecifier */: + case 252 /* NamedImports */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: return false; default: return true; @@ -34366,28 +34916,36 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 149 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); - if (source.flags & 32768 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); + if (source.flags & 131072 /* Never */) { return emptyObjectType; } - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } - var members = ts.createSymbolTable(); - var names = ts.createUnderscoreEscapedMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; - names.set(ts.getTextOfPropertyName(name), true); + var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); + if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) { + if (omitKeyType.flags & 131072 /* Never */) { + return source; + } + var pickTypeAlias = getGlobalPickSymbol(); + var excludeTypeAlias = getGlobalExcludeSymbol(); + if (!pickTypeAlias || !excludeTypeAlias) { + return errorType; + } + var pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]); + return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]); } - for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { - var prop = _b[_a]; - if (!names.has(prop.escapedName) + var members = ts.createSymbolTable(); + for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), omitKeyType) && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { - members.set(prop.escapedName, getNonReadonlySymbol(prop)); + members.set(prop.escapedName, getSpreadSymbol(prop)); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -34411,8 +34969,12 @@ var ts; if (isTypeAny(parentType)) { return parentType; } + // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation + if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + parentType = getNonNullableType(parentType); + } var type; - if (pattern.kind === 182 /* ObjectBindingPattern */) { + if (pattern.kind === 184 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -34430,51 +34992,9 @@ var ts; else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; - var isLate = isLateBindableName(name); - var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); - if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { - var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); - } - return anyType; - } - var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); - if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { - if (getIndexTypeOfType(parentType, 1 /* Number */)) { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); - } - else { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(parentType)); - } - } - return indexerType || anyType; - } - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - var nameType = isLate ? checkComputedPropertyName(name) : undefined; - var text = isLate ? getLateBoundNameFromType(nameType) : - isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : - ts.getTextOfPropertyName(name); - // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { - parentType = getNonNullableType(parentType); - } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); - } - return anyType; - } - var declaredType = getConstraintForLocation(getTypeOfPropertyOfType(parentType, text), declaration.name); - type = declaredType && getFlowTypeOfReference(declaration, declaredType) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return errorType; - } + var exprType = getLiteralTypeFromPropertyName(name); + var declaredType = checkIndexedAccessIndexType(getIndexedAccessType(parentType, exprType, name), name); + type = getFlowTypeOfReference(declaration, getConstraintForLocation(declaredType, declaration.name)); } } else { @@ -34510,8 +35030,8 @@ var ts; } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 8192 /* Undefined */)) { - type = getTypeWithFacts(type, 131072 /* NEUndefined */); + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */)) { + type = getTypeWithFacts(type, 524288 /* NEUndefined */); } return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkDeclarationInitializer(declaration)], 2 /* Subtype */) : @@ -34526,11 +35046,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 95 /* NullKeyword */ || expr.kind === 71 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 96 /* NullKeyword */ || expr.kind === 72 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 187 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -34540,11 +35060,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 224 /* ForInStatement */) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 226 /* ForInStatement */) { + var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); + return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* 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, @@ -34563,7 +35083,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 237 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* 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 @@ -34577,11 +35097,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); + if (func.kind === 159 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 158 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -34645,7 +35165,7 @@ var ts; var types; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - var expression = ts.isBinaryExpression(declaration) ? declaration : + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { @@ -34660,9 +35180,11 @@ var ts; definedInMethod = true; } } - jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + if (!ts.isCallExpression(expression)) { + jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } if (!jsdocType) { - (types || (types = [])).push(ts.isBinaryExpression(expression) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } var type = jsdocType; @@ -34676,11 +35198,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(98304 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -34721,8 +35243,33 @@ var ts; } /** If we don't have an explicit JSDoc type, get the type from the initializer. */ function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) { + if (ts.isCallExpression(expression)) { + if (resolvedSymbol) { + return getTypeOfSymbol(resolvedSymbol); // This shouldn't happen except under some hopefully forbidden merges of export assignments and object define assignments + } + var objectLitType = checkExpressionCached(expression.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + return valueType; + } + var getFunc = getTypeOfPropertyOfType(objectLitType, "get"); + if (getFunc) { + var getSig = getSingleCallSignature(getFunc); + if (getSig) { + return getReturnTypeOfSignature(getSig); + } + } + var setFunc = getTypeOfPropertyOfType(objectLitType, "set"); + if (setFunc) { + var setSig = getSingleCallSignature(setFunc); + if (setSig) { + return getTypeOfFirstParameterOfSignature(setSig); + } + } + return anyType; + } var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 131072 /* Object */ && + if (type.flags & 524288 /* Object */ && kind === 2 /* ModuleExports */ && symbol.escapedName === "export=" /* ExportEquals */) { var exportedType_1 = resolveStructuredTypeMembers(type); @@ -34756,9 +35303,9 @@ var ts; 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 === 155 /* Constructor */ || - thisContainer.kind === 237 /* FunctionDeclaration */ || - (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 157 /* Constructor */ || + thisContainer.kind === 239 /* FunctionDeclaration */ || + (thisContainer.kind === 196 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -34833,7 +35380,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 186 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -34856,7 +35403,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 182 /* ObjectBindingPattern */ + return pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -34878,7 +35425,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -34895,7 +35442,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 151 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -34935,12 +35482,12 @@ var ts; return emptyObjectType; } var type_1 = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression)); - if (type_1.flags & 131072 /* Object */) { + if (type_1.flags & 524288 /* Object */) { return getRegularTypeOfObjectLiteral(type_1); } return type_1; } - if (declaration.kind === 252 /* ExportAssignment */) { + if (declaration.kind === 254 /* ExportAssignment */) { return widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } // Handle variable, parameter or property @@ -34949,7 +35496,7 @@ var ts; } var type; if (ts.isInJSFile(declaration) && - (ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { type = getWidenedTypeFromAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) @@ -34986,6 +35533,14 @@ var ts; || ts.isBindingElement(declaration)) { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); } + // getTypeOfSymbol dispatches some JS merges incorrectly because their symbol flags are not mutually exclusive. + // Re-dispatch based on valueDeclaration.kind instead. + else if (ts.isEnumDeclaration(declaration)) { + type = getTypeOfFuncClassEnumModule(symbol); + } + else if (ts.isEnumMember(declaration)) { + type = getTypeOfEnumMember(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } @@ -34996,7 +35551,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -35023,8 +35578,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 159 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -35067,7 +35622,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -35075,7 +35630,7 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -35107,8 +35662,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 202 /* BinaryExpression */ || - declaration.kind === 187 /* PropertyAccessExpression */ && declaration.parent.kind === 202 /* BinaryExpression */) { + else if (declaration.kind === 204 /* BinaryExpression */ || + declaration.kind === 189 /* PropertyAccessExpression */ && declaration.parent.kind === 204 /* BinaryExpression */) { return getWidenedTypeFromAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -35220,7 +35775,7 @@ var ts; var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, check); } return false; @@ -35244,35 +35799,35 @@ var ts; return undefined; } switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 179 /* MappedType */: - case 173 /* ConditionalType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 181 /* MappedType */: + case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 179 /* MappedType */) { + if (node.kind === 181 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 173 /* ConditionalType */) { + else if (node.kind === 175 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && + (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */ || node.kind === 241 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -35280,7 +35835,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, 239 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -35289,9 +35844,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 238 /* ClassDeclaration */ || - node.kind === 207 /* ClassExpression */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || + node.kind === 209 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -35318,7 +35873,7 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } @@ -35361,7 +35916,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 & (131072 /* Object */ | 524288 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* 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); @@ -35371,7 +35926,18 @@ var ts; return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + if (baseConstructorType.flags & 262144 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(baseConstructorType); + var ctorReturn = unknownType; + if (constraint) { + var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + if (ctorSig[0]) { + ctorReturn = getReturnTypeOfSignature(ctorSig[0]); + } + } + addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; @@ -35400,7 +35966,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -35467,14 +36033,14 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || - !!(type.flags & 524288 /* Intersection */) && ts.every(type.types, isValidBaseType); + return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 241 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -35510,7 +36076,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */) { + if (declaration.kind === 241 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -35551,7 +36117,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -35568,7 +36134,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 242 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -35592,10 +36158,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 9 /* StringLiteral */) { + if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 202 /* BinaryExpression */) { + else if (expr.kind === 204 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -35606,15 +36172,15 @@ var ts; return !(member.flags & 4194304 /* Ambient */); } switch (expr.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 38 /* MinusToken */ && + case 202 /* PrefixUnaryExpression */: + return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -35628,10 +36194,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { + if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -35643,7 +36209,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -35655,7 +36221,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getFreshTypeOfLiteralType(getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member))); // TODO: GH#18217 @@ -35666,8 +36232,8 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 262144 /* Union */) { - enumType_1.flags |= 512 /* EnumLiteral */; + if (enumType_1.flags & 1048576 /* Union */) { + enumType_1.flags |= 1024 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; @@ -35690,7 +36256,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(65536 /* TypeParameter */); + var type = createType(262144 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -35734,22 +36300,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: - case 180 /* LiteralType */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: + case 182 /* LiteralType */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isThislessType(node.elementType); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -35775,7 +36342,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 157 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -35791,12 +36358,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -35840,7 +36407,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -35883,10 +36450,10 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -36051,7 +36618,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -36180,7 +36747,7 @@ var ts; function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { var s = signatureList_1[_i]; - if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { + if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) { return s; } } @@ -36214,8 +36781,7 @@ var ts; // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional // parameters and may differ in return types. When signatures differ in return types, the resulting return // type is the union of the constituent return types. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + function getUnionSignatures(signatureLists) { var result; for (var i = 0; i < signatureLists.length; i++) { for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { @@ -36261,8 +36827,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(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 0 /* Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -36358,7 +36924,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -36392,7 +36958,7 @@ var ts; var modifiers = getMappedTypeModifiers(type.mappedType); var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; - var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType), readonlyMask && indexInfo.isReadonly); + var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly); var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -36402,6 +36968,7 @@ var ts; inferredProp.nameType = prop.nameType; inferredProp.propertyType = getTypeOfSymbol(prop); inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -36420,12 +36987,12 @@ 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 ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; - addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include)); + addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); } if (modifiersType.flags & 1 /* Any */ || getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); @@ -36435,11 +37002,9 @@ var ts; } } else { - // First, if the constraint type is a type parameter, obtain the base constraint. Then, - // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. - // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + // If the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. + // Then iterate over the constituents of the key type. + var iterationType = constraintType.flags & 4194304 /* Index */ ? getIndexType(getApparentType(constraintType.type)) : constraintType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -36451,7 +37016,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 8576 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -36463,7 +37028,7 @@ var ts; // 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. prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; @@ -36499,8 +37064,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 177 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; + return constraintDeclaration.kind === 179 /* TypeOperator */ && + constraintDeclaration.operator === 129 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -36516,16 +37081,16 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 38 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 38 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -36544,7 +37109,7 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -36561,10 +37126,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 262144 /* Union */) { + else if (type.flags & 1048576 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -36572,7 +37137,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -36581,7 +37146,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -36605,7 +37170,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 - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { break; } } @@ -36615,12 +37180,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 786432 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { - return obj.properties.some(function (property) { + var list = obj.properties; + return list.some(function (property) { var name = property.name && ts.getTextOfPropertyName(property.name); var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && typeIsLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); @@ -36628,7 +37194,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 262144 /* Union */)) { + if (!(unionType.flags & 1048576 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -36647,9 +37213,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -36669,7 +37235,11 @@ var ts; function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = !(rootTrueType.flags & 33554432 /* Substitution */) + ? rootTrueType + : (rootTrueType.substitute).flags & 3 /* AnyOrUnknown */ + ? rootTrueType.typeVariable + : getIntersectionType([rootTrueType.substitute, rootTrueType.typeVariable]); type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -36686,7 +37256,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 32768 /* Never */)) { + if (!(instantiated.flags & 131072 /* Never */)) { return instantiated; } } @@ -36701,23 +37271,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 15794176 /* Instantiable */) { + if (t.flags & 63176704 /* 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 & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 262144 /* Union */)) { + if (!(constraint.flags & 1048576 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 16809468 /* DisjointDomains */) { + else if (t.flags & 67238908 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -36729,7 +37299,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 16809468 /* DisjointDomains */) { + if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -36739,11 +37309,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { + if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 1048576 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -36792,13 +37362,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 65536 /* TypeParameter */) { + if (t.flags & 262144 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 786432 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -36808,24 +37378,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 1048576 /* Index */) { + if (t.flags & 4194304 /* Index */) { return keyofConstraintType; } - if (t.flags & 2097152 /* IndexedAccess */) { + if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType, /*accessNode*/ undefined, errorType) : undefined; return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 4194304 /* Conditional */) { + if (t.flags & 16777216 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 8388608 /* Substitution */) { + if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -36897,21 +37467,22 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + var t = type.flags & 63176704 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 68 /* StringLike */ ? globalStringType : - t.flags & 168 /* NumberLike */ ? globalNumberType : - t.flags & 272 /* BooleanLike */ ? globalBooleanType : - t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : - t.flags & 1048576 /* Index */ ? keyofConstraintType : - t; + t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 132 /* StringLike */ ? globalStringType : + t.flags & 296 /* NumberLike */ ? globalNumberType : + t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 6 /* ESNext */) : + 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; } function createUnionOrIntersectionProperty(containingType, name) { var props; var indexTypes; - var isUnion = containingType.flags & 262144 /* Union */; + var isUnion = containingType.flags & 1048576 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -37024,7 +37595,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -37042,13 +37613,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -37062,7 +37633,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -37118,10 +37689,10 @@ 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 === 286 /* JSDocOptionalType */ + node.type && node.type.kind === 288 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -37155,7 +37726,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -37180,30 +37751,32 @@ var ts; } function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); - if (numTypeParameters) { - var numTypeArguments = ts.length(typeArguments); - if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { - if (!typeArguments) { - typeArguments = []; - } - // Map an unsatisfied type parameter with a default type. - // If a type parameter does not have a default type, or if the default type - // is a forward reference, the empty object type is used. - for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - for (var i = numTypeArguments; i < numTypeParameters; i++) { - var mapper = createTypeMapper(typeParameters, typeArguments); - var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { - defaultType = anyType; - } - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - typeArguments.length = typeParameters.length; - } + if (!numTypeParameters) { + return []; } - return typeArguments; + var numTypeArguments = ts.length(typeArguments); + if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { + var result = typeArguments ? typeArguments.slice() : []; + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + var baseDefaultType_1 = getDefaultTypeArgumentType(isJavaScriptImplicitAny); + var circularityMapper = createTypeMapper(typeParameters, ts.map(typeParameters, function () { return baseDefaultType_1; })); + for (var i = numTypeArguments; i < numTypeParameters; i++) { + result[i] = instantiateType(getConstraintFromTypeParameter(typeParameters[i]) || baseDefaultType_1, circularityMapper); + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, result); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { + defaultType = anyType; + } + result[i] = defaultType ? instantiateType(defaultType, mapper) : baseDefaultType_1; + } + result.length = typeParameters.length; + return result; + } + return typeArguments && typeArguments.slice(); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); @@ -37239,7 +37812,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 180 /* LiteralType */) { + if (type && type.kind === 182 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -37253,16 +37826,16 @@ 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 === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && + if ((declaration.kind === 158 /* GetAccessor */ || declaration.kind === 159 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = declaration.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 155 /* Constructor */ ? + var classType = declaration.kind === 157 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -37320,13 +37893,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return node.name.kind === 147 /* ComputedPropertyName */ + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return node.name.kind === 149 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -37401,7 +37974,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, func) { var parameterName = node.parameterName; var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 71 /* Identifier */) { + if (parameterName.kind === 72 /* Identifier */) { return createIdentifierTypePredicate(parameterName.escapedText, getTypePredicateParameterIndex(func.parameters, parameterName), type); } else { @@ -37411,7 +37984,7 @@ var ts; function getTypePredicateParameterIndex(parameterList, parameter) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 71 /* Identifier */ && param.name.escapedText === parameter.escapedText) { + if (param.name.kind === 72 /* Identifier */ && param.name.escapedText === parameter.escapedText) { return i; } } @@ -37451,7 +38024,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 155 /* Constructor */) { + if (declaration.kind === 157 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -37461,12 +38034,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 158 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 159 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -37544,7 +38117,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 + var isConstructor = signature.declaration.kind === 157 /* Constructor */ || signature.declaration.kind === 161 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -37558,7 +38131,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 134 /* NumberKeyword */ : 137 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 135 /* NumberKeyword */ : 138 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -37585,7 +38158,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 150 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -37593,13 +38166,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 174 /* InferType */) { + if (declaration.parent.kind === 176 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 162 /* TypeReference */) { + if (grandParent.kind === 164 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -37624,7 +38197,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 151 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -37648,7 +38221,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 150 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -37781,9 +38354,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -37827,7 +38400,7 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : + res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { @@ -37884,13 +38457,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(8388608 /* Substitution */); + var result = createType(33554432 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 170 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -37899,9 +38472,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -37912,7 +38485,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 162 /* TypeReference */ || node.kind === 181 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 164 /* TypeReference */ || node.kind === 183 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -37970,7 +38543,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -38013,9 +38586,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return declaration; } } @@ -38024,7 +38597,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 131072 /* Object */)) { + if (!(type.flags & 524288 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -38101,6 +38674,15 @@ var ts; function getGlobalExtractSymbol() { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } + function getGlobalExcludeSymbol() { + return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalPickSymbol() { + return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalBigIntType(reportErrors) { + return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors)) || emptyObjectType; + } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -38149,7 +38731,7 @@ var ts; if (arity) { typeParameters = new Array(arity); for (var i = 0; i < arity; i++) { - var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + var typeParameter = typeParameters[i] = createType(262144 /* TypeParameter */); if (i < maxLength) { var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); property.type = typeParameter; @@ -38171,7 +38753,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -38206,8 +38788,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 172 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 171 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -38254,16 +38836,17 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { + if (t.flags & 109440 /* Unit */ && combined & 109440 /* Unit */) { return true; } combined |= t.flags; - if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || - combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || - combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || - combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || - combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || - combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { + if (combined & 98304 /* Nullable */ && combined & (524288 /* Object */ | 67108864 /* NonPrimitive */) || + combined & 67108864 /* NonPrimitive */ && combined & (67238908 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || + combined & 132 /* StringLike */ && combined & (67238908 /* DisjointDomains */ & ~132 /* StringLike */) || + combined & 296 /* NumberLike */ && combined & (67238908 /* DisjointDomains */ & ~296 /* NumberLike */) || + combined & 2112 /* BigIntLike */ && combined & (67238908 /* DisjointDomains */ & ~2112 /* BigIntLike */) || + combined & 12288 /* ESSymbolLike */ && combined & (67238908 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || + combined & 49152 /* VoidLike */ && combined & (67238908 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return true; } } @@ -38271,20 +38854,18 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Union */) { + if (flags & 1048576 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + if (!(flags & 131072 /* Never */ || flags & 2097152 /* Intersection */ && isEmptyIntersectionType(type))) { includes |= flags & ~939524096 /* ConstructionFlags */; - if (flags & 3 /* AnyOrUnknown */) { - if (type === wildcardType) - includes |= 268435456 /* Wildcard */; - } - else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (type === wildcardType) + includes |= 268435456 /* Wildcard */; + if (!strictNullChecks && flags & 98304 /* Nullable */) { if (!(flags & 134217728 /* ContainsWideningType */)) includes |= 134217728 /* NonWideningType */; } @@ -38320,11 +38901,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 512 /* EnumLiteral */) { + if (first.flags & 1024 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -38349,10 +38930,11 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || - t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || - t.flags & 448 /* Literal */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 128 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || + t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38375,25 +38957,27 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + if (unionReduction !== 0 /* None */) { + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + } + switch (unionReduction) { + case 1 /* Literal */: + if (includes & 8576 /* StringOrNumberLiteralOrUnique */ | 512 /* BooleanLiteral */) { + removeRedundantLiteralTypes(typeSet, includes); + } + break; + case 2 /* Subtype */: + removeSubtypes(typeSet); + break; + } + if (typeSet.length === 0) { + return includes & 65536 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : + neverType; + } } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & 2240 /* StringOrNumberLiteralOrUnique */ | 256 /* BooleanLiteral */) { - removeRedundantLiteralTypes(typeSet, includes); - } - break; - case 2 /* Subtype */: - removeSubtypes(typeSet); - break; - } - if (typeSet.length === 0) { - return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : - includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : - neverType; - } - return getUnionTypeFromSortedList(typeSet, includes & 16748579 /* NotPrimitiveUnion */ ? 0 : 67108864 /* UnionOfPrimitiveTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, !(includes & 66994211 /* NotPrimitiveUnion */), aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -38430,7 +39014,7 @@ var ts; : !ts.isIdentifierTypePredicate(b); } // This function assumes the constituent type list is sorted and deduplicated. - function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) { + function getUnionTypeFromSortedList(types, primitiveTypesOnly, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { return neverType; } @@ -38440,10 +39024,11 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* Union */ | propagatedFlags); unionTypes.set(id, type); type.types = types; + type.primitiveTypesOnly = primitiveTypesOnly; /* Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. @@ -38465,11 +39050,14 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 536870912 /* EmptyObject */; + if (isEmptyAnonymousObjectType(type)) { + if (!(includes & 536870912 /* EmptyObject */)) { + includes |= 536870912 /* EmptyObject */; + typeSet.push(type); + } } else { includes |= flags & ~939524096 /* ConstructionFlags */; @@ -38477,7 +39065,7 @@ var ts; if (type === wildcardType) includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type)) { + else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !ts.contains(typeSet, type)) { typeSet.push(type); } } @@ -38497,9 +39085,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; + 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 */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38512,10 +39101,11 @@ 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 & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - undefined; + var primitive = type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + undefined; if (!primitive || !containsType(u.types, primitive)) { return false; } @@ -38528,13 +39118,16 @@ 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 (t.flags & 67108864 /* UnionOfPrimitiveTypes */) !== 0; }); + var index = ts.findIndex(types, function (t) { return !!(t.flags & 1048576 /* Union */) && t.primitiveTypesOnly; }); + if (index < 0) { + return false; + } var i = index + 1; // Remove all but the first union of primitive types and collect them in // the unionTypes array. while (i < types.length) { var t = types[i]; - if (t.flags & 67108864 /* UnionOfPrimitiveTypes */) { + if (t.flags & 1048576 /* Union */ && t.primitiveTypesOnly) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -38563,7 +39156,7 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 67108864 /* UnionOfPrimitiveTypes */); + types[index] = getUnionTypeFromSortedList(result, /*primitiveTypesOnly*/ true); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -38579,22 +39172,23 @@ var ts; function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 32768 /* Never */) { + if (includes & 131072 /* Never */) { return neverType; } if (includes & 1 /* Any */) { return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 24576 /* Nullable */) { - return includes & 8192 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* Nullable */) { + return includes & 32768 /* Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { + 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 */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { - typeSet.push(emptyObjectType); + if (includes & 536870912 /* EmptyObject */ && includes & 524288 /* Object */) { + ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { return unknownType; @@ -38602,8 +39196,8 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 262144 /* Union */) { - if (includes & 67108864 /* UnionOfPrimitiveTypes */ && intersectUnionsOfPrimitiveTypes(typeSet)) { + if (includes & 1048576 /* 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. @@ -38611,15 +39205,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(524288 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(2097152 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -38636,7 +39230,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(1048576 /* Index */); + var result = createType(4194304 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -38646,14 +39240,22 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } - function getLiteralTypeFromPropertyName(prop, include) { + function getLiteralTypeFromPropertyName(name) { + return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : + getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); + } + function getBigIntLiteralType(node) { + return getLiteralType({ + negative: false, + base10Value: ts.parsePseudoBigInt(node.text) + }); + } + function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : - getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { return type; @@ -38661,8 +39263,8 @@ var ts; } return neverType; } - function getLiteralTypeFromPropertyNames(type, include) { - return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromPropertyName(t, include); })); + function getLiteralTypeFromProperties(type, include) { + return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromProperty(t, include); })); } function getNonEnumNumberIndexInfo(type) { var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); @@ -38670,16 +39272,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromProperties(type, 128 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 /* StringLiteral */ | 8192 /* UniqueESSymbol */)]) : + getLiteralTypeFromProperties(type, 8576 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -38690,17 +39292,17 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 32768 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 128 /* KeyOfKeyword */: + case 129 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 141 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ + case 142 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 139 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; @@ -38709,7 +39311,7 @@ var ts; return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(2097152 /* IndexedAccess */); + var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; @@ -38730,28 +39332,32 @@ var ts; if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { return true; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { return isJSLiteralType(getResolvedBaseConstraint(type)); } return false; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol, missingType) { - var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; - var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - undefined; + var accessExpression = accessNode && accessNode.kind === 190 /* ElementAccessExpression */ ? accessNode : undefined; + var propName = isTypeUsableAsLateBoundName(indexType) + ? getLateBoundNameFromType(indexType) + : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) + ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) + : accessNode && ts.isPropertyName(accessNode) + // late bound names are handled in the first branch, so here we only need to handle normal names + ? ts.getPropertyNameForPropertyNameNode(accessNode) + : undefined; if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 100 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); return missingType; @@ -38767,22 +39373,22 @@ var ts; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; })) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; }); } } - if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 32768 /* Never */)) { + if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { + if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -38790,7 +39396,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 32768 /* Never */) { + if (indexType.flags & 131072 /* Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -38823,8 +39429,8 @@ var ts; return anyType; } if (accessNode) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + var indexNode = getIndexNodeForAccessExpression(accessNode); + if (indexType.flags & (128 /* StringLiteral */ | 256 /* 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 */)) { @@ -38839,14 +39445,33 @@ var ts; } return missingType; } + function getIndexNodeForAccessExpression(accessNode) { + return accessNode.kind === 190 /* ElementAccessExpression */ + ? accessNode.argumentExpression + : accessNode.kind === 180 /* IndexedAccessType */ + ? accessNode.indexType + : accessNode.kind === 149 /* ComputedPropertyName */ + ? accessNode.expression + : accessNode; + } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */); } function getSimplifiedType(type) { - return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + } + function distributeIndexOverObjectType(objectType, indexType) { + // (T | U)[K] -> T[K] | U[K] + if (objectType.flags & 1048576 /* Union */) { + return mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); + } + // (T & U)[K] -> T[K] & U[K] + if (objectType.flags & 2097152 /* Intersection */) { + return getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + } } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -38860,18 +39485,14 @@ var ts; var objectType = getSimplifiedType(type.objectType); var indexType = getSimplifiedType(type.indexType); // T[A | B] -> T[A] | T[B] - if (indexType.flags & 262144 /* Union */) { + if (indexType.flags & 1048576 /* Union */) { return type.simplified = mapType(indexType, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t)); }); } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 15794176 /* Instantiable */)) { - // (T | U)[K] -> T[K] | U[K] - if (objectType.flags & 262144 /* Union */) { - return type.simplified = mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); - } - // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 524288 /* Intersection */) { - return type.simplified = getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + if (!(indexType.flags & 63176704 /* Instantiable */)) { + var simplified = distributeIndexOverObjectType(objectType, indexType); + if (simplified) { + return type.simplified = simplified; } } // So ultimately: @@ -38883,7 +39504,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 65536 /* TypeParameter */) { + if (objectType.flags & 262144 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -38906,7 +39527,7 @@ var ts; // 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 === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 180 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -38922,7 +39543,7 @@ 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 = getApparentType(objectType); - if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { @@ -38953,7 +39574,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -38975,7 +39596,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; + return type.flags & 33554432 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -38986,7 +39607,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 63176704 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -39025,7 +39646,7 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(4194304 /* Conditional */); + var result = createType(16777216 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -39057,7 +39678,7 @@ var ts; return true; } while (node) { - if (node.kind === 173 /* ConditionalType */) { + if (node.kind === 175 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -39080,7 +39701,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -39200,6 +39821,9 @@ var ts; function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } + function isNonGenericObjectType(type) { + return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + } /** * Since the source of spread types are object literals, which are not binary, * this function should be called in a left folding style, with left = previous result of getSpreadType @@ -39212,21 +39836,37 @@ var ts; if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { return unknownType; } - if (left.flags & 32768 /* Never */) { + if (left.flags & 131072 /* Never */) { return right; } - if (right.flags & 32768 /* Never */) { + if (right.flags & 131072 /* Never */) { return left; } - if (left.flags & 262144 /* Union */) { + if (left.flags & 1048576 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 262144 /* Union */) { + if (right.flags & 1048576 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { + if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { return left; } + if (isGenericObjectType(left) || isGenericObjectType(right)) { + if (isEmptyObjectType(left)) { + return right; + } + // 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 */) { + var types = left.types; + var lastLeft = types[types.length - 1]; + if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { + return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, typeFlags, objectFlags)])); + } + } + return getIntersectionType([left, right]); + } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); var stringIndexInfo; @@ -39246,7 +39886,7 @@ var ts; skippedPrivateMembers.set(rightProp.escapedName, true); } else if (isSpreadableProperty(rightProp)) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSpreadSymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -39261,7 +39901,7 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -39270,27 +39910,28 @@ var ts; } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSpreadSymbol(leftProp)); } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; - spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); + spread.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 1024 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */) - ? !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }) - : !(prop.flags & 65536 /* SetAccessor */); // Setter without getter is not spreadable + return !(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }); } - function getNonReadonlySymbol(prop) { - if (!isReadonlySymbol(prop)) { + function getSpreadSymbol(prop) { + var isReadonly = isReadonlySymbol(prop); + var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (!isReadonly && !isSetonlyAccessor) { return prop; } var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); var result = createSymbol(flags, prop.escapedName); - result.type = getTypeOfSymbol(prop); + result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = prop.nameType; result.syntheticOrigin = prop; @@ -39309,10 +39950,11 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 448 /* Literal */ && !(type.flags & 33554432 /* FreshLiteral */)) { - if (!type.freshType) { // NOTE: Safe because all freshable intrinsics always have fresh types already - var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); + if (type.flags & 2944 /* Literal */) { + if (!type.freshType) { + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; + freshType.freshType = freshType; type.freshType = freshType; } return type.freshType; @@ -39320,21 +39962,27 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + return type.flags & 2944 /* Literal */ ? type.regularType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : type; } + function isFreshLiteralType(type) { + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', // where NNN is the text representation of a numeric literal and SSS are the characters // of a string literal. For literal enum members we use 'EEE#NNN' and 'EEE@SSS', where // EEE is a unique id for the containing enum type. - var qualifier = typeof value === "number" ? "#" : "@"; - var key = enumId ? enumId + qualifier + value : qualifier + value; + var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; + var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value); var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 256 /* NumberLiteral */ : + typeof value === "string" ? 128 /* StringLiteral */ : 2048 /* BigIntLiteral */) | + (enumId ? 1024 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); + type.regularType = type; } return type; } @@ -39346,7 +39994,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(2048 /* UniqueESSymbol */); + var type = createType(8192 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -39361,9 +40009,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 241 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 157 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -39379,87 +40027,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 120 /* AnyKeyword */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return anyType; - case 142 /* UnknownKeyword */: + case 143 /* UnknownKeyword */: return unknownType; - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return stringType; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return numberType; - case 122 /* BooleanKeyword */: + case 146 /* BigIntKeyword */: + return bigintType; + case 123 /* BooleanKeyword */: return booleanType; - case 138 /* SymbolKeyword */: + case 139 /* SymbolKeyword */: return esSymbolType; - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return voidType; - case 140 /* UndefinedKeyword */: + case 141 /* UndefinedKeyword */: return undefinedType; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullType; - case 131 /* NeverKeyword */: + case 132 /* NeverKeyword */: return neverType; - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return getTypeFromTypeReference(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return booleanType; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 175 /* ParenthesizedType */: - case 170 /* RestType */: - case 285 /* JSDocNonNullableType */: - case 281 /* JSDocTypeExpression */: + case 177 /* ParenthesizedType */: + case 172 /* RestType */: + case 287 /* JSDocNonNullableType */: + case 283 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 174 /* InferType */: + case 176 /* InferType */: return getTypeFromInferTypeNode(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -39540,10 +40190,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; + return type.flags & 262144 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(65536 /* TypeParameter */); + var result = createType(262144 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -39589,7 +40239,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -39669,8 +40319,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 146 /* QualifiedName */ || - node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 148 /* QualifiedName */ || + node.parent.kind === 164 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -39678,19 +40328,19 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 218 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 176 /* ThisType */: + case 178 /* ThisType */: return !!tp.isThisType; - case 71 /* Identifier */: + case 72 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -39698,9 +40348,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 1048576 /* Index */) { + if (constraintType.flags & 4194304 /* Index */) { var typeVariable = constraintType.type; - if (typeVariable.flags & 65536 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeParameter */) { return typeVariable; } } @@ -39730,7 +40380,7 @@ var ts; } type.instantiating = true; var result = mapType(mappedTypeVariable, function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */) && t !== wildcardType) { + if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType) { var replacementMapper = createReplacementMapper(typeVariable, t, mapper); return isArrayType(t) ? createArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : isReadonlyArrayType(t) ? createReadonlyArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : @@ -39761,7 +40411,7 @@ var ts; var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper) { @@ -39806,7 +40456,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -39829,10 +40479,10 @@ var ts; } function instantiateTypeWorker(type, mapper) { var flags = type.flags; - if (flags & 65536 /* TypeParameter */) { + if (flags & 262144 /* TypeParameter */) { return mapper(type); } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or @@ -39851,32 +40501,32 @@ var ts; } return type; } - if (flags & 262144 /* Union */ && !(flags & 32764 /* Primitive */)) { + if (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 1048576 /* Index */) { + if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } return type; } function getWildcardInstantiation(type) { - return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : + return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -39885,34 +40535,34 @@ 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 !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 202 /* BinaryExpression */: - return node.operatorToken.kind === 54 /* BarBarToken */ && + case 204 /* BinaryExpression */: + return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 266 /* JsxAttributes */: - return ts.some(node.properties, isContextSensitive); - case 265 /* JsxAttribute */: { + case 268 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); + case 267 /* 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 268 /* JsxExpression */: { + case 270 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -39929,7 +40579,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* 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); @@ -39942,14 +40592,14 @@ var ts; function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 216 /* Block */ ? false : isContextSensitive(body); + return body.kind === 218 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -39960,7 +40610,7 @@ var ts; return result; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -39975,6 +40625,9 @@ var ts; function compareTypesAssignable(source, target) { return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; } + function compareTypesSubtypeOf(source, target) { + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); } @@ -39990,11 +40643,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : - target === globalObjectType ? !!(source.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 131072 /* Object */) && isFunctionObjectType(source) : + 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) || emptyObjectType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)); } /** @@ -40032,7 +40685,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 4194304 /* Conditional */ || (type.flags & 524288 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage) { if (!node || isOrHasGenericConditional(target)) @@ -40041,23 +40694,23 @@ var ts; return true; } switch (node.kind) { - case 268 /* JsxExpression */: - case 193 /* ParenthesizedExpression */: + case 270 /* JsxExpression */: + case 195 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage); } break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return elaborateJsxAttributes(node, source, target, relation); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation); } return false; @@ -40069,7 +40722,7 @@ var ts; var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 32768 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = {}; checkTypeAssignableTo(source, target, node, headMessage, /*containingChain*/ undefined, resultObj); @@ -40126,8 +40779,10 @@ var ts; var reportedError = false; 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 sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); var targetPropType = getIndexedAccessType(target, nameType, /*accessNode*/ undefined, errorType); + if (targetPropType === errorType || targetPropType.flags & 8388608 /* IndexedAccess */) + continue; // Don't elaborate on indexes on generic variables + var sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); if (sourcePropType !== errorType && targetPropType !== errorType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined); if (elaborated) { @@ -40149,7 +40804,7 @@ var ts; var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; var issuedElaboration = false; if (!targetProp) { - var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(nameType, 296 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || getIndexInfoOfType(target, 0 /* String */) || undefined; if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) { @@ -40160,7 +40815,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) { - addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + 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))); } } } @@ -40253,17 +40908,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 32768 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 157 /* SetAccessor */: return [3 /*break*/, 2]; - case 156 /* GetAccessor */: return [3 /*break*/, 2]; - case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 159 /* SetAccessor */: return [3 /*break*/, 2]; + case 158 /* GetAccessor */: return [3 /*break*/, 2]; + case 156 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 276 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 275 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -40322,8 +40977,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && - kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 156 /* MethodDeclaration */ && + kind !== 155 /* MethodSignature */ && kind !== 157 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -40357,7 +41012,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : @@ -40449,12 +41104,15 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 16777216 /* NonPrimitive */ ? true : - type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 524288 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* Object */ ? 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) : false; } + function isEmptyAnonymousObjectType(type) { + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && isEmptyObjectType(type); + } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { if (sourceSymbol === targetSymbol) { return true; @@ -40491,43 +41149,45 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) return true; - if (t & 32768 /* Never */) + if (t & 131072 /* Never */) return false; - if (s & 68 /* StringLike */ && t & 4 /* String */) + if (s & 132 /* StringLike */ && t & 4 /* String */) return true; - if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && - t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && + t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 168 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && - t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && + t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true; - if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) + if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + return true; + if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true; if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { - if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { + if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 448 /* Literal */ && t & 448 /* Literal */ && + if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) + if (s & 32768 /* Undefined */ && (!strictNullChecks || t & (32768 /* Undefined */ | 16384 /* Void */))) return true; - if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) + if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */)) return true; - if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) + if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) return true; - if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) + if (s & 8192 /* UniqueESSymbol */ || t & 8192 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -40535,30 +41195,30 @@ var ts; // 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 */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { + if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { + if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -40578,6 +41238,7 @@ var ts; */ function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; + var relatedInfo; var maybeKeys; var sourceStack; var targetStack; @@ -40585,7 +41246,7 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var isIntersectionConstituent = false; + var suppressNextError = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { @@ -40612,15 +41273,27 @@ var ts; } } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (relatedInfo) { + addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + } if (errorOutputContainer) { errorOutputContainer.error = diag; } diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { + function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); + } + function associateRelatedInfo(info) { + ts.Debug.assert(!!errorInfo); + if (!relatedInfo) { + relatedInfo = [info]; + } + else { + relatedInfo.push(info); + } } function reportRelationError(message, source, target) { var sourceType = typeToString(source); @@ -40653,7 +41326,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 786432 /* UnionOrIntersection */)) { + if (!(type.flags & 3145728 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -40661,7 +41334,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 24576 /* Nullable */) { + if (t.flags & 98304 /* Nullable */) { continue; } if (seenNonNullable) { @@ -40677,24 +41350,24 @@ var ts; * * Ternary.Maybe if they are related with assumptions of other relationships, or * * Ternary.False if they are not related. */ - function isRelatedTo(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage, isApparentIntersectionConstituent) { if (reportErrors === void 0) { reportErrors = false; } - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } - if (source.flags & 8388608 /* Substitution */) { + if (source.flags & 33554432 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 8388608 /* Substitution */) { + if (target.flags & 33554432 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8388608 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 2097152 /* IndexedAccess */) { + if (target.flags & 8388608 /* IndexedAccess */) { target = getSimplifiedType(target); } // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. @@ -40706,10 +41379,10 @@ var ts; // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" // when dealing with generics. // * We also don't deal with primitive source types, since we already halt elaboration below. - if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && - target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { - var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); - if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); + if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { target = nullStrippedTarget; } } @@ -40719,11 +41392,12 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { - var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + if (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */) { + var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -40738,11 +41412,11 @@ var ts; source = getRegularTypeOfObjectLiteral(source); } } - if (relation !== comparableRelation && !isIntersectionConstituent && - source.flags & (32764 /* Primitive */ | 131072 /* Object */ | 524288 /* Intersection */) && source !== globalObjectType && - target.flags & (131072 /* Object */ | 524288 /* Intersection */) && isWeakType(target) && + if (relation !== comparableRelation && !isApparentIntersectionConstituent && + source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && + target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target)) { + !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -40758,25 +41432,24 @@ var ts; } var result = 0 /* False */; var saveErrorInfo = errorInfo; - var saveIsIntersectionConstituent = isIntersectionConstituent; - isIntersectionConstituent = false; + var isIntersectionConstituent = !!isApparentIntersectionConstituent; // 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 & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { - if (target.flags & 262144 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); + if (target.flags & 1048576 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); } - else if (target.flags & 524288 /* Intersection */) { - isIntersectionConstituent = true; + else if (target.flags & 2097152 /* Intersection */) { + isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 524288 /* Intersection */) { + else if (source.flags & 2097152 /* Intersection */) { // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually @@ -40792,13 +41465,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { - if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { + if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 524288 /* Intersection */) { + if (!result && source.flags & 2097152 /* Intersection */) { // 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 @@ -40808,22 +41481,23 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { + if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { + var maybeSuppress = suppressNextError; + suppressNextError = false; + if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* 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) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -40833,6 +41507,10 @@ var ts; return result; } } + if (!headMessage && maybeSuppress) { + // Used by, eg, missing property checking to replace the top-level message with a more informative one + return result; + } reportRelationError(headMessage, source, target); } return result; @@ -40840,10 +41518,10 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 131072 /* Object */ || flags & 2097152 /* IndexedAccess */ || flags & 4194304 /* Conditional */ || flags & 1048576 /* Index */ || flags & 8388608 /* Substitution */) { - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); + if (flags & 524288 /* Object */ || flags & 8388608 /* IndexedAccess */ || flags & 16777216 /* Conditional */ || flags & 4194304 /* Index */ || flags & 33554432 /* Substitution */) { + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); } - if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { + if (flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -40856,7 +41534,7 @@ var ts; if (!noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 524288 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -40867,16 +41545,17 @@ var ts; return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } var _loop_6 = function (prop) { - if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. if (!errorNode) return { value: ts.Debug.fail() }; - if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. + // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -40912,8 +41591,8 @@ var ts; } return false; } - function isPropertyFromSpread(prop, container) { - return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + function shouldCheckAsExcessProperty(prop, container) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration; } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; @@ -40930,7 +41609,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -40951,9 +41630,9 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 131072 /* Object */) { + if (target.flags & 524288 /* Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); if (overlapObjFlags & 4 /* Reference */) { return source.target === target.target; @@ -40981,11 +41660,13 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - if (sourceProperties) { - var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); - if (sourcePropertiesFiltered) { - return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + if (target.flags & 1048576 /* Union */) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (sourcePropertiesFiltered) { + return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + } } } return undefined; @@ -40995,7 +41676,7 @@ var ts; 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, reportErrors); + var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, /*isIntersectionConstituent*/ true); if (!related) { return 0 /* False */; } @@ -41005,7 +41686,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -41030,9 +41711,10 @@ var ts; } return result; } - function typeArgumentsRelatedTo(source, target, variances, reportErrors) { - var sources = source.typeArguments || ts.emptyArray; - var targets = target.typeArguments || ts.emptyArray; + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + if (sources === void 0) { sources = ts.emptyArray; } + if (targets === void 0) { targets = ts.emptyArray; } + if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { return 0 /* False */; } @@ -41086,7 +41768,7 @@ var ts; // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function recursiveTypeRelatedTo(source, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0 /* False */; } @@ -41129,7 +41811,7 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; - var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -41152,21 +41834,21 @@ var ts; function getConstraintForRelation(type) { return relation === definitelyAssignableRelation ? undefined : getConstraintOfType(type); } - function structuredTypeRelatedTo(source, target, reportErrors) { + function structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { var flags = source.flags & target.flags; - if (relation === identityRelation && !(flags & 131072 /* Object */)) { - if (flags & 1048576 /* Index */) { + if (relation === identityRelation && !(flags & 524288 /* Object */)) { + if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } var result_2 = 0 /* False */; - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { if (result_2 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result_2; } } } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result_2 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -41179,7 +41861,7 @@ var ts; } } } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; @@ -41187,9 +41869,22 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 65536 /* TypeParameter */) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + // 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 (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && + source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && + !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { + var variances = getAliasVariances(source.aliasSymbol); + if (result = typeArgumentsRelatedTo(source.aliasTypeArguments, target.aliasTypeArguments, variances, reportErrors)) { + return result; + } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; + } + if (target.flags & 262144 /* 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 */ && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); @@ -41199,9 +41894,9 @@ var ts; } } } - else if (target.flags & 1048576 /* Index */) { + else if (target.flags & 4194304 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 1048576 /* Index */) { + if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -41222,7 +41917,7 @@ var ts; } } } - else if (target.flags & 2097152 /* IndexedAccess */) { + else if (target.flags & 8388608 /* IndexedAccess */) { // A type S is related to a type T[K], where T and K aren't both type variables, if S is related to C, // where C is the base constraint of T[K] if (relation !== identityRelation && !(isGenericObjectType(target.objectType) && isGenericIndexType(target.indexType))) { @@ -41239,22 +41934,24 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 8388608 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (!isGenericMappedType(source) && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + // A source type T is related to a target type { [P in Q]: X } if Q is related to keyof T and T[Q] is related to X. + if (!isGenericMappedType(source) && isRelatedTo(getConstraintTypeFromMappedType(target), getIndexType(source))) { var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { return result; } } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; } } - if (source.flags & 2162688 /* TypeVariable */) { - if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8650752 /* TypeVariable */) { + if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { // 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, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); @@ -41265,29 +41962,32 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { + if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } } - else { - var instantiated = getTypeWithThisArgument(constraint, source); - if (result = isRelatedTo(instantiated, target, reportErrors)) { - errorInfo = 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, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = 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, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = saveErrorInfo; + return result; } } - else if (source.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 4194304 /* Conditional */) { - if (target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */) { + if (target.flags & 16777216 /* 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. @@ -41336,7 +42036,7 @@ var ts; if (relation === definitelyAssignableRelation && isGenericMappedType(source)) { return 0 /* False */; } - var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } @@ -41346,7 +42046,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - if (result = typeArgumentsRelatedTo(source, target, variances, reportErrors)) { + if (result = typeArgumentsRelatedTo(source.typeArguments, target.typeArguments, variances, reportErrors)) { return result; } // The type arguments did not relate appropriately, but it may be because we have no variance @@ -41381,7 +42081,7 @@ var ts; // 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 (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors); @@ -41431,7 +42131,24 @@ var ts; var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties)); + if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code && + headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) { + suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it + } + if (props.length === 1) { + var propName = symbolToString(unmatchedProperty); + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, typeToString(source), typeToString(target)); + if (ts.length(unmatchedProperty.declarations)) { + associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); + } + } + else if (props.length > 5) { // arbitrary cutoff for too-long list form + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, typeToString(source), typeToString(target), ts.map(props.slice(0, 4), function (p) { return symbolToString(p); }).join(", "), props.length - 4); + } + else { + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); + } } return 0 /* False */; } @@ -41478,8 +42195,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { - var targetProp = properties_3[_b]; + for (var _b = 0, properties_2 = properties; _b < properties_2.length; _b++) { + var targetProp = properties_2[_b]; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { @@ -41550,7 +42267,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { + if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -41678,7 +42395,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 8192 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -41797,20 +42514,19 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; } - function hasCommonProperties(source, target) { - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + function hasCommonProperties(source, target, isComparingJsxAttributes) { for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { @@ -41826,62 +42542,71 @@ var ts; result.objectFlags |= 8192 /* MarkerType */; return result; } + 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 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 if we're not in strictFunctionTypes mode or if the function // has been invoked recursively for the given generic type. + function getVariancesWorker(typeParameters, cache, createMarkerType) { + if (typeParameters === void 0) { typeParameters = ts.emptyArray; } + var variances = cache.variances; + if (!variances) { + // The emptyArray singleton is used to signal a recursive invocation. + cache.variances = ts.emptyArray; + variances = []; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var tp = typeParameters_1[_i]; + // 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 */; + } + variances.push(variance); + } + cache.variances = variances; + } + return variances; + } function getVariances(type) { if (!strictFunctionTypes) { return ts.emptyArray; } - var typeParameters = type.typeParameters || ts.emptyArray; - var variances = type.variances; - if (!variances) { - if (type === globalArrayType || type === globalReadonlyArrayType) { - // Arrays are known to be covariant, no need to spend time computing this - variances = [1 /* Covariant */]; - } - else { - // The emptyArray singleton is used to signal a recursive invocation. - type.variances = ts.emptyArray; - variances = []; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - // 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 = getMarkerTypeReference(type, tp, markerSuperType); - var typeWithSub = getMarkerTypeReference(type, 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(getMarkerTypeReference(type, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; - } - variances.push(variance); - } - } - type.variances = variances; + if (type === globalArrayType || type === globalReadonlyArrayType) { + // Arrays are known to be covariant, no need to spend time computing this (emptyArray implies covariance for all parameters) + return ts.emptyArray; } - return variances; + return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference); } // 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(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 16384 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 65536 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); @@ -41974,13 +42699,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 131072 /* Object */) { + if (depth >= 5 && type.flags & 524288 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 131072 /* Object */ && t.symbol === symbol) { + if (t.flags & 524288 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -42086,7 +42811,7 @@ var ts; for (var i = 0; i < targetLen; i++) { var s = getTypeAtPosition(source, i); var t = getTypeAtPosition(target, i); - var related = compareTypes(s, t); + var related = compareTypes(t, s); if (!related) { return 0 /* False */; } @@ -42131,9 +42856,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -42150,7 +42875,7 @@ var ts; // 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 return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -42170,35 +42895,37 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); + return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 27072 /* Unit */); + return !!(type.flags & 109440 /* Unit */); } function isLiteralType(type) { return type.flags & 16 /* Boolean */ ? true : - type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : - type; + return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 512 /* BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type; } function getWidenedLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, 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 */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -42224,6 +42951,10 @@ var ts; function getLengthOfTupleType(type) { return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); } + function isZeroBigInt(_a) { + var value = _a.value; + return value.base10Value === "0"; + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -42236,15 +42967,16 @@ 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 & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : - type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : - type.flags & 256 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 256 /* BooleanLiteral */ : 0 : - type.flags & 29148 /* PossiblyFalsy */; + 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 */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { @@ -42253,12 +42985,14 @@ var ts; function getDefinitelyFalsyPartOfType(type) { return type.flags & 4 /* String */ ? emptyStringType : type.flags & 8 /* Number */ ? zeroType : - type === regularFalseType || - type === falseType || - type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || - type.flags & 64 /* StringLiteral */ && type.value === "" || - type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : - neverType; + type.flags & 64 /* BigInt */ ? zeroBigIntType : + type === regularFalseType || + type === falseType || + type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */) || + type.flags & 128 /* StringLiteral */ && type.value === "" || + type.flags & 256 /* NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + neverType; } /** * Add undefined or null or both to a type if they are missing. @@ -42266,15 +43000,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); return missing === 0 ? type : - missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 16384 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -42284,7 +43018,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -42327,7 +43061,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -42337,7 +43071,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; + regularNew.flags = resolved.flags; regularNew.objectFlags |= 128 /* ObjectLiteral */ | (ts.getObjectFlags(resolved) & 16384 /* JSLiteral */); type.regularType = regularNew; return regularNew; @@ -42425,15 +43159,15 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (type.flags & 402653184 /* RequiresWidening */) { - if (type.flags & 24576 /* Nullable */) { + if (type.flags & 98304 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* 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 {}). @@ -42459,7 +43193,7 @@ var ts; function reportWideningErrorsInType(type) { var errorReported = false; if (type.flags & 134217728 /* ContainsWideningType */) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -42503,39 +43237,42 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 202 /* BinaryExpression */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + case 204 /* BinaryExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* 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 149 /* Parameter */: + case 151 /* Parameter */: diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + 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 184 /* BindingElement */: + case 186 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + diagnostic = noImplicitAny ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type : ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage; break; - case 179 /* MappedType */: + case 181 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } return; default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + diagnostic = noImplicitAny ? ts.Diagnostics.Variable_0_implicitly_has_an_1_type : ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; } errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } @@ -42614,11 +43351,11 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 15794176 /* Instantiable */ || + return !!(type.flags & 63176704 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -42627,13 +43364,13 @@ var ts; return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 3145728 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, 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 & 64 /* StringLiteral */)) { + if (!(t.flags & 128 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -42654,25 +43391,25 @@ var ts; * property is computed by inferring from the source property type to X for the type * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ - function inferTypeForHomomorphicMappedType(source, target) { - var key = source.id + "," + target.id; + function inferTypeForHomomorphicMappedType(source, target, constraint) { + var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } reverseMappedCache.set(key, undefined); - var type = createReverseMappedType(source, target); + var type = createReverseMappedType(source, target, constraint); reverseMappedCache.set(key, type); return type; } - function createReverseMappedType(source, target) { + function createReverseMappedType(source, target, constraint) { var properties = getPropertiesOfType(source); if (properties.length === 0 && !getIndexInfoOfType(source, 0 /* String */)) { return undefined; } // If any property contains context sensitive functions that have been skipped, the source type // is incomplete and we can't infer a meaningful input type. - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var prop = properties_3[_i]; if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } @@ -42680,13 +43417,13 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isReadonlyArrayType(source)) { - return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target); }); + var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.associatedNames); @@ -42696,30 +43433,46 @@ var ts; var reversed = createObjectType(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; + reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType); + return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); } - function inferReverseMappedType(sourceType, target) { - var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target)); + function inferReverseMappedType(sourceType, target, constraint) { + var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); var inference = createInferenceInfo(typeParameter); inferTypes([inference], sourceType, templateType); return getTypeFromInference(inference); } - function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; - if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (!sourceProp) { - return targetProp; - } + function getUnmatchedProperties(source, target, requireOptionalProperties) { + var properties, _i, properties_4, targetProp, sourceProp; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + properties = target.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + _i = 0, properties_4 = properties; + _a.label = 1; + case 1: + if (!(_i < properties_4.length)) return [3 /*break*/, 4]; + targetProp = properties_4[_i]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */))) return [3 /*break*/, 3]; + sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (!!sourceProp) return [3 /*break*/, 3]; + return [4 /*yield*/, targetProp]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; } - } - return undefined; + }); + } + function getUnmatchedProperty(source, target, requireOptionalProperties) { + return getUnmatchedProperties(source, target, requireOptionalProperties).next().value; } function tupleTypesDefinitelyUnrelated(source, target) { return target.target.minLength > source.target.minLength || @@ -42769,8 +43522,8 @@ var ts; } return; } - if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || - source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { + if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || + source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -42793,7 +43546,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { + else if (t.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -42808,7 +43561,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 2162688 /* TypeVariable */) { + if (target.flags & 8650752 /* 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 @@ -42816,7 +43569,7 @@ 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.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType || (priority & 8 /* ReturnType */ && (source === autoType || source === autoArrayType))) { return; } var inference = getInferenceInfoForType(target); @@ -42838,12 +43591,30 @@ var ts; inference.candidates = ts.appendIfUnique(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } return; } + else { + // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine + var simplified = getSimplifiedType(target); + if (simplified !== target) { + inferFromTypesOnce(source, simplified); + } + else if (target.flags & 8388608 /* IndexedAccess */) { + var indexType = getSimplifiedType(target.indexType); + // 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 & 63176704 /* Instantiable */) { + var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType), indexType); + if (simplified_1 && simplified_1 !== target) { + inferFromTypesOnce(source, simplified_1); + } + } + } + } } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments @@ -42860,12 +43631,12 @@ var ts; } } } - else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -42874,20 +43645,20 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */ && target.flags & 16777216 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 4194304 /* Conditional */) { + else if (target.flags & 16777216 /* Conditional */) { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } - else if (target.flags & 786432 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -42912,7 +43683,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 262144 /* Union */) { + else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -42921,12 +43692,12 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 63176704 /* 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 & (131072 /* Object */ | 524288 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* 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 @@ -42939,7 +43710,7 @@ var ts; } source = apparentSource; } - if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -42949,7 +43720,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 131072 /* Object */ && + var isNonConstructorObject = target.flags & 524288 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -42965,6 +43736,13 @@ var ts; } } } + function inferFromTypesOnce(source, target) { + var key = source.id + "," + target.id; + if (!visited || !visited.get(key)) { + (visited || (visited = ts.createMap())).set(key, true); + inferFromTypes(source, target); + } + } } function inferFromContravariantTypes(source, target) { if (strictFunctionTypes || priority & 64 /* AlwaysStrict */) { @@ -42977,7 +43755,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -42987,6 +43765,44 @@ var ts; } return undefined; } + function inferFromMappedTypeConstraint(source, target, constraintType) { + if (constraintType.flags & 1048576 /* Union */) { + var result = false; + for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { + var type = _a[_i]; + result = inferFromMappedTypeConstraint(source, target, type) || result; + } + return result; + } + if (constraintType.flags & 4194304 /* 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 + // such that direct inferences to T get priority over inferences to Partial, for example. + var inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + var savePriority = priority; + priority |= 2 /* HomomorphicMappedType */; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + return true; + } + if (constraintType.flags & 262144 /* TypeParameter */) { + // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type + // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. + var savePriority = priority; + priority |= 4 /* MappedTypeConstraint */; + inferFromTypes(getIndexType(source), constraintType); + priority = savePriority; + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return true; + } + return false; + } function inferFromObjectTypes(source, target) { if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer @@ -42996,31 +43812,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 1048576 /* 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 - // such that direct inferences to T get priority over inferences to Partial, for example. - var inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - var inferredType = inferTypeForHomomorphicMappedType(source, target); - if (inferredType) { - var savePriority = priority; - priority |= 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - return; - } - if (constraintType.flags & 65536 /* TypeParameter */) { - // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type - // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. - var savePriority = priority; - priority |= 4 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; - inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + if (inferFromMappedTypeConstraint(source, target, constraintType)) { return; } } @@ -43060,8 +43852,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -43084,7 +43876,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ || kind === 155 /* Constructor */; + bivariant = bivariant || kind === 156 /* MethodDeclaration */ || kind === 155 /* MethodSignature */ || kind === 157 /* Constructor */; forEachMatchingParameterType(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -43138,11 +43930,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 4194304 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 32764 /* Primitive */ | 1048576 /* Index */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -43191,7 +43983,7 @@ var ts; var inferredContravariantType = getContravariantInference(inference); // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype and not 'never'. - inferredType = inferredCovariantType && !(inferredCovariantType.flags & 32768 /* Never */) && + inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ? inferredCovariantType : inferredContravariantType; } @@ -43250,17 +44042,17 @@ var ts; case "console": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; case "$": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig; case "describe": case "suite": case "it": case "test": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig; case "process": case "require": case "Buffer": case "module": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig; case "Map": case "Set": case "Promise": @@ -43286,7 +44078,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 === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 167 /* TypeQuery */ ? true : n.kind === 72 /* Identifier */ || n.kind === 148 /* 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 @@ -43295,20 +44087,20 @@ var ts; // occurring in an apparent type position with '@' because the control flow type // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; } - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { return "0"; } - if (node.kind === 187 /* PropertyAccessExpression */) { + if (node.kind === 189 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 184 /* BindingElement */) { + if (node.kind === 186 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 186 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -43317,14 +44109,14 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 182 /* ObjectBindingPattern */) { + if (parent.kind === 184 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; default: @@ -43338,29 +44130,29 @@ var ts; } function isMatchingReference(source, target) { switch (source.kind) { - case 71 /* Identifier */: - return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && + case 72 /* Identifier */: + return target.kind === 72 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 237 /* VariableDeclaration */ || target.kind === 186 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 99 /* ThisKeyword */: - return target.kind === 99 /* ThisKeyword */; - case 97 /* SuperKeyword */: - return target.kind === 97 /* SuperKeyword */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 100 /* ThisKeyword */: + return target.kind === 100 /* ThisKeyword */; + case 98 /* SuperKeyword */: + return target.kind === 98 /* SuperKeyword */; + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return (ts.isPropertyAccessExpression(target) || ts.isElementAccessExpression(target)) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 184 /* BindingElement */: - if (target.kind !== 187 /* PropertyAccessExpression */) + case 186 /* BindingElement */: + if (target.kind !== 189 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 186 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 235 /* VariableDeclaration */) { + if (source.parent.parent.kind === 237 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -43373,7 +44165,7 @@ var ts; undefined; } function containsMatchingReference(source, target) { - while (source.kind === 187 /* PropertyAccessExpression */) { + while (source.kind === 189 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -43386,23 +44178,23 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 187 /* PropertyAccessExpression */ && + return target.kind === 189 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 71 /* Identifier */) { + if (expr.kind === 72 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 187 /* PropertyAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantType(type) { - if (type.flags & 262144 /* Union */) { - if (type.flags & (16 /* Boolean */ | 512 /* EnumLiteral */)) { + if (type.flags & 1048576 /* Union */) { + if (type.flags & (16 /* Boolean */ | 1024 /* EnumLiteral */)) { return true; } var combined = 0; @@ -43410,14 +44202,14 @@ var ts; var t = _a[_i]; combined |= t.flags; } - if (combined & 27072 /* Unit */ && !(combined & 15794176 /* Instantiable */)) { + if (combined & 109440 /* Unit */ && !(combined & 63176704 /* Instantiable */)) { return true; } } return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 262144 /* Union */) { + if (type && type.flags & 1048576 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { @@ -43428,6 +44220,10 @@ var ts; } return false; } + function hasNarrowableDeclaredType(expr) { + var type = getDeclaredTypeOfReference(expr); + return !!(type && type.flags & 1048576 /* Union */); + } function findDiscriminantProperties(sourceProperties, target) { var result; for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { @@ -43454,7 +44250,7 @@ var ts; } } } - if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 189 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -43468,7 +44264,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 262144 /* Union */)) { + if (!(source.flags & 1048576 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -43484,11 +44280,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 32768 /* Never */) { + if (assignedType.flags & 131072 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 33554432 /* FreshLiteral */ && assignedType.flags & 256 /* BooleanLiteral */) { + if (assignedType.flags & 512 /* 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. @@ -43519,57 +44315,66 @@ var ts; function getTypeFacts(type) { var flags = type.flags; if (flags & 4 /* String */) { - return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; + return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; } - if (flags & 64 /* StringLiteral */) { + if (flags & 128 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : - isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; } if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; + return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; } - if (flags & 128 /* NumberLiteral */) { + if (flags & 256 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : - isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; + isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + } + if (flags & 64 /* BigInt */) { + return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + } + if (flags & 2048 /* BigIntLiteral */) { + var isZero = isZeroBigInt(type); + return strictNullChecks ? + isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; } if (flags & 16 /* Boolean */) { - return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; + return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; } - if (flags & 272 /* BooleanLike */) { + if (flags & 528 /* BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 4079615 /* EmptyObjectStrictFacts */ : 4194303 /* EmptyObjectFacts */ : + strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : - strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : + strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { - return 2457472 /* UndefinedFacts */; + if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { + return 9830144 /* UndefinedFacts */; } - if (flags & 16384 /* Null */) { - return 2340752 /* NullFacts */; + if (flags & 65536 /* Null */) { + return 9363232 /* NullFacts */; } - if (flags & 3072 /* ESSymbolLike */) { - return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; + if (flags & 12288 /* ESSymbolLike */) { + return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; } - if (flags & 16777216 /* NonPrimitive */) { - return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + if (flags & 67108864 /* NonPrimitive */) { + return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & 15794176 /* Instantiable */) { + if (flags & 63176704 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 786432 /* UnionOrIntersection */) { + if (flags & 3145728 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } - return 4194303 /* All */; + return 16777215 /* All */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -43577,7 +44382,7 @@ var ts; function getTypeWithDefault(type, defaultExpression) { if (defaultExpression) { var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 131072 /* NEUndefined */), defaultType]); + return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); } return type; } @@ -43597,15 +44402,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 187 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 275 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 204 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 227 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -43622,21 +44427,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return stringType; - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return undefinedType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -43644,7 +44449,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 182 /* ObjectBindingPattern */ ? + var type = pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -43662,39 +44467,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 224 /* ForInStatement */) { + if (node.parent.parent.kind === 226 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.parent.kind === 227 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 235 /* VariableDeclaration */ ? + return node.kind === 237 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 235 /* VariableDeclaration */ && node.initializer && + return node.kind === 237 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && + node.kind !== 186 /* BindingElement */ && node.parent.kind === 204 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return getReferenceCandidate(node.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return getReferenceCandidate(node.right); } } @@ -43702,13 +44507,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 193 /* ParenthesizedExpression */ || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 195 /* ParenthesizedExpression */ || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */ && parent.left === node || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -43730,8 +44535,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 269 /* CaseClause */) { - if (clause.expression.kind === 9 /* StringLiteral */) { + if (clause.kind === 271 /* CaseClause */) { + if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; } @@ -43742,13 +44547,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* 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 & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -43757,30 +44562,30 @@ var ts; } return true; } - if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 262144 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfPrimitiveTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.primitiveTypesOnly); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return type; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return mapper(type); } var types = type.types; @@ -43810,12 +44615,14 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) || + isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : - t; + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : + t; }); } return typeWithPrimitives; @@ -43849,9 +44656,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 32768 /* Never */ ? + return elementType.flags & 131072 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 262144 /* Union */ ? + createArrayType(elementType.flags & 1048576 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -43869,7 +44676,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - if (!(t.flags & 32768 /* Never */)) { + if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -43891,15 +44698,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 189 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 191 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 190 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 202 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 58 /* EqualsToken */ && + parent.parent.kind === 204 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 59 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -43910,7 +44717,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 97 /* SuperKeyword */) { + if (node.expression.kind !== 98 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -43932,7 +44739,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -43942,8 +44749,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent && reference.parent.kind === 213 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -44015,9 +44822,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 187 /* PropertyAccessExpression */ && - reference.kind !== 188 /* ElementAccessExpression */ && - reference.kind !== 99 /* ThisKeyword */) { + reference.kind !== 189 /* PropertyAccessExpression */ && + reference.kind !== 190 /* ElementAccessExpression */ && + reference.kind !== 100 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -44055,7 +44862,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 262144 /* Union */) { + if (declaredType.flags & 1048576 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); } return declaredType; @@ -44069,19 +44876,23 @@ 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 === 194 /* FunctionExpression */ || init.kind === 195 /* ArrowFunction */)) { + if (init && (init.kind === 196 /* FunctionExpression */ || init.kind === 197 /* 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 === 226 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + } // Assignment doesn't affect reference return undefined; } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 189 /* CallExpression */ ? + var expr = node.kind === 191 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -44089,7 +44900,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -44098,7 +44909,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, 168 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -44112,7 +44923,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -44129,7 +44940,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 131072 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -44145,7 +44956,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 197 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 199 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } return createFlowType(type, isIncomplete(flowType)); @@ -44261,8 +45072,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 262144 /* Union */) || - expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (!(computedType.flags & 1048576 /* Union */) || + expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { return false; } var access = expr; @@ -44283,10 +45094,10 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); + return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } if (isMatchingReferenceDiscriminant(expr, declaredType)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); }); + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; @@ -44304,7 +45115,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -44312,19 +45123,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -44343,15 +45154,15 @@ var ts; return declaredType; } break; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 92 /* InKeyword */: + case 93 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); } break; - case 26 /* CommaToken */: + case 27 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -44360,28 +45171,28 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 24576 /* Nullable */) { + if (valueType.flags & 98304 /* Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; + var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 16384 /* Null */ ? - assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : - assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; + assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : + valueType.flags & 65536 /* Null */ ? + assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : + assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 16909315 /* NotUnionOrUnit */) { + if (type.flags & 67637251 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 131072 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -44393,22 +45204,22 @@ var ts; // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { - // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, target)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, a + // 'typeof x === ...' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, target) && hasNarrowableDeclaredType(target)) { return declaredType; } return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); function narrowTypeForTypeof(type) { if (type.flags & 2 /* Unknown */ && literal.text === "object") { @@ -44425,7 +45236,7 @@ var ts; if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -44444,13 +45255,37 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + } + function getImpliedTypeFromTypeofCase(type, text) { + switch (text) { + case "function": + return type.flags & 1 /* Any */ ? type : globalFunctionType; + case "object": + return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + default: + return typeofTypesByName.get(text) || type; + } + } + function narrowTypeForTypeofSwitch(candidate) { + return function (type) { + if (isTypeSubtypeOf(candidate, type)) { + return candidate; + } + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(candidate, constraint)) { + return getIntersectionType([type, candidate]); + } + } + return type; + }; } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); @@ -44469,7 +45304,7 @@ var ts; // that we don't have to worry about undefined // in the witness array. var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; }); - // The adjust clause start and end after removing the `default` statement. + // The adjusted clause start and end after removing the `default` statement. var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart; var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd; clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd); @@ -44479,6 +45314,9 @@ var ts; clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); } + if (hasDefaultClause) { + return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }); + } /* The implied type is the raw type suggested by a value being caught in this clause. @@ -44507,33 +45345,18 @@ var ts; boolean. We know that number cannot be selected because it is caught in the first clause. */ - if (!(hasDefaultClause || (type.flags & 262144 /* Union */))) { - var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return typeofTypesByName.get(text) || neverType; })), switchFacts); - if (impliedType.flags & 262144 /* Union */) { - impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOfType(type) || type); - } - if (!(impliedType.flags & 32768 /* Never */)) { - if (isTypeSubtypeOf(impliedType, type)) { - return impliedType; - } - if (type.flags & 15794176 /* Instantiable */) { - var constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(impliedType, constraint)) { - return getIntersectionType([type, impliedType]); - } - } - } + var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts); + if (impliedType.flags & 1048576 /* Union */) { + impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type)); } - return hasDefaultClause ? - filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }) : - getTypeWithFacts(type, switchFacts); + return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { - // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, left)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, an + // 'x instanceof T' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, left) && hasNarrowableDeclaredType(left)) { return declaredType; } return type; @@ -44570,9 +45393,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 & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 32768 /* Never */)) { + if (!(assignableType.flags & 131072 /* Never */)) { return assignableType; } } @@ -44612,7 +45435,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 190 /* ElementAccessExpression */ || invokedExpression.kind === 189 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -44629,20 +45452,20 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 200 /* PrefixUnaryExpression */: - if (expr.operator === 51 /* ExclamationToken */) { + case 202 /* PrefixUnaryExpression */: + if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -44656,7 +45479,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 === 71 /* Identifier */) { + if (location.kind === 72 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -44677,9 +45500,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 243 /* ModuleBlock */ || - node.kind === 277 /* SourceFile */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 245 /* ModuleBlock */ || + node.kind === 279 /* SourceFile */ || + node.kind === 154 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -44698,10 +45521,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 151 /* Parameter */) { symbol.isAssigned = true; } } @@ -44716,21 +45539,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 149 /* Parameter */ && + declaration.kind === 151 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 8192 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; + getFalsyFlags(declaredType) & 32768 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 187 /* PropertyAccessExpression */ || - parent.kind === 189 /* CallExpression */ && parent.expression === node || - parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 189 /* PropertyAccessExpression */ || + parent.kind === 191 /* CallExpression */ && parent.expression === node || + parent.kind === 190 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 186 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); + return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 98304 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -44761,7 +45584,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -44782,7 +45605,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 238 /* ClassDeclaration */ + if (declaration.kind === 240 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -44794,14 +45617,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 207 /* ClassExpression */) { + else if (declaration.kind === 209 /* 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 !== 277 /* SourceFile */) { + while (container.kind !== 279 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -44845,7 +45668,7 @@ 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 === 149 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 151 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -44854,8 +45677,8 @@ var ts; // 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 === 194 /* FunctionExpression */ || - flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 196 /* FunctionExpression */ || + flowContainer.kind === 197 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -44864,9 +45687,9 @@ var ts; // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || - node.parent.kind === 211 /* NonNullExpression */ || - declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 257 /* ExportSpecifier */) || + node.parent.kind === 213 /* NonNullExpression */ || + declaration.kind === 237 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -44875,7 +45698,7 @@ var ts; // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType || type === autoArrayType) { + if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) { if (flowType === autoType || flowType === autoArrayType) { if (noImplicitAny) { error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); @@ -44884,7 +45707,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* 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; @@ -44900,7 +45723,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -44923,7 +45746,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -44941,8 +45764,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 223 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && + if (container.kind === 225 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -44960,7 +45783,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 193 /* ParenthesizedExpression */) { + while (current.parent.kind === 195 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -44968,9 +45791,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 202 /* PrefixUnaryExpression */ || current.parent.kind === 203 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; + isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -44981,7 +45804,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { + if (container.kind === 154 /* PropertyDeclaration */ || container.kind === 157 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -45049,37 +45872,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 155 /* Constructor */) { + if (container.kind === 157 /* 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 === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* 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 241 /* EnumDeclaration */: + case 243 /* 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 155 /* Constructor */: + case 157 /* 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 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -45090,9 +45913,15 @@ var ts; var type = tryGetThisTypeAt(node, container); if (!type && noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' - error(node, capturedByArrowFunction && container.kind === 277 /* SourceFile */ ? + var diag = error(node, capturedByArrowFunction && container.kind === 279 /* SourceFile */ ? ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + if (!ts.isSourceFile(container)) { + var outsideThis = tryGetThisTypeAt(container); + if (outsideThis) { + addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + } + } } return type || anyType; } @@ -45118,7 +45947,7 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 194 /* FunctionExpression */ || container.kind === 237 /* FunctionDeclaration */) && + (container.kind === 196 /* FunctionExpression */ || container.kind === 239 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { var classType = getJSClassType(container.symbol); if (classType) { @@ -45144,7 +45973,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 194 /* FunctionExpression */ && + if (container.kind === 196 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -45154,24 +45983,49 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 154 /* MethodDeclaration */ && - container.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 156 /* MethodDeclaration */ && + container.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 194 /* FunctionExpression */ && - container.parent.kind === 273 /* PropertyAssignment */ && - container.parent.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 196 /* FunctionExpression */ && + container.parent.kind === 275 /* PropertyAssignment */ && + container.parent.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* 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 === 196 /* 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 */) { + return container.parent.parent.parent.arguments[0].expression; + } + // Object.defineProperty(x, "method", { value() { } }); + // Object.defineProperty(x, "method", { set(x: () => void) {} }); + // Object.defineProperty(x, "method", { get() { return () => {} } }); + else if (ts.isMethodDeclaration(container) && + ts.isIdentifier(container.name) && + (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") && + ts.isObjectLiteralExpression(container.parent) && + ts.isCallExpression(container.parent.parent) && + container.parent.parent.arguments[2] === container.parent && + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + return container.parent.parent.arguments[0].expression; + } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -45185,15 +46039,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 151 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 189 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 191 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 195 /* ArrowFunction */) { + while (container && container.kind === 197 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -45206,14 +46060,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); - if (current && current.kind === 147 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 149 /* ComputedPropertyName */; }); + if (current && current.kind === 149 /* 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 === 186 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -45221,7 +46075,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 155 /* Constructor */) { + if (!isCallExpression && container.kind === 157 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -45290,7 +46144,7 @@ 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 === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 156 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -45304,7 +46158,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (container.parent.kind === 188 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -45325,7 +46179,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 155 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 157 /* 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; @@ -45340,7 +46194,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 === 155 /* Constructor */; + return container.kind === 157 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -45348,21 +46202,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */; } else { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */ || - container.kind === 152 /* PropertyDeclaration */ || - container.kind === 151 /* PropertySignature */ || - container.kind === 155 /* Constructor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */ || + container.kind === 154 /* PropertyDeclaration */ || + container.kind === 153 /* PropertySignature */ || + container.kind === 157 /* Constructor */; } } } @@ -45370,10 +46224,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 154 /* MethodDeclaration */ || - func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 156 /* MethodDeclaration */ || + func.kind === 158 /* GetAccessor */ || + func.kind === 159 /* SetAccessor */) && func.parent.kind === 188 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 196 /* FunctionExpression */ && func.parent.kind === 275 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -45381,11 +46235,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -45412,7 +46266,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 273 /* PropertyAssignment */) { + if (literal.parent.kind !== 275 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -45426,9 +46280,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */) { var target = parent.left; - if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { + if (target.kind === 189 /* PropertyAccessExpression */ || target.kind === 190 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -45488,7 +46342,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -45500,7 +46354,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 184 /* BindingElement */) { + if (parentDeclaration.kind !== 186 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -45590,10 +46444,13 @@ var ts; // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); + if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { + return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 191 /* TaggedTemplateExpression */) { + if (template.parent.kind === 193 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -45602,7 +46459,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: if (node !== right) { return undefined; } @@ -45611,15 +46468,15 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); return !type && node === right && !ts.isDefaultedExpandoInitializer(binaryExpression) ? getTypeOfExpression(left) : type; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression) : undefined; default: return undefined; @@ -45686,13 +46543,17 @@ var ts; } var thisType = checkThisExpression(thisAccess.expression); return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - if (t.flags & 917504 /* StructuredType */) { + if (t.flags & 3670016 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -45703,8 +46564,8 @@ var ts; return restType; } } - return isNumericLiteralName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); + return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1 /* Number */) || + getIndexTypeOfContextualType(t, 0 /* String */); } return undefined; }, /*noReductions*/ true); @@ -45748,7 +46609,6 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || getIndexTypeOfContextualType(arrayContextualType, 1 /* Number */) || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -45790,35 +46650,36 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 71 /* Identifier */: - case 140 /* UndefinedKeyword */: + case 9 /* BigIntLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: + case 141 /* UndefinedKeyword */: return true; - case 187 /* PropertyAccessExpression */: - case 193 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 195 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 273 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 275 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 265 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 267 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (contextualType && contextualType.flags & 262144 /* Union */) { + if (contextualType && contextualType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, contextualType); } @@ -45855,54 +46716,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 186 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 195 /* ArrowFunction */: - case 228 /* ReturnStatement */: + case 197 /* ArrowFunction */: + case 230 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 185 /* ArrayLiteralExpression */: { + case 187 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 214 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); + case 216 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 206 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 193 /* ParenthesizedExpression */: { + case 195 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -45918,67 +46779,10 @@ var ts; // (as below) instead! return node.parent.contextualType; } - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - var valueType = checkExpression(node.tagName); - if (isTypeAny(valueType)) { - // Short-circuit if the class tag is using an element type 'any' - return anyType; - } - var isJs = ts.isInJSFile(node); - return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); + return getContextualTypeForArgumentAtIndex(node, 0); } - function getJsxSignaturesParameterTypes(valueType, isJs, context) { - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 4 /* String */) { - return anyType; - } - else if (valueType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = valueType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - } - return anyType; - } - // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(valueType, 1 /* Construct */); - var ctor = true; - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(valueType, 0 /* Call */); - ctor = false; - if (signatures.length === 0) { - // We found no signatures at all, which is an error - return errorType; - } - } - var links = getNodeLinks(context); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(valueType); - var cachedResolved = links.resolvedSignatures.get(cacheKey); - if (cachedResolved && cachedResolved !== resolvingSignaturesArray) { - signatures = cachedResolved; - } - else if (!cachedResolved) { - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); - links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures)); - } - return getUnionType(ts.map(signatures, ctor ? function (t) { return getJsxPropsTypeFromClassType(t, isJs, context, /*reportErrors*/ false); } : function (t) { return getJsxPropsTypeFromCallSignature(t, context); }), 0 /* None */); + function getEffectiveFirstArgumentForJsxSignature(signature, node) { + return getJsxReferenceKind(node) !== 0 /* Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); @@ -45993,22 +46797,40 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getStaticTypeOfReferencedJsxConstructor(context) { + if (isJsxIntrinsicIdentifier(context.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context); + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + var tagType = checkExpressionCached(context.tagName); + if (tagType.flags & 128 /* StringLiteral */) { + var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); + if (!result) { + return errorType; + } + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + return tagType; + } function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var ctorType = getStaticTypeOfReferencedJsxConstructor(context); if (ts.length(declaredManagedType.typeParameters) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); } } return attributesType; } - function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { + function getJsxPropsTypeFromClassType(sig, context) { var ns = getJsxNamespaceAt(context); var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined @@ -46021,7 +46843,7 @@ var ts; : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation); if (!attributesType) { // There is no property named 'props' on this instance type - if (reportErrors && !!forcedLookupLocation && !!ts.length(context.attributes.properties)) { + if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) { error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation)); } return emptyObjectType; @@ -46039,7 +46861,7 @@ var ts; var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams - ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isJs)) + ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context))) : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); @@ -46075,7 +46897,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; + return node.kind === 196 /* FunctionExpression */ || node.kind === 197 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -46094,7 +46916,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -46103,7 +46925,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -46142,8 +46964,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 184 /* BindingElement */ && !!node.initializer) || - (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 186 /* BindingElement */ && !!node.initializer) || + (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -46154,7 +46976,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 208 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -46179,12 +47001,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 208 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 208 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -46211,15 +47033,15 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 185 /* ArrayBindingPattern */ || pattern.kind === 187 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementCount; i < patternElements.length; i++) { var e = patternElements[i]; if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { - if (e.kind !== 208 /* OmittedExpression */) { + else if (i < patternElements.length - 1 || !(e.kind === 186 /* BindingElement */ && e.dotDotDotToken || e.kind === 208 /* SpreadElement */)) { + if (e.kind !== 210 /* OmittedExpression */) { error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -46237,12 +47059,12 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isNumericComputedName(name); - case 71 /* Identifier */: + case 72 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return isNumericLiteralName(name.text); default: return false; @@ -46251,7 +47073,7 @@ 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), 168 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -46286,8 +47108,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 24576 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -46314,10 +47136,10 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 33554432 /* FreshLiteral */; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 184 /* ObjectBindingPattern */ || contextualType.pattern.kind === 188 /* ObjectLiteralExpression */); var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -46330,13 +47152,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 149 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 273 /* PropertyAssignment */ || - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 275 /* PropertyAssignment */ || + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 275 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -46349,7 +47171,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -46360,8 +47182,8 @@ var ts; 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 === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 275 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 276 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -46386,12 +47208,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 275 /* SpreadAssignment */) { + else if (memberDecl.kind === 277 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); propertiesArray = []; propertiesTable = ts.createSymbolTable(); hasComputedStringProperty = false; @@ -46403,7 +47225,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 32768 /* FreshLiteral */); offset = i + 1; continue; } @@ -46413,10 +47235,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 === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 158 /* GetAccessor */ || memberDecl.kind === 159 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -46450,7 +47272,7 @@ var ts; } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); } return spread; } @@ -46459,9 +47281,8 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; - result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); - result.objectFlags |= 128 /* ObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags & 939524096 /* PropagatingFlags */; + result.objectFlags |= 128 /* ObjectLiteral */ | freshObjectLiteralFlag; if (isJSObjectLiteral) { result.objectFlags |= 16384 /* JSLiteral */; } @@ -46471,20 +47292,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 24576 /* Nullable */)) { - propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); - } + propagatedFlags |= result.flags & 939524096 /* PropagatingFlags */; return result; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || - getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 131072 /* Object */ && !isGenericMappedType(type) || - type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); + return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { - checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node); } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); @@ -46492,7 +47310,7 @@ var ts; } function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -46500,18 +47318,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } + checkJsxChildren(node); } function checkJsxElement(node, _checkMode) { checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxFragment(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment, checkMode); + function checkJsxFragment(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment); if (compilerOptions.jsx === 2 /* React */ && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) { error(node, compilerOptions.jsxFactory ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma); } + checkJsxChildren(node); return getJsxElementTypeAt(node) || anyType; } /** @@ -46525,7 +47345,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 === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 72 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -46544,18 +47364,19 @@ var ts; function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createSymbolTable(); - var spread = emptyObjectType; + var spread = emptyJsxObjectType; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var propagatingFlags = 0; + var typeFlags = 0; + var objectFlags = 4096 /* 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); - propagatingFlags |= (exprType.flags & 939524096 /* PropagatingFlags */); + typeFlags |= exprType.flags & 939524096 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | 33554432 /* Transient */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -46570,9 +47391,9 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 269 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); attributesTable = ts.createSymbolTable(); } var exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -46580,7 +47401,7 @@ var ts; hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, openingLikeElement.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, exprType, attributes.symbol, typeFlags, objectFlags); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -46589,11 +47410,11 @@ var ts; } if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 260 /* 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); @@ -46613,25 +47434,26 @@ var ts; (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, /*hasRestElement*/ false) || createArrayType(getUnionType(childrenTypes))); var childPropMap = ts.createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); - spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, typeFlags, objectFlags); } } if (hasSpreadAnyType) { return anyType; } - if (typeToIntersect && spread !== emptyObjectType) { + if (typeToIntersect && spread !== emptyJsxObjectType) { return getIntersectionType([typeToIntersect, spread]); } - return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); + return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread); /** * Create anonymous type from given attributes symbol table. * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable * @param attributesTable a symbol table of attributes property */ function createJsxAttributesType() { + objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= (propagatingFlags |= 268435456 /* ContainsObjectLiteral */); - result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + result.objectFlags |= 128 /* ObjectLiteral */ | objectFlags; return result; } } @@ -46641,7 +47463,7 @@ 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 === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { if (!child.containsOnlyWhiteSpaces) { childrenTypes.push(stringType); } @@ -46704,57 +47526,6 @@ var ts; } return links.resolvedSymbol; } - function instantiateJsxSignatures(node, signatures) { - var instantiatedSignatures = []; - var candidateForTypeArgumentError; - var hasTypeArgumentError = !!node.typeArguments; - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; - if (signature.typeParameters) { - var isJavascript = ts.isInJSFile(node); - var typeArgumentInstantiated = getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, /*reportErrors*/ false); - if (typeArgumentInstantiated) { - hasTypeArgumentError = false; - instantiatedSignatures.push(typeArgumentInstantiated); - } - else { - if (node.typeArguments && hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - candidateForTypeArgumentError = signature; - } - var inferenceContext = createInferenceContext(signature.typeParameters, signature, /*flags*/ isJavascript ? 2 /* AnyDefault */ : 0 /* None */); - var typeArguments = inferJsxTypeArguments(signature, node, inferenceContext); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); - } - } - else { - instantiatedSignatures.push(signature); - } - } - if (node.typeArguments && hasTypeArgumentError) { - if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true); - } - // Length check to avoid issuing an arity error on length=0, the "Type argument list cannot be empty" grammar error alone is fine - else if (node.typeArguments.length !== 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, node.typeArguments)); - } - } - return instantiatedSignatures; - } - function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { - if (reportErrors === void 0) { reportErrors = false; } - if (!node.typeArguments) { - return; - } - if (!hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - return; - } - var args = checkTypeArguments(signature, node.typeArguments, reportErrors); - if (!args) { - return; - } - return getSignatureInstantiation(signature, args, isJavascript); - } function getJsxNamespaceAt(location) { var links = location && getNodeLinks(location); if (links && links.jsxNamespace) { @@ -46825,217 +47596,63 @@ var ts; function getJsxElementChildrenPropertyName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } - function getApparentTypeOfJsxPropsType(propsType) { - if (!propsType) { - return undefined; - } - if (propsType.flags & 524288 /* Intersection */) { - var propsApparentType = []; - for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { - var t = _a[_i]; - propsApparentType.push(getApparentType(t)); - } - return getIntersectionType(propsApparentType); - } - return getApparentType(propsType); - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return only attributes type of successfully resolved call signature. - * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) - * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. - var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined, /*isForSignatureHelp*/ false); - if (callSignature !== unknownSignature) { - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } - } - } - return undefined; - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return all attributes type of resolved call signature including candidate signatures. - * This function assumes that the caller handled other possible element type of the JSX element. - * This function is a behavior used by language service when looking up completion in JSX element. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. - var candidatesOutArray = []; - getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, /*isForSignatureHelp*/ false); - var result = void 0; - var allMatchingAttributesType = void 0; - for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { - var candidate = candidatesOutArray_1[_i]; - var callReturnType = getReturnTypeOfSignature(candidate); - // TODO: GH#18217: callReturnType should always be defined... - var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - var shouldBeCandidate = true; - for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { - var attribute = _b[_a]; - if (ts.isJsxAttribute(attribute) && - isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 - shouldBeCandidate = false; - break; - } - } - if (shouldBeCandidate) { - result = intersectTypes(result, paramType); - } - allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); - } - } - // If we can't find any matching, just return everything. - if (!result) { - result = allMatchingAttributesType; - } - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - result = intersectTypes(intrinsicAttributes, result); - } - return result; - } - } - return undefined; - } - function getInstantiatedJsxSignatures(openingLikeElement, elementType, reportErrors) { - var links = getNodeLinks(openingLikeElement); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(elementType); - if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) === resolvingSignaturesArray) { - return; - } - else if (links.resolvedSignatures.get(cacheKey)) { - return links.resolvedSignatures.get(cacheKey); - } - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + function getUninstantiatedJsxSignaturesOfType(elementType) { // Resolve the signatures, preferring constructor var signatures = getSignaturesOfType(elementType, 1 /* Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures signatures = getSignaturesOfType(elementType, 0 /* Call */); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - if (reportErrors) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(openingLikeElement.tagName)); - } + } + if (signatures.length === 0 && elementType.flags & 1048576 /* Union */) { + // If each member has some combination of new/call signatures; make a union signature list for those + signatures = getUnionSignatures(ts.map(elementType.types, getUninstantiatedJsxSignaturesOfType)); + } + return signatures; + } + function getIntrinsicAttributesTypeFromStringLiteralType(type, location) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location); + if (intrinsicElementsType !== errorType) { + var stringLiteralTypeName = type.value; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + return indexSignatureType; + } + return undefined; + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } + function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { + if (refKind === 1 /* Function */) { + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + if (sfcReturnConstraint) { + checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else if (refKind === 0 /* Component */) { + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (classConstraint) { + // Issue an error if this return type isn't assignable to JSX.ElementClass or JSX.Element, failing that + checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else { // Mixed + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (!sfcReturnConstraint || !classConstraint) { return; } + var combined = getUnionType([sfcReturnConstraint, classConstraint]); + checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } - // Instantiate in context of source type - var results = instantiateJsxSignatures(openingLikeElement, signatures); - links.resolvedSignatures.set(cacheKey, results); - return results; - } - /** - * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. - * For instance: - * declare function Foo(attr: { p1: string}): JSX.Element; - * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" - * - * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. - * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component - * - * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement - * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature - * @param sourceAttributesType Is the attributes type the user passed, and is used to create inferences in the target type if present - * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) - * @return attributes type if able to resolve the type of node - * anyType if there is no type ElementAttributesProperty or there is an error - * emptyObjectType if there is no "prop" in the element instance type - */ - function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 262144 /* Union */) { - var types = elementType.types; - return getUnionType(types.map(function (type) { - return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); - }), 2 /* Subtype */); - } - // Shortcircuit any - if (isTypeAny(elementType)) { - return elementType; - } - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 4 /* String */) { - return anyType; - } - else if (elementType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = elementType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); - } - // If we need to report an error, we already done so here. So just return any to prevent any more error downstream - return anyType; - } - // Get the element instance type (the result of newing or invoking this tag) - var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); - if (!ts.length(instantiatedSignatures)) { - return errorType; - } - var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); - // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. - // Otherwise get only attributes type from the signature picked by choose-overload logic. - var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? - tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : - defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); - if (statelessAttributesType) { - return statelessAttributesType; - } - // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elementClassType) { - checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - var isJs = ts.isInJSFile(openingLikeElement); - return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -47059,53 +47676,6 @@ var ts; } return links.resolvedJsxElementAttributesType; } - /** - * Get attributes type of the given custom opening-like JSX element. - * This function is intended to be called from a caller that handles intrinsic JSX element already. - * @param node a custom JSX opening-like element - * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component - */ - function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { - return resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, checkExpression(node.tagName), getJsxElementClassTypeAt(node)); - } - /** - * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. - * This function is called by language service (see: completions-tryGetGlobalSymbols). - * @param node a JSX opening-like element to get attributes type for - */ - function getAllAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - // Because in language service, the given JSX opening-like element may be incomplete and therefore, - // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); - } - } - /** - * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. - * @param node a JSXOpeningLikeElement node - * @return an attributes type of the given node - */ - function getAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); - } - } - /** - * Given a JSX attribute, returns the symbol for the corresponds property - * of the element attributes type. Will return unknownSymbol for attributes - * that have no matching element attributes type property. - */ - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); - var prop = getPropertyOfType(attributesType, attrib.name.escapedText); - return prop || unknownSymbol; - } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); if (type === errorType) @@ -47139,7 +47709,7 @@ var ts; } } } - function checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode) { + function checkJsxOpeningLikeElementOrOpeningFragment(node) { var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node); if (isNodeOpeningLikeElement) { checkGrammarJsxElement(node); @@ -47161,10 +47731,8 @@ var ts; } } if (isNodeOpeningLikeElement) { - checkJsxAttributesAssignableToTagNameAttributes(node, checkMode); - } - else { - checkJsxChildren(node.parent); + var sig = getResolvedSignature(node); + checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(node), getReturnTypeOfSignature(sig), node); } } /** @@ -47181,7 +47749,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 131072 /* Object */) { + if (targetType.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -47191,7 +47759,7 @@ var ts; return true; } } - else if (targetType.flags & 786432 /* UnionOrIntersection */) { + else if (targetType.flags & 3145728 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -47199,55 +47767,12 @@ var ts; } } } - else if (targetType.flags & 4194304 /* Conditional */) { + else if (targetType.flags & 16777216 /* Conditional */) { return isKnownProperty(targetType.root.trueType, name, isComparingJsxAttributes) || isKnownProperty(targetType.root.falseType, name, isComparingJsxAttributes); } return false; } - /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ - function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement, checkMode) { - // The function involves following steps: - // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. - // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) - // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. - // 3. Check if the two are assignable to each other - // targetAttributesType is a type of an attribute from resolving tagName of an opening-like JSX element. - var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? - getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : - getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); - // sourceAttributesType is a type of an attributes properties. - // i.e
- // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); - // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties - var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); - // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. - // This will allow excess properties in spread type as it is very common pattern to spread outer attributes into React component in its render method. - if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { - for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { - var attribute = _a[_i]; - if (!ts.isJsxAttribute(attribute)) { - continue; - } - var attrName = attribute.name; - var isNotIgnoredJsxProperty = (isUnhyphenatedJsxName(ts.idText(attrName)) || !!(getPropertyOfType(targetAttributesType, attrName.escapedText))); - if (isNotIgnoredJsxProperty && !isKnownProperty(targetAttributesType, attrName.escapedText, /*isComparingJsxAttributes*/ true)) { - error(attribute, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(attrName), typeToString(targetAttributesType)); - // We break here so that errors won't be cascading - break; - } - } - } - else if (!isSourceAttributeTypeAssignableToTarget) { - checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); - } - } function checkJsxExpression(node, checkMode) { if (node.expression) { var type = checkExpression(node.expression, checkMode); @@ -47287,7 +47812,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 146 /* QualifiedName */ ? node.right : node.kind === 181 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 148 /* QualifiedName */ ? node.right : node.kind === 183 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -47359,13 +47884,13 @@ var ts; return false; } var thisType = getTypeFromTypeNode(thisParameter.type); - enclosingClass = ((thisType.flags & 65536 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); + enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); } // No further restrictions for static properties if (flags & 32 /* Static */) { return true; } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -47385,19 +47910,26 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function getNonNullableTypeIfNeeded(type) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + if (kind) { + return getNonNullableType(type); + } + return type; + } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? + error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; + return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } @@ -47430,7 +47962,7 @@ var ts; return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } return errorType; } @@ -47441,9 +47973,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 100 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 97 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 98 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); @@ -47455,9 +47987,9 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 187 /* PropertyAccessExpression */ || + if (node.kind !== 189 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -47465,11 +47997,11 @@ 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 && left.kind === 99 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && left.kind === 100 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 157 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -47481,7 +48013,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { error(right, 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; @@ -47500,8 +48032,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && - node.parent.kind !== 162 /* TypeReference */ && + else if (valueDeclaration.kind === 240 /* ClassDeclaration */ && + node.parent.kind !== 164 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -47513,9 +48045,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -47553,7 +48085,7 @@ var ts; function reportNonexistentProperty(propNode, containingType) { var errorInfo; var relatedInfo; - if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { + if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -47662,16 +48194,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 97 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 98 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 148 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 181 /* ImportType */: + case 183 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind !== 181 /* ImportType */ && node.expression.kind === 97 /* SuperKeyword */, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind !== 183 /* ImportType */ && node.expression.kind === 98 /* SuperKeyword */, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -47698,20 +48230,20 @@ var ts; var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, isSuper, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJSFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); + : ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer.kind === 238 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 71 /* Identifier */) { + else if (initializer.kind === 72 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -47728,13 +48260,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 71 /* Identifier */) { + if (e.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 224 /* ForInStatement */ && + if (node.kind === 226 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -47752,7 +48284,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 190 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 192 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -47768,7 +48300,7 @@ var ts; if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -47783,7 +48315,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -47810,8 +48342,7 @@ var ts; return true; } function callLikeExpressionMayHaveTypeArguments(node) { - // TODO: Also include tagged templates (https://github.com/Microsoft/TypeScript/issues/11947) - return ts.isCallOrNewExpression(node); + return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); } function resolveUntypedCall(node) { if (callLikeExpressionMayHaveTypeArguments(node)) { @@ -47819,10 +48350,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 150 /* Decorator */) { + else if (ts.isJsxOpeningLikeElement(node)) { + checkExpression(node.attributes); + } + else if (node.kind !== 152 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -47849,8 +48383,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var signature = signatures_4[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -47886,22 +48420,23 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 208 /* SpreadElement */ || arg.kind === 215 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } + function acceptsVoid(t) { + return !!(t.flags & 16384 /* Void */); + } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } - if (ts.isJsxOpeningLikeElement(node)) { - // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". - return true; - } var argCount; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 191 /* TaggedTemplateExpression */) { + var effectiveParameterCount = getParameterCount(signature); + var effectiveMinimumArguments = getMinArgumentCount(signature); + if (node.kind === 193 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 204 /* TemplateExpression */) { + if (node.template.kind === 206 /* 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. @@ -47912,17 +48447,26 @@ 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 === 13 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 150 /* Decorator */) { + else if (node.kind === 152 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } + else if (ts.isJsxOpeningLikeElement(node)) { + callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + argCount = effectiveMinimumArguments === 0 ? args.length : 1; + effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1; // class may have argumentless ctor functions - still resolve ctor and compare vs props member type + effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1); // sfc may specify context argument - handled by framework and not typechecked + } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 190 /* NewExpression */); + ts.Debug.assert(node.kind === 192 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -47935,12 +48479,21 @@ var ts; } } // Too many arguments implies incorrect arity. - if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { + if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= getMinArgumentCount(signature); - return callIsIncomplete || hasEnoughArguments; + // JSX signatures can have extra parameters provided by the library which we don't check + if (callIsIncomplete || argCount >= effectiveMinimumArguments) { + return true; + } + for (var i = argCount; i < effectiveMinimumArguments; i++) { + var type = getTypeAtPosition(signature, i); + if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + return false; + } + } + return true; } function hasCorrectTypeArgumentArity(signature, typeArguments) { // If the user supplied type arguments, but the number of type arguments does not match @@ -47952,7 +48505,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -47974,14 +48527,9 @@ var ts; } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); } - function inferJsxTypeArguments(signature, node, context) { - // Skip context sensitive pass - var skipContextParamType = getTypeAtPosition(signature, 0); - var checkAttrTypeSkipContextSensitive = checkExpressionWithContextualType(node.attributes, skipContextParamType, identityMapper); - inferTypes(context.inferences, checkAttrTypeSkipContextSensitive, skipContextParamType); - // Standard pass - var paramType = getTypeAtPosition(signature, 0); - var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context); + function inferJsxTypeArguments(node, signature, excludeArgument, context) { + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] !== undefined ? identityMapper : context); inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } @@ -47997,11 +48545,14 @@ var ts; inference.inferredType = undefined; } } + if (ts.isJsxOpeningLikeElement(node)) { + return inferJsxTypeArguments(node, signature, excludeArgument, context); + } // If a contextual type is available, infer from that type to the return type of the call expression. For // example, given a 'function wrap(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 !== 150 /* Decorator */) { + if (node.kind !== 152 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -48034,7 +48585,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards @@ -48050,7 +48601,7 @@ var ts; return getInferredTypes(context); } function getArrayifiedType(type) { - if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 15794176 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { + if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 63176704 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { return createArrayType(getIndexTypeOfType(type, 1 /* Number */) || errorType); } return type; @@ -48061,13 +48612,13 @@ 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 arg.kind === 213 /* SyntheticExpression */ ? + return arg.kind === 215 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context)); } } var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */); var types = []; var spreadIndex = -1; for (var i = index; i < argCount; i++) { @@ -48103,6 +48654,19 @@ var ts; } return typeArgumentTypes; } + function getJsxReferenceKind(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return 2 /* Mixed */; + } + var tagType = getApparentType(checkExpression(node.tagName)); + if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { + return 0 /* Component */; + } + if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { + return 1 /* Function */; + } + return 2 /* Mixed */; + } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. * @param node a JSX opening-like element we are trying to figure its call signature @@ -48110,37 +48674,20 @@ var ts; * @param relation a relationship to check parameter and argument type * @param excludeArgument */ - function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { - // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: - // 1. callIsIncomplete - // 2. attributes property has same number of properties as the parameter object type. - // We can figure that out by resolving attributes property and check number of properties in the resolved type - // If the call has correct arity, we will then check if the argument type and parameter type is assignable - var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete - if (callIsIncomplete) { - return true; - } - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors) { // Stateless function components can have maximum of three arguments: "props", "context", and "updater". // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, // can be specified by users through attributes property. - var paramType = getTypeAtPosition(signature, 0); - var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); - var argProperties = getPropertiesOfType(attributesType); - for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { - var arg = argProperties_1[_i]; - if (!getPropertyOfType(paramType, arg.escapedName) && isUnhyphenatedJsxName(arg.escapedName)) { - return false; - } - } - return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] ? identityMapper : undefined); + return checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes); } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { if (ts.isJsxOpeningLikeElement(node)) { - return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 190 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 192 /* 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. @@ -48157,7 +48704,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), @@ -48180,15 +48727,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { + if (callee.kind === 189 /* PropertyAccessExpression */ || callee.kind === 190 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(213 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(215 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -48198,21 +48745,21 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - if (node.kind === 150 /* Decorator */) { + if (node.kind === 152 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { - return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; + return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray; } var args = node.arguments || ts.emptyArray; var length = args.length; @@ -48238,30 +48785,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 149 /* Parameter */: + case 151 /* 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 === 155 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 157 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 !== 152 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 154 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -48275,17 +48822,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 1; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return 2; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 149 /* Parameter */: + case 151 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -48298,8 +48845,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -48343,8 +48890,8 @@ var ts; function getTypeArgumentArityError(node, signatures, typeArguments) { var min = Infinity; var max = -Infinity; - for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { - var sig = signatures_6[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); max = Math.max(max, ts.length(sig.typeParameters)); } @@ -48352,14 +48899,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp, fallbackError) { - var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 150 /* Decorator */; + var isTaggedTemplate = node.kind === 193 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 152 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); + 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 !== 97 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 98 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -48367,7 +48915,9 @@ var ts; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + if (reportErrors) { + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + } return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -48412,7 +48962,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 = isForSignatureHelp && node.kind === 189 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = isForSignatureHelp && node.kind === 191 /* 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 @@ -48436,34 +48986,32 @@ var ts; // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. - if (candidateForArgumentError) { - if (isJsxOpeningOrSelfClosingElement) { - // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". - return candidateForArgumentError; + if (reportErrors) { + if (candidateForArgumentError) { + // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] + // The importance of excludeArgument is to prevent us from typing function expression parameters + // in arguments too early. If possible, we'd like to only type them once we know the correct + // overload. However, this matters for the case where the call is correct. When the call is + // an error, we don't need to exclude any arguments, although it would cause no harm to do so. + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } - // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] - // The importance of excludeArgument is to prevent us from typing function expression parameters - // in arguments too early. If possible, we'd like to only type them once we know the correct - // overload. However, this matters for the case where the call is correct. When the call is - // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); - } - else if (candidateForArgumentArityError) { - diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); - } - else if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); - } - else { - var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); - if (signaturesWithCorrectTypeArgumentArity.length === 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + else if (candidateForArgumentArityError) { + diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); } - else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + else if (candidateForTypeArgumentError) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); } - else if (fallbackError) { - diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + else { + var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); + if (signaturesWithCorrectTypeArgumentArity.length === 0) { + diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + } + else if (!isDecorator) { + diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + } + else if (fallbackError) { + diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + } } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); @@ -48666,7 +49214,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, isForSignatureHelp) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -48721,7 +49269,7 @@ var ts; } else { var relatedInformation = void 0; - if (node.arguments.length === 1 && isTypeAssertion(ts.first(node.arguments))) { + if (node.arguments.length === 1) { var text = ts.getSourceFileOfNode(node).text; if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); @@ -48745,8 +49293,8 @@ 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 & 65536 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 262144 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 /* Union */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, isForSignatureHelp) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -48824,7 +49372,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 524288 /* Intersection */) { + if (firstBase.flags & 2097152 /* Intersection */) { var types = firstBase.types; var mixinCount = ts.countWhere(types, isMixinConstructorType); var i = 0; @@ -48924,16 +49472,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -48969,6 +49517,58 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp, 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, 67897832 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(120 /* AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + parameterSymbol.type = result; + return createSignature(declaration, + /*typeParameters*/ undefined, + /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, + /*returnTypePredicate*/ undefined, 1, + /*hasRestparameter*/ false, + /*hasLiteralTypes*/ false); + } + function resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + var fakeSignature = createSignatureForJSXIntrinsic(node, result); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), result, node.tagName, node.attributes); + return fakeSignature; + } + var exprTypes = checkExpression(node.tagName); + var apparentType = getApparentType(exprTypes); + if (apparentType === errorType) { + return resolveErrorCall(node); + } + if (exprTypes.flags & 128 /* StringLiteral */) { + var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(exprTypes, node); + if (!intrinsicType) { + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, exprTypes.value, "JSX." + JsxNames.IntrinsicElements); + return resolveUntypedCall(node); + } + else { + var fakeSignature = createSignatureForJSXIntrinsic(node, intrinsicType); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), intrinsicType, node.tagName, node.attributes); + return fakeSignature; + } + } + var signatures = getUninstantiatedJsxSignaturesOfType(apparentType); + if (exprTypes.flags & 4 /* String */ || isUntypedFunctionCall(exprTypes, apparentType, signatures.length, /*constructSignatures*/ 0)) { + return resolveUntypedCall(node); + } + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return resolveErrorCall(node); + } + return resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp); + } /** * Sometimes, we have a decorator that could accept zero arguments, * but is receiving too many arguments as part of the decorator invocation. @@ -48981,49 +49581,19 @@ var ts; signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } - /** - * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. - * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName - * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) - * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. - * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function - * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. - * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; - * the function will fill it up with appropriate candidate signatures - */ - function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, isForSignatureHelp) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); - if (callSignatures && callSignatures.length > 0) { - return resolveCall(openingLikeElement, callSignatures, candidatesOutArray, isForSignatureHelp); - } - return undefined; - } function resolveSignature(node, candidatesOutArray, isForSignatureHelp) { switch (node.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, isForSignatureHelp); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, isForSignatureHelp); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, isForSignatureHelp); - case 150 /* Decorator */: + case 152 /* Decorator */: return resolveDecorator(node, candidatesOutArray, isForSignatureHelp); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - // This code-path is called by language service - var exprTypes = checkExpression(node.tagName); - return forEachType(exprTypes, function (exprType) { - var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray, isForSignatureHelp); - if (sfcResult && sfcResult !== unknownSignature) { - return sfcResult; - } - var sigs = getInstantiatedJsxSignatures(node, exprType); - if (candidatesOutArray && ts.length(sigs)) { - candidatesOutArray.push.apply(candidatesOutArray, sigs); - } - return ts.length(sigs) ? sigs[0] : unknownSignature; - }) || unknownSignature; + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + return resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -49075,7 +49645,7 @@ var ts; return false; } function isJSConstructorType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); } @@ -49110,10 +49680,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 187 /* PropertyAccessExpression */) { + while (parent && parent.kind === 189 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 59 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -49139,15 +49709,15 @@ var ts; if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return voidType; } - if (node.kind === 190 /* NewExpression */) { + if (node.kind === 192 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 155 /* Constructor */ && - declaration.kind !== 159 /* ConstructSignature */ && - declaration.kind !== 164 /* ConstructorType */ && + declaration.kind !== 157 /* Constructor */ && + declaration.kind !== 161 /* ConstructSignature */ && + declaration.kind !== 166 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -49155,7 +49725,7 @@ var ts; // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. var funcSymbol = checkExpression(node.expression).symbol; - if (!funcSymbol && node.expression.kind === 71 /* Identifier */) { + if (!funcSymbol && node.expression.kind === 72 /* Identifier */) { funcSymbol = getResolvedSymbol(node.expression); } var type = funcSymbol && getJSClassType(funcSymbol); @@ -49175,7 +49745,7 @@ 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 & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } var jsAssignmentType; @@ -49221,7 +49791,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -49274,9 +49844,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 237 /* FunctionDeclaration */ + ? 239 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 235 /* VariableDeclaration */ + ? 237 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -49312,10 +49882,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 94 /* NewKeyword */) { + if (node.keywordToken === 95 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 91 /* ImportKeyword */) { + if (node.keywordToken === 92 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -49326,7 +49896,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 === 155 /* Constructor */) { + else if (container.kind === 157 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -49497,7 +50067,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71 /* Identifier */) { + if (element.name.kind === 72 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -49511,7 +50081,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* Identifier */) { // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType) { links.type = getTypeFromBindingPattern(decl.name); @@ -49561,7 +50131,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 216 /* Block */) { + if (func.body.kind !== 218 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -49671,7 +50241,7 @@ var ts; 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]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -49681,7 +50251,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -49689,7 +50259,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]) || 64 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -49703,14 +50273,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 197 /* TypeOfExpression */) { + if (node.expression.kind === 199 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // 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_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 32768 /* Never */); + return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -49726,7 +50296,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 232 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -49748,7 +50318,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, 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 & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -49769,11 +50339,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 154 /* MethodDeclaration */: - return func.parent.kind === 186 /* ObjectLiteralExpression */; + case 156 /* MethodDeclaration */: + return func.parent.kind === 188 /* ObjectLiteralExpression */; default: return false; } @@ -49792,16 +50362,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 4096 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 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 === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 155 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 218 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 32768 /* Never */) { + if (returnType && returnType.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -49830,7 +50400,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -49850,7 +50420,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 196 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -49895,7 +50465,7 @@ var ts; getAwaitedType(type) || errorType : type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -49911,7 +50481,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 216 /* Block */) { + if (node.body.kind === 218 /* Block */) { checkSourceElement(node.body); } else { @@ -49934,34 +50504,66 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { + if (!isTypeAssignableTo(type, numberOrBigIntType)) { error(operand, diagnostic); return false; } return true; } + function isReadonlyAssignmentDeclaration(d) { + if (!ts.isCallExpression(d)) { + return false; + } + if (!ts.isBindableObjectDefinePropertyCall(d)) { + return false; + } + var objectLitType = checkExpressionCached(d.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + var writableProp = getPropertyOfType(objectLitType, "writable"); + var writableType = writableProp && getTypeOfSymbol(writableProp); + if (!writableType || writableType === falseType || writableType === regularFalseType) { + return true; + } + // We include this definition whereupon we walk back and check the type at the declaration because + // The usual definition of `Object.defineProperty` will _not_ cause literal types to be preserved in the + // argument types, should the type be contextualized by the call itself. + if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) { + var initializer = writableProp.valueDeclaration.initializer; + var rawOriginalType = checkExpression(initializer); + if (rawOriginalType === falseType || rawOriginalType === regularFalseType) { + return true; + } + } + return false; + } + var setProp = getPropertyOfType(objectLitType, "set"); + return !setProp; + } function isReadonlySymbol(symbol) { // The following symbols are considered read-only: // Properties with a 'readonly' modifier // Variables declared with 'const' // Get accessors without matching set accessors // 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 */); + symbol.flags & 8 /* EnumMember */ || + ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && - expr.expression.kind === 99 /* ThisKeyword */) { + (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) && + expr.expression.kind === 100 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 155 /* Constructor */)) { + if (!(func && func.kind === 157 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -49974,13 +50576,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 249 /* NamespaceImport */; + return !!declaration && declaration.kind === 251 /* NamespaceImport */; } } } @@ -49989,7 +50591,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 72 /* Identifier */ && node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -49998,7 +50600,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -50035,37 +50637,52 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operand.kind === 8 /* NumericLiteral */) { - if (node.operator === 38 /* MinusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - } - else if (node.operator === 37 /* PlusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); - } + switch (node.operand.kind) { + case 8 /* NumericLiteral */: + switch (node.operator) { + case 39 /* MinusToken */: + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + case 38 /* PlusToken */: + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } + break; + case 9 /* BigIntLiteral */: + if (node.operator === 39 /* MinusToken */) { + return getFreshTypeOfLiteralType(getLiteralType({ + negative: true, + base10Value: ts.parsePseudoBigInt(node.operand.text) + })); + } } switch (node.operator) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - return numberType; - case 51 /* ExclamationToken */: + if (node.operator === 38 /* PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + } + return numberType; + } + return getUnaryResultType(operandType); + case 52 /* ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); - return facts === 1048576 /* Truthy */ ? falseType : - facts === 2097152 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); + return facts === 4194304 /* Truthy */ ? falseType : + facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + case 44 /* PlusPlusToken */: + case 45 /* 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } - return numberType; + return getUnaryResultType(operandType); } return errorType; } @@ -50074,11 +50691,20 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } + return getUnaryResultType(operandType); + } + function getUnaryResultType(operandType) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + ? numberOrBigIntType + : bigintType; + } + // If it's not a bigint type, implicit coercion will result in a number return numberType; } // Return true if type might be of the given kind. A union or intersection type might be of a given @@ -50087,7 +50713,7 @@ var ts; if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -50102,21 +50728,22 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { return false; } - return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 132 /* 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); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 262144 /* Union */ ? + return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } @@ -50136,7 +50763,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, 32764 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* 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 @@ -50155,10 +50782,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -50168,8 +50795,8 @@ var ts; if (strictNullChecks && properties.length === 0) { return checkNonNullType(sourceType, node); } - for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { - var p = properties_7[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var p = properties_6[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis); } return sourceType; @@ -50177,9 +50804,9 @@ var ts; /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) { if (rightIsThis === void 0) { rightIsThis = false; } - if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */ || property.kind === 276 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -50188,13 +50815,13 @@ var ts; var type = getTypeOfObjectLiteralDestructuringProperty(objectLiteralType, name, property, rightIsThis); if (type) { // non-shorthand property assignments should always have initializers - return checkDestructuringAssignment(property.kind === 274 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 276 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } else { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 275 /* SpreadAssignment */) { + else if (property.kind === 277 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -50246,8 +50873,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 208 /* OmittedExpression */) { - if (element.kind !== 206 /* SpreadElement */) { + if (element.kind !== 210 /* OmittedExpression */) { + if (element.kind !== 208 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType : everyType(sourceType, isTupleLikeType) ? getTupleElementType(sourceType, elementIndex) : @@ -50271,7 +50898,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 204 /* BinaryExpression */ && restExpression.operatorToken.kind === 59 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -50288,14 +50915,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 276 /* 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)) & 8192 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -50304,21 +50931,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 204 /* BinaryExpression */ && target.operatorToken.kind === 59 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 186 /* ObjectLiteralExpression */) { + if (target.kind === 188 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 185 /* ArrayLiteralExpression */) { + if (target.kind === 187 /* 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 === 275 /* SpreadAssignment */ ? + var error = target.parent.kind === 277 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -50337,58 +50964,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 191 /* TaggedTemplateExpression */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 193 /* TaggedTemplateExpression */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 140 /* UndefinedKeyword */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 197 /* TypeOfExpression */: - case 211 /* NonNullExpression */: - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 141 /* UndefinedKeyword */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 199 /* TypeOfExpression */: + case 213 /* NonNullExpression */: + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: return true; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 51 /* ExclamationToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 52 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 198 /* VoidExpression */: // Explicit opt-out - case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 200 /* VoidExpression */: // Explicit opt-out + case 194 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 212 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { @@ -50398,11 +51026,11 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 99 /* ThisKeyword */); + if (operator === 59 /* EqualsToken */ && (left.kind === 188 /* ObjectLiteralExpression */ || left.kind === 187 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 100 /* ThisKeyword */); } var leftType; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -50410,28 +51038,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 39 /* AsteriskToken */: - case 40 /* AsteriskAsteriskToken */: - case 61 /* AsteriskEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 42 /* PercentToken */: - case 64 /* PercentEqualsToken */: - case 38 /* MinusToken */: - case 60 /* MinusEqualsToken */: - case 45 /* LessThanLessThanToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: + case 40 /* AsteriskToken */: + case 41 /* AsteriskAsteriskToken */: + case 62 /* AsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 43 /* PercentToken */: + case 65 /* PercentEqualsToken */: + case 39 /* MinusToken */: + case 61 /* MinusEqualsToken */: + case 46 /* LessThanLessThanToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -50440,36 +51068,61 @@ 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 & 272 /* BooleanLike */) && - (rightType.flags & 272 /* BooleanLike */) && + if ((leftType.flags & 528 /* BooleanLike */) && + (rightType.flags & 528 /* 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; } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + 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 */)) || + // Or, if neither could be bigint, implicit coercion results in a number result + !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + resultType_1 = numberType; } + // At least one is assignable to bigint, so both should be only assignable to bigint + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + switch (operator) { + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + reportOperatorError(); + } + resultType_1 = bigintType; + } + else { + reportOperatorError(); + resultType_1 = errorType; + } + if (leftOk && rightOk) { + checkAssignmentOperator(resultType_1); + } + return resultType_1; } - return numberType; - case 37 /* PlusToken */: - case 59 /* PlusEqualsToken */: + case 38 /* PlusToken */: + case 60 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 132 /* StringLike */) && !isTypeAssignableToKind(rightType, 132 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* 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, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* 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, 132 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 132 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -50486,26 +51139,27 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 59 /* PlusEqualsToken */) { + if (operator === 60 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); - if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { + if (!(isTypeComparableTo(leftType, rightType) || isTypeComparableTo(rightType, leftType) || + (isTypeAssignableTo(leftType, numberOrBigIntType) && isTypeAssignableTo(rightType, numberOrBigIntType)))) { reportOperatorError(); } } return booleanType; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -50516,19 +51170,19 @@ var ts; reportOperatorError(); } return booleanType; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 53 /* AmpersandAmpersandToken */: - return getTypeFacts(leftType) & 1048576 /* Truthy */ ? + case 54 /* AmpersandAmpersandToken */: + return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 54 /* BarBarToken */: - return getTypeFacts(leftType) & 2097152 /* Falsy */ ? + case 55 /* BarBarToken */: + return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, right); if (isAssignmentDeclaration(declKind)) { @@ -50538,7 +51192,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 26 /* CommaToken */: + case 27 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -50564,12 +51218,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 72 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 12288 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -50579,15 +51233,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - return 54 /* BarBarToken */; - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - return 35 /* ExclamationEqualsEqualsToken */; - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: - return 53 /* AmpersandAmpersandToken */; + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + return 55 /* BarBarToken */; + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + return 36 /* ExclamationEqualsEqualsToken */; + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: + return 54 /* AmpersandAmpersandToken */; default: return undefined; } @@ -50634,11 +51288,11 @@ var ts; } function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { switch (operatorToken.kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); } return undefined; @@ -50716,14 +51370,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } }); return stringType; } function getContextNode(node) { - if (node.kind === 266 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 268 /* 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; @@ -50759,7 +51413,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; + return node.kind === 194 /* TypeAssertionExpression */ || node.kind === 212 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -50768,7 +51422,7 @@ var ts; ts.isDeclarationReadonly(declaration) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 24576 /* Nullable */) { + if (widened.flags & 98304 /* Nullable */) { reportImplicitAny(declaration, anyType); return anyType; } @@ -50781,26 +51435,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 786432 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* 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) || emptyObjectType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || + 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 */) || 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 & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || - contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */) && 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 false; } @@ -50816,7 +51472,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -50827,7 +51483,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -50858,14 +51514,14 @@ var ts; var 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 (expr.kind === 189 /* CallExpression */ && expr.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 191 /* CallExpression */ && expr.expression.kind !== 98 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - else if (expr.kind === 192 /* TypeAssertionExpression */ || expr.kind === 210 /* AsExpression */) { + else if (expr.kind === 194 /* TypeAssertionExpression */ || expr.kind === 212 /* AsExpression */) { return getTypeFromTypeNode(expr.type); } // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions @@ -50900,7 +51556,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode, forceTuple) { var type; - if (node.kind === 146 /* QualifiedName */) { + if (node.kind === 148 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -50912,10 +51568,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 167 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } @@ -50931,94 +51587,97 @@ var ts; } function checkExpressionWorker(node, checkMode, forceTuple) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return checkIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return checkThisExpression(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkSuperExpression(node); - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullWideningType; - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101 /* TrueKeyword */: + case 9 /* BigIntLiteral */: + checkGrammarBigIntLiteral(node); + return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); + case 102 /* TrueKeyword */: return trueType; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: return falseType; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return checkTemplateExpression(node); - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 189 /* CallExpression */: - if (node.expression.kind === 91 /* ImportKeyword */) { + case 191 /* CallExpression */: + if (node.expression.kind === 92 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 190 /* NewExpression */: + case 192 /* NewExpression */: return checkCallExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return checkClassExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return checkAssertion(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return checkNonNullAssertion(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return checkMetaProperty(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkDeleteExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return checkVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return checkAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return undefinedWideningType; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return checkYieldExpression(node); - case 213 /* SyntheticExpression */: + case 215 /* SyntheticExpression */: return node.type; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return checkJsxElement(node, checkMode); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 262 /* JsxFragment */: - return checkJsxFragment(node, checkMode); - case 266 /* JsxAttributes */: + case 264 /* JsxFragment */: + return checkJsxFragment(node); + case 268 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -51056,7 +51715,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 157 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -51067,10 +51726,10 @@ 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 === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { + if (func.kind === 157 /* Constructor */ || func.kind === 161 /* ConstructSignature */ || func.kind === 166 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -51125,13 +51784,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 195 /* ArrowFunction */: - case 158 /* CallSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 163 /* FunctionType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 197 /* ArrowFunction */: + case 160 /* CallSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 165 /* FunctionType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -51145,11 +51804,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 71 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 72 /* 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 === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { + else if (name.kind === 185 /* ArrayBindingPattern */ || name.kind === 184 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -51158,13 +51817,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* 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 === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || - node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || - node.kind === 159 /* ConstructSignature */) { + else if (node.kind === 165 /* FunctionType */ || node.kind === 239 /* FunctionDeclaration */ || node.kind === 166 /* ConstructorType */ || + node.kind === 160 /* CallSignature */ || node.kind === 157 /* Constructor */ || + node.kind === 161 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -51194,10 +51853,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -51227,7 +51886,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -51244,7 +51903,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 155 /* Constructor */) { + if (member.kind === 157 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -51259,16 +51918,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: addName(names, name, memberName, 1 /* Getter */); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: addName(names, name, memberName, 2 /* Setter */); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* Property */); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: addName(names, name, memberName, 4 /* Method */); break; } @@ -51331,15 +51990,15 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* PropertySignature */) { + if (member.kind === 153 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: memberName = name.text; break; - case 71 /* Identifier */: + case 72 /* Identifier */: memberName = ts.idText(name); break; default: @@ -51356,7 +52015,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* 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 @@ -51376,7 +52035,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -51384,7 +52043,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -51411,7 +52070,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 156 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -51436,7 +52095,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 152 /* PropertyDeclaration */ && + return n.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -51466,7 +52125,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -51491,7 +52150,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -51501,13 +52160,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -51525,7 +52184,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -51573,7 +52232,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 164 /* 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); } var type = getTypeFromTypeReference(node); @@ -51621,7 +52280,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 170 /* RestType */) { + if (e.kind === 172 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -51630,7 +52289,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 169 /* OptionalType */) { + else if (e.kind === 171 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -51645,14 +52304,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 2097152 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* 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 === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 190 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -51660,7 +52319,7 @@ 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. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -51692,7 +52351,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 175 /* 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); @@ -51709,9 +52368,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 239 /* InterfaceDeclaration */ && - n.parent.kind !== 238 /* ClassDeclaration */ && - n.parent.kind !== 207 /* ClassExpression */ && + if (n.parent.kind !== 241 /* InterfaceDeclaration */ && + n.parent.kind !== 240 /* ClassDeclaration */ && + n.parent.kind !== 209 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* 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 @@ -51802,7 +52461,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && + var reportError = (node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -51841,7 +52500,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 241 /* InterfaceDeclaration */ || node.parent.kind === 168 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -51852,7 +52511,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 239 /* FunctionDeclaration */ || node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */ || node.kind === 157 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -51904,8 +52563,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_7 = signatures; _a < signatures_7.length; _a++) { - var signature = signatures_7[_a]; + for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { + var signature = signatures_6[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -51981,22 +52640,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -52004,17 +52663,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: var result_4 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_4 |= getDeclarationSpaces(d); }); return result_4; - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 237 /* FunctionDeclaration */: - case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 239 /* FunctionDeclaration */: + case 253 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -52061,7 +52720,7 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } @@ -52092,7 +52751,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -52243,7 +52902,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 71 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 72 /* 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 { @@ -52282,24 +52941,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 149 /* Parameter */: + case 151 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -52320,7 +52979,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 71 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 72 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -52345,50 +53004,55 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 172 /* IntersectionType */: - case 171 /* UnionType */: - var commonEntityName = void 0; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { - typeNode = typeNode.type; // Skip parens if need be - } - if (typeNode.kind === 131 /* NeverKeyword */) { - continue; // Always elide `never` from the union/intersection if possible - } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* 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); - if (!individualEntityName) { - // Individual is something like string number - // So it would be serialized to either that type or object - // Safe to return here - return undefined; - } - if (commonEntityName) { - // Note this is in sync with the transformation that happens for type node. - // Keep this in sync with serializeUnionOrIntersectionType - // Verify if they refer to same entity and is identifier - // return undefined if they dont match because we would emit object - if (!ts.isIdentifier(commonEntityName) || - !ts.isIdentifier(individualEntityName) || - commonEntityName.escapedText !== individualEntityName.escapedText) { - return undefined; - } - } - else { - commonEntityName = individualEntityName; - } - } - return commonEntityName; - case 175 /* ParenthesizedType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return getEntityNameForDecoratorMetadataFromTypeList(node.types); + case 175 /* ConditionalType */: + return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + case 177 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; } } } + function getEntityNameForDecoratorMetadataFromTypeList(types) { + var commonEntityName; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { + typeNode = typeNode.type; // Skip parens if need be + } + if (typeNode.kind === 132 /* NeverKeyword */) { + continue; // Always elide `never` from the union/intersection if possible + } + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); + if (!individualEntityName) { + // Individual is something like string number + // So it would be serialized to either that type or object + // Safe to return here + return undefined; + } + if (commonEntityName) { + // Note this is in sync with the transformation that happens for type node. + // Keep this in sync with serializeUnionOrIntersectionType + // Verify if they refer to same entity and is identifier + // return undefined if they dont match because we would emit object + if (!ts.isIdentifier(commonEntityName) || + !ts.isIdentifier(individualEntityName) || + commonEntityName.escapedText !== individualEntityName.escapedText) { + return undefined; + } + } + else { + commonEntityName = individualEntityName; + } + } + return commonEntityName; + } function getParameterTypeNodeForDecoratorCheck(node) { var typeNode = ts.getEffectiveTypeAnnotationNode(node); return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode; @@ -52408,14 +53072,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -52424,23 +53088,23 @@ var ts; } } break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 154 /* MethodDeclaration */: + case 156 /* 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 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 149 /* Parameter */: + case 151 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -52493,16 +53157,22 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } } } } + function checkJSDocFunctionType(node) { + if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) { + reportImplicitAny(node, anyType); + } + checkSignatureDeclaration(node); + } function checkJSDocAugmentsTag(node) { var classLike = ts.getJSDocHost(node); if (!ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { @@ -52525,9 +53195,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -52540,7 +53210,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 === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -52569,7 +53239,7 @@ var ts; } } } - var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 155 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); @@ -52614,42 +53284,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 277 /* SourceFile */: - case 242 /* ModuleDeclaration */: - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 279 /* SourceFile */: + case 244 /* ModuleDeclaration */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 240 /* TypeAliasDeclaration */: - case 174 /* InferType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 242 /* TypeAliasDeclaration */: + case 176 /* InferType */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -52670,11 +53340,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 154 /* MethodDeclaration */: - case 152 /* PropertyDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 156 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + if (member.kind === 159 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -52683,7 +53353,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -52691,8 +53361,8 @@ var ts; } } break; - case 160 /* IndexSignature */: - case 215 /* SemicolonClassElement */: + case 162 /* IndexSignature */: + case 217 /* SemicolonClassElement */: // Can't be private break; default: @@ -52704,9 +53374,9 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (node.flags & 4194304 /* Ambient */ || node.kind !== 174 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) + if (node.flags & 4194304 /* Ambient */ || node.kind !== 176 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) return; - if (node.kind === 174 /* InferType */) { + if (node.kind === 176 /* InferType */) { 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))); @@ -52721,7 +53391,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 174 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 176 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -52807,7 +53477,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 251 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -52825,7 +53495,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 237 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 238 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -52846,7 +53516,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -52858,24 +53528,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; + return node.kind === 250 /* ImportClause */ || node.kind === 253 /* ImportSpecifier */ || node.kind === 251 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 250 /* ImportClause */ ? decl : decl.kind === 251 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 216 /* Block */) { + if (node.kind === 218 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -52905,12 +53575,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 152 /* PropertyDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 154 /* MethodDeclaration */ || - node.kind === 153 /* MethodSignature */ || - node.kind === 156 /* GetAccessor */ || - node.kind === 157 /* SetAccessor */) { + if (node.kind === 154 /* PropertyDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 156 /* MethodDeclaration */ || + node.kind === 155 /* MethodSignature */ || + node.kind === 158 /* GetAccessor */ || + node.kind === 159 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -52919,7 +53589,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 151 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -52929,7 +53599,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 71 /* Identifier */; + var isDeclaration_1 = node.kind !== 72 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -52944,7 +53614,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 71 /* Identifier */; + var isDeclaration_2 = node.kind !== 72 /* 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); } @@ -52970,7 +53640,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -52985,7 +53655,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -53020,7 +53690,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 237 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -53032,17 +53702,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 217 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 238 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 219 /* 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 === 216 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 243 /* ModuleBlock */ || - container.kind === 242 /* ModuleDeclaration */ || - container.kind === 277 /* SourceFile */); + (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 245 /* ModuleBlock */ || + container.kind === 244 /* ModuleDeclaration */ || + container.kind === 279 /* 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 @@ -53057,7 +53727,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 151 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -53068,11 +53738,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 187 /* PropertyAccessExpression */) { + if (n.kind === 189 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 71 /* Identifier */) { + else if (n.kind === 72 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.escapedText, 67220415 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -53087,8 +53757,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 184 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 151 /* Parameter */ || + symbol.valueDeclaration.kind === 186 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -53102,7 +53772,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 152 /* PropertyDeclaration */ && + (current.parent.kind === 154 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -53135,18 +53805,18 @@ 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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 184 /* BindingElement */) { - if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 186 /* BindingElement */) { + if (node.parent.kind === 184 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -53159,27 +53829,27 @@ var ts; var property = getPropertyOfType(parentType, nameText); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { - checkPropertyAccessibility(parent, parent.initializer.kind === 97 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, parent.initializer.kind === 98 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 185 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 151 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 226 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -53202,11 +53872,16 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 226 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } + if (symbol.declarations.length > 1) { + if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); + } + } } else { // Node is a secondary declaration, check that type is identical to primary declaration and check that @@ -53221,14 +53896,13 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { - error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { + if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -53237,14 +53911,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* PropertySignature */ + var message = nextDeclaration.kind === 154 /* PropertyDeclaration */ || nextDeclaration.kind === 153 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || - (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 151 /* Parameter */ && right.kind === 237 /* VariableDeclaration */) || + (left.kind === 237 /* VariableDeclaration */ && right.kind === 151 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -53283,7 +53957,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 218 /* EmptyStatement */) { + if (node.thenStatement.kind === 220 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -53302,7 +53976,7 @@ var ts; } function checkTruthinessExpression(node, checkMode) { var type = checkExpression(node, checkMode); - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -53310,12 +53984,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 238 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -53349,14 +54023,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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. @@ -53382,13 +54056,13 @@ var ts; function checkForInStatement(node) { // Grammar checking checkGrammarForInOrForOfStatement(node); - var rightType = checkNonNullExpression(node.expression); + var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); // TypeScript 1.0 spec (April 2014): 5.4 // In a 'for-in' statement of the form // 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 === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* 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); @@ -53402,7 +54076,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 === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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)) { @@ -53415,7 +54089,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, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* 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); @@ -53470,16 +54144,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 262144 /* Union */) { + if (arrayType.flags & 1048576 /* 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 & 68 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 68 /* StringLike */) { + else if (arrayType.flags & 132 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -53492,7 +54166,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 & 32768 /* Never */) { + if (arrayType.flags & 131072 /* Never */) { return stringType; } } @@ -53523,7 +54197,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 68 /* StringLike */) { + if (arrayElementType.flags & 132 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -53737,7 +54411,7 @@ var ts; var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -53753,7 +54427,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -53762,12 +54436,12 @@ var ts; // for generators. return; } - else if (func.kind === 157 /* SetAccessor */) { + else if (func.kind === 159 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 155 /* Constructor */) { + else if (func.kind === 157 /* 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); } @@ -53788,7 +54462,7 @@ var ts; } } } - else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 157 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -53817,7 +54491,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 === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 272 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -53829,7 +54503,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 271 /* 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. @@ -53858,7 +54532,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 233 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -53965,8 +54639,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 202 /* BinaryExpression */ || - name.kind === 147 /* ComputedPropertyName */ || + (propDeclaration.kind === 204 /* BinaryExpression */ || + name.kind === 149 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -53995,6 +54669,7 @@ var ts; case "any": case "unknown": case "number": + case "bigint": case "boolean": case "string": case "symbol": @@ -54174,10 +54849,10 @@ var ts; // 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 & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 8650752 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { + 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. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -54272,7 +54947,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; + return d.kind === 240 /* ClassDeclaration */ || d.kind === 241 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -54311,7 +54986,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 207 /* ClassExpression */) { + if (derivedClassDecl.kind === 209 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -54361,8 +55036,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { - var prop = properties_8[_a]; + for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { + var prop = properties_7[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -54393,7 +55068,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* 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)); } @@ -54403,7 +55078,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 152 /* PropertyDeclaration */ && + return node.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -54414,7 +55089,7 @@ var ts; reference.parent = constructor; reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 8192 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -54427,7 +55102,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -54532,60 +55207,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 37 /* PlusToken */: return value_2; - case 38 /* MinusToken */: return -value_2; - case 52 /* TildeToken */: return ~value_2; + case 38 /* PlusToken */: return value_2; + case 39 /* MinusToken */: return -value_2; + case 53 /* TildeToken */: return ~value_2; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 49 /* BarToken */: return left | right; - case 48 /* AmpersandToken */: return left & right; - case 46 /* GreaterThanGreaterThanToken */: return left >> right; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 45 /* LessThanLessThanToken */: return left << right; - case 50 /* CaretToken */: return left ^ right; - case 39 /* AsteriskToken */: return left * right; - case 41 /* SlashToken */: return left / right; - case 37 /* PlusToken */: return left + right; - case 38 /* MinusToken */: return left - right; - case 42 /* PercentToken */: return left % right; - case 40 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 50 /* BarToken */: return left | right; + case 49 /* AmpersandToken */: return left & right; + case 47 /* GreaterThanGreaterThanToken */: return left >> right; + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 46 /* LessThanLessThanToken */: return left << right; + case 51 /* CaretToken */: return left ^ right; + case 40 /* AsteriskToken */: return left * right; + case 42 /* SlashToken */: return left / right; + case 38 /* PlusToken */: return left + right; + case 39 /* MinusToken */: return left - right; + case 43 /* PercentToken */: return left % right; + case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 37 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { return left + right; } break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 71 /* Identifier */: + case 72 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 187 /* PropertyAccessExpression */) { + if (ex.kind === 189 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -54616,10 +55291,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 71 /* Identifier */ || - node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 9 /* StringLiteral */; + return node.kind === 72 /* Identifier */ || + node.kind === 189 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 190 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -54656,7 +55331,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 !== 241 /* EnumDeclaration */) { + if (declaration.kind !== 243 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -54679,8 +55354,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 238 /* ClassDeclaration */ || - (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 240 /* ClassDeclaration */ || + (declaration.kind === 239 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -54717,7 +55392,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 9 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -54743,7 +55418,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 240 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -54793,23 +55468,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -54820,12 +55495,12 @@ var ts; break; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 237 /* FunctionDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -54838,7 +55513,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -54846,17 +55521,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; } } @@ -54870,9 +55545,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 253 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -54905,14 +55580,14 @@ var ts; (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 255 /* ExportSpecifier */ ? + var message = node.kind === 257 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 255 /* ExportSpecifier */ + && node.kind === 257 /* ExportSpecifier */ && !(target.flags & 67220415 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -54939,7 +55614,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -54963,7 +55638,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 259 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67220415 /* Value */) { @@ -54999,10 +55674,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -55019,7 +55694,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -55048,8 +55723,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 === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -55062,7 +55737,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { markExportAsReferenced(node); if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); @@ -55137,7 +55812,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 239 /* FunctionDeclaration */ && declaration.kind !== 156 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -55155,158 +55830,158 @@ 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return checkTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return checkParameter(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return checkPropertyDeclaration(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return checkSignatureDeclaration(node); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return checkMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return checkConstructorDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return checkAccessorDeclaration(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return checkTypeReferenceNode(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return checkTypePredicate(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return checkTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return checkTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return checkArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return checkTupleType(node); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 175 /* ParenthesizedType */: - case 169 /* OptionalType */: - case 170 /* RestType */: + case 177 /* ParenthesizedType */: + case 171 /* OptionalType */: + case 172 /* RestType */: return checkSourceElement(node.type); - case 176 /* ThisType */: + case 178 /* ThisType */: return checkThisType(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return checkTypeOperator(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return checkConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return checkInferType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return checkImportType(node); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 287 /* JSDocFunctionType */: - checkSignatureDeclaration(node); + case 289 /* JSDocFunctionType */: + checkJSDocFunctionType(node); // falls through - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: - case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: + case 292 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 281 /* JSDocTypeExpression */: + case 283 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return checkMappedType(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return checkBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return checkVariableStatement(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return checkExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return checkIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return checkDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return checkWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return checkForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return checkForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkForOfStatement(node); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return checkReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return checkSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return checkThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return checkTryStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return checkBindingElement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return checkClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return checkImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return checkExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return checkExportAssignment(node); - case 218 /* EmptyStatement */: - case 234 /* DebuggerStatement */: + case 220 /* EmptyStatement */: + case 236 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -55397,23 +56072,23 @@ var ts; } links.deferredNodes.forEach(function (node) { switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 258 /* JsxElement */: + case 260 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -55450,6 +56125,7 @@ var ts; ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); ts.forEach(node.statements, checkSourceElement); + checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); if (ts.isExternalOrCommonJsModule(node)) { registerForUnusedIdentifiersCheck(node); @@ -55542,13 +56218,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) + break; + // falls through + case 244 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -55556,8 +56236,8 @@ var ts; // falls through // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* 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. @@ -55566,7 +56246,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -55608,17 +56288,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 71 /* Identifier */ && + return name.kind === 72 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 148 /* TypeParameter */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 150 /* TypeParameter */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -55626,16 +56306,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 162 /* TypeReference */; + return node.parent.kind === 164 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 187 /* PropertyAccessExpression */) { + while (node.parent.kind === 189 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 209 /* ExpressionWithTypeArguments */; + return node.parent.kind === 211 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -55663,13 +56343,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 148 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 248 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 254 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -55695,7 +56375,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 183 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -55705,7 +56385,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 187 /* PropertyAccessExpression */ && + entityName.parent.kind === 189 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -55713,7 +56393,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 254 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -55723,7 +56403,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 248 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -55741,7 +56421,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 211 /* ExpressionWithTypeArguments */) { meaning = 67897832 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -55757,10 +56437,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 297 /* JSDocParameterTag */) { + if (entityName.parent.kind === 299 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 301 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -55770,19 +56450,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 71 /* Identifier */) { + if (entityName.kind === 72 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 189 /* PropertyAccessExpression */ || entityName.kind === 148 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 187 /* PropertyAccessExpression */) { + if (entityName.kind === 189 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -55792,20 +56472,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 164 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 265 /* JsxAttribute */) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 161 /* TypePredicate */) { + if (entityName.parent.kind === 163 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -55821,12 +56498,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 184 /* BindingElement */ && - grandParent.kind === 182 /* ObjectBindingPattern */ && + else if (parent.kind === 186 /* BindingElement */ && + grandParent.kind === 184 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -55836,11 +56513,11 @@ var ts; } } switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -55852,29 +56529,32 @@ var ts; return checkExpression(node).symbol; } // falls through - case 176 /* ThisType */: + case 178 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkExpression(node).symbol; - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 157 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: + case 14 /* 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 === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 249 /* ImportDeclaration */ || node.parent.kind === 255 /* 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); } + if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) { + return getSymbolOfNode(parent); + } // falls through case 8 /* NumericLiteral */: // index access @@ -55884,19 +56564,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 79 /* DefaultKeyword */: - case 89 /* FunctionKeyword */: - case 36 /* EqualsGreaterThanToken */: - case 75 /* ClassKeyword */: + case 80 /* DefaultKeyword */: + case 90 /* FunctionKeyword */: + case 37 /* EqualsGreaterThanToken */: + case 76 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; + case 85 /* ExportKeyword */: + return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 276 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -55964,28 +56646,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 188 /* ObjectLiteralExpression */ || expr.kind === 187 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 225 /* ForOfStatement */) { + if (expr.parent.kind === 227 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 202 /* BinaryExpression */) { + if (expr.parent.kind === 204 /* 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 === 273 /* PropertyAssignment */) { + if (expr.parent.kind === 275 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 187 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -56021,14 +56703,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return getLiteralType(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: ts.Debug.fail("Unsupported property name."); return errorType; @@ -56083,7 +56765,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -56139,7 +56821,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* 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. @@ -56194,7 +56876,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 218 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -56235,18 +56917,18 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return node.expression - && node.expression.kind === 71 /* Identifier */ + && node.expression.kind === 72 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -56254,7 +56936,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -56281,7 +56963,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -56354,15 +57037,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 276 /* EnumMember */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 278 /* EnumMember */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 276 /* EnumMember */) { + if (node.kind === 278 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -56376,7 +57059,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. @@ -56413,22 +57096,25 @@ var ts; else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + return ts.TypeReferenceSerializationKind.BigIntLikeType; + } + else if (isTypeAssignableToKind(type, 132 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -56444,14 +57130,14 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* 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 */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 2048 /* UniqueESSymbol */ && + if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -56463,7 +57149,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56471,7 +57157,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56509,19 +57195,18 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } - function literalTypeToNode(type, enclosing) { - var enumResult = type.flags & 512 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing) + function literalTypeToNode(type, enclosing, tracker) { + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } - function createLiteralConstValue(node) { + function createLiteralConstValue(node, tracker) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return literalTypeToNode(type, node); + return literalTypeToNode(type, node, tracker); } function createResolver() { // this variable and functions that use it are deliberately moved here from the outer scope @@ -56594,12 +57279,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* SetAccessor */; + var otherKind = accessor.kind === 159 /* SetAccessor */ ? 158 /* GetAccessor */ : 159 /* 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 === 157 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 159 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 158 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -56615,7 +57300,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; + return node.parent && node.parent.kind === 211 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 273 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -56627,7 +57312,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 72 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 189 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -56678,7 +57363,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -56693,12 +57378,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 244 /* 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, 277 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -56876,14 +57561,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 154 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 156 /* 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 === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */) { + else if (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* 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); @@ -56900,23 +57585,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { + if (modifier.kind !== 133 /* ReadonlyKeyword */) { + if (node.kind === 153 /* PropertySignature */ || node.kind === 155 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 76 /* ConstKeyword */: - if (node.kind !== 241 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); + case 77 /* ConstKeyword */: + if (node.kind !== 243 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(77 /* ConstKeyword */)); } break; - case 114 /* PublicKeyword */: - case 113 /* ProtectedKeyword */: - case 112 /* PrivateKeyword */: + case 115 /* PublicKeyword */: + case 114 /* ProtectedKeyword */: + case 113 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -56930,11 +57615,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* 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 === 112 /* PrivateKeyword */) { + if (modifier.kind === 113 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -56943,7 +57628,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -56953,10 +57638,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -56965,18 +57650,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 132 /* ReadonlyKeyword */: + case 133 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { + else if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */ && node.kind !== 162 /* IndexSignature */ && node.kind !== 151 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -56989,52 +57674,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 79 /* DefaultKeyword */: - var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 80 /* DefaultKeyword */: + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 124 /* DeclareKeyword */: + case 125 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 245 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 117 /* AbstractKeyword */: + case 118 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 238 /* ClassDeclaration */) { - if (node.kind !== 154 /* MethodDeclaration */ && - node.kind !== 152 /* PropertyDeclaration */ && - node.kind !== 156 /* GetAccessor */ && - node.kind !== 157 /* SetAccessor */) { + if (node.kind !== 240 /* ClassDeclaration */) { + if (node.kind !== 156 /* MethodDeclaration */ && + node.kind !== 154 /* PropertyDeclaration */ && + node.kind !== 158 /* GetAccessor */ && + node.kind !== 159 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 240 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -57046,14 +57731,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -57061,7 +57746,7 @@ var ts; break; } } - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -57076,13 +57761,13 @@ var ts; } return false; } - else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 249 /* ImportDeclaration */ || node.kind === 248 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -57103,38 +57788,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 242 /* ModuleDeclaration */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 149 /* Parameter */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 244 /* ModuleDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 151 /* Parameter */: return false; default: - if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return false; } switch (node.kind) { - case 237 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 238 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 239 /* InterfaceDeclaration */: - case 217 /* VariableStatement */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AsyncKeyword */); + case 240 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 118 /* AbstractKeyword */); + case 241 /* InterfaceDeclaration */: + case 219 /* VariableStatement */: + case 242 /* TypeAliasDeclaration */: return true; - case 241 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); + case 243 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 77 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -57146,10 +57831,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -57267,12 +57952,12 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { + if (parameter.type.kind !== 138 /* StringKeyword */ && parameter.type.kind !== 135 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(getTypeFromTypeNode(node.type))); } - if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -57303,7 +57988,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 208 /* OmittedExpression */) { + if (arg.kind === 210 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -57333,7 +58018,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 === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -57346,7 +58031,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -57362,14 +58047,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -57380,20 +58065,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 147 /* ComputedPropertyName */) { + if (node.kind !== 149 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 204 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 237 /* FunctionDeclaration */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 154 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 239 /* FunctionDeclaration */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 156 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -57419,15 +58104,15 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */) { + if (prop.kind === 277 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 274 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 276 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -57436,7 +58121,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { + if (mod.kind !== 121 /* AsyncKeyword */ || prop.kind !== 156 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -57451,23 +58136,23 @@ 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 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); /* tslint:disable:no-switch-case-fall-through */ - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: @@ -57504,7 +58189,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 267 /* JsxSpreadAttribute */) { + if (attr.kind === 269 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -57514,7 +58199,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 270 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -57523,12 +58208,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 227 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 238 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -57543,20 +58228,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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); @@ -57583,11 +58268,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 158 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 157 /* SetAccessor */) { + else if (kind === 159 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -57611,23 +58296,23 @@ 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 === 156 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 141 /* UniqueKeyword */) { - if (node.type.kind !== 138 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(138 /* SymbolKeyword */)); + if (node.operator === 142 /* UniqueKeyword */) { + if (node.type.kind !== 139 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(139 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* 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)) { @@ -57637,13 +58322,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { 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 151 /* PropertySignature */: + case 153 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* 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); } @@ -57662,10 +58347,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 156 /* MethodDeclaration */) { + if (node.parent.kind === 188 /* 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 === 120 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 121 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -57691,14 +58376,14 @@ var ts; if (node.flags & 4194304 /* 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 === 154 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 156 /* 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 === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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 === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* 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); } } @@ -57709,11 +58394,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 231 /* LabeledStatement */: + case 233 /* 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 === 226 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 228 /* 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); @@ -57721,8 +58406,8 @@ var ts; return false; } break; - case 230 /* SwitchStatement */: - if (node.kind === 227 /* BreakStatement */ && !node.label) { + case 232 /* SwitchStatement */: + if (node.kind === 229 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -57737,13 +58422,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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 === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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); @@ -57766,34 +58451,43 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } + function isBigIntLiteralExpression(expr) { + return expr.kind === 9 /* BigIntLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.operand.kind === 9 /* BigIntLiteral */; + } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) - return !!(checkExpressionCached(expr).flags & 512 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); } function checkAmbientInitializer(node) { - if (node.initializer) { - var isInvalidInitializer = !(isStringOrNumberLiteralExpression(node.initializer) || isSimpleLiteralEnumReference(node.initializer) || node.initializer.kind === 101 /* TrueKeyword */ || node.initializer.kind === 86 /* FalseKeyword */); + var initializer = node.initializer; + if (initializer) { + var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || + isSimpleLiteralEnumReference(initializer) || + initializer.kind === 102 /* TrueKeyword */ || initializer.kind === 87 /* FalseKeyword */ || + isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { if (isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); + return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); } } else { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { + if (node.parent.parent.kind !== 226 /* ForInStatement */ && node.parent.parent.kind !== 227 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -57806,7 +58500,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 219 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -57823,7 +58517,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -57840,8 +58534,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 71 /* Identifier */) { - if (name.originalKeywordKind === 110 /* LetKeyword */) { + if (name.kind === 72 /* Identifier */) { + if (name.originalKeywordKind === 111 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -57868,15 +58562,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return false; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -57894,12 +58588,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 94 /* NewKeyword */: + case 95 /* 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 91 /* ImportKeyword */: + case 92 /* 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"); } @@ -57954,7 +58648,7 @@ var ts; return true; } } - else if (node.parent.kind === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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; } @@ -57962,7 +58656,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -57991,13 +58685,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 240 /* TypeAliasDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 253 /* ExportDeclaration */ || - node.kind === 252 /* ExportAssignment */ || - node.kind === 245 /* NamespaceExportDeclaration */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 242 /* TypeAliasDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 255 /* ExportDeclaration */ || + node.kind === 254 /* ExportAssignment */ || + node.kind === 247 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -58006,7 +58700,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 === 217 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 219 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -58033,7 +58727,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 === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -58055,20 +58749,32 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 182 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 278 /* 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 === 38 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } return false; } + function checkGrammarBigIntLiteral(node) { + var literalType = ts.isLiteralTypeNode(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); + if (!literalType) { + if (languageVersion < 6 /* ESNext */) { + if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ESNext)) { + return true; + } + } + } + return false; + } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -58113,8 +58819,8 @@ var ts; /** 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 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -58122,14 +58828,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 248 /* ImportClause */: // For default import - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: // For rename import `x as y` + case 250 /* ImportClause */: // For default import + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: // For rename import `x as y` return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 251 /* ImportSpecifier */; + return decl.parent.kind === 253 /* ImportSpecifier */; default: return false; } @@ -58149,7 +58855,7 @@ var ts; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function typeIsLiteralType(type) { - return !!(type.flags & 448 /* Literal */); + return !!(type.flags & 2944 /* Literal */); } })(ts || (ts = {})); var ts; @@ -58213,6 +58919,9 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt + return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); + } if (typeof value === "boolean") { return value ? createTrue() : createFalse(); } @@ -58232,14 +58941,20 @@ var ts; return node; } ts.createNumericLiteral = createNumericLiteral; + function createBigIntLiteral(value) { + var node = createSynthesizedNode(9 /* BigIntLiteral */); + node.text = value; + return node; + } + ts.createBigIntLiteral = createBigIntLiteral; function createStringLiteral(text) { - var node = createSynthesizedNode(9 /* StringLiteral */); + var node = createSynthesizedNode(10 /* StringLiteral */); node.text = text; return node; } ts.createStringLiteral = createStringLiteral; function createRegularExpressionLiteral(text) { - var node = createSynthesizedNode(12 /* RegularExpressionLiteral */); + var node = createSynthesizedNode(13 /* RegularExpressionLiteral */); node.text = text; return node; } @@ -58250,7 +58965,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(71 /* Identifier */); + var node = createSynthesizedNode(72 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -58331,23 +59046,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(97 /* SuperKeyword */); + return createSynthesizedNode(98 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(99 /* ThisKeyword */); + return createSynthesizedNode(100 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(95 /* NullKeyword */); + return createSynthesizedNode(96 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(101 /* TrueKeyword */); + return createSynthesizedNode(102 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(86 /* FalseKeyword */); + return createSynthesizedNode(87 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -58358,44 +59073,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(84 /* ExportKeyword */)); + result.push(createModifier(85 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(124 /* DeclareKeyword */)); + result.push(createModifier(125 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(79 /* DefaultKeyword */)); + result.push(createModifier(80 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(76 /* ConstKeyword */)); + result.push(createModifier(77 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(114 /* PublicKeyword */)); + result.push(createModifier(115 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(112 /* PrivateKeyword */)); + result.push(createModifier(113 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(113 /* ProtectedKeyword */)); + result.push(createModifier(114 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(117 /* AbstractKeyword */)); + result.push(createModifier(118 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(115 /* StaticKeyword */)); + result.push(createModifier(116 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(132 /* ReadonlyKeyword */)); + result.push(createModifier(133 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(120 /* AsyncKeyword */)); + result.push(createModifier(121 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(146 /* QualifiedName */); + var node = createSynthesizedNode(148 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -58414,7 +59129,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(147 /* ComputedPropertyName */); + var node = createSynthesizedNode(149 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -58427,7 +59142,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(148 /* TypeParameter */); + var node = createSynthesizedNode(150 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -58443,7 +59158,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(149 /* Parameter */); + var node = createSynthesizedNode(151 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -58467,7 +59182,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(150 /* Decorator */); + var node = createSynthesizedNode(152 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -58480,7 +59195,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertySignature */); + var node = createSynthesizedNode(153 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -58500,12 +59215,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(152 /* PropertyDeclaration */); + var node = createSynthesizedNode(154 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -58515,8 +59230,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -58524,7 +59239,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(155 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -58541,7 +59256,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(154 /* MethodDeclaration */); + var node = createSynthesizedNode(156 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -58569,7 +59284,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(155 /* Constructor */); + var node = createSynthesizedNode(157 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -58589,7 +59304,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(156 /* GetAccessor */); + var node = createSynthesizedNode(158 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58612,7 +59327,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(157 /* SetAccessor */); + var node = createSynthesizedNode(159 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58633,7 +59348,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(160 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -58641,7 +59356,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(161 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -58649,7 +59364,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(160 /* IndexSignature */); + var node = createSynthesizedNode(162 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -58689,7 +59404,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(161 /* TypePredicate */); + var node = createSynthesizedNode(163 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -58703,7 +59418,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(162 /* TypeReference */); + var node = createSynthesizedNode(164 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -58717,7 +59432,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -58725,7 +59440,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(166 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -58733,7 +59448,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(165 /* TypeQuery */); + var node = createSynthesizedNode(167 /* TypeQuery */); node.exprName = exprName; return node; } @@ -58745,7 +59460,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(166 /* TypeLiteral */); + var node = createSynthesizedNode(168 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -58757,7 +59472,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(167 /* ArrayType */); + var node = createSynthesizedNode(169 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -58769,7 +59484,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(168 /* TupleType */); + var node = createSynthesizedNode(170 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -58781,7 +59496,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(169 /* OptionalType */); + var node = createSynthesizedNode(171 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -58793,7 +59508,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(170 /* RestType */); + var node = createSynthesizedNode(172 /* RestType */); node.type = type; return node; } @@ -58805,7 +59520,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(173 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -58813,7 +59528,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(174 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -58832,7 +59547,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(173 /* ConditionalType */); + var node = createSynthesizedNode(175 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -58850,7 +59565,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(174 /* InferType */); + var node = createSynthesizedNode(176 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -58862,7 +59577,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(181 /* ImportType */); + var node = createSynthesizedNode(183 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -58880,7 +59595,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(175 /* ParenthesizedType */); + var node = createSynthesizedNode(177 /* ParenthesizedType */); node.type = type; return node; } @@ -58892,12 +59607,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(176 /* ThisType */); + return createSynthesizedNode(178 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(177 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; + var node = createSynthesizedNode(179 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 129 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -58907,7 +59622,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(178 /* IndexedAccessType */); + var node = createSynthesizedNode(180 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -58921,7 +59636,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(179 /* MappedType */); + var node = createSynthesizedNode(181 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -58939,7 +59654,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(180 /* LiteralType */); + var node = createSynthesizedNode(182 /* LiteralType */); node.literal = literal; return node; } @@ -58952,7 +59667,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(182 /* ObjectBindingPattern */); + var node = createSynthesizedNode(184 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58964,7 +59679,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(183 /* ArrayBindingPattern */); + var node = createSynthesizedNode(185 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58976,7 +59691,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(184 /* BindingElement */); + var node = createSynthesizedNode(186 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -58995,7 +59710,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(187 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -59009,7 +59724,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(188 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -59023,7 +59738,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(187 /* PropertyAccessExpression */); + var node = createSynthesizedNode(189 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -59040,7 +59755,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(188 /* ElementAccessExpression */); + var node = createSynthesizedNode(190 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -59054,7 +59769,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(189 /* CallExpression */); + var node = createSynthesizedNode(191 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -59070,7 +59785,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(190 /* NewExpression */); + var node = createSynthesizedNode(192 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -59086,7 +59801,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(193 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -59109,7 +59824,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(192 /* TypeAssertionExpression */); + var node = createSynthesizedNode(194 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -59123,7 +59838,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(193 /* ParenthesizedExpression */); + var node = createSynthesizedNode(195 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -59135,7 +59850,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(194 /* FunctionExpression */); + var node = createSynthesizedNode(196 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -59159,12 +59874,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(195 /* ArrowFunction */); + var node = createSynthesizedNode(197 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -59181,7 +59896,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(196 /* DeleteExpression */); + var node = createSynthesizedNode(198 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59193,7 +59908,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(197 /* TypeOfExpression */); + var node = createSynthesizedNode(199 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59205,7 +59920,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(198 /* VoidExpression */); + var node = createSynthesizedNode(200 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59217,7 +59932,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(199 /* AwaitExpression */); + var node = createSynthesizedNode(201 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59229,7 +59944,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(202 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -59242,7 +59957,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(203 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -59255,7 +59970,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(202 /* BinaryExpression */); + var node = createSynthesizedNode(204 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -59272,11 +59987,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(203 /* ConditionalExpression */); + var node = createSynthesizedNode(205 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(56 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -59292,7 +60007,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(204 /* TemplateExpression */); + var node = createSynthesizedNode(206 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -59306,33 +60021,33 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createTemplateHead(text) { - var node = createSynthesizedNode(14 /* TemplateHead */); + var node = createSynthesizedNode(15 /* TemplateHead */); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; function createTemplateMiddle(text) { - var node = createSynthesizedNode(15 /* TemplateMiddle */); + var node = createSynthesizedNode(16 /* TemplateMiddle */); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; function createTemplateTail(text) { - var node = createSynthesizedNode(16 /* TemplateTail */); + var node = createSynthesizedNode(17 /* TemplateTail */); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(13 /* NoSubstitutionTemplateLiteral */); + var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); node.text = text; return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(205 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(207 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -59344,7 +60059,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(206 /* SpreadElement */); + var node = createSynthesizedNode(208 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -59356,7 +60071,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(207 /* ClassExpression */); + var node = createSynthesizedNode(209 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59377,11 +60092,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(208 /* OmittedExpression */); + return createSynthesizedNode(210 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(211 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -59395,7 +60110,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(210 /* AsExpression */); + var node = createSynthesizedNode(212 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -59409,7 +60124,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(211 /* NonNullExpression */); + var node = createSynthesizedNode(213 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -59421,7 +60136,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(212 /* MetaProperty */); + var node = createSynthesizedNode(214 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -59435,7 +60150,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(214 /* TemplateSpan */); + var node = createSynthesizedNode(216 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -59449,12 +60164,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(215 /* SemicolonClassElement */); + return createSynthesizedNode(217 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(216 /* Block */); + var block = createSynthesizedNode(218 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -59468,7 +60183,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(217 /* VariableStatement */); + var node = createSynthesizedNode(219 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -59483,11 +60198,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(218 /* EmptyStatement */); + return createSynthesizedNode(220 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(219 /* ExpressionStatement */); + var node = createSynthesizedNode(221 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -59503,7 +60218,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(220 /* IfStatement */); + var node = createSynthesizedNode(222 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -59519,7 +60234,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(221 /* DoStatement */); + var node = createSynthesizedNode(223 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -59533,7 +60248,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(222 /* WhileStatement */); + var node = createSynthesizedNode(224 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -59547,7 +60262,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(223 /* ForStatement */); + var node = createSynthesizedNode(225 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -59565,7 +60280,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(224 /* ForInStatement */); + var node = createSynthesizedNode(226 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -59581,7 +60296,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(225 /* ForOfStatement */); + var node = createSynthesizedNode(227 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -59599,7 +60314,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(226 /* ContinueStatement */); + var node = createSynthesizedNode(228 /* ContinueStatement */); node.label = asName(label); return node; } @@ -59611,7 +60326,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(227 /* BreakStatement */); + var node = createSynthesizedNode(229 /* BreakStatement */); node.label = asName(label); return node; } @@ -59623,7 +60338,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(228 /* ReturnStatement */); + var node = createSynthesizedNode(230 /* ReturnStatement */); node.expression = expression; return node; } @@ -59635,7 +60350,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(229 /* WithStatement */); + var node = createSynthesizedNode(231 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -59649,7 +60364,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(230 /* SwitchStatement */); + var node = createSynthesizedNode(232 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -59663,7 +60378,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(231 /* LabeledStatement */); + var node = createSynthesizedNode(233 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -59677,7 +60392,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(232 /* ThrowStatement */); + var node = createSynthesizedNode(234 /* ThrowStatement */); node.expression = expression; return node; } @@ -59689,7 +60404,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(233 /* TryStatement */); + var node = createSynthesizedNode(235 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -59705,11 +60420,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(234 /* DebuggerStatement */); + return createSynthesizedNode(236 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(235 /* VariableDeclaration */); + var node = createSynthesizedNode(237 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -59726,7 +60441,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(236 /* VariableDeclarationList */); + var node = createSynthesizedNode(238 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -59739,7 +60454,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(237 /* FunctionDeclaration */); + var node = createSynthesizedNode(239 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -59765,7 +60480,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(238 /* ClassDeclaration */); + var node = createSynthesizedNode(240 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59787,7 +60502,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(239 /* InterfaceDeclaration */); + var node = createSynthesizedNode(241 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59809,7 +60524,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(242 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59829,7 +60544,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(241 /* EnumDeclaration */); + var node = createSynthesizedNode(243 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59848,7 +60563,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(242 /* ModuleDeclaration */); + var node = createSynthesizedNode(244 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -59867,7 +60582,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(243 /* ModuleBlock */); + var node = createSynthesizedNode(245 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -59879,7 +60594,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(244 /* CaseBlock */); + var node = createSynthesizedNode(246 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -59891,7 +60606,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(247 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -59903,7 +60618,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(248 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59921,7 +60636,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(247 /* ImportDeclaration */); + var node = createSynthesizedNode(249 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -59939,7 +60654,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(248 /* ImportClause */); + var node = createSynthesizedNode(250 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -59953,7 +60668,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(249 /* NamespaceImport */); + var node = createSynthesizedNode(251 /* NamespaceImport */); node.name = name; return node; } @@ -59965,7 +60680,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(250 /* NamedImports */); + var node = createSynthesizedNode(252 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -59977,7 +60692,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ImportSpecifier */); + var node = createSynthesizedNode(253 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -59991,11 +60706,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(252 /* ExportAssignment */); + var node = createSynthesizedNode(254 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(58 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(59 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -60008,7 +60723,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(253 /* ExportDeclaration */); + var node = createSynthesizedNode(255 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -60026,7 +60741,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(254 /* NamedExports */); + var node = createSynthesizedNode(256 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -60038,7 +60753,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(255 /* ExportSpecifier */); + var node = createSynthesizedNode(257 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -60053,7 +60768,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(257 /* ExternalModuleReference */); + var node = createSynthesizedNode(259 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -60064,9 +60779,57 @@ var ts; : node; } ts.updateExternalModuleReference = updateExternalModuleReference; + // JSDoc + /* @internal */ + function createJSDocTypeExpression(type) { + var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + node.type = type; + return node; + } + ts.createJSDocTypeExpression = createJSDocTypeExpression; + /* @internal */ + function createJSDocTypeTag(typeExpression, comment) { + var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocTypeTag = createJSDocTypeTag; + /* @internal */ + function createJSDocReturnTag(typeExpression, comment) { + var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocReturnTag = createJSDocReturnTag; + /* @internal */ + function createJSDocParamTag(name, isBracketed, typeExpression, comment) { + var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + tag.typeExpression = typeExpression; + tag.name = name; + tag.isBracketed = isBracketed; + tag.comment = comment; + return tag; + } + ts.createJSDocParamTag = createJSDocParamTag; + /* @internal */ + function createJSDocComment(comment, tags) { + var node = createSynthesizedNode(291 /* JSDocComment */); + node.comment = comment; + node.tags = tags; + return node; + } + ts.createJSDocComment = createJSDocComment; + /* @internal */ + function createJSDocTag(kind, tagName) { + var node = createSynthesizedNode(kind); + node.tagName = createIdentifier(tagName); + return node; + } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(258 /* JsxElement */); + var node = createSynthesizedNode(260 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -60082,7 +60845,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(261 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60098,7 +60861,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(260 /* JsxOpeningElement */); + var node = createSynthesizedNode(262 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60114,7 +60877,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(261 /* JsxClosingElement */); + var node = createSynthesizedNode(263 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -60126,7 +60889,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(262 /* JsxFragment */); + var node = createSynthesizedNode(264 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -60142,7 +60905,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(265 /* JsxAttribute */); + var node = createSynthesizedNode(267 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -60156,7 +60919,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(266 /* JsxAttributes */); + var node = createSynthesizedNode(268 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -60168,7 +60931,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(269 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -60180,7 +60943,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(268 /* JsxExpression */); + var node = createSynthesizedNode(270 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -60194,7 +60957,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(269 /* CaseClause */); + var node = createSynthesizedNode(271 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -60208,7 +60971,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(270 /* DefaultClause */); + var node = createSynthesizedNode(272 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -60220,7 +60983,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(271 /* HeritageClause */); + var node = createSynthesizedNode(273 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -60233,7 +60996,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(272 /* CatchClause */); + var node = createSynthesizedNode(274 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -60248,7 +61011,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(273 /* PropertyAssignment */); + var node = createSynthesizedNode(275 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -60263,7 +61026,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(276 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -60277,7 +61040,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(275 /* SpreadAssignment */); + var node = createSynthesizedNode(277 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -60290,7 +61053,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(276 /* EnumMember */); + var node = createSynthesizedNode(278 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -60311,7 +61074,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(277 /* SourceFile */); + var updated = createSynthesizedNode(279 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -60395,7 +61158,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(305 /* NotEmittedStatement */); + var node = createSynthesizedNode(307 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -60407,7 +61170,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(309 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60419,7 +61182,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(308 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60434,7 +61197,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(306 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -60450,17 +61213,17 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 307 /* CommaListExpression */) { + if (node.kind === 309 /* CommaListExpression */) { return node.elements; } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { return [node.left, node.right]; } } return node; } function createCommaList(elements) { - var node = createSynthesizedNode(307 /* CommaListExpression */); + var node = createSynthesizedNode(309 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -60473,14 +61236,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(278 /* Bundle */); + var node = ts.createNode(280 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(279 /* UnparsedSource */); + var node = ts.createNode(281 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -60488,7 +61251,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(280 /* InputFiles */); + var node = ts.createNode(282 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -60530,47 +61293,47 @@ var ts; } ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { - return createBinary(left, 26 /* CommaToken */, right); + return createBinary(left, 27 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 27 /* LessThanToken */, right); + return createBinary(left, 28 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 58 /* EqualsToken */, right); + return createBinary(left, 59 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 34 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 35 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 37 /* PlusToken */, right); + return createBinary(left, 38 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 38 /* MinusToken */, right); + return createBinary(left, 39 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 43 /* PlusPlusToken */); + return createPostfix(operand, 44 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 53 /* AmpersandAmpersandToken */, right); + return createBinary(left, 54 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 54 /* BarBarToken */, right); + return createBinary(left, 55 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(51 /* ExclamationToken */, operand); + return createPrefix(52 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -60631,7 +61394,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 === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -61142,7 +61905,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 233 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -61154,19 +61917,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return cacheIdentifiers; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: return false; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -61181,7 +61945,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 97 /* SuperKeyword */) { + else if (callee.kind === 98 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -61193,7 +61957,7 @@ var ts; } else { switch (callee.kind) { - case 187 /* PropertyAccessExpression */: { + case 189 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61206,7 +61970,7 @@ var ts; } break; } - case 188 /* ElementAccessExpression */: { + case 190 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61263,14 +62027,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -61278,7 +62042,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_9 = []; + var properties_8 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -61289,7 +62053,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_9.push(getter); + properties_8.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -61301,15 +62065,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_9.push(setter); + properties_8.push(setter); } - properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_9, multiLine) + ts.createObjectLiteral(properties_8, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -61596,7 +62360,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 === 193 /* ParenthesizedExpression */) { + if (skipped.kind === 195 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -61630,10 +62394,10 @@ 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(202 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(204 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 195 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 197 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -61645,7 +62409,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 205 /* YieldExpression */) { + && operand.kind === 207 /* YieldExpression */) { return false; } return true; @@ -61682,7 +62446,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 37 /* PlusToken */) { + if (binaryOperator === 38 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -61717,10 +62481,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 === 39 /* AsteriskToken */ - || binaryOperator === 49 /* BarToken */ - || binaryOperator === 48 /* AmpersandToken */ - || binaryOperator === 50 /* CaretToken */; + return binaryOperator === 40 /* AsteriskToken */ + || binaryOperator === 50 /* BarToken */ + || binaryOperator === 49 /* AmpersandToken */ + || binaryOperator === 51 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -61733,7 +62497,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -61748,7 +62512,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(205 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -61783,8 +62547,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: needsParens = true; } } @@ -61800,9 +62564,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.createParen(expression); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -61825,7 +62589,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 192 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -61863,7 +62627,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -61874,29 +62638,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { + if (kind === 196 /* FunctionExpression */ || kind === 197 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { + if (leftmostExpressionKind === 188 /* ObjectLiteralExpression */ || leftmostExpressionKind === 196 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 175 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -61904,9 +62668,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 174 /* InferType */: + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 176 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -61932,28 +62696,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: node = node.operand; continue; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: node = node.left; continue; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: node = node.condition; continue; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: node = node.tag; continue; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 210 /* AsExpression */: - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: - case 211 /* NonNullExpression */: - case 306 /* PartiallyEmittedExpression */: + case 212 /* AsExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 213 /* NonNullExpression */: + case 308 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -61961,15 +62725,15 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 188 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || - node.kind === 307 /* CommaListExpression */; + return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 309 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -61982,13 +62746,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 211 /* NonNullExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -62013,7 +62777,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 213 /* NonNullExpression */) { node = node.expression; } return node; @@ -62021,11 +62785,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 306 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 195 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -62043,7 +62807,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 193 /* ParenthesizedExpression */ + return node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -62108,10 +62872,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 249 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 255 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -62127,7 +62891,7 @@ var ts; */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 - if (moduleName.kind === 9 /* StringLiteral */) { + if (moduleName.kind === 10 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) || ts.getSynthesizedClone(moduleName); @@ -62230,7 +62994,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -62242,11 +63006,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -62278,12 +63042,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 151 /* Parameter */: + case 186 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 206 /* SpreadElement */: - case 275 /* SpreadAssignment */: + case 208 /* SpreadElement */: + case 277 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -62295,7 +63059,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 184 /* BindingElement */: + case 186 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -62307,7 +63071,7 @@ var ts; : propertyName; } break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -62319,7 +63083,7 @@ var ts; : propertyName; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -62334,7 +63098,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ + return kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */; } /** @@ -62342,13 +63106,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -62388,11 +63152,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -62553,276 +63317,276 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */) || kind === 178 /* ThisType */) { return node; } switch (kind) { // Names - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 150 /* Decorator */: + case 152 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 155 /* Constructor */: + case 157 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 168 /* TupleType */: + case 170 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 170 /* RestType */: + case 172 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 171 /* UnionType */: + case 173 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 174 /* InferType */: + case 176 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 179 /* MappedType */: + case 181 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 216 /* Block */: + case 218 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -62864,58 +63628,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { + if ((kind >= 163 /* TypePredicate */ && kind <= 182 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 215 /* SemicolonClassElement */: - case 218 /* EmptyStatement */: - case 208 /* OmittedExpression */: - case 234 /* DebuggerStatement */: - case 305 /* NotEmittedStatement */: + case 217 /* SemicolonClassElement */: + case 220 /* EmptyStatement */: + case 210 /* OmittedExpression */: + case 236 /* DebuggerStatement */: + case 307 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 149 /* Parameter */: + case 151 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 150 /* Decorator */: + case 152 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62924,12 +63688,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* Constructor */: + case 157 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62937,7 +63701,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62945,49 +63709,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 190 /* NewExpression */: + case 192 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -62995,123 +63760,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ParenthesizedExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 210 /* AsExpression */: + case 212 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 216 /* Block */: + case 218 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 222 /* WhileStatement */: - case 229 /* WithStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63120,7 +63885,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63128,139 +63893,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); + result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -63333,7 +64099,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 211 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -63383,7 +64149,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -63420,288 +64186,623 @@ var ts; /* @internal */ var ts; (function (ts) { - function createSourceFileLikeCache(host) { - var cached = ts.createMap(); + function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) { + var _a = generatorOptions.extendedDiagnostics + ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap") + : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit; + // Current source map file and its index in the sources list + var rawSources = []; + var sources = []; + var sourceToSourceIndexMap = ts.createMap(); + var sourcesContent; + var names = []; + var nameToNameIndexMap; + var mappings = ""; + // Last recorded and encoded mappings + var lastGeneratedLine = 0; + var lastGeneratedCharacter = 0; + var lastSourceIndex = 0; + var lastSourceLine = 0; + var lastSourceCharacter = 0; + var lastNameIndex = 0; + var hasLast = false; + var pendingGeneratedLine = 0; + var pendingGeneratedCharacter = 0; + var pendingSourceIndex = 0; + var pendingSourceLine = 0; + var pendingSourceCharacter = 0; + var pendingNameIndex = 0; + var hasPending = false; + var hasPendingSource = false; + var hasPendingName = false; return { - get: function (path) { - if (cached.has(path)) { - return cached.get(path); + getSources: function () { return rawSources; }, + addSource: addSource, + setSourceContent: setSourceContent, + addName: addName, + addMapping: addMapping, + appendSourceMap: appendSourceMap, + toJSON: toJSON, + toString: function () { return JSON.stringify(toJSON()); } + }; + function addSource(fileName) { + enter(); + var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + var sourceIndex = sourceToSourceIndexMap.get(source); + if (sourceIndex === undefined) { + sourceIndex = sources.length; + sources.push(source); + rawSources.push(fileName); + sourceToSourceIndexMap.set(source, sourceIndex); + } + exit(); + return sourceIndex; + } + function setSourceContent(sourceIndex, content) { + enter(); + if (content !== null) { + if (!sourcesContent) + sourcesContent = []; + while (sourcesContent.length < sourceIndex) { + // tslint:disable-next-line:no-null-keyword boolean-trivia + sourcesContent.push(null); } - if (!host.fileExists || !host.readFile || !host.fileExists(path)) - return; - // And failing that, check the disk - var text = host.readFile(path); // TODO: GH#18217 - var file = { - text: text, - lineMap: undefined, - getLineAndCharacterOfPosition: function (pos) { - return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + sourcesContent[sourceIndex] = content; + } + exit(); + } + function addName(name) { + enter(); + if (!nameToNameIndexMap) + nameToNameIndexMap = ts.createMap(); + var nameIndex = nameToNameIndexMap.get(name); + if (nameIndex === undefined) { + nameIndex = names.length; + names.push(name); + nameToNameIndexMap.set(name, nameIndex); + } + exit(); + return nameIndex; + } + function isNewGeneratedPosition(generatedLine, generatedCharacter) { + return !hasPending + || pendingGeneratedLine !== generatedLine + || pendingGeneratedCharacter !== generatedCharacter; + } + function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) { + return sourceIndex !== undefined + && sourceLine !== undefined + && sourceCharacter !== undefined + && pendingSourceIndex === sourceIndex + && (pendingSourceLine > sourceLine + || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter); + } + function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) { + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative"); + ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative"); + ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative"); + enter(); + // If this location wasn't recorded or the location in source is going backwards, record the mapping + if (isNewGeneratedPosition(generatedLine, generatedCharacter) || + isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) { + commitPendingMapping(); + pendingGeneratedLine = generatedLine; + pendingGeneratedCharacter = generatedCharacter; + hasPendingSource = false; + hasPendingName = false; + hasPending = true; + } + if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) { + pendingSourceIndex = sourceIndex; + pendingSourceLine = sourceLine; + pendingSourceCharacter = sourceCharacter; + hasPendingSource = true; + if (nameIndex !== undefined) { + pendingNameIndex = nameIndex; + hasPendingName = true; + } + } + exit(); + } + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + var _a; + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + enter(); + // First, decode the old component sourcemap + var sourceIndexToNewSourceIndexMap = []; + var nameIndexToNewNameIndexMap; + var mappingIterator = decodeMappings(map.mappings); + for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + // Then reencode all the updated mappings into the overall map + var newSourceIndex = void 0; + var newSourceLine = void 0; + var newSourceCharacter = void 0; + var newNameIndex = void 0; + if (raw.sourceIndex !== undefined) { + newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex]; + if (newSourceIndex === undefined) { + // Apply offsets to each position and fixup source entries + var rawPath = map.sources[raw.sourceIndex]; + var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath); + sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath); + if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") { + setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]); + } } - }; - cached.set(path, file); - return file; + newSourceLine = raw.sourceLine; + newSourceCharacter = raw.sourceCharacter; + if (map.names && raw.nameIndex !== undefined) { + if (!nameIndexToNewNameIndexMap) + nameIndexToNewNameIndexMap = []; + newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex]; + if (newNameIndex === undefined) { + nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]); + } + } + } + var newGeneratedLine = raw.generatedLine + generatedLine; + var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); + } + exit(); + } + function shouldCommitMapping() { + return !hasLast + || lastGeneratedLine !== pendingGeneratedLine + || lastGeneratedCharacter !== pendingGeneratedCharacter + || lastSourceIndex !== pendingSourceIndex + || lastSourceLine !== pendingSourceLine + || lastSourceCharacter !== pendingSourceCharacter + || lastNameIndex !== pendingNameIndex; + } + function commitPendingMapping() { + if (!hasPending || !shouldCommitMapping()) { + return; + } + enter(); + // Line/Comma delimiters + if (lastGeneratedLine < pendingGeneratedLine) { + // Emit line delimiters + do { + mappings += ";"; + lastGeneratedLine++; + lastGeneratedCharacter = 0; + } while (lastGeneratedLine < pendingGeneratedLine); + } + else { + ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); + // Emit comma to separate the entry + if (hasLast) { + mappings += ","; + } + } + // 1. Relative generated character + mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + lastGeneratedCharacter = pendingGeneratedCharacter; + if (hasPendingSource) { + // 2. Relative sourceIndex + mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + lastSourceIndex = pendingSourceIndex; + // 3. Relative source line + mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + lastSourceLine = pendingSourceLine; + // 4. Relative source character + mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + lastSourceCharacter = pendingSourceCharacter; + if (hasPendingName) { + // 5. Relative nameIndex + mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + lastNameIndex = pendingNameIndex; + } + } + hasLast = true; + exit(); + } + function toJSON() { + commitPendingMapping(); + return { + version: 3, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings, + sourcesContent: sourcesContent, + }; + } + } + ts.createSourceMapGenerator = createSourceMapGenerator; + // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + /** + * Tries to find the sourceMappingURL comment at the end of a file. + * @param text The source text of the file. + * @param lineStarts The line starts of the file. + */ + function tryGetSourceMappingURL(text, lineStarts) { + if (lineStarts === void 0) { lineStarts = ts.computeLineStarts(text); } + for (var index = lineStarts.length - 1; index >= 0; index--) { + var line = text.substring(lineStarts[index], lineStarts[index + 1]); + var comment = sourceMapCommentRegExp.exec(line); + if (comment) { + return comment[1]; + } + // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!line.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + function isStringOrNull(x) { + // tslint:disable-next-line:no-null-keyword + return typeof x === "string" || x === null; + } + function isRawSourceMap(x) { + // tslint:disable-next-line:no-null-keyword + return x !== null + && typeof x === "object" + && x.version === 3 + && typeof x.file === "string" + && typeof x.mappings === "string" + && ts.isArray(x.sources) && ts.every(x.sources, ts.isString) + && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string") + && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull)) + && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); + } + ts.isRawSourceMap = isRawSourceMap; + function tryParseRawSourceMap(text) { + try { + var parsed = JSON.parse(text); + if (isRawSourceMap(parsed)) { + return parsed; + } + } + catch (_a) { + // empty + } + return undefined; + } + ts.tryParseRawSourceMap = tryParseRawSourceMap; + function decodeMappings(mappings) { + var done = false; + var pos = 0; + var generatedLine = 0; + var generatedCharacter = 0; + var sourceIndex = 0; + var sourceLine = 0; + var sourceCharacter = 0; + var nameIndex = 0; + var error; + return { + get pos() { return pos; }, + get error() { return error; }, + get state() { return captureMapping(/*hasSource*/ true, /*hasName*/ true); }, + next: function () { + while (!done && pos < mappings.length) { + var ch = mappings.charCodeAt(pos); + if (ch === 59 /* semicolon */) { + // new line + generatedLine++; + generatedCharacter = 0; + pos++; + continue; + } + if (ch === 44 /* comma */) { + // Next entry is on same line - no action needed + pos++; + continue; + } + var hasSource = false; + var hasName = false; + generatedCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (generatedCharacter < 0) + return setErrorAndStopIterating("Invalid generatedCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasSource = true; + sourceIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceIndex < 0) + return setErrorAndStopIterating("Invalid sourceIndex found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex"); + sourceLine += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceLine < 0) + return setErrorAndStopIterating("Invalid sourceLine found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine"); + sourceCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceCharacter < 0) + return setErrorAndStopIterating("Invalid sourceCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasName = true; + nameIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (nameIndex < 0) + return setErrorAndStopIterating("Invalid nameIndex found"); + if (!isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex"); + } + } + return { value: captureMapping(hasSource, hasName), done: done }; + } + return stopIterating(); } }; + function captureMapping(hasSource, hasName) { + return { + generatedLine: generatedLine, + generatedCharacter: generatedCharacter, + sourceIndex: hasSource ? sourceIndex : undefined, + sourceLine: hasSource ? sourceLine : undefined, + sourceCharacter: hasSource ? sourceCharacter : undefined, + nameIndex: hasName ? nameIndex : undefined + }; + } + function stopIterating() { + done = true; + return { value: undefined, done: true }; + } + function setError(message) { + if (error === undefined) { + error = message; + } + } + function setErrorAndStopIterating(message) { + setError(message); + return stopIterating(); + } + function hasReportedError() { + return error !== undefined; + } + function isSourceMappingSegmentEnd() { + return (pos === mappings.length || + mappings.charCodeAt(pos) === 44 /* comma */ || + mappings.charCodeAt(pos) === 59 /* semicolon */); + } + function base64VLQFormatDecode() { + var moreDigits = true; + var shiftCount = 0; + var value = 0; + for (; moreDigits; pos++) { + if (pos >= mappings.length) + return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1; + // 6 digit number + var currentByte = base64FormatDecode(mappings.charCodeAt(pos)); + if (currentByte === -1) + return setError("Invalid character in VLQ"), -1; + // If msb is set, we still have more bits to continue + moreDigits = (currentByte & 32) !== 0; + // least significant 5 bits are the next msbs in the final value. + value = value | ((currentByte & 31) << shiftCount); + shiftCount += 5; + } + // Least significant bit if 1 represents negative and rest of the msb is actual absolute value + if ((value & 1) === 0) { + // + number + value = value >> 1; + } + else { + // - number + value = value >> 1; + value = -value; + } + return value; + } } - ts.createSourceFileLikeCache = createSourceFileLikeCache; -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - var sourcemaps; - (function (sourcemaps) { - sourcemaps.identitySourceMapper = { getOriginalPosition: ts.identity, getGeneratedPosition: ts.identity }; - function decode(host, mapPath, map, program, fallbackCache) { - if (fallbackCache === void 0) { fallbackCache = ts.createSourceFileLikeCache(host); } - var currentDirectory = ts.getDirectoryPath(mapPath); - var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory; - var decodedMappings; - var generatedOrderedMappings; - var sourceOrderedMappings; - return { - getOriginalPosition: getOriginalPosition, - getGeneratedPosition: getGeneratedPosition - }; - function getGeneratedPosition(loc) { - var maps = getSourceOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { sourcePath: loc.fileName, sourcePosition: loc.position }, ts.identity, compareProcessedPositionSourcePositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - if (!maps[targetIndex] || ts.comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot) !== 0) { - return loc; - } - return { fileName: ts.toPath(map.file, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].emittedPosition }; // Closest pos - } - function getOriginalPosition(loc) { - var maps = getGeneratedOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { emittedPosition: loc.position }, ts.identity, compareProcessedPositionEmittedPositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - return { fileName: ts.toPath(maps[targetIndex].sourcePath, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].sourcePosition }; // Closest pos - } - function getSourceFileLike(fileName, location) { - // Lookup file in program, if provided - var path = ts.toPath(fileName, location, host.getCanonicalFileName); - var file = program && program.getSourceFile(path); - // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file - if (!file || file.resolvedPath !== path) { - // Otherwise check the cache (which may hit disk) - return fallbackCache.get(path); - } - return file; - } - function getPositionOfLineAndCharacterUsingName(fileName, directory, line, character) { - var file = getSourceFileLike(fileName, directory); - if (!file) { - return -1; - } - return ts.getPositionOfLineAndCharacter(file, line, character); - } - function getDecodedMappings() { - return decodedMappings || (decodedMappings = calculateDecodedMappings(map, processPosition, host)); - } - function getSourceOrderedMappings() { - return sourceOrderedMappings || (sourceOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionSourcePositions)); - } - function getGeneratedOrderedMappings() { - return generatedOrderedMappings || (generatedOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionEmittedPositions)); - } - function compareProcessedPositionSourcePositions(a, b) { - return ts.comparePaths(a.sourcePath, b.sourcePath, sourceRoot) || - ts.compareValues(a.sourcePosition, b.sourcePosition); - } - function compareProcessedPositionEmittedPositions(a, b) { - return ts.compareValues(a.emittedPosition, b.emittedPosition); - } - function processPosition(position) { - var sourcePath = map.sources[position.sourceIndex]; - return { - emittedPosition: getPositionOfLineAndCharacterUsingName(map.file, currentDirectory, position.emittedLine, position.emittedColumn), - sourcePosition: getPositionOfLineAndCharacterUsingName(sourcePath, sourceRoot, position.sourceLine, position.sourceColumn), - sourcePath: sourcePath, - }; - } + ts.decodeMappings = decodeMappings; + function sameMapping(left, right) { + return left === right + || left.generatedLine === right.generatedLine + && left.generatedCharacter === right.generatedCharacter + && left.sourceIndex === right.sourceIndex + && left.sourceLine === right.sourceLine + && left.sourceCharacter === right.sourceCharacter + && left.nameIndex === right.nameIndex; + } + ts.sameMapping = sameMapping; + function isSourceMapping(mapping) { + return mapping.sourceIndex !== undefined + && mapping.sourceLine !== undefined + && mapping.sourceCharacter !== undefined; + } + 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 */ : + ts.Debug.fail(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 : + -1; + } + function base64VLQFormatEncode(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; } - sourcemaps.decode = decode; - /*@internal*/ - function decodeMappings(map) { - var state = { - encodedText: map.mappings, - currentNameIndex: undefined, - sourceMapNamesLength: map.names ? map.names.length : undefined, - currentEmittedColumn: 0, - currentEmittedLine: 0, - currentSourceColumn: 0, - currentSourceLine: 0, - currentSourceIndex: 0, - decodingIndex: 0 - }; - function captureSpan() { - return { - emittedColumn: state.currentEmittedColumn, - emittedLine: state.currentEmittedLine, - sourceColumn: state.currentSourceColumn, - sourceIndex: state.currentSourceIndex, - sourceLine: state.currentSourceLine, - nameIndex: state.currentNameIndex - }; + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + return encodedStr; + } + function isSourceMappedPosition(value) { + return value.sourceIndex !== undefined + && value.sourcePosition !== undefined; + } + function sameMappedPosition(left, right) { + return left.generatedPosition === right.generatedPosition + && left.sourceIndex === right.sourceIndex + && left.sourcePosition === right.sourcePosition; + } + function compareSourcePositions(left, right) { + return ts.compareValues(left.sourceIndex, right.sourceIndex); + } + function compareGeneratedPositions(left, right) { + return ts.compareValues(left.generatedPosition, right.generatedPosition); + } + function getSourcePositionOfMapping(value) { + return value.sourcePosition; + } + function getGeneratedPositionOfMapping(value) { + return value.generatedPosition; + } + function createDocumentPositionMapper(host, map, mapPath) { + var mapDirectory = ts.getDirectoryPath(mapPath); + var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory; + var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory); + var generatedCanonicalFilePath = host.getCanonicalFileName(generatedAbsoluteFilePath); + var generatedFile = host.getSourceFileLike(generatedCanonicalFilePath); + var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); }); + var sourceFileCanonicalPaths = sourceFileAbsolutePaths.map(function (source) { return host.getCanonicalFileName(source); }); + var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileCanonicalPaths.map(function (source, i) { return [source, i]; })); + var decodedMappings; + var generatedMappings; + var sourceMappings; + return { + getSourcePosition: getSourcePosition, + getGeneratedPosition: getGeneratedPosition + }; + function processMapping(mapping) { + var generatedPosition = generatedFile !== undefined + ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter) + : -1; + var source; + var sourcePosition; + if (isSourceMapping(mapping)) { + var sourceFilePath = sourceFileCanonicalPaths[mapping.sourceIndex]; + var sourceFile = host.getSourceFileLike(sourceFilePath); + source = map.sources[mapping.sourceIndex]; + sourcePosition = sourceFile !== undefined + ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter) + : -1; } return { - get decodingIndex() { return state.decodingIndex; }, - get error() { return state.error; }, - get lastSpan() { return captureSpan(); }, - next: function () { - if (hasCompletedDecoding(state) || state.error) - return { done: true, value: undefined }; - if (!decodeSinglePosition(state)) - return { done: true, value: undefined }; - return { done: false, value: captureSpan() }; - } + generatedPosition: generatedPosition, + source: source, + sourceIndex: mapping.sourceIndex, + sourcePosition: sourcePosition, + nameIndex: mapping.nameIndex }; } - sourcemaps.decodeMappings = decodeMappings; - function calculateDecodedMappings(map, processPosition, host) { - var decoder = decodeMappings(map); - var positions = ts.arrayFrom(decoder, processPosition); - if (decoder.error) { - if (host && host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); - } - return []; - } - return positions; - } - function hasCompletedDecoding(state) { - return state.decodingIndex === state.encodedText.length; - } - function decodeSinglePosition(state) { - while (state.decodingIndex < state.encodedText.length) { - var char = state.encodedText.charCodeAt(state.decodingIndex); - if (char === 59 /* semicolon */) { - // New line - state.currentEmittedLine++; - state.currentEmittedColumn = 0; - state.decodingIndex++; - continue; - } - if (char === 44 /* comma */) { - // Next entry is on same line - no action needed - state.decodingIndex++; - continue; - } - // Read the current position - // 1. Column offset from prev read jsColumn - state.currentEmittedColumn += base64VLQFormatDecode(); - // Incorrect emittedColumn dont support this map - if (createErrorIfCondition(state.currentEmittedColumn < 0, "Invalid emittedColumn found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted column")) { - return false; - } - // 2. Relative sourceIndex - state.currentSourceIndex += base64VLQFormatDecode(); - // Incorrect sourceIndex dont support this map - if (createErrorIfCondition(state.currentSourceIndex < 0, "Invalid sourceIndex found")) { - return false; - } - // Dont support reading mappings that dont have information about original source position - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after sourceIndex")) { - return false; - } - // 3. Relative sourceLine 0 based - state.currentSourceLine += base64VLQFormatDecode(); - // Incorrect sourceLine dont support this map - if (createErrorIfCondition(state.currentSourceLine < 0, "Invalid sourceLine found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted Line")) { - return false; - } - // 4. Relative sourceColumn 0 based - state.currentSourceColumn += base64VLQFormatDecode(); - // Incorrect sourceColumn dont support this map - if (createErrorIfCondition(state.currentSourceColumn < 0, "Invalid sourceLine found")) { - return false; - } - // 5. Check if there is name: - if (!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex)) { - if (state.currentNameIndex === undefined) { - state.currentNameIndex = 0; + function getDecodedMappings() { + if (decodedMappings === undefined) { + var decoder = decodeMappings(map.mappings); + var mappings = ts.arrayFrom(decoder, processMapping); + if (decoder.error !== undefined) { + if (host.log) { + host.log("Encountered error while decoding sourcemap: " + decoder.error); } - state.currentNameIndex += base64VLQFormatDecode(); - // Incorrect nameIndex dont support this map - // TODO: If we start using `name`s, issue errors when they aren't correct in the sourcemap - // if (createErrorIfCondition(state.currentNameIndex < 0 || state.currentNameIndex >= state.sourceMapNamesLength, "Invalid name index for the source map entry")) { - // return; - // } - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: There are more entries after " + (state.currentNameIndex === undefined ? "sourceColumn" : "nameIndex"))) { - return false; - } - // Entry should be complete - return true; - } - createErrorIfCondition(/*condition*/ true, "No encoded entry found"); - return false; - function createErrorIfCondition(condition, errormsg) { - if (state.error) { - // An error was already reported - return true; - } - if (condition) { - state.error = errormsg; - } - return condition; - } - function base64VLQFormatDecode() { - var moreDigits = true; - var shiftCount = 0; - var value = 0; - for (; moreDigits; state.decodingIndex++) { - if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return undefined; // TODO: GH#18217 - } - // 6 digit number - var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); - // If msb is set, we still have more bits to continue - moreDigits = (currentByte & 32) !== 0; - // least significant 5 bits are the next msbs in the final value. - value = value | ((currentByte & 31) << shiftCount); - shiftCount += 5; - } - // Least significant bit if 1 represents negative and rest of the msb is actual absolute value - if ((value & 1) === 0) { - // + number - value = value >> 1; + decodedMappings = ts.emptyArray; } else { - // - number - value = value >> 1; - value = -value; + decodedMappings = mappings; } - return value; } + return decodedMappings; } - function base64FormatDecode(char) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(char); + function getSourceMappings(sourceIndex) { + if (sourceMappings === undefined) { + var lists = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + if (!isSourceMappedPosition(mapping)) + continue; + var list = lists[mapping.sourceIndex]; + if (!list) + lists[mapping.sourceIndex] = list = []; + list.push(mapping); + } + sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); }); + } + return sourceMappings[sourceIndex]; } - function isSourceMappingSegmentEnd(encodedText, pos) { - return (pos === encodedText.length || - encodedText.charCodeAt(pos) === 44 /* comma */ || - encodedText.charCodeAt(pos) === 59 /* semicolon */); + function getGeneratedMappings() { + if (generatedMappings === undefined) { + var list = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + list.push(mapping); + } + generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition); + } + return generatedMappings; } - })(sourcemaps = ts.sourcemaps || (ts.sourcemaps = {})); + function getGeneratedPosition(loc) { + var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName)); + if (sourceIndex === undefined) + return loc; + var sourceMappings = getSourceMappings(sourceIndex); + if (!ts.some(sourceMappings)) + return loc; + var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = sourceMappings[targetIndex]; + if (mapping === undefined || mapping.sourceIndex !== sourceIndex) { + return loc; + } + return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition }; // Closest pos + } + function getSourcePosition(loc) { + var generatedMappings = getGeneratedMappings(); + if (!ts.some(generatedMappings)) + return loc; + var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = generatedMappings[targetIndex]; + if (mapping === undefined || !isSourceMappedPosition(mapping)) { + return loc; + } + return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition }; // Closest pos + } + } + ts.createDocumentPositionMapper = createDocumentPositionMapper; + ts.identitySourceMapConsumer = { + getSourcePosition: ts.identity, + getGeneratedPosition: ts.identity + }; })(ts || (ts = {})); /* @internal */ var ts; @@ -63724,7 +64825,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -63770,7 +64871,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -63778,13 +64879,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 246 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + case 248 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -63814,13 +64915,13 @@ var ts; } } break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -63828,7 +64929,7 @@ var ts; } } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -63848,7 +64949,7 @@ var ts; } } break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -64464,8 +65565,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -64495,14 +65596,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -64551,16 +65652,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 243 /* ModuleBlock */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 245 /* ModuleBlock */: + case 218 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -64572,7 +65673,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 === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 240 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -64620,10 +65721,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -64644,13 +65745,13 @@ var ts; return node; } switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -64670,11 +65771,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 253 /* ExportDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 248 /* ImportClause */ || - (node.kind === 246 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 257 /* ExternalModuleReference */)) { + if (node.kind === 255 /* ExportDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 250 /* ImportClause */ || + (node.kind === 248 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 259 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -64704,19 +65805,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 152 /* PropertyDeclaration */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -64726,7 +65827,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 84 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 85 /* ExportKeyword */) { return undefined; } return node; @@ -64743,67 +65844,67 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 133 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 166 /* TypeLiteral */: - case 161 /* TypePredicate */: - case 148 /* TypeParameter */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 122 /* BooleanKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 105 /* VoidKeyword */: - case 138 /* SymbolKeyword */: - case 164 /* ConstructorType */: - case 163 /* FunctionType */: - case 165 /* TypeQuery */: - case 162 /* TypeReference */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 175 /* ParenthesizedType */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 168 /* TypeLiteral */: + case 163 /* TypePredicate */: + case 150 /* TypeParameter */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 123 /* BooleanKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 132 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 139 /* SymbolKeyword */: + case 166 /* ConstructorType */: + case 165 /* FunctionType */: + case 167 /* TypeQuery */: + case 164 /* TypeReference */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 177 /* ParenthesizedType */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: // TypeScript type nodes are elided. - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: // TypeScript index signatures are elided. - case 150 /* Decorator */: + case 152 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 152 /* PropertyDeclaration */: + case 154 /* 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 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructor(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64814,7 +65915,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64825,35 +65926,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -64863,35 +65964,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -64928,7 +66029,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -64997,7 +66098,7 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -65199,7 +66300,7 @@ var ts; pendingExpressions = undefined; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85 /* ExtendsKeyword */; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 86 /* ExtendsKeyword */; })); var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); @@ -65375,7 +66476,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -65446,7 +66547,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 152 /* PropertyDeclaration */ + return member.kind === 154 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -65457,8 +66558,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -65474,8 +66575,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); ts.startOnNewLine(expression); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -65586,12 +66687,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -65744,7 +66845,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 152 /* PropertyDeclaration */ + ? member.kind === 154 /* 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`. ? ts.createVoidZero() @@ -65845,13 +66946,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -65867,10 +66968,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 152 /* PropertyDeclaration */; + return kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 154 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -65880,7 +66981,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -65891,12 +66992,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; } return false; @@ -65913,15 +67014,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: return serializeTypeNode(node.type); - case 157 /* SetAccessor */: - case 156 /* GetAccessor */: + case 159 /* SetAccessor */: + case 158 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 156 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -65958,7 +67059,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 156 /* GetAccessor */) { + if (container && node.kind === 158 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -66003,77 +67104,83 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: return ts.createVoidZero(); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createIdentifier("Function"); - case 167 /* ArrayType */: - case 168 /* TupleType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: return ts.createIdentifier("Array"); - case 161 /* TypePredicate */: - case 122 /* BooleanKeyword */: + case 163 /* TypePredicate */: + case 123 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return ts.createIdentifier("String"); - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 180 /* LiteralType */: + case 182 /* LiteralType */: switch (node.literal.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + return getGlobalBigIntNameWithFallback(); + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 138 /* SymbolKeyword */: + case 146 /* BigIntKeyword */: + return getGlobalBigIntNameWithFallback(); + case 139 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return serializeTypeReferenceNode(node); - case 172 /* IntersectionType */: - case 171 /* UnionType */: - return serializeUnionOrIntersectionType(node); - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 166 /* TypeLiteral */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 176 /* ThisType */: - case 181 /* ImportType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return serializeTypeList(node.types); + case 175 /* ConditionalType */: + return serializeTypeList([node.trueType, node.falseType]); + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 168 /* TypeLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 178 /* ThisType */: + case 183 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); } return ts.createIdentifier("Object"); } - function serializeUnionOrIntersectionType(node) { + function serializeTypeList(types) { // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 131 /* NeverKeyword */) { + if (typeNode.kind === 132 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); @@ -66109,6 +67216,10 @@ var ts; var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: + // From conditional type type reference that cannot be resolved is Similar to any or unknown + if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { + return ts.createIdentifier("Object"); + } var serialized = serializeEntityNameAsExpressionFallback(node.typeName); var temp = ts.createTempVariable(hoistVariableDeclaration); return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object")); @@ -66116,6 +67227,8 @@ var ts; return serializeEntityNameAsExpression(node.typeName); case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.createVoidZero(); + case ts.TypeReferenceSerializationKind.BigIntLikeType: + return getGlobalBigIntNameWithFallback(); case ts.TypeReferenceSerializationKind.BooleanType: return ts.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -66147,12 +67260,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 71 /* Identifier */) { + if (node.left.kind === 72 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -66168,7 +67281,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* 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.getMutableClone(node); @@ -66176,7 +67289,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -66197,6 +67310,15 @@ var ts; function getGlobalSymbolNameWithFallback() { return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object")); } + /** + * Gets an expression that points to the global "BigInt" constructor at runtime if it is + * available. + */ + function getGlobalBigIntNameWithFallback() { + return languageVersion < 6 /* ESNext */ + ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object")) + : ts.createIdentifier("BigInt"); + } /** * A simple inlinable expression is an expression which can be copied into multiple locations * without risk of repeating any sideeffects and whose value could not possibly change between @@ -66277,9 +67399,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 85 /* ExtendsKeyword */) { + if (node.token === 86 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(85 /* ExtendsKeyword */, types), node); + return ts.setTextRange(ts.createHeritageClause(86 /* ExtendsKeyword */, types), node); } return undefined; } @@ -66675,7 +67797,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -66756,12 +67878,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 241 /* EnumDeclaration */) { + if (node.kind === 243 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -66886,7 +68008,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 243 /* ModuleBlock */) { + if (body.kind === 245 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -66932,13 +68054,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 243 /* ModuleBlock */) { + if (body.kind !== 245 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -66979,7 +68101,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 249 /* NamespaceImport */) { + if (node.kind === 251 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -67192,7 +68314,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -67200,7 +68322,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -67210,17 +68332,17 @@ var ts; enabledSubstitutions |= 2 /* 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(71 /* Identifier */); - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); + context.enableSubstitution(72 /* Identifier */); + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(242 /* ModuleDeclaration */); + context.enableEmitNotification(244 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 244 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 243 /* EnumDeclaration */; } /** * Hook for node emit. @@ -67279,11 +68401,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -67321,9 +68443,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 !== 277 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); + if (container && container.kind !== 279 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -67463,26 +68585,26 @@ var ts; return node; } switch (node.kind) { - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -67493,27 +68615,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 216 /* Block */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 229 /* WithStatement */: - case 231 /* LabeledStatement */: + case 218 /* Block */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 231 /* WithStatement */: + case 233 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -67714,7 +68836,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 195 /* ArrowFunction */; + var isArrowFunction = node.kind === 197 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -67799,17 +68921,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -67857,23 +68979,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -67893,11 +69015,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -67964,7 +69086,7 @@ var ts; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -68032,7 +69154,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 120 /* AsyncKeyword */) { + if (node.kind === 121 /* AsyncKeyword */) { return undefined; } return node; @@ -68042,55 +69164,55 @@ var ts; return node; } switch (node.kind) { - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitVoidExpression(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructorDeclaration(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -68126,7 +69248,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 227 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -68138,7 +69260,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 275 /* SpreadAssignment */) { + if (e.kind === 277 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -68147,7 +69269,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 275 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -68165,7 +69287,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 188 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -68193,7 +69315,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 262144 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -68421,7 +69543,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); @@ -68490,17 +69612,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -68548,23 +69670,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -68584,11 +69706,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -68697,13 +69819,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -68711,15 +69833,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 10 /* JsxText */: + case 11 /* JsxText */: return visitJsxText(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -68787,14 +69909,14 @@ var ts; if (node === undefined) { return ts.createTrue(); } - else if (node.kind === 9 /* StringLiteral */) { + else if (node.kind === 10 /* 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 literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text); literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 268 /* JsxExpression */) { + else if (node.kind === 270 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -68888,7 +70010,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 258 /* JsxElement */) { + if (node.kind === 260 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -69194,7 +70316,7 @@ var ts; return node; } switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69202,9 +70324,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 62 /* AsteriskAsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69432,13 +70554,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 228 /* ReturnStatement */ + && node.kind === 230 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 218 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -69457,104 +70579,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: return undefined; // elide static keyword - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return visitClassExpression(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 71 /* Identifier */: + case 72 /* Identifier */: return visitIdentifier(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return visitTemplateLiteral(node); - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitSpreadElement(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return visitThisKeyword(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitMetaProperty(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -69641,14 +70763,14 @@ 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 === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 229 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -69659,7 +70781,7 @@ var ts; } } else { - if (node.kind === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -69678,10 +70800,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 26 /* CommaToken */, copyExpr); + expr = ts.createBinary(expr, 27 /* CommaToken */, copyExpr); } } - returnExpression = ts.createBinary(expr, 26 /* CommaToken */, returnExpression); + returnExpression = ts.createBinary(expr, 27 /* CommaToken */, returnExpression); } return ts.createReturn(returnExpression); } @@ -69815,7 +70937,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -69920,7 +71042,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -69959,11 +71081,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 228 /* ReturnStatement */) { + if (statement.kind === 230 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 220 /* IfStatement */) { + else if (statement.kind === 222 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -69971,7 +71093,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 216 /* Block */) { + else if (statement.kind === 218 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -70029,7 +71151,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -70039,8 +71161,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (8192 /* ContainsLexicalThis */ | 16384 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 202 /* BinaryExpression */ - || superCallExpression.left.kind !== 189 /* CallExpression */) { + if (superCallExpression.kind !== 204 /* BinaryExpression */ + || superCallExpression.left.kind !== 191 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -70185,7 +71307,7 @@ var ts; * synthesized call to `super` */ function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 71 /* Identifier */ && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 72 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** * Adds statements to the body of a function-like node if it contains a rest parameter. @@ -70237,7 +71359,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { + if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 197 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -70256,25 +71378,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return statements; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 94 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70302,20 +71424,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -70507,7 +71629,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 239 /* FunctionDeclaration */ || node.kind === 196 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -70552,7 +71674,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 195 /* ArrowFunction */); + ts.Debug.assert(node.kind === 197 /* 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 @@ -70590,7 +71712,7 @@ var ts; ts.setEmitFlags(block, 1 /* SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 18 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -70620,9 +71742,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -70641,9 +71763,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -70678,7 +71800,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 58 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 59 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -70852,14 +71974,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -71043,7 +72165,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 147 /* ComputedPropertyName */) { + if (property.name.kind === 149 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -71098,7 +72220,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -71164,11 +72286,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 223 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 224 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 225 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 221 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 222 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 225 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 226 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 227 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 223 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 224 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -71193,11 +72315,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 238 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -71348,7 +72470,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -71410,7 +72532,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(51 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -71448,7 +72570,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -71459,7 +72581,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 58 /* EqualsToken */, source); + return ts.createBinary(target, 59 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -71472,7 +72594,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -71486,7 +72608,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -71507,10 +72629,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -71596,20 +72718,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -71720,7 +72842,7 @@ var ts; var body = node.transformFlags & (16384 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -71897,10 +73019,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 131072 /* ContainsRestOrSpread */ || - node.expression.kind === 97 /* SuperKeyword */ || + node.expression.kind === 98 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -71933,7 +73055,7 @@ var ts; resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -71998,7 +73120,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 187 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -72115,7 +73237,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 === 13 /* NoSubstitutionTemplateLiteral */ || node.kind === 16 /* TemplateTail */; + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's @@ -72213,7 +73335,7 @@ var ts; : ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 94 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 95 /* NewKeyword */ && node.name.escapedText === "target") { if (hierarchyFacts & 8192 /* ComputedPropertyName */) { hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; } @@ -72250,7 +73372,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } /** @@ -72260,14 +73382,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(155 /* Constructor */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(195 /* ArrowFunction */); - context.enableEmitNotification(194 /* FunctionExpression */); - context.enableEmitNotification(237 /* FunctionDeclaration */); + context.enableSubstitution(100 /* ThisKeyword */); + context.enableEmitNotification(157 /* Constructor */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(197 /* ArrowFunction */); + context.enableEmitNotification(196 /* FunctionExpression */); + context.enableEmitNotification(239 /* FunctionDeclaration */); } } /** @@ -72308,10 +73430,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 237 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -72324,9 +73446,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -72393,19 +73515,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 221 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 191 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 98 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 208 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -72458,15 +73580,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(260 /* JsxOpeningElement */); - context.enableEmitNotification(261 /* JsxClosingElement */); - context.enableEmitNotification(259 /* JsxSelfClosingElement */); + context.enableEmitNotification(262 /* JsxOpeningElement */); + context.enableEmitNotification(263 /* JsxClosingElement */); + context.enableEmitNotification(261 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(273 /* PropertyAssignment */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(275 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -72485,9 +73607,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -72544,7 +73666,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -72819,13 +73941,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -72838,24 +73960,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return visitBreakStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return visitContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 4194304 /* ContainsYield */) { @@ -72876,21 +73998,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitConditionalExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -72903,9 +74025,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -73104,23 +74226,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 59 /* FirstCompoundAssignment */ - && kind <= 70 /* LastCompoundAssignment */; + return kind >= 60 /* FirstCompoundAssignment */ + && kind <= 71 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 59 /* PlusEqualsToken */: return 37 /* PlusToken */; - case 60 /* MinusEqualsToken */: return 38 /* MinusToken */; - case 61 /* AsteriskEqualsToken */: return 39 /* AsteriskToken */; - case 62 /* AsteriskAsteriskEqualsToken */: return 40 /* AsteriskAsteriskToken */; - case 63 /* SlashEqualsToken */: return 41 /* SlashToken */; - case 64 /* PercentEqualsToken */: return 42 /* PercentToken */; - case 65 /* LessThanLessThanEqualsToken */: return 45 /* LessThanLessThanToken */; - case 66 /* GreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanToken */; - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanGreaterThanToken */; - case 68 /* AmpersandEqualsToken */: return 48 /* AmpersandToken */; - case 69 /* BarEqualsToken */: return 49 /* BarToken */; - case 70 /* CaretEqualsToken */: return 50 /* CaretToken */; + case 60 /* PlusEqualsToken */: return 38 /* PlusToken */; + case 61 /* MinusEqualsToken */: return 39 /* MinusToken */; + case 62 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; + case 63 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; + case 64 /* SlashEqualsToken */: return 42 /* SlashToken */; + case 65 /* PercentEqualsToken */: return 43 /* PercentToken */; + case 66 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; + case 67 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; + case 69 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; + case 70 /* BarEqualsToken */: return 50 /* BarToken */; + case 71 /* CaretEqualsToken */: return 51 /* CaretToken */; } } /** @@ -73133,7 +74255,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -73145,7 +74267,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -73177,7 +74299,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -73232,7 +74354,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 === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -73263,7 +74385,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -73521,35 +74643,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: return transformAndEmitBlock(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return transformAndEmitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return transformAndEmitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return transformAndEmitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return transformAndEmitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -73979,7 +75101,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 272 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -73992,7 +75114,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -74304,7 +75426,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -75220,12 +76342,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(279 /* 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. @@ -75553,23 +76675,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -75596,24 +76718,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -76091,7 +77213,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -76146,10 +77268,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -76331,8 +77453,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -76348,7 +77470,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -76410,12 +77532,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -76436,7 +77558,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -76504,15 +77626,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 203 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 60 /* PlusEqualsToken */ : 61 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -76586,12 +77708,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(279 /* 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. @@ -76812,7 +77934,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 255 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -76837,7 +77959,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 253 /* ExportDeclaration */) { + if (externalImport.kind !== 255 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -76915,19 +78037,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -76977,15 +78099,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -77161,7 +78283,7 @@ 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 === 277 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -77225,7 +78347,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -77287,10 +78409,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -77470,43 +78592,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitDefaultClause(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitTryStatement(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -77689,7 +78811,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 202 /* BinaryExpression */) { + && node.kind === 204 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -77754,7 +78876,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 277 /* SourceFile */; + return container !== undefined && container.kind === 279 /* SourceFile */; } else { return false; @@ -77770,8 +78892,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -77787,7 +78909,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -77835,7 +78957,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -77869,12 +78991,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -77960,22 +79082,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ + var expression = node.kind === 203 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 201 /* PostfixUnaryExpression */) { - expression = node.operator === 43 /* PlusPlusToken */ + if (node.kind === 203 /* PostfixUnaryExpression */) { + expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -77996,7 +79118,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -78035,8 +79157,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(277 /* SourceFile */); - context.enableSubstitution(71 /* Identifier */); + context.enableEmitNotification(279 /* SourceFile */); + context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -78064,10 +79186,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -78174,7 +79296,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78203,7 +79325,7 @@ var ts; 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 === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78250,7 +79372,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78259,8 +79381,8 @@ var ts; } // 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 === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || - (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 154 /* PropertyDeclaration */ || node.kind === 153 /* PropertySignature */ || + (node.kind === 151 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -78269,7 +79391,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 240 /* ClassDeclaration */ || node.kind === 151 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78294,7 +79416,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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.hasModifier(node, 32 /* Static */)) { @@ -78333,26 +79455,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78360,7 +79482,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78374,7 +79496,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78399,30 +79521,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 159 /* ConstructSignature */: - case 164 /* ConstructorType */: + case 161 /* ConstructSignature */: + case 166 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78430,7 +79552,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78443,8 +79565,8 @@ 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 237 /* FunctionDeclaration */: - case 163 /* FunctionType */: + case 239 /* FunctionDeclaration */: + case 165 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78458,34 +79580,34 @@ 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 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* 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 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -78500,9 +79622,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + if (node.parent.parent.kind === 240 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 108 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 109 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -78667,10 +79789,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -78693,14 +79815,14 @@ 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_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(124 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(125 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -78814,11 +79936,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { return name; } else { - if (name.kind === 183 /* ArrayBindingPattern */) { + if (name.kind === 185 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -78826,7 +79948,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 208 /* OmittedExpression */) { + if (elem.kind === 210 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -78839,7 +79961,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(55 /* QuestionToken */)) : undefined, ensureType(p, 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 || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -78851,7 +79973,7 @@ var ts; } function ensureNoInitializer(node) { if (shouldPrintWithInitializer(node)) { - return resolver.createLiteralConstValue(ts.getParseTreeNode(node)); // TODO: Make safe + return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker); // TODO: Make safe } return undefined; } @@ -78864,19 +79986,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 149 /* Parameter */ && + var shouldUseResolverType = node.kind === 151 /* 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) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(120 /* AnyKeyword */); } - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -78884,12 +80006,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 149 /* Parameter */ - || node.kind === 152 /* PropertyDeclaration */ - || node.kind === 151 /* PropertySignature */) { + if (node.kind === 151 /* Parameter */ + || node.kind === 154 /* PropertyDeclaration */ + || node.kind === 153 /* 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)); @@ -78900,26 +80022,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(119 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(120 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return false; } return false; @@ -78973,7 +80095,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 244 /* ModuleDeclaration */ && parent.kind !== 183 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -78993,7 +80115,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 259 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -79020,7 +80142,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 251 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -79125,68 +80247,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 168 /* TypeLiteral */ || input.kind === 181 /* MappedType */) && input.parent.kind !== 242 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 209 /* ExpressionWithTypeArguments */: { + case 211 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 162 /* TypeReference */: { + case 164 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 155 /* Constructor */: { + case 157 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(157 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 154 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 156 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(155 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 156 /* GetAccessor */: { + case 158 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 157 /* SetAccessor */: { + case 159 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 153 /* MethodSignature */: { + case 155 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 158 /* CallSignature */: { + case 160 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 160 /* IndexSignature */: { + case 162 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(120 /* AnyKeyword */))); } - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -79194,13 +80316,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 148 /* TypeParameter */: { + case 150 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 173 /* ConditionalType */: { + case 175 /* 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); @@ -79212,13 +80334,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 163 /* FunctionType */: { + case 165 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 164 /* ConstructorType */: { + case 166 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 181 /* ImportType */: { + case 183 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -79247,7 +80369,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 156 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -79257,7 +80379,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 253 /* ExportDeclaration */: { + case 255 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -79266,13 +80388,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 252 /* ExportAssignment */: { + case 254 /* 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 === 71 /* Identifier */) { + if (input.expression.kind === 72 /* Identifier */) { return input; } else { @@ -79282,7 +80404,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -79296,10 +80418,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -79320,14 +80442,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 242 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 239 /* InterfaceDeclaration */: { + case 241 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 237 /* FunctionDeclaration */: { + case 239 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), @@ -79349,10 +80471,10 @@ var ts; return clean; } } - case 242 /* ModuleDeclaration */: { + case 244 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 243 /* ModuleBlock */) { + if (inner && inner.kind === 245 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -79373,7 +80495,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 238 /* ClassDeclaration */: { + case 240 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -79384,7 +80506,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 71 /* Identifier */) { + if (param.name.kind === 72 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -79414,7 +80536,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 96 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ @@ -79423,16 +80545,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 85 /* ExtendsKeyword */) { + if (clause.token === 86 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 96 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -79443,10 +80565,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 241 /* EnumDeclaration */: { + case 243 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -79465,7 +80587,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 242 /* ModuleDeclaration */) { + if (input.kind === 244 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -79486,7 +80608,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 208 /* OmittedExpression */) { + if (e.kind === 210 /* OmittedExpression */) { return; } if (e.name) { @@ -79549,7 +80671,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 277 /* SourceFile */; + var parentIsFile = node.parent.kind === 279 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -79591,13 +80713,13 @@ var ts; } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 85 /* ExtendsKeyword */ && t.expression.kind === 95 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 86 /* ExtendsKeyword */ && t.expression.kind === 96 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* InterfaceDeclaration */) { return true; } return false; @@ -79622,7 +80744,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 156 /* GetAccessor */ + return accessor.kind === 158 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -79631,52 +80753,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 217 /* VariableStatement */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 219 /* VariableStatement */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 235 /* VariableDeclaration */: - case 148 /* TypeParameter */: - case 209 /* ExpressionWithTypeArguments */: - case 162 /* TypeReference */: - case 173 /* ConditionalType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 181 /* ImportType */: + case 161 /* ConstructSignature */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 237 /* VariableDeclaration */: + case 150 /* TypeParameter */: + case 211 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 175 /* ConditionalType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 183 /* ImportType */: return true; } return false; @@ -79741,6 +80863,14 @@ var ts; return transformers; } ts.getTransformers = getTransformers; + function noEmitSubstitution(_hint, node) { + return node; + } + ts.noEmitSubstitution = noEmitSubstitution; + function noEmitNotification(hint, node, callback) { + callback(hint, node); + } + ts.noEmitNotification = noEmitNotification; /** * Transforms an array of SourceFiles by passing them through each transformer. * @@ -79752,7 +80882,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(310 /* Count */); + var enabledSyntaxKindFeatures = new Array(312 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -79760,8 +80890,8 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; - var onSubstituteNode = function (_, node) { return node; }; - var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var onSubstituteNode = noEmitSubstitution; + var onEmitNode = noEmitNotification; var state = 0 /* Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer @@ -80010,825 +81140,11 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans - var defaultLastEncodedSourceMapSpan = { - emittedLine: 0, - emittedColumn: 0, - sourceLine: 0, - sourceColumn: 0, - sourceIndex: 0 - }; - function createSourceMapWriter(host, writer, compilerOptions) { - if (compilerOptions === void 0) { compilerOptions = host.getCompilerOptions(); } - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var currentSource; - var currentSourceText; - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex; - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan; - var lastEncodedNameIndex; - // Source map data - var sourceMapData; - var sourceMapDataList; - var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); - return { - initialize: initialize, - reset: reset, - setSourceFile: setSourceFile, - emitPos: emitPos, - emitNodeWithSourceMap: emitNodeWithSourceMap, - emitTokenWithSourceMap: emitTokenWithSourceMap, - getText: getText, - getSourceMappingURL: getSourceMappingURL, - }; - /** - * Skips trivia such as comments and white-space that can optionally overriden by the source map source - */ - function skipSourceTrivia(pos) { - return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); - } - /** - * Initialize the SourceMapWriter for a new output file. - * - * @param filePath The path to the generated output file. - * @param sourceMapFilePath The path to the output source map file. - * @param sourceFileOrBundle The input source file or bundle for the program. - */ - function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { - return; - } - if (sourceMapData) { - reset(); - } - sourceMapDataList = outputSourceMapDataList; - currentSource = undefined; - currentSourceText = undefined; - // Current source map file and its index in the sources list - sourceMapSourceIndex = -1; - // Last recorded and encoded spans - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; - lastEncodedNameIndex = 0; - // Initialize source map data - sourceMapData = { - sourceMapFilePath: sourceMapFilePath, - jsSourceMappingURL: !compilerOptions.inlineSourceMap ? ts.getBaseFileName(ts.normalizeSlashes(sourceMapFilePath)) : undefined, - sourceMapFile: ts.getBaseFileName(ts.normalizeSlashes(filePath)), - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 277 /* SourceFile */) { // emitting single module file - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle.fileName, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(filePath)); - } - } - /** - * Reset the SourceMapWriter to an empty state. - */ - function reset() { - if (disabled) { - return; - } - // Record source map data for the test harness. - if (sourceMapDataList) { - sourceMapDataList.push(sourceMapData); - } - currentSource = undefined; - sourceMapDir = undefined; - sourceMapSourceIndex = undefined; - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = undefined; - lastEncodedNameIndex = undefined; - sourceMapData = undefined; - sourceMapDataList = undefined; - } - function captureSection() { - return { - version: 3, - file: sourceMapData.sourceMapFile, - sourceRoot: sourceMapData.sourceMapSourceRoot, - sources: sourceMapData.sourceMapSources, - names: sourceMapData.sourceMapNames, - mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent, - }; - } - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - ts.Debug.assert(lastRecordedSourceMapSpan.emittedColumn >= 0, "lastEncodedSourceMapSpan.emittedColumn was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceIndex >= 0, "lastEncodedSourceMapSpan.sourceIndex was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceLine >= 0, "lastEncodedSourceMapSpan.sourceLine was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceColumn >= 0, "lastEncodedSourceMapSpan.sourceColumn was negative"); - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 0; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - } - /** - * Emits a mapping. - * - * If the position is synthetic (undefined or a negative value), no mapping will be - * created. - * - * @param pos The position. - */ - function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeSourcemap"); - } - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSource, pos); - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - sourceIndex: sourceMapSourceIndex - }; - } - else { - // Take the new pos instead since there is no change in emittedLine and column since last location - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - if (extendedDiagnostics) { - ts.performance.mark("afterSourcemap"); - ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); - } - } - function isPossiblySourceMap(x) { - return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; - } - /** - * Emits a node with possible leading and trailing source maps. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to emit. - * @param emitCallback The callback used to emit the node. - */ - function emitNodeWithSourceMap(hint, node, emitCallback) { - var _a; - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(hint, node); - } - if (node) { - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var text = node.sourceMapText; - var parsed = void 0; - try { - parsed = JSON.parse(text); - } - catch (_b) { - // empty - } - if (!parsed || !isPossiblySourceMap(parsed)) { - return emitCallback(hint, node); - } - var offsetLine = writer.getLine(); - var firstLineColumnOffset = writer.getColumn(); - // First, decode the old component sourcemap - var originalMap = parsed; - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache = ts.createMap(); - var absolutePathCache = ts.createMap(); - var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); - for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { - var pathCacheKey = "" + raw.sourceIndex; - // Apply offsets to each position and fixup source entries - if (!resolvedPathCache.has(pathCacheKey)) { - var rawPath = originalMap.sources[raw.sourceIndex]; - var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - resolvedPathCache.set(pathCacheKey, resolvedPath_1); - absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); - } - var resolvedPath = resolvedPathCache.get(pathCacheKey); - var absolutePath = absolutePathCache.get(pathCacheKey); - // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? - var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); - // Then reencode all the updated spans into the overall map - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); - } - // And actually emit the text these sourcemaps are for - return emitCallback(hint, node); - } - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.sourceMapRange; - var _d = range || node, pos = _d.pos, end = _d.end; - var source = range && range.source; - var oldSource = currentSource; - if (source === oldSource) - source = undefined; - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitPos(skipSourceTrivia(pos)); - } - if (source) - setSourceFile(oldSource); - if (emitFlags & 64 /* NoNestedSourceMaps */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitPos(end); - } - if (source) - setSourceFile(oldSource); - } - } - /** - * Emits a token of a node with possible leading and trailing source maps. - * - * @param node The node containing the token. - * @param token The token to emit. - * @param tokenStartPos The start pos of the token. - * @param emitCallback The callback used to emit the token. - */ - function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(token, writer, tokenPos); - } - var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; - tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - tokenPos = emitCallback(token, writer, tokenPos); - if (range) - tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - return tokenPos; - } - function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); - } - /** - * Set the current source file. - * - * @param sourceFile The source file. - */ - function setSourceFile(sourceFile) { - if (disabled) { - return; - } - currentSource = sourceFile; - currentSourceText = currentSource.text; - if (isJsonSourceMapSource(sourceFile)) { - return; - } - setupSourceEntry(sourceFile.fileName, sourceFile.text); - } - function setupSourceEntry(fileName, content, source) { - if (!source) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); - if (sourceMapSourceIndex === -1) { - sourceMapSourceIndex = sourceMapData.sourceMapSources.length; - sourceMapData.sourceMapSources.push(source); - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(fileName); - if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent.push(content); - } - } - } - /** - * Gets the text for the source map. - */ - function getText() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - encodeLastRecordedSourceMapSpan(); - return JSON.stringify(captureSection()); - } - /** - * Gets the SourceMappingURL for the source map. - */ - function getSourceMappingURL() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.base64encode(ts.sys, getText()); - return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; - } - else { - return sourceMapData.jsSourceMappingURL; - } - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - function base64FormatEncode(inValue) { - if (inValue < 64) { - return base64Chars.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - function createCommentWriter(printerOptions, emitPos) { - var extendedDiagnostics = printerOptions.extendedDiagnostics; - var newLine = ts.getNewLineCharacter(printerOptions); - var writer; - var containerPos = -1; - var containerEnd = -1; - var declarationListContainerEnd = -1; - var currentSourceFile; - var currentText; - var currentLineMap; - var detachedCommentsInfo; - var hasWrittenComment = false; - var disabled = !!printerOptions.removeComments; - return { - reset: reset, - setWriter: setWriter, - setSourceFile: setSourceFile, - emitNodeWithComments: emitNodeWithComments, - emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, - emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, - }; - function emitNodeWithComments(hint, node, emitCallback) { - if (disabled) { - emitCallback(hint, node); - return; - } - if (node) { - hasWrittenComment = false; - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; - if ((pos < 0 && end < 0) || (pos === end)) { - // Both pos and end are synthesized, so just emit the node without comments. - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - } - else { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithComment"); - } - var isEmittedNode = node.kind !== 305 /* NotEmittedStatement */; - // 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 === 10 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 10 /* JsxText */; - // 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); - } - // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { - // Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments. - containerPos = pos; - } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* 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 === 236 /* VariableDeclarationList */) { - declarationListContainerEnd = end; - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithComment"); - } - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithComment"); - } - // Restore previous container state. - containerPos = savedContainerPos; - containerEnd = savedContainerEnd; - 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 && isEmittedNode) { - emitTrailingComments(end); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithComment"); - } - } - } - } - function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { - var leadingComments = emitNode && emitNode.leadingComments; - if (ts.some(leadingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithSynthesizedComments"); - } - ts.forEach(leadingComments, emitLeadingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); - } - } - emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); - var trailingComments = emitNode && emitNode.trailingComments; - if (ts.some(trailingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithSynthesizedComments"); - } - ts.forEach(trailingComments, emitTrailingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); - } - } - } - function emitLeadingSynthesizedComment(comment) { - if (comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function emitTrailingSynthesizedComment(comment) { - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - } - function writeSynthesizedComment(comment) { - var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; - ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); - } - function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; - } - function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - } - function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitBodyWithDetachedComments"); - } - var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = disabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; - if (!skipLeadingComments) { - emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); - } - if (emitFlags & 2048 /* NoNestedComments */ && !disabled) { - disabled = true; - emitCallback(node); - disabled = false; - } - else { - emitCallback(node); - } - if (extendedDiagnostics) { - ts.performance.mark("beginEmitBodyWithDetachedComments"); - } - if (!skipTrailingComments) { - emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); - if (hasWrittenComment && !writer.isAtStartOfLine()) { - writer.writeLine(); - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitBodyWithDetachedComments"); - } - } - function emitLeadingComments(pos, isEmittedNode) { - hasWrittenComment = false; - if (isEmittedNode) { - forEachLeadingCommentToEmit(pos, emitLeadingComment); - } - else if (pos === 0) { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted - forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); - } - } - function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); - } - } - function shouldWriteComment(text, pos) { - if (printerOptions.onlyPrintJsDocStyle) { - return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); - } - return true; - } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (!hasWrittenComment) { - ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); - hasWrittenComment = true; - } - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else if (kind === 3 /* MultiLineCommentTrivia */) { - writer.write(" "); - } - } - function emitLeadingCommentsOfPosition(pos) { - if (disabled || pos === -1) { - return; - } - emitLeadingComments(pos, /*isEmittedNode*/ true); - } - function emitTrailingComments(pos) { - forEachTrailingCommentToEmit(pos, emitTrailingComment); - } - function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - } - function emitTrailingCommentsOfPosition(pos, prefixSpace) { - if (disabled) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); - } - forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); - } - } - function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function forEachLeadingCommentToEmit(pos, cb) { - // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments - if (containerPos === -1 || pos !== containerPos) { - if (hasDetachedComments(pos)) { - forEachLeadingCommentWithoutDetachedComments(cb); - } - else { - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - } - } - function forEachTrailingCommentToEmit(end, cb) { - // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments - if (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd)) { - ts.forEachTrailingCommentRange(currentText, end, cb); - } - } - function reset() { - currentSourceFile = undefined; - currentText = undefined; - currentLineMap = undefined; - detachedCommentsInfo = undefined; - } - function setWriter(output) { - writer = output; - } - function setSourceFile(sourceFile) { - currentSourceFile = sourceFile; - currentText = currentSourceFile.text; - currentLineMap = ts.getLineStarts(currentSourceFile); - detachedCommentsInfo = undefined; - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; - } - function forEachLeadingCommentWithoutDetachedComments(cb) { - // get the leading comments from detachedPos - var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentText, currentLineMap, writer, writeComment, range, newLine, disabled); - if (currentDetachedCommentInfo) { - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - */ - function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); - } - } - ts.createCommentWriter = createCommentWriter; -})(ts || (ts = {})); var ts; (function (ts) { var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); + var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. @@ -80866,7 +81182,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 278 /* Bundle */) { + if (sourceFile.kind === 280 /* Bundle */) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); @@ -80928,22 +81244,16 @@ var ts; var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); - var newLine = host.getNewLine(); + var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); - var sourceMap = ts.createSourceMapWriter(host, writer); - var declarationSourceMap = ts.createSourceMapWriter(host, writer, { - sourceMap: compilerOptions.declarationMap, - sourceRoot: compilerOptions.sourceRoot, - mapRoot: compilerOptions.mapRoot, - extendedDiagnostics: compilerOptions.extendedDiagnostics, - }); + var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; var bundleInfo = createDefaultBundleInfo(); var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file - ts.performance.mark("beforePrint"); + enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); - ts.performance.measure("printTime", "beforePrint"); + exit(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -80986,22 +81296,27 @@ var ts; } // Transform the source files var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], transformers, /*allowDtsFiles*/ false); + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: compilerOptions.noEmitHelpers, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + inlineSources: compilerOptions.inlineSources, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }; // Create a printer to print the nodes - var printer = createPrinter(__assign({}, compilerOptions, { noEmitHelpers: compilerOptions.noEmitHelpers }), { + var printer = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, // transform hooks onEmitNode: transform.emitNodeWithNotification, substituteNode: transform.substituteNode, - // sourcemap hooks - onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: sourceMap.emitPos, - // emitter hooks - onSetSourceFile: setSourceFile, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, sourceMap); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); } @@ -81025,14 +81340,20 @@ var ts; emitterDiagnostics.add(diagnostic); } } - var declarationPrinter = createPrinter(__assign({}, compilerOptions, { onlyPrintJsDocStyle: true, noEmitHelpers: true }), { + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: true, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + onlyPrintJsDocStyle: true, + }; + var declarationPrinter = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, - // sourcemap hooks - onEmitSourceMapOfNode: declarationSourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: declarationSourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: declarationSourceMap.emitPos, - onSetSourceFile: setSourceFileForDeclarationSourceMaps, // transform hooks onEmitNode: declarationTransform.emitNodeWithNotification, substituteNode: declarationTransform.substituteNode, @@ -81041,8 +81362,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, declarationSourceMap); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 277 /* SourceFile */) { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + sourceMap: compilerOptions.declarationMap, + sourceRoot: compilerOptions.sourceRoot, + mapRoot: compilerOptions.mapRoot, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }); + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -81051,7 +81377,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -81062,25 +81388,41 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; - mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); + var sourceMapGenerator; + if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { + sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); + } if (bundle) { - printer.writeBundle(bundle, writer, bundleInfo); + printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); } else { - printer.writeFile(sourceFile, writer); + printer.writeFile(sourceFile, writer, sourceMapGenerator); } - writer.writeLine(); - var sourceMappingURL = mapRecorder.getSourceMappingURL(); - if (sourceMappingURL) { - writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + if (sourceMapGenerator) { + if (sourceMapDataList) { + sourceMapDataList.push({ + inputSourceFileNames: sourceMapGenerator.getSources(), + sourceMap: sourceMapGenerator.toJSON() + }); + } + var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile); + if (sourceMappingURL) { + if (!writer.isAtStartOfLine()) + writer.rawWrite(newLine); + writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + } + // Write the source map + if (sourceMapFilePath) { + var sourceMap = sourceMapGenerator.toString(); + ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); + } } - // Write the source map - if (sourceMapFilePath) { - ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); + else { + writer.writeLine(); } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); @@ -81090,32 +81432,84 @@ var ts; ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); } // Reset state - mapRecorder.reset(); writer.clear(); bundleInfo = createDefaultBundleInfo(); } - function setSourceFile(node) { - sourceMap.setSourceFile(node); + function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { + return (mapOptions.sourceMap || mapOptions.inlineSourceMap) + && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } - function setSourceFileForDeclarationSourceMaps(node) { - declarationSourceMap.setSourceFile(node); + function getSourceRoot(mapOptions) { + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); + return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot; + } + function getSourceMapDirectory(mapOptions, filePath, sourceFile) { + if (mapOptions.sourceRoot) + return host.getCommonSourceDirectory(); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + } + return sourceMapDir; + } + return ts.getDirectoryPath(ts.normalizePath(filePath)); + } + function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) { + if (mapOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var sourceMapText = sourceMapGenerator.toString(); + var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); + return "data:application/json;base64," + base64SourceMapText; + } + var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath))); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapFile), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + return ts.combinePaths(sourceMapDir, sourceMapFile); + } + } + return sourceMapFile; } } ts.emitFiles = emitFiles; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; - PipelinePhase[PipelinePhase["Comments"] = 1] = "Comments"; - PipelinePhase[PipelinePhase["SourceMaps"] = 2] = "SourceMaps"; - PipelinePhase[PipelinePhase["Emit"] = 3] = "Emit"; + PipelinePhase[PipelinePhase["Substitution"] = 1] = "Substitution"; + PipelinePhase[PipelinePhase["Comments"] = 2] = "Comments"; + PipelinePhase[PipelinePhase["SourceMaps"] = 3] = "SourceMaps"; + PipelinePhase[PipelinePhase["Emit"] = 4] = "Emit"; })(PipelinePhase || (PipelinePhase = {})); function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); - var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var moduleKind = ts.getEmitModuleKind(printerOptions); + var bundledHelpers = ts.createMap(); var currentSourceFile; var nodeIdToGeneratedName; // Map of generated names for specific nodes. var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. @@ -81125,19 +81519,23 @@ var ts; var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes. var reservedNames; // TempFlags to reserve in nested name generation scopes. var writer; - var ownWriter; + var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; - var commitPendingSemicolon = ts.noop; - var writeSemicolon = writeSemicolonInternal; - var pendingSemicolon = false; - if (printerOptions.omitTrailingSemicolon) { - commitPendingSemicolon = commitPendingSemicolonInternal; - writeSemicolon = deferWriteSemicolon; - } - var syntheticParent = { pos: -1, end: -1 }; - var moduleKind = ts.getEmitModuleKind(printerOptions); - var bundledHelpers = ts.createMap(); var isOwnFileEmit; + // Source Maps + var sourceMapsDisabled = true; + var sourceMapGenerator; + var sourceMapSource; + var sourceMapSourceIndex = -1; + // Comments + var containerPos = -1; + var containerEnd = -1; + var declarationListContainerEnd = -1; + var currentLineMap; + var detachedCommentsInfo; + var hasWrittenComment = false; + var commentsDisabled = !!printerOptions.removeComments; + var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { // public API @@ -81164,9 +81562,9 @@ var ts; break; } switch (node.kind) { - case 277 /* SourceFile */: return printFile(node); - case 278 /* Bundle */: return printBundle(node); - case 279 /* UnparsedSource */: return printUnparsedSource(node); + case 279 /* SourceFile */: return printFile(node); + case 280 /* Bundle */: return printBundle(node); + case 281 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -81176,11 +81574,11 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, beginPrint()); + writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { - writeFile(sourceFile, beginPrint()); + writeFile(sourceFile, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printUnparsedSource(unparsed) { @@ -81189,14 +81587,14 @@ var ts; } function writeNode(hint, node, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(hint, node, sourceFile); reset(); writer = previousWriter; } function writeList(format, nodes, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); if (sourceFile) { setSourceFile(sourceFile); } @@ -81204,18 +81602,18 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, output, bundleInfo) { + function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { isOwnFileEmit = false; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(bundle); emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { var prepend = _b[_a]; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); writeLine(); + print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); } if (bundleInfo) { bundleInfo.originalOffset = writer.getTextPos(); @@ -81229,15 +81627,15 @@ var ts; } function writeUnparsedSource(unparsed, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } - function writeFile(sourceFile, output) { + function writeFile(sourceFile, output, sourceMapGenerator) { isOwnFileEmit = true; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); print(0 /* SourceFile */, sourceFile, sourceFile); @@ -81256,19 +81654,24 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, hint); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; - comments.setSourceFile(sourceFile); - if (onSetSourceFile) { - onSetSourceFile(sourceFile); + currentLineMap = undefined; + detachedCommentsInfo = undefined; + if (sourceFile) { + setSourceMapSource(sourceFile); } } - function setWriter(output) { - writer = output; // TODO: GH#18217 - comments.setWriter(output); + function setWriter(_writer, _sourceMapGenerator) { + if (_writer && printerOptions.omitTrailingSemicolon) { + _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + } + writer = _writer; // TODO: GH#18217 + sourceMapGenerator = _sourceMapGenerator; + sourceMapsDisabled = !writer || !sourceMapGenerator; } function reset() { nodeIdToGeneratedName = []; @@ -81277,68 +81680,66 @@ var ts; tempFlagsStack = []; tempFlags = 0 /* Auto */; reservedNamesStack = []; - comments.reset(); - setWriter(/*output*/ undefined); + currentSourceFile = undefined; + currentLineMap = undefined; + detachedCommentsInfo = undefined; + setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); + } + function getCurrentLineMap() { + return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } function emit(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 4 /* Unspecified */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); } function emitIdentifierName(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 2 /* IdentifierName */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(2 /* IdentifierName */, node); } function emitExpression(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(1 /* Expression */, node); } - function getPipelinePhase(phase, hint) { + function getPipelinePhase(phase, node) { switch (phase) { case 0 /* Notification */: - if (onEmitNode) { + if (onEmitNode !== ts.noEmitNotification) { return pipelineEmitWithNotification; } // falls through - case 1 /* Comments */: - if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + case 1 /* Substitution */: + if (substituteNode !== ts.noEmitSubstitution) { + return pipelineEmitWithSubstitution; + } + // falls through + case 2 /* Comments */: + if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { return pipelineEmitWithComments; } - return pipelineEmitWithoutComments; - case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { + // falls through + case 3 /* SourceMaps */: + if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through - case 3 /* Emit */: + case 4 /* Emit */: return pipelineEmitWithHint; default: - return ts.Debug.assertNever(phase, "Unexpected value for PipelinePhase: " + phase); + return ts.Debug.assertNever(phase); } } - function getNextPipelinePhase(currentPhase, hint) { - return getPipelinePhase(currentPhase + 1, hint); + function getNextPipelinePhase(currentPhase, node) { + return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); - } - function pipelineEmitWithComments(hint, node) { - ts.Debug.assertDefined(emitNodeWithComments); - ts.Debug.assert(hint !== 0 /* SourceFile */); - emitNodeWithComments(hint, trySubstituteNode(hint, node), getNextPipelinePhase(1 /* Comments */, hint)); - } - function pipelineEmitWithoutComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Comments */, hint); - pipelinePhase(hint, trySubstituteNode(hint, node)); - } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */); - ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); + var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); + onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -81347,254 +81748,285 @@ var ts; return emitIdentifier(ts.cast(node, ts.isIdentifier)); if (hint === 3 /* MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + if (hint === 5 /* EmbeddedStatement */) { + ts.Debug.assertNode(node, ts.isEmptyStatement); + return emitEmptyStatement(/*isEmbeddedStatement*/ true); + } if (hint === 4 /* Unspecified */) { if (ts.isKeyword(node.kind)) return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return emitLiteral(node); - case 279 /* UnparsedSource */: + case 281 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return emitQualifiedName(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return emitTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return emitParameter(node); - case 150 /* Decorator */: + case 152 /* Decorator */: return emitDecorator(node); // Type members - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return emitPropertySignature(node); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return emitMethodSignature(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return emitConstructor(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return emitAccessorDeclaration(node); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return emitCallSignature(node); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return emitConstructSignature(node); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return emitIndexSignature(node); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return emitTypePredicate(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return emitTypeReference(node); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return emitFunctionType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return emitConstructorType(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return emitTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return emitTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return emitArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return emitTupleType(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return emitOptionalType(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return emitUnionType(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return emitIntersectionType(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return emitConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return emitInferType(node); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return emitParenthesizedType(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return emitThisType(); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return emitTypeOperator(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return emitMappedType(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return emitLiteralType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return emitImportTypeNode(node); - case 282 /* JSDocAllType */: - write("*"); + case 284 /* JSDocAllType */: + writePunctuation("*"); return; - case 283 /* JSDocUnknownType */: - write("?"); + case 285 /* JSDocUnknownType */: + writePunctuation("?"); return; - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 170 /* RestType */: - case 288 /* JSDocVariadicType */: + case 172 /* RestType */: + case 290 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return emitBindingElement(node); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return emitTemplateSpan(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 216 /* Block */: + case 218 /* Block */: return emitBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return emitVariableStatement(node); - case 218 /* EmptyStatement */: - return emitEmptyStatement(); - case 219 /* ExpressionStatement */: + case 220 /* EmptyStatement */: + return emitEmptyStatement(/*isEmbeddedStatement*/ false); + case 221 /* ExpressionStatement */: return emitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return emitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return emitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return emitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return emitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return emitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return emitForOfStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return emitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return emitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return emitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return emitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return emitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return emitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return emitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return emitTryStatement(node); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return emitClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return emitModuleBlock(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return emitCaseBlock(node); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return emitImportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return emitImportClause(node); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return emitNamespaceImport(node); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return emitNamedImports(node); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return emitImportSpecifier(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return emitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return emitExportDeclaration(node); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return emitNamedExports(node); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return emitExportSpecifier(node); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 10 /* JsxText */: + case 11 /* JsxText */: return emitJsxText(node); - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 261 /* JsxClosingElement */: - case 264 /* JsxClosingFragment */: + case 263 /* JsxClosingElement */: + case 266 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return emitJsxAttribute(node); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return emitJsxAttributes(node); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return emitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return emitDefaultClause(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return emitHeritageClause(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return emitEnumMember(node); - // JSDoc nodes (ignored) + // JSDoc nodes (only used in codefixes currently) + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + return emitJSDocPropertyLikeTag(node); + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 301 /* JSDocThisTag */: + case 298 /* JSDocEnumTag */: + return emitJSDocSimpleTypedTag(node); + case 295 /* JSDocAugmentsTag */: + return emitJSDocAugmentsTag(node); + case 303 /* JSDocTemplateTag */: + return emitJSDocTemplateTag(node); + case 304 /* JSDocTypedefTag */: + return emitJSDocTypedefTag(node); + case 297 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + case 293 /* JSDocSignature */: + return emitJSDocSignature(node); + case 292 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 296 /* JSDocClassTag */: + case 294 /* JSDocTag */: + return emitJSDocSimpleTag(node); + case 291 /* JSDocComment */: + return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; - node = trySubstituteNode(1 /* Expression */, node); + if (substituteNode !== ts.noEmitSubstitution) { + node = substituteNode(hint, node); + } } else if (ts.isToken(node)) { return writeTokenNode(node, writePunctuation); @@ -81604,89 +82036,90 @@ var ts; switch (node.kind) { // Literals case 8 /* NumericLiteral */: - return emitNumericLiteral(node); - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + return emitNumericOrBigIntLiteral(node); + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Reserved words - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 101 /* TrueKeyword */: - case 99 /* ThisKeyword */: - case 91 /* ImportKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 102 /* TrueKeyword */: + case 100 /* ThisKeyword */: + case 92 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return emitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return emitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return emitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return emitArrowFunction(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return emitDeleteExpression(node); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return emitVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return emitAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return emitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return emitConditionalExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return emitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return emitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return emitSpreadExpression(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return emitClassExpression(node); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: return emitAsExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return emitNonNullExpression(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return emitJsxElement(node); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return emitCommaList(node); } } @@ -81698,12 +82131,13 @@ var ts; writeSpace(); emit(node.constraint); } - function trySubstituteNode(hint, node) { - return node && substituteNode && substituteNode(hint, node) || node; + function pipelineEmitWithSubstitution(hint, node) { + var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); + pipelinePhase(hint, substituteNode(hint, node)); } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 278 /* Bundle */ ? node : undefined; + var bundle = node.kind === 280 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -81752,7 +82186,8 @@ var ts; // Literals/Pseudo-literals // // SyntaxKind.NumericLiteral - function emitNumericLiteral(node) { + // SyntaxKind.BigIntLiteral + function emitNumericOrBigIntLiteral(node) { emitLiteral(node); } // SyntaxKind.StringLiteral @@ -81764,7 +82199,7 @@ var ts; function emitLiteral(node) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -81782,7 +82217,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 26896 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -81793,7 +82228,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -81829,7 +82264,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -81851,7 +82286,7 @@ var ts; emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitPropertyDeclaration(node) { emitDecorators(node, node.decorators); @@ -81861,7 +82296,7 @@ var ts; emit(node.exclamationToken); emitTypeAnnotation(node.type); emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node); - writeSemicolon(); + writeTrailingSemicolon(); } function emitMethodSignature(node) { pushNameGenerationScope(node); @@ -81872,7 +82307,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitMethodDeclaration(node) { @@ -81891,7 +82326,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 158 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -81903,7 +82338,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitConstructSignature(node) { @@ -81915,7 +82350,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitIndexSignature(node) { @@ -81923,10 +82358,10 @@ var ts; emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitSemicolonClassElement() { - writeSemicolon(); + writeTrailingSemicolon(); } // // Types @@ -81953,22 +82388,22 @@ var ts; popNameGenerationScope(node); } function emitJSDocFunctionType(node) { - write("function"); + writeKeyword("function"); emitParameters(node, node.parameters); - write(":"); + writePunctuation(":"); emit(node.type); } function emitJSDocNullableType(node) { - write("?"); + writePunctuation("?"); emit(node.type); } function emitJSDocNonNullableType(node) { - write("!"); + writePunctuation("!"); emit(node.type); } function emitJSDocOptionalType(node) { emit(node.type); - write("="); + writePunctuation("="); } function emitConstructorType(node) { pushNameGenerationScope(node); @@ -81989,8 +82424,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineTypeLiteralMembers */ : 16449 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 262144 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -81999,23 +82434,23 @@ var ts; writePunctuation("]"); } function emitRestOrJSDocVariadicType(node) { - write("..."); + writePunctuation("..."); emit(node.type); } function emitTupleType(node) { writePunctuation("["); - emitList(node, node.elementTypes, 272 /* TupleTypeElements */); + emitList(node, node.elementTypes, 528 /* TupleTypeElements */); writePunctuation("]"); } function emitOptionalType(node) { emit(node.type); - write("?"); + writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 260 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */); } function emitIntersectionType(node) { - emitList(node, node.types, 264 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */); } function emitConditionalType(node) { emit(node.checkType); @@ -82068,25 +82503,25 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 3 /* MappedTypeParameter */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 55 /* QuestionToken */) { + if (node.questionToken.kind !== 56 /* QuestionToken */) { writePunctuation("?"); } } writePunctuation(":"); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); if (emitFlags & 1 /* SingleLine */) { writeSpace(); } @@ -82119,12 +82554,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 262448 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -82142,8 +82577,8 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -82151,9 +82586,9 @@ var ts; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + 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); if (indentedFlag) { decreaseIndent(); } @@ -82164,20 +82599,20 @@ var ts; if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = ts.createToken(23 /* DotToken */); + var dotToken = ts.createToken(24 /* DotToken */); dotToken.pos = dotRangeStart; dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } emitExpression(node.expression); - increaseIndentIf(indentBeforeDot); + increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(23 /* DotToken */, node.expression.end, writePunctuation, node); - increaseIndentIf(indentAfterDot); + emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } @@ -82189,7 +82624,7 @@ var ts; // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); return !expression.numericLiteralFlags - && !ts.stringContains(text, ts.tokenToString(23 /* DotToken */)); + && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -82202,21 +82637,21 @@ var ts; } function emitElementAccessExpression(node) { emitExpression(node.expression); - emitTokenWithComment(21 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(22 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(94 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(95 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { emitExpression(node.tag); @@ -82231,9 +82666,9 @@ var ts; emitExpression(node.expression); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(19 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -82252,22 +82687,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(80 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(103 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(105 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(121 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(122 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -82292,24 +82727,24 @@ 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 === 200 /* PrefixUnaryExpression */ - && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) - || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); + return operand.kind === 202 /* PrefixUnaryExpression */ + && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) + || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator, writeOperator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 26 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); - increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 93 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - increaseIndentIf(indentAfterOperator, " "); + increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); } @@ -82319,23 +82754,23 @@ var ts; var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken); var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); - increaseIndentIf(indentBeforeQuestion, " "); + increaseIndentIf(indentBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); - increaseIndentIf(indentAfterQuestion, " "); + increaseIndentIf(indentAfterQuestion, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); - increaseIndentIf(indentBeforeColon, " "); + increaseIndentIf(indentBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); - increaseIndentIf(indentAfterColon, " "); + increaseIndentIf(indentAfterColon, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 131072 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(116 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(117 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -82383,38 +82818,45 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineBlockStatements */ : 65 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(18 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); emit(node.declarationList); - writeSemicolon(); + writeTrailingSemicolon(); } - function emitEmptyStatement() { - writeSemicolon(); + function emitEmptyStatement(isEmbeddedStatement) { + // While most trailing semicolons are possibly insignificant, an embedded "empty" + // statement is significant and cannot be elided by a trailing-semicolon-omitting writer. + if (isEmbeddedStatement) { + writePunctuation(";"); + } + else { + writeTrailingSemicolon(); + } } function emitExpressionStatement(node) { emitExpression(node.expression); // 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)) { - writeSemicolon(); + writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(91 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 220 /* IfStatement */) { + emitTokenWithComment(83 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 222 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -82424,14 +82866,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(106 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(81 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -82447,45 +82889,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.condition ? node.condition.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(20 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(92 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(93 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(147 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 236 /* VariableDeclarationList */) { + if (node.kind === 238 /* VariableDeclarationList */) { emit(node); } else { @@ -82494,14 +82936,14 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(77 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(78 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(72 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(73 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) { var node = ts.getParseTreeNode(contextNode); @@ -82527,40 +82969,40 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(96 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(97 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(107 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(108 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(98 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(56 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(100 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(101 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(102 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -82569,14 +83011,14 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(87 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(88 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(78 /* DebuggerKeyword */, node.pos, writeKeyword); - writeSemicolon(); + writeToken(79 /* DebuggerKeyword */, node.pos, writeKeyword); + writeTrailingSemicolon(); } // // Declarations @@ -82589,7 +83031,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 272 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -82637,7 +83079,7 @@ var ts; } else { emitSignatureHead(node); - writeSemicolon(); + writeTrailingSemicolon(); } } function emitSignatureHead(node) { @@ -82689,7 +83131,7 @@ var ts; emitBlockFunctionBody(body); } decreaseIndent(); - writeToken(18 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -82701,7 +83143,7 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); increaseIndent(); } else { @@ -82728,7 +83170,7 @@ var ts; emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* ClassMembers */); + emitList(node, node.members, 129 /* ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -82741,10 +83183,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 256 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* InterfaceMembers */); + emitList(node, node.members, 129 /* InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -82758,7 +83200,7 @@ var ts; writePunctuation("="); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitEnumDeclaration(node) { emitModifiers(node, node.modifiers); @@ -82767,7 +83209,7 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 81 /* EnumMembers */); + emitList(node, node.members, 145 /* EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { @@ -82779,8 +83221,8 @@ var ts; emit(node.name); var body = node.body; if (!body) - return writeSemicolon(); - while (body.kind === 242 /* ModuleDeclaration */) { + return writeTrailingSemicolon(); + while (body.kind === 244 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -82795,23 +83237,23 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 65 /* CaseBlockClauses */); - emitTokenWithComment(18 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* CaseBlockClauses */); + emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(59 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); - writeSemicolon(); + writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -82820,29 +83262,29 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); - writeSemicolon(); + writeTrailingSemicolon(); } function emitImportClause(node) { emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(26 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(39 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -82853,45 +83295,45 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(58 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(59 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(79 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(80 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(39 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(118 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(119 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(130 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(131 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamedExports(node) { emitNamedImportsOrExports(node); @@ -82901,14 +83343,14 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -82927,7 +83369,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -82939,7 +83381,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -82954,7 +83396,6 @@ var ts; writePunctuation(">"); } function emitJsxText(node) { - commitPendingSemicolon(); writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); } function emitJsxClosingElementOrFragment(node) { @@ -82965,7 +83406,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 131328 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -82985,7 +83426,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -82996,13 +83437,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(73 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(74 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(79 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(80 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -83012,14 +83453,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 81985 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 64 /* Indented */); + format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -83027,15 +83468,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 272 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(74 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(75 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(20 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -83084,6 +83525,142 @@ var ts; emitInitializer(node.initializer, node.name.end, node); } // + // JSDoc + // + function emitJSDoc(node) { + write("/**"); + if (node.comment) { + var lines = node.comment.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } + } + if (node.tags) { + if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + writeSpace(); + emit(node.tags[0]); + } + else { + emitList(node, node.tags, 33 /* JSDocComment */); + } + } + writeSpace(); + write("*/"); + } + function emitJSDocSimpleTypedTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.typeExpression); + emitJSDocComment(tag.comment); + } + function emitJSDocAugmentsTag(tag) { + emitJSDocTagName(tag.tagName); + writeSpace(); + writePunctuation("{"); + emit(tag.class); + writePunctuation("}"); + emitJSDocComment(tag.comment); + } + function emitJSDocTemplateTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.constraint); + writeSpace(); + emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitJSDocComment(tag.comment); + } + function emitJSDocTypedefTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.typeExpression) { + if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + emitJSDocTypeExpression(tag.typeExpression); + } + else { + writeSpace(); + writePunctuation("{"); + write("Object"); + if (tag.typeExpression.isArrayType) { + writePunctuation("["); + writePunctuation("]"); + } + writePunctuation("}"); + } + } + if (tag.fullName) { + writeSpace(); + emit(tag.fullName); + } + emitJSDocComment(tag.comment); + if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + emitJSDocTypeLiteral(tag.typeExpression); + } + } + function emitJSDocCallbackTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.name) { + writeSpace(); + emit(tag.name); + } + emitJSDocComment(tag.comment); + emitJSDocSignature(tag.typeExpression); + } + function emitJSDocSimpleTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocComment(tag.comment); + } + function emitJSDocTypeLiteral(lit) { + emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + } + function emitJSDocSignature(sig) { + if (sig.typeParameters) { + emitList(sig, ts.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + } + if (sig.parameters) { + emitList(sig, ts.createNodeArray(sig.parameters), 33 /* JSDocComment */); + } + if (sig.type) { + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + emit(sig.type); + } + } + function emitJSDocPropertyLikeTag(param) { + emitJSDocTagName(param.tagName); + emitJSDocTypeExpression(param.typeExpression); + writeSpace(); + if (param.isBracketed) { + writePunctuation("["); + } + emit(param.name); + if (param.isBracketed) { + writePunctuation("]"); + } + emitJSDocComment(param.comment); + } + function emitJSDocTagName(tagName) { + writePunctuation("@"); + emit(tagName); + } + function emitJSDocComment(comment) { + if (comment) { + writeSpace(); + write(comment); + } + } + function emitJSDocTypeExpression(typeExpression) { + if (typeExpression) { + writeSpace(); + writePunctuation("{"); + emit(typeExpression.type); + writePunctuation("}"); + } + } + // // Top-level nodes // function emitSourceFile(node) { @@ -83111,38 +83688,38 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - write("/// "); + writeComment("/// "); } else { - write("/// "); + writeComment("/// "); } writeLine(); } } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; - write("/// "); + writeComment("/// "); writeLine(); } - for (var _d = 0, types_16 = types; _d < types_16.length; _d++) { - var directive = types_16[_d]; - write("/// "); + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; + writeComment("/// "); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; - write("/// "); + writeComment("/// "); writeLine(); } } @@ -83161,7 +83738,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 272 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -83201,13 +83778,14 @@ var ts; setSourceFile(sourceFile); emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); } + setSourceFile(undefined); } } function emitShebangIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { - write(shebang); + writeComment(shebang); writeLine(); return true; } @@ -83235,7 +83813,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 131328 /* Modifiers */); + emitList(node, modifiers, 262656 /* Modifiers */); writeSpace(); } } @@ -83249,7 +83827,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(59 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -83286,24 +83864,30 @@ var ts; else { writeLine(); increaseIndent(); - emit(node); + if (ts.isEmptyStatement(node)) { + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); + pipelinePhase(5 /* EmbeddedStatement */, node); + } + else { + emit(node); + } decreaseIndent(); } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 24577 /* Decorators */); + emitList(parentNode, decorators, 49153 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 26896 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */); } 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, 26896 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 1296 /* Parameters */); + emitList(parentNode, parameters, 2576 /* Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -83324,14 +83908,14 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 1296 /* Parameters */ & ~1024 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 4432 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } function emitList(parentNode, children, format, start, count) { emitNodeList(emit, parentNode, children, format, start, count); @@ -83340,7 +83924,7 @@ var ts; emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { - switch (format & 28 /* DelimitersMask */) { + switch (format & 60 /* DelimitersMask */) { case 0 /* None */: break; case 16 /* CommaDelimited */: @@ -83350,6 +83934,11 @@ var ts; writeSpace(); writePunctuation("|"); break; + case 32 /* AsteriskDelimited */: + writeSpace(); + writePunctuation("*"); + writeSpace(); + break; case 8 /* AmpersandDelimited */: writeSpace(); writePunctuation("&"); @@ -83360,11 +83949,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 & 8192 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 16384 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -83373,7 +83962,7 @@ var ts; } return; } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { // TODO: GH#18217 @@ -83388,23 +83977,23 @@ var ts; if (format & 1 /* MultiLine */) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */ && !(format & 262144 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { writeSpace(); } } else { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { increaseIndent(); } // Emit each child. @@ -83413,14 +84002,19 @@ 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 (previousSibling) { + if (format & 32 /* AsteriskDelimited */) { + // always write JSDoc in the format "\n *" + writeLine(); + writeDelimiter(format); + } + else if (previousSibling) { // i.e // function commentedParameters( // /* Parameter a */ // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -83428,14 +84022,14 @@ var ts; if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 64 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 256 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { writeSpace(); } } @@ -83457,7 +84051,7 @@ var ts; previousSibling = child; } // Write a trailing comma, if requested. - var hasTrailingComma = (format & 32 /* AllowTrailingComma */) && children.hasTrailingComma; + var hasTrailingComma = (format & 64 /* AllowTrailingComma */) && children.hasTrailingComma; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { writePunctuation(","); } @@ -83467,25 +84061,25 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { + if (previousSibling && format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { emitLeadingCommentsOfPosition(previousSibling.end); } // Decrease the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { decreaseIndent(); } // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { if (isEmpty && !isUndefined) { // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists @@ -83493,73 +84087,55 @@ var ts; writePunctuation(getClosingBracket(format)); } } - function commitPendingSemicolonInternal() { - if (pendingSemicolon) { - writeSemicolonInternal(); - pendingSemicolon = false; - } - } + // Writers function writeLiteral(s) { - commitPendingSemicolon(); writer.writeLiteral(s); } function writeStringLiteral(s) { - commitPendingSemicolon(); writer.writeStringLiteral(s); } function writeBase(s) { - commitPendingSemicolon(); writer.write(s); } function writeSymbol(s, sym) { - commitPendingSemicolon(); writer.writeSymbol(s, sym); } function writePunctuation(s) { - commitPendingSemicolon(); writer.writePunctuation(s); } - function deferWriteSemicolon() { - pendingSemicolon = true; - } - function writeSemicolonInternal() { - writer.writePunctuation(";"); + function writeTrailingSemicolon() { + writer.writeTrailingSemicolon(";"); } function writeKeyword(s) { - commitPendingSemicolon(); writer.writeKeyword(s); } function writeOperator(s) { - commitPendingSemicolon(); writer.writeOperator(s); } function writeParameter(s) { - commitPendingSemicolon(); writer.writeParameter(s); } + function writeComment(s) { + writer.writeComment(s); + } function writeSpace() { - commitPendingSemicolon(); writer.writeSpace(" "); } function writeProperty(s) { - commitPendingSemicolon(); writer.writeProperty(s); } function writeLine() { - commitPendingSemicolon(); writer.writeLine(); } function increaseIndent() { - commitPendingSemicolon(); writer.increaseIndent(); } function decreaseIndent() { - commitPendingSemicolon(); writer.decreaseIndent(); } function writeToken(token, pos, writer, contextNode) { - return onEmitSourceMapOfToken - ? onEmitSourceMapOfToken(contextNode, token, writer, pos, writeTokenText) + return !sourceMapsDisabled + ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText) : writeTokenText(token, writer, pos); } function writeTokenNode(node, writer) { @@ -83587,23 +84163,23 @@ var ts; function writeLines(text) { var lines = text.split(/\r\n?|\n/g); var indentation = ts.guessIndentation(lines); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var lineText = lines_2[_a]; + for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) { + var lineText = lines_3[_a]; var line = indentation ? lineText.slice(indentation) : lineText; if (line.length) { writeLine(); write(line); - writeLine(); + writer.rawWrite(newLine); } } } - function increaseIndentIf(value, valueToWriteWhenNotIndenting) { + function increaseIndentIf(value, writeSpaceIfNotIndenting) { if (value) { increaseIndent(); writeLine(); } - else if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); + else if (writeSpaceIfNotIndenting) { + writeSpace(); } } // Helper function to decrease the indent if we previously indented. Allows multiple @@ -83623,7 +84199,7 @@ var ts; return true; } if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var firstChild = children[0]; @@ -83662,10 +84238,10 @@ var ts; } function shouldWriteClosingLineTerminator(parentNode, children, format) { if (format & 1 /* MultiLine */) { - return (format & 65536 /* NoTrailingNewLine */) === 0; + return (format & 131072 /* NoTrailingNewLine */) === 0; } else if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var lastChild = ts.lastOrUndefined(children); @@ -83687,11 +84263,11 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { parent = skipSynthesizedParentheses(parent); @@ -83711,7 +84287,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -83723,7 +84299,7 @@ var ts; else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { return ts.idText(node); } - else if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { @@ -83732,7 +84308,7 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape) { - if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode)) { return neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? @@ -83776,81 +84352,81 @@ var ts; if (!node) return; switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: ts.forEach(node.statements, generateNames); break; - case 231 /* LabeledStatement */: - case 229 /* WithStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 233 /* LabeledStatement */: + case 231 /* WithStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: generateNames(node.statement); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: generateNames(node.declarationList); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: generateNames(node.importClause); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -83859,12 +84435,12 @@ var ts; if (!node) return; switch (node.kind) { - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -84044,23 +84620,23 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 254 /* ExportAssignment */: return generateNameForExportDefault(); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return generateNameForClassExpression(); - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -84101,21 +84677,396 @@ var ts; // otherwise, return the original node for the source; return node; } + // Comments + function pipelineEmitWithComments(hint, node) { + enterComment(); + hasWrittenComment = false; + var emitFlags = ts.getEmitFlags(node); + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + // 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 */; + // Save current container state on the stack. + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + 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); + } + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* 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)) { + // 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 === 238 /* VariableDeclarationList */) { + declarationListContainerEnd = end; + } + } + } + ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); + exitComment(); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, node); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + pipelinePhase(hint, node); + commentsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + enterComment(); + ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); + if ((pos > 0 || end > 0) && pos !== end) { + // Restore previous container state. + containerPos = savedContainerPos; + containerEnd = savedContainerEnd; + 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 && isEmittedNode) { + emitTrailingComments(end); + } + } + exitComment(); + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 /* MultiLineCommentTrivia */ + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { + 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; + if (!skipLeadingComments) { + emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); + } + exitComment(); + if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + commentsDisabled = true; + emitCallback(node); + commentsDisabled = false; + } + else { + emitCallback(node); + } + enterComment(); + if (!skipTrailingComments) { + emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); + if (hasWrittenComment && !writer.isAtStartOfLine()) { + writer.writeLine(); + } + } + exitComment(); + } + function emitLeadingComments(pos, isEmittedNode) { + hasWrittenComment = false; + if (isEmittedNode) { + forEachLeadingCommentToEmit(pos, emitLeadingComment); + } + else if (pos === 0) { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted + forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); + } + } + function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (isTripleSlashComment(commentPos, commentEnd)) { + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + } + } + function shouldWriteComment(text, pos) { + if (printerOptions.onlyPrintJsDocStyle) { + return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); + } + return true; + } + function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + if (!hasWrittenComment) { + ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); + hasWrittenComment = true; + } + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + else if (kind === 3 /* MultiLineCommentTrivia */) { + writer.writeSpace(" "); + } + } + function emitLeadingCommentsOfPosition(pos) { + if (commentsDisabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } + function emitTrailingComments(pos) { + forEachTrailingCommentToEmit(pos, emitTrailingComment); + } + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + } + function emitTrailingCommentsOfPosition(pos, prefixSpace) { + if (commentsDisabled) { + return; + } + enterComment(); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); + exitComment(); + } + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + // 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 (hasTrailingNewLine) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function forEachLeadingCommentToEmit(pos, cb) { + // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) { + if (hasDetachedComments(pos)) { + forEachLeadingCommentWithoutDetachedComments(cb); + } + else { + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + } + } + function forEachTrailingCommentToEmit(end, cb) { + // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) { + ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; + } + function forEachLeadingCommentWithoutDetachedComments(cb) { + // get the leading comments from detachedPos + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + function emitDetachedCommentsAndUpdateCommentsInfo(range) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + emitPos(commentPos); + ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + */ + function isTripleSlashComment(commentPos, commentEnd) { + return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + } + // Source Maps + function pipelineEmitWithSourceMap(hint, node) { + var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); + if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { + var parsed = ts.tryParseRawSourceMap(node.sourceMapText); + if (parsed) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + } + pipelinePhase(hint, node); + } + else { + var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; + var emitFlags = ts.getEmitFlags(node); + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + && pos >= 0) { + emitSourcePos(source, skipSourceTrivia(source, pos)); + } + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = true; + pipelinePhase(hint, node); + sourceMapsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + && end >= 0) { + emitSourcePos(source, end); + } + } + } + /** + * Skips trivia such as comments and white-space that can optionally overriden by the source map source + */ + function skipSourceTrivia(source, pos) { + return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(sourceMapSource.text, pos); + } + /** + * Emits a mapping. + * + * If the position is synthetic (undefined or a negative value), no mapping will be + * created. + * + * @param pos The position. + */ + function emitPos(pos) { + if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) { + return; + } + var _a = ts.getLineAndCharacterOfPosition(currentSourceFile, pos), sourceLine = _a.line, sourceCharacter = _a.character; + sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, + /*nameIndex*/ undefined); + } + function emitSourcePos(source, pos) { + if (source !== sourceMapSource) { + var savedSourceMapSource = sourceMapSource; + setSourceMapSource(source); + emitPos(pos); + setSourceMapSource(savedSourceMapSource); + } + else { + emitPos(pos); + } + } + /** + * Emits a token of a node with possible leading and trailing source maps. + * + * @param node The node containing the token. + * @param token The token to emit. + * @param tokenStartPos The start pos of the token. + * @param emitCallback The callback used to emit the token. + */ + function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { + if (sourceMapsDisabled || node && ts.isInJsonFile(node)) { + return emitCallback(token, writer, tokenPos); + } + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags || 0 /* 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) { + emitSourcePos(source, tokenPos); + } + tokenPos = emitCallback(token, writer, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + emitSourcePos(source, tokenPos); + } + return tokenPos; + } + function setSourceMapSource(source) { + if (sourceMapsDisabled) { + return; + } + sourceMapSource = source; + if (isJsonSourceMapSource(source)) { + return; + } + sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName); + if (printerOptions.inlineSources) { + sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text); + } + } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* Braces */] = ["{", "}"]; + brackets[2048 /* Parenthesis */] = ["(", ")"]; + brackets[4096 /* AngleBrackets */] = ["<", ">"]; + brackets[8192 /* SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; + return brackets[format & 15360 /* BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; + return brackets[format & 15360 /* BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -84810,7 +85761,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function loadWithLocalCache(names, containingFile, loader) { + function loadWithLocalCache(names, containingFile, redirectedReference, loader) { if (names.length === 0) { return []; } @@ -84823,7 +85774,7 @@ var ts; result = cache.get(name); } else { - cache.set(name, result = loader(name, containingFile)); + cache.set(name, result = loader(name, containingFile, redirectedReference)); } resolutions.push(result); } @@ -84842,6 +85793,7 @@ var ts; if (program.getRootFileNames().length !== rootFileNames.length) { return false; } + var seenResolvedRefs; // If project references dont match if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { return false; @@ -84867,7 +85819,7 @@ var ts; return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || - hasInvalidatedResolution(sourceFile.resolvedPath); + hasInvalidatedResolution(sourceFile.path); } function sourceFileVersionUptoDate(sourceFile) { return sourceFile.version === getSourceVersion(sourceFile.resolvedPath); @@ -84876,10 +85828,24 @@ var ts; if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { return false; } - var oldResolvedRef = program.getResolvedProjectReferences()[index]; + return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + } + function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { + if (ts.contains(seenResolvedRefs, oldResolvedRef)) { + // Assume true + return true; + } // If sourceFile for the oldResolvedRef existed, check the version for uptodate - return sourceFileVersionUptoDate(oldResolvedRef.sourceFile); + if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + return false; + } + // Add to seen before checking the referenced paths of this config file + (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); + // If child project references are upto date, this project reference is uptodate + return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) { + return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]); + }); } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. @@ -84926,7 +85892,7 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; - var modifiedFilePaths; + var ambientModuleNameToUnmodifiedFileName = ts.createMap(); var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -84958,12 +85924,11 @@ var ts; // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createMap(); var _compilerOptionsObjectLiteralSyntax; - var _referencesArrayLiteralSyntax; var moduleResolutionCache; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -84975,16 +85940,16 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 - resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; + var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 + resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, 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). @@ -85000,7 +85965,7 @@ var ts; // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; // A parallel array to projectReferences storing the results of reading in the referenced tsconfig files - var resolvedProjectReferences = projectReferences ? [] : undefined; + var resolvedProjectReferences; var projectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -85008,23 +85973,25 @@ var ts; processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { - for (var _i = 0, projectReferences_1 = projectReferences; _i < projectReferences_1.length; _i++) { - var ref = projectReferences_1[_i]; - var parsedRef = parseProjectReferenceConfigFile(ref); - resolvedProjectReferences.push(parsedRef); - if (parsedRef) { - var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - var dtsOutfile = ts.changeExtension(out, ".d.ts"); - processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (!resolvedProjectReferences) { + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + } + if (rootNames.length) { + for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { + var parsedRef = resolvedProjectReferences_1[_i]; + if (parsedRef) { + var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; + if (out) { + var dtsOutfile = ts.changeExtension(out, ".d.ts"); + processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } - addProjectReferenceRedirects(parsedRef.commandLine); } } } ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false); }); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); @@ -85038,7 +86005,7 @@ var ts; // - The '--noLib' flag is used. // - A 'no-default-lib' reference comment is encountered in // processing the root files. - if (!skipDefaultLib) { + if (rootNames.length && !skipDefaultLib) { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file var defaultLibraryFileName = getDefaultLibraryFileName(); @@ -85063,10 +86030,18 @@ var ts; var oldSourceFiles = oldProgram.getSourceFiles(); for (var _a = 0, oldSourceFiles_1 = oldSourceFiles; _a < oldSourceFiles_1.length; _a++) { var oldSourceFile = oldSourceFiles_1[_a]; - if (!getSourceFile(oldSourceFile.path) || shouldCreateNewSourceFile) { - host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions()); + var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); + if (shouldCreateNewSourceFile || !newFile || + // old file wasnt redirect but new file is + (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { + host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; @@ -85107,7 +86082,10 @@ var ts; getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, getProjectReferences: getProjectReferences, getResolvedProjectReferences: getResolvedProjectReferences, - getProjectReferenceRedirect: getProjectReferenceRedirect + getProjectReferenceRedirect: getProjectReferenceRedirect, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, + forEachResolvedProjectReference: forEachResolvedProjectReference }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -85170,13 +86148,13 @@ var ts; } return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) { if (structuralIsReused === 0 /* 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, containingFile); + return resolveModuleNamesWorker(moduleNames, containingFile, /*reusedNames*/ undefined, getResolvedProjectReferenceToRedirect(file.originalFileName)); } - var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile); + var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); if (oldSourceFile !== file && file.resolvedModules) { // `file` was created for the new program. // @@ -85239,7 +86217,7 @@ var ts; } } else { - resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName); } if (resolvesToAmbientModuleInNonModifiedFile) { (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; @@ -85250,7 +86228,7 @@ var ts; } } var resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames) + ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName)) : ts.emptyArray; // Combine results of resolutions and predicted results if (!result) { @@ -85276,12 +86254,9 @@ var ts; return result; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. - function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - if (!oldProgramState.program) { - return false; - } - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 - var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) { + var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName); + var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same // place as we expected to find an actual module file. @@ -85290,16 +86265,34 @@ var ts; return false; } // at least one of declarations should come from non-modified source file - var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); }); - if (!firstUnmodifiedFile) { + var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName); + if (!unmodifiedFile) { return false; } if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile); } return true; } } + function canReuseProjectReferences() { + return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) { + var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var newResolvedRef = parseProjectReferenceConfigFile(newRef); + if (oldResolvedRef) { + // Resolved project reference has gone missing or changed + return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + } + else { + // A previously-unresolved reference may be resolved now + return newResolvedRef !== undefined; + } + }, function (oldProjectReferences, parent) { + // If array of references is changed, we cant resue old program + var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences; + return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo); + }); + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return 0 /* Not */; @@ -85320,40 +86313,14 @@ var ts; return oldProgram.structureIsReused = 0 /* Not */; } // Check if any referenced project tsconfig files are different - // If array of references is changed, we cant resue old program - var oldProjectReferences = oldProgram.getProjectReferences(); - if (!ts.arrayIsEqualTo(oldProjectReferences, projectReferences, ts.projectReferenceIsEqualTo)) { + if (!canReuseProjectReferences()) { return oldProgram.structureIsReused = 0 /* Not */; } - // Check the json files for the project references - var oldRefs = oldProgram.getResolvedProjectReferences(); if (projectReferences) { - // Resolved project referenced should be array if projectReferences provided are array - ts.Debug.assert(!!oldRefs); - for (var i = 0; i < projectReferences.length; i++) { - var oldRef = oldRefs[i]; - var newRef = parseProjectReferenceConfigFile(projectReferences[i]); - if (oldRef) { - if (!newRef || newRef.sourceFile !== oldRef.sourceFile) { - // Resolved project reference has gone missing or changed - return oldProgram.structureIsReused = 0 /* Not */; - } - } - else { - // A previously-unresolved reference may be resolved now - if (newRef !== undefined) { - return oldProgram.structureIsReused = 0 /* Not */; - } - } - } - } - else { - // Resolved project referenced should be undefined if projectReferences is undefined - ts.Debug.assert(!oldRefs); + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2 /* Completely */; // If the missing file paths are now present, it can change the progam structure, @@ -85404,7 +86371,6 @@ var ts; newSourceFile.originalFileName = oldSourceFile.originalFileName; newSourceFile.resolvedPath = oldSourceFile.resolvedPath; newSourceFile.fileName = oldSourceFile.fileName; - filePaths.push(newSourceFile.path); 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, @@ -85465,15 +86431,23 @@ var ts; if (oldProgram.structureIsReused !== 2 /* Completely */) { return oldProgram.structureIsReused; } - modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); + for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) { + var oldFile = oldSourceFiles_3[_a]; + if (!ts.contains(modifiedFiles, oldFile)) { + for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) { + var moduleName = _c[_b]; + ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); + } + } + } // try to verify results of module resolution - for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { - var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; + for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { + var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = getModuleNames(newSourceFile); - var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { @@ -85487,7 +86461,7 @@ var ts; if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); if (resolutionsChanged) { @@ -85507,28 +86481,22 @@ var ts; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping - for (var i = 0; i < newSourceFiles.length; i++) { - filesByName.set(filePaths[i], newSourceFiles[i]); + for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { + var newSourceFile = newSourceFiles_1[_f]; + var filePath = newSourceFile.path; + addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); // Set the file as found during node modules search if it was found that way in old progra, - if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) { - sourceFilesFoundSearchingNodeModules.set(filePaths[i], true); + if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePath))) { + sourceFilesFoundSearchingNodeModules.set(filePath, true); } } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) { - var modifiedFile = modifiedSourceFiles_2[_c]; + for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) { + var modifiedFile = modifiedSourceFiles_2[_g]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - resolvedProjectReferences = oldProgram.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - resolvedProjectReferences.forEach(function (ref) { - if (ref) { - addProjectReferenceRedirects(ref.commandLine); - } - }); - } sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; return oldProgram.structureIsReused = 2 /* Completely */; @@ -85791,22 +86759,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 149 /* Parameter */: - case 152 /* PropertyDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 235 /* VariableDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 237 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -85814,41 +86782,41 @@ var ts; } } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 108 /* ImplementsKeyword */) { + if (heritageClause.token === 109 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -85861,51 +86829,51 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 240 /* ClassDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 219 /* VariableStatement */); } break; - case 152 /* PropertyDeclaration */: + case 154 /* 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 !== 115 /* StaticKeyword */) { + if (modifier.kind !== 116 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -85922,24 +86890,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 124 /* DeclareKeyword */: - case 117 /* AbstractKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 125 /* DeclareKeyword */: + case 118 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 115 /* StaticKeyword */: - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 116 /* StaticKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: } } } @@ -85987,10 +86955,22 @@ var ts; return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } function getOptionsDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), options.configFile ? programDiagnostics.getDiagnostics(options.configFile.fileName) : []))); + return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile()))); + } + function getOptionsDiagnosticsOfConfigFile() { + if (!options.configFile) { + return ts.emptyArray; + } + var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); + } + }); + return diagnostics; } function getGlobalDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); + return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray; } function getConfigFileParsingDiagnostics() { return configFileParsingDiagnostics || ts.emptyArray; @@ -86002,9 +86982,9 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 71 /* Identifier */ - ? b.kind === 71 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 9 /* StringLiteral */ && a.text === b.text; + return a.kind === 72 /* Identifier */ + ? b.kind === 72 /* Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -86032,12 +87012,9 @@ var ts; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(node); - } } if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(file.endOfFileToken); + collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; file.moduleAugmentations = moduleAugmentations || ts.emptyArray; @@ -86085,24 +87062,37 @@ var ts; } } } - function collectDynamicImportOrRequireCalls(node) { - if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { - imports = ts.append(imports, node.arguments[0]); - } - // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. - else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { - imports = ts.append(imports, node.arguments[0]); - } - else if (ts.isLiteralImportTypeNode(node)) { - imports = ts.append(imports, node.argument.literal); - } - collectDynamicImportOrRequireCallsForEachChild(node); - if (ts.hasJSDocNodes(node)) { - ts.forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild); + function collectDynamicImportOrRequireCalls(file) { + var r = /import|require/g; + while (r.exec(file.text) !== null) { + var node = getNodeAtPosition(file, r.lastIndex); + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { + imports = ts.append(imports, node.arguments[0]); + } + // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. + else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { + imports = ts.append(imports, node.arguments[0]); + } + else if (ts.isLiteralImportTypeNode(node)) { + imports = ts.append(imports, node.argument.literal); + } } } - function collectDynamicImportOrRequireCallsForEachChild(node) { - ts.forEachChild(node, collectDynamicImportOrRequireCalls); + /** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */ + 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 */)))) { + return child; + } + }; + while (true) { + var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild); + if (!child) { + return current; + } + current = child; + } } } function getLibFileFromReference(ref) { @@ -86264,7 +87254,7 @@ var ts; // Instead of creating a duplicate, just redirect to the existing one. var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 redirectTargetsMap.add(fileFromPackageId.path, fileName); - filesByName.set(path, dupFile); + addFileToFilesByName(dupFile, path, redirectedPath); sourceFileToPackageName.set(path, packageId.name); processingOtherFiles.push(dupFile); return dupFile; @@ -86275,10 +87265,7 @@ var ts; sourceFileToPackageName.set(path, packageId.name); } } - filesByName.set(path, file); - if (redirectedPath) { - filesByName.set(redirectedPath, file); - } + addFileToFilesByName(file, path, redirectedPath); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; @@ -86312,24 +87299,82 @@ var ts; } return file; } + function addFileToFilesByName(file, path, redirectedPath) { + filesByName.set(path, file); + if (redirectedPath) { + filesByName.set(redirectedPath, file); + } + } function getProjectReferenceRedirect(fileName) { // Ignore dts or any of the non ts files - if (!projectReferenceRedirects || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to // look in the output folder of the referenced project rather than the input - return ts.forEach(projectReferenceRedirects, function (referencedProject) { + var referencedProject = getResolvedProjectReferenceToRedirect(fileName); + if (!referencedProject) { + return undefined; + } + var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out; + return out ? + ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine); + } + /** + * Get the referenced project if the file is input file from that reference project + */ + function getResolvedProjectReferenceToRedirect(fileName) { + return forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) { // not input file from the referenced project, ignore - if (!ts.contains(referencedProject.fileNames, fileName, isSameFile)) { + if (!referencedProject || + toPath(options.configFilePath) === referenceProjectPath || + !ts.contains(referencedProject.commandLine.fileNames, fileName, isSameFile)) { return undefined; } - var out = referencedProject.options.outFile || referencedProject.options.out; - return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : - ts.getOutputDeclarationFileName(fileName, referencedProject); + return referencedProject; }); } + function forEachResolvedProjectReference(cb) { + return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var resolvedRefPath = toPath(resolveProjectReferencePath(ref)); + return cb(resolvedRef, resolvedRefPath); + }); + } + function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { + var seenResolvedRefs; + return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); + function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) { + // Visit project references first + if (cbRef) { + var result = cbRef(projectReferences, parent); + if (result) { + return result; + } + } + return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { + if (ts.contains(seenResolvedRefs, resolvedRef)) { + // ignore recursives + return undefined; + } + var result = cbResolvedRef(resolvedRef, index, parent); + if (result) { + return result; + } + if (!resolvedRef) + return undefined; + (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef); + return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef); + }); + } + } + function getResolvedProjectReferenceByPath(projectReferencePath) { + if (!projectReferenceRedirects) { + return undefined; + } + return projectReferenceRedirects.get(projectReferencePath) || undefined; + } function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); @@ -86342,7 +87387,7 @@ var ts; if (!typeDirectives) { return; } - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName)); for (var i = 0; i < typeDirectives.length; i++) { var ref = file.typeReferenceDirectives[i]; var resolvedTypeReferenceDirective = resolutions[i]; @@ -86360,6 +87405,8 @@ var ts; } var saveResolution = true; if (resolvedTypeReferenceDirective) { + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 @@ -86384,6 +87431,8 @@ var ts; processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth--; } else { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 @@ -86428,8 +87477,7 @@ var ts; if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); - var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file); ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; @@ -86497,20 +87545,34 @@ var ts; return allFilesBelongToPath; } function parseProjectReferenceConfigFile(ref) { + if (!projectReferenceRedirects) { + projectReferenceRedirects = ts.createMap(); + } // The actual filename (i.e. add "/tsconfig.json" if necessary) var refPath = resolveProjectReferencePath(ref); + var sourceFilePath = toPath(refPath); + var fromCache = projectReferenceRedirects.get(sourceFilePath); + if (fromCache !== undefined) { + return fromCache || undefined; + } // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); return undefined; } - sourceFile.path = toPath(refPath); + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; var commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); - return { commandLine: commandLine, sourceFile: sourceFile }; - } - function addProjectReferenceRedirects(referencedProject) { - (projectReferenceRedirects || (projectReferenceRedirects = [])).push(referencedProject); + var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile }; + projectReferenceRedirects.set(sourceFilePath, resolvedRef); + if (commandLine.projectReferences) { + resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile); + } + return resolvedRef; } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { @@ -86546,30 +87608,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } } - if (projectReferences) { - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i] && resolvedProjectReferences[i].commandLine.options; - if (resolvedRefOpts === undefined) { - createDiagnosticForReference(i, ts.Diagnostics.File_0_does_not_exist, ref.path); - continue; - } - if (!resolvedRefOpts.composite) { - createDiagnosticForReference(i, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); - } - if (ref.prepend) { - var out = resolvedRefOpts.outFile || resolvedRefOpts.out; - if (out) { - if (!host.fileExists(out)) { - createDiagnosticForReference(i, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); - } - } - else { - createDiagnosticForReference(i, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); - } - } - } - } + verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); @@ -86648,12 +87687,12 @@ var ts; } var languageVersion = options.target || 0 /* ES3 */; var outFile = options.outFile || options.out; - var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + 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 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } - var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); @@ -86691,7 +87730,7 @@ var ts; // Precalculate and cache the common source directory var dir = getCommonSourceDirectory(); // If we failed to find a good common directory, but outDir is specified and at least one of our files is on a windows drive/URL/other resource, add a failure - if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { + if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) { createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } @@ -86761,6 +87800,35 @@ var ts; } } } + function verifyProjectReferences() { + forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var parentFile = parent && parent.sourceFile; + if (!resolvedRef) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path); + return; + } + var options = resolvedRef.commandLine.options; + if (!options.composite) { + // ok to not have composite if the current program is container only + var inputs = parent ? parent.commandLine.fileNames : rootNames; + if (inputs.length) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); + } + } + if (ref.prepend) { + var out = options.outFile || options.out; + if (out) { + if (!host.fileExists(out)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); + } + } + else { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); + } + } + }); + } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { var needCompilerDiagnostic = true; var pathsSyntax = getOptionPathsSyntax(); @@ -86811,10 +87879,10 @@ var ts; function createOptionValueDiagnostic(option1, message, arg0) { createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0); } - function createDiagnosticForReference(index, message, arg0, arg1) { - var referencesSyntax = getProjectReferencesSyntax(); + function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) { + var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; }); if (referencesSyntax && referencesSyntax.elements.length > index) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); } else { programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1)); @@ -86828,22 +87896,6 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2)); } } - function getProjectReferencesSyntax() { - if (_referencesArrayLiteralSyntax === undefined) { - _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword - if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 - for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { - var prop = _a[_i]; - if (ts.isArrayLiteralExpression(prop.initializer)) { - _referencesArrayLiteralSyntax = prop.initializer; - break; - } - } - } - } - return _referencesArrayLiteralSyntax; - } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword @@ -86918,7 +87970,8 @@ var ts; readFile: function (f) { return host.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: function () { return undefined; } + onUnRecoverableConfigFileDiagnostic: function () { return undefined; }, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost; @@ -86968,7 +88021,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 === 9 /* StringLiteral */) { + if (aug.kind === 10 /* StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -87193,6 +88246,11 @@ var ts; var latestSignature; if (sourceFile.isDeclarationFile) { latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.path) : undefined; + exportedModulesMapCache.set(sourceFile.path, references || false); + } } else { var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); @@ -87258,7 +88316,7 @@ var ts; return getAllFileNames(state, programOfThisState); } // If this is non module emit, or its a global file, it depends on all the source files - if (!state.referencedMap || (!ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile))) { + if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) { return getAllFileNames(state, programOfThisState); } // Get the references, traversing deep from the referenceMap @@ -87317,6 +88375,20 @@ var ts; } return true; } + /** + * Return true if file contains anything that augments to global scope we need to build them as if + * they are global files as well as module + */ + function containsGlobalScopeAugmentation(sourceFile) { + return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); }); + } + /** + * Return true if the file will invalidate all files because it affectes global scope + */ + function isFileAffectingGlobalScope(sourceFile) { + return containsGlobalScopeAugmentation(sourceFile) || + !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + } /** * Gets all files of the program excluding the default library file */ @@ -87357,7 +88429,7 @@ var ts; * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { - if (!ts.isExternalModule(sourceFileWithUpdatedShape) && !containsOnlyAmbientModules(sourceFileWithUpdatedShape)) { + if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } var compilerOptions = programOfThisState.getCompilerOptions(); @@ -87407,8 +88479,9 @@ var ts; } state.changedFilesSet = ts.createMap(); var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); + var oldCompilerOptions = useOldState ? oldState.program.getCompilerOptions() : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && - !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldState.program.getCompilerOptions()); + !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions); if (useOldState) { // Verify the sanity of old state if (!oldState.currentChangedFilePath) { @@ -87423,6 +88496,8 @@ var ts; // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; + var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck; + var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -87440,6 +88515,13 @@ var ts; state.changedFilesSet.set(sourceFilePath, true); } else if (canCopySemanticDiagnostics) { + var sourceFile = state.program.getSourceFileByPath(sourceFilePath); + if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { + return; + } + if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { + return; + } // Unchanged file copy diagnostics var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath); if (diagnostics) { @@ -87523,18 +88605,31 @@ var ts; // If there are no more diagnostics from old cache, done return; } + // Clean lib file diagnostics if its all files excluding default files to emit + if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles && !state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var options_2 = state.program.getCompilerOptions(); + if (ts.forEach(state.program.getSourceFiles(), function (f) { + return state.program.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2) && + removeSemanticDiagnosticsOf(state, f.path); + })) { + return; + } + } // If there was change in signature for the changed file, // then delete the semantic diagnostics for files that are affected by using exports of this module if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { return; } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); + var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { return exportedModules && exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); })) { return; } @@ -87542,16 +88637,44 @@ var ts; ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** * removes the semantic diagnostics of files referencing referencedPath and * returns true if there are no more semantic diagnostics from old state */ - function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath) { + function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile) { return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) { - return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOf(state, filePath); + return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile); + }); + } + /** + * Removes semantic diagnostics of file and anything that exports this file + */ + function removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile) { + if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) { + return false; + } + if (removeSemanticDiagnosticsOf(state, filePath)) { + // If there are no more diagnostics from old cache, done + return true; + } + 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 + if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { + return exportedModules && + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); + })) { + return true; + } + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + return !!ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { + return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** @@ -87560,7 +88683,7 @@ var ts; */ function removeSemanticDiagnosticsOf(state, path) { if (!state.semanticDiagnosticsFromOldState) { - return false; + return true; } state.semanticDiagnosticsFromOldState.delete(path); state.semanticDiagnosticsPerFile.delete(path); @@ -87833,6 +88956,10 @@ var ts; /*@internal*/ var ts; (function (ts) { + function isPathInNodeModulesStartingWithDot(path) { + return ts.stringContains(path, "/node_modules/."); + } + ts.isPathInNodeModulesStartingWithDot = isPathInNodeModulesStartingWithDot; ts.maxNumberOfFilesToIterateForInvalidation = 256; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; @@ -87846,11 +88973,11 @@ var ts; // The key in the map is source file's path. // The values are Map of resolutions with key being name lookedup. var resolvedModuleNames = ts.createMap(); - var perDirectoryResolvedModuleNames = ts.createMap(); - var nonRelaticeModuleNameCache = ts.createMap(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelaticeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); + var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); + var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); var resolvedTypeReferenceDirectives = ts.createMap(); - var perDirectoryResolvedTypeReferenceDirectives = ts.createMap(); + var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -87874,6 +89001,7 @@ var ts; resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives: resolveTypeReferenceDirectives, + removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects, removeResolutionsOfFile: removeResolutionsOfFile, invalidateResolutionOfFile: invalidateResolutionOfFile, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, @@ -87935,7 +89063,7 @@ var ts; } function clearPerDirectoryResolutions() { perDirectoryResolvedModuleNames.clear(); - nonRelaticeModuleNameCache.clear(); + nonRelativeModuleNameCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); @@ -87951,8 +89079,8 @@ var ts; } }); } - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache); + function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference); // 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; @@ -87970,10 +89098,11 @@ var ts; // Default return the result from the first pass return primaryResult; } - function resolveNamesWithLocalCache(names, containingFile, cache, perDirectoryCache, loader, getResolutionWithResolvedFileName, reusedNames, logChanges) { + function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) { var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); + var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); var perDirectoryResolution = perDirectoryCache.get(dirPath); if (!perDirectoryResolution) { perDirectoryResolution = ts.createMap(); @@ -87982,22 +89111,28 @@ var ts; var resolvedModules = []; var compilerOptions = resolutionHost.getCompilationSettings(); var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path); + // All the resolutions in this file are invalidated if this file wasnt resolved using same redirect + var program = resolutionHost.getCurrentProgram(); + var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile); + var unmatchedRedirects = oldRedirect ? + !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : + !!redirectedReference; var seenNamesInFile = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { var name = names_2[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && - allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated || + allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate - (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && !getResolutionWithResolvedFileName(resolution))) { + (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; } else { - resolution = loader(name, containingFile, compilerOptions, resolutionHost); + resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -88013,7 +89148,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -88041,12 +89176,14 @@ var ts; return oldResult.resolvedFileName === newResult.resolvedFileName; } } - function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile) { - return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) { + return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + /*shouldRetryResolution*/ function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, /*reusedNames*/ undefined, /*logChanges*/ false); } - function resolveModuleNames(moduleNames, containingFile, reusedNames) { - return resolveNamesWithLocalCache(moduleNames, containingFile, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, reusedNames, logChangesWhenResolvingModule); + function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { + return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, + /*shouldRetryResolution*/ function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule); } function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); @@ -88089,12 +89226,6 @@ var ts; } return true; } - function filterFSRootDirectoriesToWatch(watchPath, dirPath) { - if (!canWatchDirectory(dirPath)) { - watchPath.ignore = true; - } - return watchPath; - } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path @@ -88114,13 +89245,13 @@ var ts; } function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) { // If directory path contains node module, get the most parent node_modules directory for watching - while (ts.stringContains(dirPath, ts.nodeModulesPathPart)) { + while (ts.pathContainsNodeModules(dirPath)) { dir = ts.getDirectoryPath(dir); dirPath = ts.getDirectoryPath(dirPath); } // If the directory is node_modules use it to watch, always watch it recursively if (isNodeModulesDirectory(dirPath)) { - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); + return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -88138,7 +89269,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive }, dirPath); + return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -88167,8 +89298,9 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, nonRecursive = _a.nonRecursive, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive; // If the failed lookup location path is not one of the supported extensions, // store it in the custom path if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { @@ -88221,8 +89353,9 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dirPath = toWatch.dirPath; var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { if (refCount === 1) { @@ -88270,6 +89403,22 @@ var ts; cache.delete(filePath); } } + function removeResolutionsFromProjectReferenceRedirects(filePath) { + if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) { + return; + } + var program = resolutionHost.getCurrentProgram(); + if (!program) { + return; + } + // If this file is input file for the referenced project, get it + var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath); + if (!resolvedProjectReference) { + return; + } + // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution + resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); + } function removeResolutionsOfFile(filePath) { removeResolutionsOfFileFromCache(resolvedModuleNames, filePath); removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath); @@ -88331,6 +89480,9 @@ var ts; isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); }; } else { + // If something to do with folder/file starting with "." in node_modules folder, skip it + if (isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return false; // Some file or directory in the watching directory is created // Return early if it does not have any of the watching extension or not the custom failed lookup path var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); @@ -88371,8 +89523,8 @@ var ts; if (isInDirectoryPath(rootPath, typeRootPath)) { return rootPath; } - var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; + var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath); + return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -88860,7 +90012,6 @@ var ts; } return false; } - /** @internal */ ts.screenStartingMessageCodes = [ ts.Diagnostics.Starting_compilation_in_watch_mode.code, ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code, @@ -88901,6 +90052,23 @@ var ts; return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; + function getErrorCountForSummary(diagnostics) { + return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + ts.getErrorCountForSummary = getErrorCountForSummary; + function getWatchErrorSummaryDiagnosticMessage(errorCount) { + return errorCount === 1 ? + ts.Diagnostics.Found_1_error_Watching_for_file_changes : + ts.Diagnostics.Found_0_errors_Watching_for_file_changes; + } + ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage; + function getErrorSummaryText(errorCount, newLine) { + if (errorCount === 0) + return ""; + var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount); + return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine; + } + ts.getErrorSummaryText = getErrorSummaryText; /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ @@ -88939,7 +90107,7 @@ var ts; } } if (reportSummary) { - reportSummary(diagnostics.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length); + reportSummary(getErrorCountForSummary(diagnostics)); } if (emitSkipped && diagnostics.length > 0) { // If the emitter didn't emit anything, then pass that value along. @@ -89018,15 +90186,7 @@ var ts; function emitFilesAndReportErrorUsingBuilder(builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - var reportSummary = function (errorCount) { - if (errorCount === 1) { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_1_error_Watching_for_file_changes, errorCount), newLine, compilerOptions); - } - else { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_0_errors_Watching_for_file_changes, errorCount, errorCount), newLine, compilerOptions); - } - }; - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, reportSummary); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); } } /** @@ -89102,7 +90262,8 @@ var ts; fileExists: function (path) { return host.fileExists(path); }, readFile: readFile, getCurrentDirectory: getCurrentDirectory, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; // From tsc we want to get already parsed result and hence check for rootFileNames var newLine = updateNewLine(); @@ -89170,11 +90331,11 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }) : - (function (moduleNames, containingFile, reusedNames) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); }); + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }) : - (function (typeDirectiveNames, containingFile) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }); + (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; synchronizeProgram(); // Update the wild card directory watch @@ -89348,8 +90509,8 @@ var ts; var hostSourceFile = sourceFilesCache.get(path); return !hostSourceFile || isFileMissingOnHost(hostSourceFile) ? undefined : hostSourceFile.version.toString(); } - function onReleaseOldSourceFile(oldSourceFile, _oldOptions) { - var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.path); + function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { + var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); // If this is the source file thats in the cache and new program doesnt need it, // remove the cached entry. // Note we arent deleting entry if file became missing in new program or @@ -89363,8 +90524,10 @@ var ts; if (hostSourceFileInfo.fileWatcher) { hostSourceFileInfo.fileWatcher.close(); } - sourceFilesCache.delete(oldSourceFile.path); - resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + sourceFilesCache.delete(oldSourceFile.resolvedPath); + if (!hasSourceFileByPath) { + resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + } } } } @@ -89444,6 +90607,7 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.get(path)) { resolutionCache.invalidateResolutionOfFile(path); } + resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -89484,6 +90648,8 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } nextSourceFileVersion(fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) { @@ -89686,7 +90852,7 @@ var ts; }; } ts.createBuilderStatusReporter = createBuilderStatusReporter; - function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus) { + function createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) { if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker({}, /*setParentNodes*/ undefined, system); host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; @@ -89696,10 +90862,15 @@ var ts; host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; } + function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { + if (system === void 0) { system = ts.sys; } + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); + host.reportErrorSummary = reportErrorSummary; + return host; + } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { - if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); host.onWatchStatusChange = watchHost.onWatchStatusChange; host.watchFile = watchHost.watchFile; @@ -89716,12 +90887,6 @@ var ts; }); return result; } - /** - * A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but - * can dynamically add/remove other projects based on changes on the rootNames' references - * TODO: use SolutionBuilderWithWatchHost => watchedSolution - * use SolutionBuilderHost => Solution - */ function createSolutionBuilder(host, rootNames, defaultOptions) { var hostWithWatch = host; var currentDirectory = host.getCurrentDirectory(); @@ -90080,9 +91245,7 @@ var ts; globalDependencyGraph = undefined; } projectStatus.removeKey(resolved); - if (options.watch) { - diagnostics.removeKey(resolved); - } + diagnostics.removeKey(resolved); addProjToQueue(resolved, reloadLevel); } /** @@ -90144,7 +91307,7 @@ var ts; } } function reportErrorSummary() { - if (options.watch) { + if (options.watch || host.reportErrorSummary) { // Report errors from the other projects getGlobalDependencyGraph().buildQueue.forEach(function (project) { if (!projectErrorsReported.hasKey(project)) { @@ -90152,8 +91315,13 @@ var ts; } }); var totalErrors_1 = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += singleProjectErrors.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length; }); - reportWatchStatus(totalErrors_1 === 1 ? ts.Diagnostics.Found_1_error_Watching_for_file_changes : ts.Diagnostics.Found_0_errors_Watching_for_file_changes, totalErrors_1); + diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += ts.getErrorCountForSummary(singleProjectErrors); }); + if (options.watch) { + reportWatchStatus(ts.getWatchErrorSummaryDiagnosticMessage(totalErrors_1), totalErrors_1); + } + else { + host.reportErrorSummary(totalErrors_1); + } } } function buildSingleInvalidatedProject(resolved, reloadLevel) { @@ -90317,9 +91485,7 @@ var ts; type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime }; - if (options.watch) { - diagnostics.removeKey(proj); - } + diagnostics.removeKey(proj); projectStatus.setValue(proj, status); return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { @@ -90445,10 +91611,8 @@ var ts; } function reportAndStoreErrors(proj, errors) { reportErrors(errors); - if (options.watch) { - projectErrorsReported.setValue(proj, true); - diagnostics.setValue(proj, errors); - } + projectErrorsReported.setValue(proj, true); + diagnostics.setValue(proj, errors); } function reportErrors(errors) { errors.forEach(function (err) { return host.reportDiagnostic(err); }); @@ -90570,10 +91734,12 @@ var ts; if (builtin !== undefined) return builtin; var entries = getEntriesOfObject(value); - return { kind: 3 /* Object */, name: name, members: ts.flatMap(entries, function (_a) { - var key = _a.key, value = _a.value; - return getValueInfo(key, value, recurser); - }) }; + var hasNontrivialPrototype = Object.getPrototypeOf(value) !== Object.prototype; + var members = ts.flatMap(entries, function (_a) { + var key = _a.key, value = _a.value; + return getValueInfo(key, value, recurser); + }); + return { kind: 3 /* Object */, name: name, hasNontrivialPrototype: hasNontrivialPrototype, members: members }; } return { kind: 0 /* Const */, name: name, typeName: isNullOrUndefined(value) ? "any" : typeof value }; }, function (isCircularReference, keyStack) { return anyValue(name, " " + (isCircularReference ? "Circular reference" : "Too-deep object hierarchy") + " from " + keyStack.join(".")); }); @@ -90702,7 +91868,6 @@ var ts; : undefined; } server.findArgument = findArgument; - /*@internal*/ function nowString() { // E.g. "12:34:56.789" var d = new Date(); @@ -90716,13 +91881,11 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - /* @internal */ function isTypingUpToDate(cachedTyping, availableTypingVersions) { var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; - /* @internal */ JsTyping.nodeCoreModuleList = [ "assert", "async_hooks", @@ -90761,7 +91924,6 @@ var ts; "vm", "zlib" ]; - /* @internal */ JsTyping.nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); @@ -91057,30 +92219,32 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + function getDefaultFormatCodeSettings(newLineCharacter) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: newLineCharacter || "\n", + convertTabsToSpaces: true, + indentStyle: IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; /* @internal */ - ts.testFormatSettings = { - baseIndentSize: 0, - indentSize: 4, - tabSize: 4, - newLineCharacter: "\n", - convertTabsToSpaces: true, - indentStyle: IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterConstructor: false, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - insertSpaceAfterTypeAssertion: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - insertSpaceBeforeTypeAnnotation: false - }; + ts.testFormatSettings = getDefaultFormatCodeSettings("\n"); var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; @@ -91142,8 +92306,9 @@ var ts; TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + TokenClass[TokenClass["BigIntLiteral"] = 7] = "BigIntLiteral"; + TokenClass[TokenClass["StringLiteral"] = 8] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 9] = "RegExpLiteral"; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { @@ -91226,6 +92391,12 @@ var ts; ScriptElementKindModifier["staticModifier"] = "static"; ScriptElementKindModifier["abstractModifier"] = "abstract"; ScriptElementKindModifier["optionalModifier"] = "optional"; + ScriptElementKindModifier["dtsModifier"] = ".d.ts"; + ScriptElementKindModifier["tsModifier"] = ".ts"; + ScriptElementKindModifier["tsxModifier"] = ".tsx"; + ScriptElementKindModifier["jsModifier"] = ".js"; + ScriptElementKindModifier["jsxModifier"] = ".jsx"; + ScriptElementKindModifier["jsonModifier"] = ".json"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames; (function (ClassificationTypeNames) { @@ -91233,6 +92404,7 @@ var ts; ClassificationTypeNames["identifier"] = "identifier"; ClassificationTypeNames["keyword"] = "keyword"; ClassificationTypeNames["numericLiteral"] = "number"; + ClassificationTypeNames["bigintLiteral"] = "bigint"; ClassificationTypeNames["operator"] = "operator"; ClassificationTypeNames["stringLiteral"] = "string"; ClassificationTypeNames["whiteSpace"] = "whitespace"; @@ -91279,6 +92451,7 @@ var ts; ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + ClassificationType[ClassificationType["bigintLiteral"] = 25] = "bigintLiteral"; })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); // These utilities are common to multiple language service features. @@ -91296,37 +92469,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 272 /* CatchClause */: - case 265 /* JsxAttribute */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 274 /* CatchClause */: + case 267 /* JsxAttribute */: return 1 /* Value */; - case 148 /* TypeParameter */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 166 /* TypeLiteral */: + case 150 /* TypeParameter */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 168 /* TypeLiteral */: return 2 /* Type */; - case 302 /* JSDocTypedefTag */: + case 304 /* 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 276 /* EnumMember */: - case 238 /* ClassDeclaration */: + case 278 /* EnumMember */: + case 240 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -91336,26 +92509,26 @@ var ts; else { return 4 /* Namespace */; } - case 241 /* EnumDeclaration */: - case 250 /* NamedImports */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 243 /* EnumDeclaration */: + case 252 /* NamedImports */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 252 /* ExportAssignment */ || node.parent.kind === 257 /* ExternalModuleReference */) { + else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -91387,11 +92560,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 148 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 248 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -91403,27 +92576,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 146 /* QualifiedName */) { - while (root.parent && root.parent.kind === 146 /* QualifiedName */) { + if (root.parent.kind === 148 /* QualifiedName */) { + while (root.parent && root.parent.kind === 148 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 162 /* TypeReference */ && !isLastClause; + return root.parent.kind === 164 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 187 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { + if (root.parent.kind === 189 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 189 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 211 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 273 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 240 /* ClassDeclaration */ && root.parent.parent.token === 109 /* ImplementsKeyword */) || + (decl.kind === 241 /* InterfaceDeclaration */ && root.parent.parent.token === 86 /* ExtendsKeyword */); } return false; } @@ -91432,17 +92605,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return true; } switch (node.parent.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return true; - case 181 /* ImportType */: + case 183 /* ImportType */: return !node.parent.isTypeOf; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -91469,7 +92642,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 233 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -91485,11 +92658,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 71 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 71 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -91497,40 +92670,40 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 244 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 71 /* Identifier */ && + return node.kind === 72 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 276 /* EnumMember */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 242 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 278 /* EnumMember */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 244 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return true; - case 180 /* LiteralType */: - return node.parent.parent.kind === 178 /* IndexedAccessType */; + case 182 /* LiteralType */: + return node.parent.parent.kind === 180 /* IndexedAccessType */; default: return false; } @@ -91554,17 +92727,17 @@ var ts; return undefined; } switch (node.kind) { - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return node; } } @@ -91572,51 +92745,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return "class" /* classElement */; - case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 240 /* TypeAliasDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 242 /* TypeAliasDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 241 /* EnumDeclaration */: return "enum" /* enumElement */; - case 235 /* VariableDeclaration */: + case 243 /* EnumDeclaration */: return "enum" /* enumElement */; + case 237 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return "function" /* functionElement */; - case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 158 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 159 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return "property" /* memberVariableElement */; - case 160 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 159 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 158 /* CallSignature */: return "call" /* callSignatureElement */; - case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 276 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: - case 249 /* NamespaceImport */: + case 162 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 161 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 160 /* CallSignature */: return "call" /* callSignatureElement */; + case 157 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 150 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 278 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 151 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: + case 251 /* NamespaceImport */: return "alias" /* alias */; - case 202 /* BinaryExpression */: + case 204 /* 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 */: @@ -91637,7 +92813,7 @@ var ts; return "" /* unknown */; } } - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -91653,12 +92829,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 149 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 151 /* Parameter */; default: return false; } @@ -91723,42 +92899,42 @@ var ts; return false; } switch (n.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 182 /* ObjectBindingPattern */: - case 166 /* TypeLiteral */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 244 /* CaseBlock */: - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 272 /* CatchClause */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 168 /* TypeLiteral */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 246 /* CaseBlock */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); + case 274 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 190 /* NewExpression */: + case 192 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 189 /* CallExpression */: - case 193 /* ParenthesizedExpression */: - case 175 /* ParenthesizedType */: - return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 191 /* CallExpression */: + case 195 /* ParenthesizedExpression */: + case 177 /* ParenthesizedType */: + return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 197 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -91767,66 +92943,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 242 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); + case 244 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 220 /* IfStatement */: + case 222 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 185 /* ArrayLiteralExpression */: - case 183 /* ArrayBindingPattern */: - case 188 /* ElementAccessExpression */: - case 147 /* ComputedPropertyName */: - case 168 /* TupleType */: - return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); - case 160 /* IndexSignature */: + hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); + case 187 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 190 /* ElementAccessExpression */: + case 149 /* ComputedPropertyName */: + case 170 /* TupleType */: + return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); + case 162 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 107 /* WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 197 /* TypeOfExpression */: - case 196 /* DeleteExpression */: - case 198 /* VoidExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: + case 199 /* TypeOfExpression */: + case 198 /* DeleteExpression */: + case 200 /* VoidExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -91843,7 +93019,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 25 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -92005,7 +93181,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 277 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* 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. @@ -92067,25 +93243,25 @@ var ts; if (!token) { return false; } - if (token.kind === 10 /* JsxText */) { + if (token.kind === 11 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 263 /* JsxClosingElement */) { return true; } return false; @@ -92099,6 +93275,20 @@ var ts; return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; + function isInJSXText(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + if (ts.isJsxText(token)) { + return true; + } + if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + return false; + } + ts.isInJSXText = isInJSXText; function findPrecedingMatchingToken(token, matchingTokenKind, sourceFile) { var tokenKind = token.kind; var remainingMatchingTokens = 0; @@ -92145,7 +93335,7 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); if (!token || !ts.isIdentifier(token)) @@ -92155,53 +93345,54 @@ var ts; } remainingLessThanTokens--; break; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: remainingLessThanTokens++; break; - case 18 /* CloseBraceToken */: + case 19 /* 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, 17 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 20 /* CloseParenToken */: + case 21 /* 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, 19 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 22 /* CloseBracketToken */: + case 23 /* 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, 21 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 26 /* CommaToken */: + case 27 /* CommaToken */: nTypeArguments++; break; - case 36 /* EqualsGreaterThanToken */: - case 71 /* Identifier */: - case 9 /* StringLiteral */: + case 37 /* EqualsGreaterThanToken */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 103 /* TypeOfKeyword */: - case 85 /* ExtendsKeyword */: - case 128 /* KeyOfKeyword */: - case 23 /* DotToken */: - case 49 /* BarToken */: - case 55 /* QuestionToken */: - case 56 /* ColonToken */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 104 /* TypeOfKeyword */: + case 86 /* ExtendsKeyword */: + case 129 /* KeyOfKeyword */: + case 24 /* DotToken */: + case 50 /* BarToken */: + case 56 /* QuestionToken */: + case 57 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -92256,10 +93447,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { + if (node.kind === 164 /* TypeReference */ || node.kind === 191 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 240 /* ClassDeclaration */ || node.kind === 241 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -92270,8 +93461,8 @@ var ts; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 /* StringLiteral */ - || kind === 12 /* RegularExpressionLiteral */ + if (kind === 10 /* StringLiteral */ + || kind === 13 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -92279,7 +93470,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 71 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -92289,9 +93480,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: return true; } return false; @@ -92304,18 +93495,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 185 /* ArrayLiteralExpression */ || - node.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 187 /* ArrayLiteralExpression */ || + node.kind === 188 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 202 /* BinaryExpression */ && + if (node.parent.kind === 204 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 58 /* EqualsToken */) { + node.parent.operatorToken.kind === 59 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 225 /* ForOfStatement */ && + if (node.parent.kind === 227 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -92323,7 +93514,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 275 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -92367,21 +93558,21 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 119 /* AnyKeyword */, - 122 /* BooleanKeyword */, - 86 /* FalseKeyword */, - 128 /* KeyOfKeyword */, - 131 /* NeverKeyword */, - 95 /* NullKeyword */, - 134 /* NumberKeyword */, - 135 /* ObjectKeyword */, - 137 /* StringKeyword */, - 138 /* SymbolKeyword */, - 101 /* TrueKeyword */, - 105 /* VoidKeyword */, - 140 /* UndefinedKeyword */, - 141 /* UniqueKeyword */, - 142 /* UnknownKeyword */, + 120 /* AnyKeyword */, + 123 /* BooleanKeyword */, + 87 /* FalseKeyword */, + 129 /* KeyOfKeyword */, + 132 /* NeverKeyword */, + 96 /* NullKeyword */, + 135 /* NumberKeyword */, + 136 /* ObjectKeyword */, + 138 /* StringKeyword */, + 139 /* SymbolKeyword */, + 102 /* TrueKeyword */, + 106 /* VoidKeyword */, + 141 /* UndefinedKeyword */, + 142 /* UniqueKeyword */, + 143 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -92417,7 +93608,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 147 /* ComputedPropertyName */ + return name.kind === 149 /* 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.getTextOfIdentifierOrLiteral(name); @@ -92493,7 +93684,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 71 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 72 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -92506,13 +93697,7 @@ var ts; ts.isObjectBindingElementWithoutPropertyName = isObjectBindingElementWithoutPropertyName; function getPropertySymbolFromBindingElement(checker, bindingElement) { var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); - var propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - if (propSymbol && propSymbol.flags & 98304 /* Accessor */) { - // See GH#16922 - ts.Debug.assert(!!(propSymbol.flags & 33554432 /* Transient */)); - return propSymbol.target; - } - return propSymbol; + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; /** @@ -92565,7 +93750,6 @@ var ts; return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); } ts.findModifier = findModifier; - /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); if (lastImportDeclaration) { @@ -92589,7 +93773,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 151 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -92615,6 +93799,7 @@ var ts; writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeTrailingSemicolon: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, @@ -92623,7 +93808,7 @@ var ts; writeSymbol: writeSymbol, writeLine: writeLine, write: unknownWrite, - writeTextOfNode: unknownWrite, + writeComment: unknownWrite, getText: function () { return ""; }, getTextPos: function () { return 0; }, getColumn: function () { return 0; }, @@ -92774,7 +93959,6 @@ var ts; return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } ts.lineBreakPart = lineBreakPart; - /* @internal */ function mapToDisplayParts(writeDisplayParts) { try { writeDisplayParts(displayPartWriter); @@ -92809,7 +93993,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && + (location.parent.kind === 253 /* ImportSpecifier */ || location.parent.kind === 257 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -92856,6 +94040,13 @@ var ts; return position; } ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getPrecedingNonSpaceCharacterPosition(text, position) { + while (position > -1 && ts.isWhiteSpaceSingleLine(text.charCodeAt(position))) { + position -= 1; + } + return position + 1; + } + ts.getPrecedingNonSpaceCharacterPosition = getPrecedingNonSpaceCharacterPosition; /** * Creates a deep, memberwise clone of a node with no source map location. * @@ -92922,7 +94113,6 @@ var ts; /** * Sets EmitFlags to suppress leading and trailing trivia on the node. */ - /* @internal */ function suppressLeadingAndTrailingTrivia(node) { suppressLeadingTrivia(node); suppressTrailingTrivia(node); @@ -92931,7 +94121,6 @@ var ts; /** * Sets EmitFlags to suppress leading trivia on the node. */ - /* @internal */ function suppressLeadingTrivia(node) { addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); } @@ -92939,7 +94128,6 @@ var ts; /** * Sets EmitFlags to suppress trailing trivia on the node. */ - /* @internal */ function suppressTrailingTrivia(node) { addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); } @@ -92953,7 +94141,6 @@ var ts; function getFirstChild(node) { return node.forEachChild(function (child) { return child; }); } - /* @internal */ function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { @@ -92967,7 +94154,6 @@ var ts; * to be on the reference, rather than the declaration, because it's closer to where the * user was before extracting it. */ - /* @internal */ function getRenameLocation(edits, renameFilename, name, preferLastLocation) { var delta = 0; var lastPos = -1; @@ -93021,6 +94207,72 @@ var ts; idx = change.indexOf('"' + name); return idx === -1 ? -1 : idx + 1; } + function getContextualTypeFromParent(node, checker) { + var parent = node.parent; + switch (parent.kind) { + case 192 /* NewExpression */: + return checker.getContextualType(parent); + case 204 /* 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 271 /* CaseClause */: + return parent.expression === node ? getSwitchedType(parent, checker) : undefined; + default: + return checker.getContextualType(node); + } + } + ts.getContextualTypeFromParent = getContextualTypeFromParent; + function quote(text, preferences) { + if (/^\d+$/.test(text)) { + return text; + } + var quoted = JSON.stringify(text); + switch (preferences.quotePreference) { + case undefined: + case "double": + return quoted; + case "single": + return "'" + stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; + default: + return ts.Debug.assertNever(preferences.quotePreference); + } + } + ts.quote = quote; + function isEqualityOperatorKind(kind) { + switch (kind) { + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + return true; + default: + return false; + } + } + ts.isEqualityOperatorKind = isEqualityOperatorKind; + function isStringLiteralOrTemplate(node) { + switch (node.kind) { + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + return true; + default: + return false; + } + } + ts.isStringLiteralOrTemplate = isStringLiteralOrTemplate; + function hasIndexSignature(type) { + return !!type.getStringIndexType() || !!type.getNumberIndexType(); + } + ts.hasIndexSignature = hasIndexSignature; + function getSwitchedType(caseClause, checker) { + return checker.getTypeAtLocation(caseClause.parent.parent.expression); + } + ts.getSwitchedType = getSwitchedType; })(ts || (ts = {})); var ts; (function (ts) { @@ -93059,7 +94311,7 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(14 /* TemplateHead */); + templateStack.push(15 /* TemplateHead */); } scanner.setText(text); var endOfLineState = 0 /* None */; @@ -93101,65 +94353,65 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 12 /* RegularExpressionLiteral */) { - token = 12 /* RegularExpressionLiteral */; + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + token = 13 /* RegularExpressionLiteral */; } break; - case 27 /* LessThanToken */: - if (lastNonTriviaToken === 71 /* Identifier */) { + case 28 /* LessThanToken */: + if (lastNonTriviaToken === 72 /* 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 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 119 /* AnyKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: + case 120 /* AnyKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: templateStack.push(token); break; - case 17 /* OpenBraceToken */: + case 18 /* 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 18 /* CloseBraceToken */: + case 19 /* 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 === 14 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 16 /* TemplateTail */) { + if (token === 17 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 15 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 17 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -93168,15 +94420,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 23 /* DotToken */) { - token = 71 /* Identifier */; + if (lastNonTriviaToken === 24 /* DotToken */) { + token = 72 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } } } @@ -93190,22 +94442,23 @@ 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([ - 71 /* Identifier */, - 9 /* StringLiteral */, + 72 /* Identifier */, + 10 /* StringLiteral */, 8 /* NumericLiteral */, - 12 /* RegularExpressionLiteral */, - 99 /* ThisKeyword */, - 43 /* PlusPlusToken */, - 44 /* MinusMinusToken */, - 20 /* CloseParenToken */, - 22 /* CloseBracketToken */, - 18 /* CloseBraceToken */, - 101 /* TrueKeyword */, - 86 /* FalseKeyword */, + 9 /* BigIntLiteral */, + 13 /* RegularExpressionLiteral */, + 100 /* ThisKeyword */, + 44 /* PlusPlusToken */, + 45 /* MinusMinusToken */, + 21 /* CloseParenToken */, + 23 /* CloseBracketToken */, + 19 /* CloseBraceToken */, + 102 /* TrueKeyword */, + 87 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; @@ -93229,15 +94482,15 @@ var ts; return undefined; } switch (token) { - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return 5 /* InTemplateMiddleOrTail */; - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 14 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { @@ -93286,6 +94539,7 @@ var ts; 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; @@ -93312,10 +94566,10 @@ var ts; return true; } switch (keyword2) { - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 123 /* ConstructorKeyword */: - case 115 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 124 /* ConstructorKeyword */: + case 116 /* 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. @@ -93348,43 +94602,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 48 /* AmpersandToken */: - case 50 /* CaretToken */: - case 49 /* BarToken */: - case 53 /* AmpersandAmpersandToken */: - case 54 /* BarBarToken */: - case 69 /* BarEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 49 /* AmpersandToken */: + case 51 /* CaretToken */: + case 50 /* BarToken */: + case 54 /* AmpersandAmpersandToken */: + case 55 /* BarBarToken */: + case 70 /* BarEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return true; default: return false; @@ -93392,12 +94646,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: return true; default: return false; @@ -93410,15 +94664,17 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 17 /* FirstPunctuation */ && token <= 70 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 71 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + return 25 /* bigintLiteral */; + case 10 /* StringLiteral */: return 6 /* stringLiteral */; - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -93427,7 +94683,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 71 /* Identifier */: + case 72 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -93452,10 +94708,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -93530,6 +94786,7 @@ var ts; 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 */; @@ -93663,22 +94920,22 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); // "@" + pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -93749,10 +95006,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -93765,22 +95022,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -93797,7 +95054,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 27 /* LessThanToken */ || tokenKind === 29 /* GreaterThanToken */) { + if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* 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)) { @@ -93807,19 +95064,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 58 /* EqualsToken */) { + if (tokenKind === 59 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 235 /* VariableDeclaration */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 149 /* Parameter */ || - parent.kind === 265 /* JsxAttribute */) { + if (parent.kind === 237 /* VariableDeclaration */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 151 /* Parameter */ || + parent.kind === 267 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 202 /* BinaryExpression */ || - parent.kind === 200 /* PrefixUnaryExpression */ || - parent.kind === 201 /* PostfixUnaryExpression */ || - parent.kind === 203 /* ConditionalExpression */) { + if (parent.kind === 204 /* BinaryExpression */ || + parent.kind === 202 /* PrefixUnaryExpression */ || + parent.kind === 203 /* PostfixUnaryExpression */ || + parent.kind === 205 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -93828,11 +95085,14 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 9 /* BigIntLiteral */) { + return 25 /* bigintLiteral */; } - else if (tokenKind === 12 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* StringLiteral */) { + // TODO: GH#18217 + return token.parent.kind === 267 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + } + else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -93840,38 +95100,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 10 /* JsxText */) { + else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 71 /* Identifier */) { + else if (tokenKind === 72 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 149 /* Parameter */: + case 151 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -93905,37 +95165,245 @@ var ts; (function (ts) { var Completions; (function (Completions) { - var PathCompletions; - (function (PathCompletions) { - function nameAndKind(name, kind) { - return { name: name, kind: kind }; + var StringCompletions; + (function (StringCompletions) { + function getStringLiteralCompletions(sourceFile, position, contextToken, checker, options, host, log, preferences) { + if (ts.isInReferenceComment(sourceFile, position)) { + var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); + return entries && convertPathCompletions(entries); + } + if (ts.isInString(sourceFile, position, contextToken)) { + return !contextToken || !ts.isStringLiteralLike(contextToken) + ? undefined + : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host), sourceFile, checker, log, preferences); + } + } + StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; + function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { + if (completion === undefined) { + return undefined; + } + switch (completion.kind) { + case 0 /* Paths */: + return convertPathCompletions(completion.paths); + case 1 /* Properties */: { + var entries = []; + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; + } + case 2 /* Types */: { + var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; + } + default: + return ts.Debug.assertNever(completion); + } + } + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + if (!contextToken || !ts.isStringLiteralLike(contextToken)) + return undefined; + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); + } + StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; + function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { + switch (completion.kind) { + case 0 /* 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 */: { + 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; + default: + return ts.Debug.assertNever(completion); + } + } + function convertPathCompletions(pathCompletions) { + var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. + var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. + var entries = pathCompletions.map(function (_a) { + var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension; + return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span }); + }); + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + } + 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 undefined: return "" /* none */; + default: + return ts.Debug.assertNever(extension); + } + } + var StringLiteralCompletionKind; + (function (StringLiteralCompletionKind) { + StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; + })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + var parent = node.parent; + switch (parent.kind) { + case 182 /* LiteralType */: + switch (parent.parent.kind) { + case 164 /* TypeReference */: + return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; + case 180 /* IndexedAccessType */: + // Get all apparent property names + // i.e. interface Foo { + // foo: string; + // bar: string; + // } + // let x: Foo["/*completion position*/"] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); + case 183 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; + case 173 /* UnionType */: { + if (!ts.isTypeReferenceNode(parent.parent.parent)) + return undefined; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + } + default: + return undefined; + } + case 275 /* PropertyAssignment */: + if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); + } + return fromContextualType(); + case 190 /* ElementAccessExpression */: { + var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; + if (node === argumentExpression) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); + } + return undefined; + } + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); + } + // falls through (is `require("")` or `import("")`) + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 259 /* 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) }; + 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 }; + } + } + function getAlreadyUsedTypesInStringLiteralUnion(union, current) { + return ts.mapDefined(union.types, function (type) { + return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; + }); + } + function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { + var isNewIdentifier = false; + var uniques = ts.createMap(); + var candidates = []; + checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); + var types = ts.flatMap(candidates, function (candidate) { + if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + return; + var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + return getStringLiteralTypes(type, uniques); + }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + } + function stringLiteralCompletionsFromProperties(type) { + return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: ts.hasIndexSignature(type) }; + } + function getStringLiteralTypes(type, uniques) { + if (uniques === void 0) { uniques = ts.createMap(); } + if (!type) + 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; + } + function nameAndKind(name, kind, extension) { + return { name: name, kind: kind, extension: extension }; + } + function directoryResult(name) { + return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); return names.map(function (_a) { - var name = _a.name, kind = _a.kind; - return ({ name: name, kind: kind, span: span }); + var name = _a.name, kind = _a.kind, extension = _a.extension; + return ({ name: name, kind: kind, extension: extension, span: span }); }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } - PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); - if (compilerOptions.rootDirs) { - return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, compilerOptions, host, scriptPath); - } - else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, host, scriptPath); - } + return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + } + function getExtensionOptions(compilerOptions, includeExtensions) { + if (includeExtensions === void 0) { includeExtensions = false; } + return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; + } + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { + var extensionOptions = getExtensionOptions(compilerOptions); + if (compilerOptions.rootDirs) { + return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); } } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -93958,21 +95426,22 @@ var ts; // Now find a path for each potential directory that is to be merged with the one containing the script return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, compilerOptions, host, exclude) { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); var result = []; for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, host, exclude, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude, result); } return result; } /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, host, exclude, result) { + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { + var extensions = _a.extensions, includeExtensions = _a.includeExtensions; if (result === void 0) { result = []; } if (fragment === undefined) { fragment = ""; @@ -93993,55 +95462,53 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles.has(foundFileName)) { - foundFiles.set(foundFileName, true); - } + if (!tryDirectoryExists(host, baseDirectory)) + return result; + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); // maps file to its extension + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; } - ts.forEachKey(foundFiles, function (foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */)); - }); + var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { - var directory = directories_1[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - if (directoryName !== "@types") { - result.push(nameAndKind(directoryName, "directory" /* directory */)); - } + foundFiles.forEach(function (ext, foundFile) { + result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { + var directory = directories_1[_b]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + if (directoryName !== "@types") { + result.push(directoryResult(directoryName)); } } - // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); - if (packageJsonPath) { - var packageJson = ts.readJson(packageJsonPath, host); - var typesVersions = packageJson.typesVersions; - if (typeof typesVersions === "object") { - var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); - var versionPaths = versionResult && versionResult.paths; - var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); - if (versionPaths) { - addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); - } + } + // check for a version redirect + var packageJsonPath = findPackageJson(baseDirectory, host); + if (packageJsonPath) { + var packageJson = ts.readJson(packageJsonPath, host); + var typesVersions = packageJson.typesVersions; + if (typeof typesVersions === "object") { + var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); + var versionPaths = versionResult && versionResult.paths; + var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); + if (versionPaths) { + addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); } } } @@ -94053,15 +95520,15 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_10 = function (name, kind) { + var _loop_10 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { - result.push(nameAndKind(name, kind)); + result.push(nameAndKind(name, kind, extension)); } }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { - var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_10(name, kind); + var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; + _loop_10(name, kind, extension); } } } @@ -94076,21 +95543,21 @@ var ts; function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; var result = []; - var fileExtensions = getSupportedExtensionsForModuleResolution(compilerOptions); + var extensionOptions = getExtensionOptions(compilerOptions); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); - getCompletionEntriesForDirectoryFragment(fragment, absolute, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, fileExtensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); } } - var fragmentDirectory = containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + 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 */)); + result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, result); + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) { // 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.) @@ -94099,7 +95566,7 @@ var ts; var _loop_11 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); + result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -94111,13 +95578,16 @@ var ts; ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); if (tryDirectoryExists(host, nodeModules)) { - getCompletionEntriesForDirectoryFragment(fragment, nodeModules, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); } } return result; } + function getFragmentDirectory(fragment) { + return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + } function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. @@ -94129,7 +95599,7 @@ var ts; return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; + return ts.startsWith(name, fragment) ? [directoryResult(name)] : ts.emptyArray; } } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { @@ -94157,15 +95627,20 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]).map(function (name) { return ({ name: name, kind: "script" /* scriptElement */ }); }); - var directories = tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }).map(function (name) { return ({ name: name, kind: "directory" /* directory */ }); }); - // Trim away prefix and suffix - return ts.mapDefined(ts.concatenate(matches, directories), function (_a) { - var name = _a.name, kind = _a.kind; - var normalizedMatch = ts.normalizePath(name); - var inner = withoutStartAndEnd(normalizedMatch, completePrefix, normalizedSuffix); - return inner !== undefined ? { name: removeLeadingDirectorySeparator(ts.removeFileExtension(inner)), kind: kind } : undefined; + var matches = ts.mapDefined(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); }); + var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var name = trimPrefixAndSuffix(dir); + return name === undefined ? undefined : directoryResult(name); + }); + return matches.concat(directories); + function trimPrefixAndSuffix(path) { + var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); + return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); + } } function withoutStartAndEnd(s, start, end) { return ts.startsWith(s, start) && ts.endsWith(s, end) ? s.slice(start.length, s.length - end.length) : undefined; @@ -94200,62 +95675,48 @@ 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, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, host, sourceFile.path) - : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath) - : undefined; - return names && addReplacementSpans(toComplete, range.pos + prefix.length, names); + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, /*includeExtensions*/ true), host, sourceFile.path) + : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) + : ts.Debug.fail(); + return addReplacementSpans(toComplete, range.pos + prefix.length, names); } - PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; - function getCompletionEntriesFromTypings(host, options, scriptPath, result) { + function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var typesName = _a[_i]; - var moduleName = ts.unmangleScopedPackageName(typesName); - pushResult(moduleName); - } + var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; + getCompletionEntriesFromDirectories(root); } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch ( /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */_b) { /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */ } - if (typeRoots) { - for (var _c = 0, typeRoots_2 = typeRoots; _c < typeRoots_2.length; _c++) { - var root = typeRoots_2[_c]; - getCompletionEntriesFromDirectories(root); - } - } - // Also get all @types typings installed in visible node_modules directories - for (var _d = 0, _e = findPackageJsons(scriptPath, host); _d < _e.length; _d++) { - var packageJson = _e[_d]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(typesDir); - } + // Also get all @types typings installed in visible node_modules directories + for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + var packageJson = _b[_a]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - ts.Debug.assert(!!host.getDirectories); - if (tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_2 = directories; _i < directories_2.length; _i++) { - var typeDirectory = directories_2[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - var directoryName = ts.getBaseFileName(typeDirectory); - var moduleName = ts.unmangleScopedPackageName(directoryName); - pushResult(moduleName); + if (!tryDirectoryExists(host, directory)) + return; + for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + var typeDirectoryName = _a[_i]; + var packageName = ts.unmangleScopedPackageName(typeDirectoryName); + if (options.types && !ts.contains(options.types, packageName)) + continue; + if (fragmentDirectory === undefined) { + if (!seen.has(packageName)) { + result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + seen.set(packageName, true); + } + } + else { + var baseDirectory = ts.combinePaths(directory, typeDirectoryName); + var remainingFragment = ts.tryRemoveDirectoryPrefix(fragmentDirectory, packageName, ts.hostGetCanonicalFileName(host)); + if (remainingFragment !== undefined) { + getCompletionEntriesForDirectoryFragment(remainingFragment, baseDirectory, extensionOptions, host, /*exclude*/ undefined, result); } } - } - } - function pushResult(moduleName) { - if (!seen.has(moduleName)) { - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); - seen.set(moduleName, true); } } } @@ -94345,27 +95806,27 @@ var ts; return tryIOAndConsumeErrors(host, host.fileExists, path); } function tryDirectoryExists(host, path) { - try { - return ts.directoryProbablyExists(path, host); - } - catch ( /*ignore*/_a) { /*ignore*/ } - return false; + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + function tryAndIgnoreErrors(cb) { try { - return toApply && toApply.apply(host, args); + return cb(); + } + catch (_a) { + return undefined; } - catch ( /*ignore*/_a) { /*ignore*/ } - return undefined; } function containsSlash(fragment) { return ts.stringContains(fragment, ts.directorySeparator); } - })(PathCompletions = Completions.PathCompletions || (Completions.PathCompletions = {})); + })(StringCompletions = Completions.StringCompletions || (Completions.StringCompletions = {})); })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -94405,20 +95866,15 @@ var ts; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); - if (ts.isInReferenceComment(sourceFile, position)) { - var entries = Completions.PathCompletions.getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); - return entries && convertPathCompletions(entries); - } var contextToken = ts.findPrecedingToken(position, sourceFile); if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) return undefined; - if (ts.isInString(sourceFile, position, contextToken)) { - return !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host), sourceFile, typeChecker, log, preferences); + var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); + if (stringCompletions) { + return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 72 /* BreakKeyword */ || contextToken.kind === 77 /* ContinueKeyword */ || contextToken.kind === 71 /* Identifier */)) { + && (contextToken.kind === 73 /* BreakKeyword */ || contextToken.kind === 78 /* ContinueKeyword */ || contextToken.kind === 72 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); @@ -94441,35 +95897,6 @@ var ts; } } Completions.getCompletionsAtPosition = getCompletionsAtPosition; - function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { - if (completion === undefined) { - return undefined; - } - switch (completion.kind) { - case 0 /* Paths */: - return convertPathCompletions(completion.paths); - case 1 /* Properties */: { - var entries = []; - getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; - } - case 2 /* Types */: { - var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; - } - default: - return ts.Debug.assertNever(completion); - } - } - function convertPathCompletions(pathCompletions) { - var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. - var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. - var entries = pathCompletions.map(function (_a) { - var name = _a.name, kind = _a.kind, span = _a.span; - return ({ name: name, kind: kind, kindModifiers: "" /* none */, sortText: "0", replacementSpan: span }); - }); - return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - } function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } @@ -94483,7 +95910,7 @@ var ts; // The completion list at "1" will contain "div>" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 29 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -94548,7 +95975,9 @@ var ts; } }); } - var completionNameForLiteral = JSON.stringify; + var completionNameForLiteral = function (literal) { + return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal); + }; function createCompletionEntryForLiteral(literal) { return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" }; } @@ -94561,13 +95990,13 @@ var ts; var insertText; var replacementSpan; if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + quote(name, preferences) + "]" : "this." + name; + insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 23 /* DotToken */, sourceFile); + insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -94602,21 +96031,6 @@ var ts; replacementSpan: replacementSpan, }; } - function quote(text, preferences) { - if (/^\d+$/.test(text)) { - return text; - } - var quoted = JSON.stringify(text); - switch (preferences.quotePreference) { - case undefined: - case "double": - return quoted; - case "single": - return "'" + ts.stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; - default: - return ts.Debug.assertNever(preferences.quotePreference); - } - } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; @@ -94654,6 +96068,7 @@ var ts; log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); return uniques; } + Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { var entries = getLabelStatementCompletions(node); if (entries.length) { @@ -94684,131 +96099,6 @@ var ts; } return entries; } - var StringLiteralCompletionKind; - (function (StringLiteralCompletionKind) { - StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; - })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { - var parent = node.parent; - switch (parent.kind) { - case 180 /* LiteralType */: - switch (parent.parent.kind) { - case 162 /* TypeReference */: - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 178 /* IndexedAccessType */: - // Get all apparent property names - // i.e. interface Foo { - // foo: string; - // bar: string; - // } - // let x: Foo["/*completion position*/"] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 181 /* ImportType */: - return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 171 /* UnionType */: { - if (!ts.isTypeReferenceNode(parent.parent.parent)) - return undefined; - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; - } - default: - return undefined; - } - case 273 /* PropertyAssignment */: - if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); - } - return fromContextualType(); - case 188 /* ElementAccessExpression */: { - var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; - if (node === argumentExpression) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); - } - return undefined; - } - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); - } - // falls through (is `require("")` or `import("")`) - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 257 /* 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: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - 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(getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; - } - } - function getAlreadyUsedTypesInStringLiteralUnion(union, current) { - return ts.mapDefined(union.types, function (type) { - return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; - }); - } - function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { - var isNewIdentifier = false; - var uniques = ts.createMap(); - var candidates = []; - checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); - var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) - return; - var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); - return getStringLiteralTypes(type, uniques); - }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; - } - function stringLiteralCompletionsFromProperties(type) { - return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: hasIndexSignature(type) }; - } - function getStringLiteralTypes(type, uniques) { - if (uniques === void 0) { uniques = ts.createMap(); } - if (!type) - return ts.emptyArray; - type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 512 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; - } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); @@ -94847,10 +96137,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - var stringLiteralCompletions = !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host); - return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); // TODO: GH#18217 + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); @@ -94894,25 +96181,11 @@ var ts; }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } - function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { - switch (completion.kind) { - case 0 /* Paths */: { - var match = ts.find(completion.paths, function (p) { return p.name === name; }); - return match && createCompletionDetails(name, "" /* none */, match.kind, [ts.textPart(name)]); - } - case 1 /* Properties */: { - var match = ts.find(completion.symbols, function (s) { return s.name === name; }); - return match && createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); - } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; - default: - return ts.Debug.assertNever(completion); - } - } + Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } + Completions.createCompletionDetails = createCompletionDetails; function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { @@ -94943,7 +96216,7 @@ var ts; CompletionKind[CompletionKind["MemberLike"] = 3] = "MemberLike"; CompletionKind[CompletionKind["String"] = 4] = "String"; CompletionKind[CompletionKind["None"] = 5] = "None"; - })(CompletionKind || (CompletionKind = {})); + })(CompletionKind = Completions.CompletionKind || (Completions.CompletionKind = {})); function getRecommendedCompletion(previousToken, contextualType, checker) { // For a union, return the first one with a recommended completion. return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { @@ -94957,56 +96230,36 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 71 /* Identifier */: - return getContextualTypeFromParent(previousToken, checker); - case 58 /* EqualsToken */: + case 72 /* Identifier */: + return ts.getContextualTypeFromParent(previousToken, checker); + case 59 /* EqualsToken */: switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return checker.getContextualType(parent); - case 73 /* CaseKeyword */: - return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); - case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + case 74 /* CaseKeyword */: + return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); + case 18 /* OpenBraceToken */: + return ts.isJsxExpression(parent) && parent.parent.kind !== 260 /* JsxElement */ ? 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 === 26 /* CommaToken */ ? 1 : 0)) - : isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind) + ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* 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) : checker.getContextualType(previousToken); } } - function getContextualTypeFromParent(node, checker) { - var parent = node.parent; - switch (parent.kind) { - case 190 /* NewExpression */: - return checker.getContextualType(parent); - case 202 /* 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 269 /* CaseClause */: - return parent.expression === node ? getSwitchedType(parent, checker) : undefined; - default: - return checker.getContextualType(node); - } - } - function getSwitchedType(caseClause, checker) { - return checker.getTypeAtLocation(caseClause.parent.parent.expression); - } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) @@ -95014,7 +96267,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -95065,11 +96318,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 303 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -95095,9 +96348,9 @@ var ts; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { - var start_4 = ts.timestamp(); + var start_3 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 - log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); + log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_3)); } // Find the node where completion is requested on. // Also determine whether we are trying to complete with members of that node @@ -95116,21 +96369,21 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 23 /* DotToken */) { + if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: node = parent.left; break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: node = parent.name; break; - case 181 /* ImportType */: - case 212 /* MetaProperty */: + case 183 /* ImportType */: + case 214 /* MetaProperty */: node = parent; break; default: @@ -95143,56 +96396,56 @@ var ts; // // 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 === 187 /* PropertyAccessExpression */) { + if (parent && parent.kind === 189 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { + case 30 /* GreaterThanToken */: + if (currentToken.parent.kind === 260 /* JsxElement */ || currentToken.parent.kind === 262 /* JsxOpeningElement */) { location = currentToken; } break; - case 41 /* SlashToken */: - if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { + case 42 /* SlashToken */: + if (currentToken.parent.kind === 261 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 261 /* JsxClosingElement */: - if (contextToken.kind === 41 /* SlashToken */) { + case 263 /* JsxClosingElement */: + if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: - case 260 /* JsxOpeningElement */: - if (contextToken.kind === 27 /* LessThanToken */) { + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: + case 262 /* JsxOpeningElement */: + if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: switch (previousToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: isJsxInitializer = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: // For `
` 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, 58 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 59 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -95240,11 +96493,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: - case 298 /* JSDocReturnTag */: - case 300 /* JSDocTypeTag */: - case 302 /* JSDocTypedefTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 304 /* JSDocTypedefTag */: return true; default: return false; @@ -95284,15 +96537,15 @@ 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.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 94 /* NewKeyword */ || node.keywordToken === 91 /* ImportKeyword */)) { - var completion = (node.keywordToken === 94 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 95 /* NewKeyword */ || node.keywordToken === 92 /* ImportKeyword */)) { + var completion = (node.keywordToken === 95 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -95313,7 +96566,7 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 183 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -95367,10 +96620,10 @@ var ts; function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element - var attrsType = jsxContainer && typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); + var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) return 0 /* Continue */; - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); + symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -95416,7 +96669,7 @@ var ts; var symbolMeanings = 67897832 /* Type */ | 67220415 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -95452,10 +96705,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 277 /* SourceFile */: - case 204 /* TemplateExpression */: - case 268 /* JsxExpression */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 206 /* TemplateExpression */: + case 270 /* JsxExpression */: + case 218 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -95491,41 +96744,35 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 103 /* TypeOfKeyword */ && - (contextToken.parent.kind === 165 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 104 /* TypeOfKeyword */ && + (contextToken.parent.kind === 167 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 56 /* ColonToken */: - return parentKind === 152 /* PropertyDeclaration */ || - parentKind === 151 /* PropertySignature */ || - parentKind === 149 /* Parameter */ || - parentKind === 235 /* VariableDeclaration */ || + case 57 /* ColonToken */: + return parentKind === 154 /* PropertyDeclaration */ || + parentKind === 153 /* PropertySignature */ || + parentKind === 151 /* Parameter */ || + parentKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 58 /* EqualsToken */: - return parentKind === 240 /* TypeAliasDeclaration */; - case 118 /* AsKeyword */: - return parentKind === 210 /* AsExpression */; + case 59 /* EqualsToken */: + return parentKind === 242 /* TypeAliasDeclaration */; + case 119 /* AsKeyword */: + return parentKind === 212 /* AsExpression */; } } return false; } - function symbolCanBeReferencedAtTypeLocation(symbol) { - symbol = symbol.exportSymbol || symbol; - // This is an alias, follow what it aliases - symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & 67897832 /* Type */) { - return true; - } - if (symbol.flags & 1536 /* Module */) { - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - // If the exported symbols contains type, - // symbol can be referenced at locations where type is allowed - return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); - } - return false; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { + if (seenModules === void 0) { seenModules = ts.createMap(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); + return !!(sym.flags & 67897832 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); @@ -95553,13 +96800,16 @@ var ts; // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. // This is just to avoid adding duplicate completion entries. // - // If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. - // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { + || ts.some(symbol.declarations, function (d) { + // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); + })) { continue; } - var isDefaultExport = symbol.name === "default" /* Default */; + var isDefaultExport = symbol.escapedName === "default" /* Default */; if (isDefaultExport) { symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; } @@ -95613,15 +96863,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 10 /* JsxText */) { + if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { + if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 262 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; + if (contextToken.parent.kind === 263 /* JsxClosingElement */ || contextToken.parent.kind === 261 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 260 /* JsxElement */; } } return false; @@ -95631,41 +96881,41 @@ var ts; var containingNodeKind = previousToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { - case 26 /* CommaToken */: - return containingNodeKind === 189 /* CallExpression */ // func( a, | - || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 190 /* NewExpression */ // new C(a, | - || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| - case 19 /* OpenParenToken */: - return containingNodeKind === 189 /* CallExpression */ // func( | - || containingNodeKind === 155 /* Constructor */ // constructor( | - || containingNodeKind === 190 /* NewExpression */ // new C(a| - || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 21 /* OpenBracketToken */: - return containingNodeKind === 185 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 129 /* ModuleKeyword */: // module | - case 130 /* NamespaceKeyword */: // namespace | + case 27 /* CommaToken */: + return containingNodeKind === 191 /* CallExpression */ // func( a, | + || containingNodeKind === 157 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 192 /* NewExpression */ // new C(a, | + || containingNodeKind === 187 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 204 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 165 /* FunctionType */; // var x: (s: string, list| + case 20 /* OpenParenToken */: + return containingNodeKind === 191 /* CallExpression */ // func( | + || containingNodeKind === 157 /* Constructor */ // constructor( | + || containingNodeKind === 192 /* NewExpression */ // new C(a| + || containingNodeKind === 195 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 177 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* OpenBracketToken */: + return containingNodeKind === 187 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 162 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 149 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 130 /* ModuleKeyword */: // module | + case 131 /* NamespaceKeyword */: // namespace | return true; - case 23 /* DotToken */: - return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| - case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | - case 58 /* EqualsToken */: - return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 202 /* BinaryExpression */; // x = a| - case 14 /* TemplateHead */: - return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| - case 15 /* TemplateMiddle */: - return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */; // class A{ public | + case 24 /* DotToken */: + return containingNodeKind === 244 /* ModuleDeclaration */; // module A.| + case 18 /* OpenBraceToken */: + return containingNodeKind === 240 /* ClassDeclaration */; // class A{ | + case 59 /* EqualsToken */: + return containingNodeKind === 237 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 204 /* BinaryExpression */; // x = a| + case 15 /* TemplateHead */: + return containingNodeKind === 206 /* TemplateExpression */; // `aa ${| + case 16 /* TemplateMiddle */: + return containingNodeKind === 216 /* TemplateSpan */; // `aa ${10} dd ${| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -95692,16 +96942,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 188 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; - isNewIdentifierLocation = hasIndexSignature(typeForObject); + isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 184 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -95712,12 +96962,12 @@ 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 === 225 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 227 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 151 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 154 /* MethodDeclaration */ || rootDeclaration.parent.kind === 157 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 156 /* MethodDeclaration */ || rootDeclaration.parent.kind === 159 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -95753,13 +97003,13 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { // `import { |` or `import { a as 0, | }` - var namedImportsOrExports = contextToken && (contextToken.kind === 17 /* OpenBraceToken */ || contextToken.kind === 26 /* CommaToken */) + var namedImportsOrExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 252 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -95782,7 +97032,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 39 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* 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)) @@ -95790,7 +97040,7 @@ var ts; var classElement = contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 71 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 72 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -95819,15 +97069,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 17 /* OpenBraceToken */: // const x = { | - case 26 /* CommaToken */: // const x = { a: 0, | + case 18 /* OpenBraceToken */: // const x = { | + case 27 /* CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 71 /* Identifier */: + case 72 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -95846,8 +97096,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 19 /* OpenParenToken */: - case 26 /* CommaToken */: + case 20 /* OpenParenToken */: + case 27 /* CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -95877,17 +97127,17 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 28 /* LessThanSlashToken */: - case 41 /* SlashToken */: - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 266 /* JsxAttributes */: - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { + case 29 /* LessThanSlashToken */: + case 42 /* SlashToken */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 268 /* JsxAttributes */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 261 /* JsxSelfClosingElement */ || parent.kind === 262 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 265 /* JsxAttribute */) { + else if (parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95898,8 +97148,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 9 /* StringLiteral */: - if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { + case 10 /* StringLiteral */: + if (parent && ((parent.kind === 267 /* JsxAttribute */) || (parent.kind === 269 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95907,10 +97157,10 @@ var ts; return parent.parent.parent; } break; - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: if (parent && - parent.kind === 268 /* JsxExpression */ && - parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { + parent.kind === 270 /* JsxExpression */ && + parent.parent && parent.parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95918,7 +97168,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 269 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95937,65 +97187,65 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 26 /* CommaToken */: - return containingNodeKind === 235 /* VariableDeclaration */ || - containingNodeKind === 236 /* VariableDeclarationList */ || - containingNodeKind === 217 /* VariableStatement */ || - containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | + case 27 /* CommaToken */: + return containingNodeKind === 237 /* VariableDeclaration */ || + containingNodeKind === 238 /* VariableDeclarationList */ || + containingNodeKind === 219 /* VariableStatement */ || + containingNodeKind === 243 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 23 /* DotToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| - case 56 /* ColonToken */: - return containingNodeKind === 184 /* BindingElement */; // var {x :html| - case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| - case 19 /* OpenParenToken */: - return containingNodeKind === 272 /* CatchClause */ || + case 24 /* DotToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [.| + case 57 /* ColonToken */: + return containingNodeKind === 186 /* BindingElement */; // var {x :html| + case 22 /* OpenBracketToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [x| + case 20 /* OpenParenToken */: + return containingNodeKind === 274 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 17 /* OpenBraceToken */: - return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | - case 27 /* LessThanToken */: - return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | - containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | + case 18 /* OpenBraceToken */: + return containingNodeKind === 243 /* EnumDeclaration */; // enum a { | + case 28 /* LessThanToken */: + return containingNodeKind === 240 /* ClassDeclaration */ || // class A< | + containingNodeKind === 209 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 241 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 242 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 115 /* StaticKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 24 /* DotDotDotToken */: - return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 118 /* AsKeyword */: - return containingNodeKind === 251 /* ImportSpecifier */ || - containingNodeKind === 255 /* ExportSpecifier */ || - containingNodeKind === 249 /* NamespaceImport */; - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* DotDotDotToken */: + return containingNodeKind === 151 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 185 /* ArrayBindingPattern */); // var [...z| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 151 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 119 /* AsKeyword */: + return containingNodeKind === 253 /* ImportSpecifier */ || + containingNodeKind === 257 /* ExportSpecifier */ || + containingNodeKind === 251 /* NamespaceImport */; + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 109 /* InterfaceKeyword */: - case 89 /* FunctionKeyword */: - case 104 /* VarKeyword */: - case 91 /* ImportKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 116 /* YieldKeyword */: - case 139 /* TypeKeyword */: // type htm| + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 110 /* InterfaceKeyword */: + case 90 /* FunctionKeyword */: + case 105 /* VarKeyword */: + case 92 /* ImportKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 117 /* YieldKeyword */: + case 140 /* TypeKeyword */: // type htm| return true; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -96016,22 +97266,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 117 /* AbstractKeyword */: - case 75 /* ClassKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 83 /* EnumKeyword */: - case 89 /* FunctionKeyword */: - case 109 /* InterfaceKeyword */: - case 110 /* LetKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 115 /* StaticKeyword */: - case 104 /* VarKeyword */: - case 116 /* YieldKeyword */: + case 118 /* AbstractKeyword */: + case 76 /* ClassKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 84 /* EnumKeyword */: + case 90 /* FunctionKeyword */: + case 110 /* InterfaceKeyword */: + case 111 /* LetKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 116 /* StaticKeyword */: + case 105 /* VarKeyword */: + case 117 /* YieldKeyword */: return true; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -96041,7 +97291,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 155 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 157 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -96064,12 +97314,12 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 273 /* PropertyAssignment */ && - m.kind !== 274 /* ShorthandPropertyAssignment */ && - m.kind !== 184 /* BindingElement */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 275 /* PropertyAssignment */ && + m.kind !== 276 /* ShorthandPropertyAssignment */ && + m.kind !== 186 /* BindingElement */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -96079,7 +97329,7 @@ var ts; var existingName = void 0; if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 71 /* Identifier */) { + if (m.propertyName.kind === 72 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -96104,10 +97354,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 !== 152 /* PropertyDeclaration */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 154 /* PropertyDeclaration */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -96147,7 +97397,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 265 /* JsxAttribute */) { + if (attr.kind === 267 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -96191,7 +97441,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72 /* FirstKeyword */; i <= 145 /* LastKeyword */; i++) { + for (var i = 73 /* FirstKeyword */; i <= 147 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -96208,8 +97458,8 @@ var ts; case 0 /* None */: return false; case 1 /* All */: - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 124 /* DeclareKeyword */ || kind === 129 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 140 /* UndefinedKeyword */; + return kind === 121 /* AsyncKeyword */ || 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 125 /* DeclareKeyword */ || kind === 130 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 141 /* UndefinedKeyword */; case 2 /* ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); case 3 /* InterfaceElementKeywords */: @@ -96226,37 +97476,26 @@ var ts; })); } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 132 /* ReadonlyKeyword */; + return kind === 133 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 117 /* AbstractKeyword */: - case 123 /* ConstructorKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 120 /* AsyncKeyword */: + case 118 /* AbstractKeyword */: + case 124 /* ConstructorKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 121 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; } - function isEqualityOperatorKind(kind) { - switch (kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - return true; - default: - return false; - } - } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { var jsdoc = ts.findAncestor(node, ts.isJSDoc); @@ -96266,7 +97505,7 @@ var ts; return contextualType.isUnion() ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - return !(memberType.flags & 32764 /* Primitive */ || + return !(memberType.flags & 131068 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); @@ -96289,31 +97528,31 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 304 /* SyntaxList */: + case 306 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { return cls; } } if (!contextToken) return undefined; switch (contextToken.kind) { - case 25 /* SemicolonToken */: // class c {getValue(): number; | } - case 18 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SemicolonToken */: // class c {getValue(): number; | } + case 19 /* CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 17 /* OpenBraceToken */: // class c { | - case 26 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* OpenBraceToken */: // class c { | + case 27 /* CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) return undefined; var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 39 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -96321,9 +97560,6 @@ var ts; function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); } - function hasIndexSignature(type) { - return !!type.getStringIndexType() || !!type.getNumberIndexType(); - } function isValidTrigger(sourceFile, triggerCharacter, contextToken, position) { switch (triggerCharacter) { case ".": @@ -96333,14 +97569,14 @@ var ts; case "'": case "`": // Only automatically bring up completions if this is an opening quote. - return !!contextToken && isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; + return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 41 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -96349,17 +97585,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function isStringLiteralOrTemplate(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - return true; - default: - return false; - } - } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -96412,40 +97637,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 90 /* IfKeyword */: - case 82 /* ElseKeyword */: + case 91 /* IfKeyword */: + case 83 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 96 /* ReturnKeyword */: + case 97 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 102 /* TryKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: - var tryStatement = node.kind === 74 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 103 /* TryKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: + var tryStatement = node.kind === 75 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 73 /* CaseKeyword */: - case 79 /* DefaultKeyword */: + case 74 /* CaseKeyword */: + case 80 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 72 /* BreakKeyword */: - case 77 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 78 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 88 /* ForKeyword */: - case 106 /* WhileKeyword */: - case 81 /* DoKeyword */: + case 89 /* ForKeyword */: + case 107 /* WhileKeyword */: + case 82 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 123 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [123 /* ConstructorKeyword */]); - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [125 /* GetKeyword */, 136 /* SetKeyword */]); - case 121 /* AwaitKeyword */: + case 124 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [124 /* ConstructorKeyword */]); + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [126 /* GetKeyword */, 137 /* SetKeyword */]); + case 122 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 116 /* YieldKeyword */: + case 117 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -96488,7 +97713,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -96520,16 +97745,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 230 /* SwitchStatement */: - if (statement.kind === 226 /* ContinueStatement */) { + case 232 /* SwitchStatement */: + if (statement.kind === 228 /* ContinueStatement */) { return false; } // falls through - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -96545,11 +97770,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 216 /* Block */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 218 /* Block */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -96557,12 +97782,12 @@ var ts; else { return container.statements; } - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: 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. @@ -96593,12 +97818,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 89 /* ForKeyword */, 107 /* WhileKeyword */, 82 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 221 /* DoStatement */) { + if (loopNode.kind === 223 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 107 /* WhileKeyword */)) { break; } } @@ -96606,7 +97831,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */, 77 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */, 78 /* ContinueKeyword */); } }); return keywords; @@ -96615,13 +97840,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -96629,13 +97854,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 98 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 99 /* 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(), 73 /* CaseKeyword */, 79 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 74 /* CaseKeyword */, 80 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */); } }); }); @@ -96643,13 +97868,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 102 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 103 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 75 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 87 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 88 /* FinallyKeyword */); } return keywords; } @@ -96660,13 +97885,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* 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, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -96678,11 +97903,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* 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, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -96694,13 +97919,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 120 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 121 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 122 /* AwaitKeyword */); } }); }); @@ -96715,7 +97940,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 116 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 117 /* YieldKeyword */); } }); }); @@ -96734,7 +97959,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 === 82 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 83 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -96769,10 +97994,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], 90 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 91 /* 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], 82 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 83 /* ElseKeyword */)) { break; } } @@ -96805,13 +98030,6 @@ var ts; // for those settings. var buckets = ts.createMap(); var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets.get(key); - if (!bucket && createIfMissing) { - buckets.set(key, bucket = ts.createMap()); - } - return bucket; // TODO: GH#18217 - } function reportStats() { var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { var entries = buckets.get(name); @@ -96847,7 +98065,7 @@ var ts; return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); + var bucket = ts.getOrUpdate(buckets, key, ts.createMap); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; if (!entry && externalCache) { @@ -96901,8 +98119,7 @@ var ts; return releaseDocumentWithKey(path, key); } function releaseDocumentWithKey(path, key) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ false); - ts.Debug.assert(bucket !== undefined); + var bucket = ts.Debug.assertDefined(buckets.get(key)); var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); @@ -96996,12 +98213,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 237 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { directImports.push(name); break; } @@ -97010,22 +98227,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 71 /* Identifier */: // for 'const x = require("y"); + case 72 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 251 /* 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 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -97035,7 +98252,7 @@ var ts; directImports.push(direct); } break; - case 181 /* ImportType */: + case 183 /* ImportType */: directImports.push(direct); break; default: @@ -97052,7 +98269,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -97107,17 +98324,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 246 /* ImportEqualsDeclaration */) { + if (decl.kind === 248 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 71 /* Identifier */) { + if (decl.kind === 72 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 181 /* ImportType */) { + if (decl.kind === 183 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -97129,20 +98346,20 @@ var ts; return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 253 /* ExportDeclaration */) { + if (decl.kind === 255 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -97192,7 +98409,7 @@ var ts; } } else { - var localSymbol = element.kind === 255 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 257 /* 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); @@ -97221,7 +98438,7 @@ var ts; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 277 /* SourceFile */) { + if (searchSourceFile.kind === 279 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -97269,7 +98486,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 === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -97284,15 +98501,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: { + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -97316,7 +98533,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 187 /* PropertyAccessExpression */) { + if (parent.kind === 189 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -97438,10 +98655,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 235 /* VariableDeclaration */) { + if (parent.kind === 237 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 274 /* CatchClause */ ? undefined : p.parent.parent.kind === 219 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -97450,15 +98667,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -97491,21 +98708,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 277 /* SourceFile */) { + if (parent.kind === 279 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 244 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 259 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -97557,18 +98774,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* 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 === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var result_7 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_7.push(nodeEntry(node)); }); return result_7; } - else if (node.kind === 97 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 98 /* 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); @@ -97630,7 +98847,7 @@ var ts; } function getDefinitionKindAndDisplayParts(symbol, checker, node) { var meaning = FindAllReferences.Core.getIntersectingMeaningFromDeclarations(node, symbol); - var enclosingDeclaration = ts.firstOrUndefined(symbol.declarations) || node; + var enclosingDeclaration = symbol.declarations && ts.firstOrUndefined(symbol.declarations) || node; var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, enclosingDeclaration.getSourceFile(), enclosingDeclaration, enclosingDeclaration, meaning), displayParts = _a.displayParts, symbolKind = _a.symbolKind; return { displayParts: displayParts, kind: symbolKind }; } @@ -97648,7 +98865,7 @@ var ts; textSpan: textSpan, fileName: fileName, isWriteAccess: isWriteAccessForReference(node), - isDefinition: node.kind === 79 /* DefaultKeyword */ + isDefinition: node.kind === 80 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined, @@ -97703,16 +98920,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 207 /* ClassExpression */) { + else if (node.kind === 209 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] }; } else { @@ -97738,7 +98955,7 @@ var ts; function getTextSpan(node, sourceFile) { var start = node.getStart(sourceFile); var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { start += 1; end -= 1; } @@ -97747,7 +98964,7 @@ var ts; /** 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 === 79 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 80 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -97758,46 +98975,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 202 /* BinaryExpression */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 79 /* DefaultKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 255 /* ExportSpecifier */: - case 248 /* ImportClause */: // default import - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 239 /* InterfaceDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 265 /* JsxAttribute */: - case 242 /* ModuleDeclaration */: - case 245 /* NamespaceExportDeclaration */: - case 249 /* NamespaceImport */: - case 149 /* Parameter */: - case 274 /* ShorthandPropertyAssignment */: - case 240 /* TypeAliasDeclaration */: - case 148 /* TypeParameter */: + case 204 /* BinaryExpression */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 80 /* DefaultKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 257 /* ExportSpecifier */: + case 250 /* ImportClause */: // default import + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 241 /* InterfaceDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 267 /* JsxAttribute */: + case 244 /* ModuleDeclaration */: + case 247 /* NamespaceExportDeclaration */: + case 251 /* NamespaceImport */: + case 151 /* Parameter */: + case 276 /* ShorthandPropertyAssignment */: + case 242 /* TypeAliasDeclaration */: + case 150 /* TypeParameter */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return !!decl.body; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 153 /* MethodSignature */: - case 151 /* PropertySignature */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 155 /* MethodSignature */: + case 153 /* PropertySignature */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -97834,6 +99051,9 @@ var ts; // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. return !options.implementations && ts.isStringLiteral(node) ? getReferencesForStringLiteral(node, sourceFiles, cancellationToken) : undefined; } + if (symbol.escapedName === "export=" /* ExportEquals */) { + return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); + } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); var referencedNode = node; @@ -97878,10 +99098,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 277 /* SourceFile */: + case 279 /* 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -97891,6 +99111,22 @@ var ts; ts.Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } + var exported = symbol.exports.get("export=" /* ExportEquals */); + if (exported) { + for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { + var decl = _c[_b]; + var sourceFile = decl.getSourceFile(); + 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.assertDefined(ts.findChildOfKind(decl, 85 /* ExportKeyword */, sourceFile)) + : ts.getNameOfDeclaration(decl) || decl; + references.push(FindAllReferences.nodeEntry(node)); + } + } + } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** getReferencedSymbols for special node kinds. */ @@ -97912,7 +99148,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -97924,7 +99160,7 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - if (node && node.kind === 79 /* DefaultKeyword */) { + if (node && node.kind === 80 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -97949,9 +99185,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: return 1 /* Constructor */; - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -98183,7 +99419,7 @@ 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 === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 196 /* FunctionExpression */ || valueDeclaration.kind === 209 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -98193,7 +99429,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 240 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -98222,7 +99458,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 279 /* 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; @@ -98243,7 +99479,9 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = checker.getSymbolAtLocation(definition); + var symbol = ts.isParameterPropertyDeclaration(definition.parent) + ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) + : checker.getSymbolAtLocation(definition); if (!symbol) return undefined; for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { @@ -98328,16 +99566,16 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.text.length === searchSymbolName.length; - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { var str = node; - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(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 */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 79 /* DefaultKeyword */: + case 80 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -98401,7 +99639,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 71 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 72 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -98456,7 +99694,7 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!(referenceLocation === propertyName && state.options.isForRename)) { - var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; + var exportKind = referenceLocation.originalKeywordKind === 80 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); if (!exportInfo) return ts.Debug.fail(); @@ -98536,7 +99774,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 80 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -98562,7 +99800,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -98579,16 +99817,16 @@ var ts; function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { for (var _i = 0, _a = classSymbol.members.get("__constructor" /* Constructor */).declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 155 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 124 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 157 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 154 /* MethodDeclaration */) { + if (decl && decl.kind === 156 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 100 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -98605,10 +99843,10 @@ var ts; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 155 /* Constructor */); + ts.Debug.assert(decl.kind === 157 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 98 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -98622,10 +99860,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 71 /* Identifier */) { + if (refNode.kind !== 72 /* Identifier */) { return; } - if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 276 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -98645,7 +99883,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 216 /* Block */) { + if (body.kind === 218 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -98673,13 +99911,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 185 /* ArrayLiteralExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 187 /* ArrayLiteralExpression */: return true; default: return false; @@ -98732,13 +99970,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -98747,7 +99985,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 97 /* SuperKeyword */) { + if (node.kind !== 98 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -98763,34 +100001,34 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -98798,19 +100036,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 277 /* SourceFile */: - return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); + case 279 /* SourceFile */: + return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -99007,7 +100245,7 @@ var ts; var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); } @@ -99016,7 +100254,7 @@ var ts; function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var originalPath = sourceMapper && sourceMapper.tryGetOriginalLocation({ fileName: path, position: 0 }); + var originalPath = sourceMapper && sourceMapper.tryGetSourcePosition({ fileName: path, pos: 0 }); var updatedPath = getUpdatedPath(originalPath ? originalPath.fileName : path); return originalPath ? updatedPath === undefined ? undefined : makeCorrespondingRelativeChange(originalPath.fileName, updatedPath, path, getCanonicalFileName) @@ -99035,7 +100273,7 @@ var ts; var rel = ts.getRelativePathFromFile(a0, b0, getCanonicalFileName); return combinePathsSafe(ts.getDirectoryPath(a1), rel); } - function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + function updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) return; @@ -99053,7 +100291,8 @@ var ts; var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); // If there isn't some include for this, add a new one. - if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + if (ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && + !ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); } } @@ -99246,7 +100485,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 97 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 98 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -99254,7 +100493,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -99407,18 +100646,18 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 71 /* Identifier */) { + if (node.kind !== 72 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 248 /* ImportClause */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: return true; - case 251 /* ImportSpecifier */: - return declaration.parent.kind === 250 /* NamedImports */; + case 253 /* ImportSpecifier */: + return declaration.parent.kind === 252 /* NamedImports */; default: return false; } @@ -99428,7 +100667,7 @@ var ts; 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 */ && (ts.isNewExpressionTarget(node) || node.kind === 123 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 124 /* ConstructorKeyword */)) { var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -99502,9 +100741,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return true; default: return false; @@ -99622,11 +100861,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: return [declaration]; - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -99647,16 +100886,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return withNode(tag.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -99833,7 +101072,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 === 71 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 72 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -99843,23 +101082,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 155 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 151 /* PropertySignature */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 153 /* PropertySignature */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 242 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -99867,14 +101106,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 277 /* SourceFile */: + case 279 /* SourceFile */: return "quit"; - case 242 /* ModuleDeclaration */: + case 244 /* 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 === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 202 /* BinaryExpression */: { + return commentOwner.parent.kind === 244 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 204 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -99893,14 +101132,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 195 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return rightHandSide.parameters; - case 207 /* ClassExpression */: { + case 209 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -99962,9 +101201,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 248 /* ImportClause */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -99974,7 +101213,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 147 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 149 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -99991,7 +101230,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 === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 149 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -100160,7 +101399,7 @@ var ts; return; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* 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); @@ -100172,21 +101411,21 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 155 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -100198,7 +101437,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -100209,8 +101448,8 @@ var ts; } } break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -100231,12 +101470,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -100246,9 +101485,9 @@ var ts; } endNode(); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -100256,18 +101495,18 @@ var ts; } endNode(); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 255 /* ExportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 160 /* IndexSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 240 /* TypeAliasDeclaration */: + case 257 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 162 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 242 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -100279,6 +101518,9 @@ var ts; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -100346,12 +101588,12 @@ var ts; return false; } switch (a.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -100367,7 +101609,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 244 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -100397,7 +101639,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -100405,16 +101647,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -100424,16 +101666,16 @@ var ts; } } switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -100441,13 +101683,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return "new()"; - case 158 /* CallSignature */: + case 160 /* CallSignature */: return "()"; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "[]"; default: return ""; @@ -100471,25 +101713,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 277 /* SourceFile */: - case 240 /* TypeAliasDeclaration */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 242 /* TypeAliasDeclaration */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return true; - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 235 /* VariableDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 237 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -100499,10 +101741,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -100511,7 +101753,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; + return childKind !== 237 /* VariableDeclaration */ && childKind !== 186 /* BindingElement */; }); } } @@ -100568,7 +101810,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -100582,13 +101824,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 147 /* ComputedPropertyName */; + return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -100603,7 +101845,7 @@ var ts; return ts.declarationNameToString(parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -100641,9 +101883,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: return true; default: return false; @@ -100770,7 +102012,7 @@ var ts; ? specifier.text : undefined; } - /* @internal */ // Internal for testing + // Internal for testing /** * @param importGroup a list of ImportDeclarations, all with the same module name. */ @@ -100869,7 +102111,7 @@ var ts; } } OrganizeImports.coalesceImports = coalesceImports; - /* @internal */ // Internal for testing + // Internal for testing /** * @param exportGroup a list of ExportDeclarations, all with the same module name. */ @@ -100972,7 +102214,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 91 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 92 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -101079,31 +102321,31 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 197 /* ArrowFunction */); } // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 221 /* DoStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 272 /* CatchClause */: + case 223 /* DoStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 274 /* CatchClause */: return spanForNode(n.parent); - case 233 /* TryStatement */: + case 235 /* 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) { - return spanForNode(ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -101111,21 +102353,21 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanForNode(n.parent); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 244 /* CaseBlock */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 246 /* CaseBlock */: return spanForNode(n); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 185 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); - case 258 /* JsxElement */: + case 187 /* ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); + case 260 /* JsxElement */: return spanForJSXElement(n); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -101141,7 +102383,7 @@ var ts; return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -101150,9 +102392,9 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); - var close = open === 17 /* OpenBraceToken */ ? 18 /* CloseBraceToken */ : 22 /* CloseBracketToken */; + var close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; var closeToken = ts.findChildOfKind(n, close, sourceFile); if (!openToken || !closeToken) { return undefined; @@ -101511,11 +102753,11 @@ var ts; characterSpans: breakIntoCharacterSpans(text) }; } - /* @internal */ function breakIntoCharacterSpans(identifier) { + function breakIntoCharacterSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - /* @internal */ function breakIntoWordSpans(identifier) { + function breakIntoWordSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; @@ -101655,10 +102897,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 17 /* OpenBraceToken */) { + if (currentToken === 18 /* OpenBraceToken */) { braceNesting++; } - else if (currentToken === 18 /* CloseBraceToken */) { + else if (currentToken === 19 /* CloseBraceToken */) { braceNesting--; } return currentToken; @@ -101688,12 +102930,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 124 /* DeclareKeyword */) { + if (token === 125 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 129 /* ModuleKeyword */) { + if (token === 130 /* ModuleKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); } } @@ -101705,42 +102947,42 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 23 /* DotToken */) { + if (lastToken === 24 /* DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 91 /* ImportKeyword */) { + if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 9 /* StringLiteral */) { + else if (token === 10 /* StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 58 /* EqualsToken */) { + else if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 26 /* CommaToken */) { + else if (token === 27 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -101749,18 +102991,18 @@ var ts; return true; } } - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -101768,15 +103010,15 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 118 /* AsKeyword */) { + if (token === 119 /* AsKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -101792,21 +103034,21 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 84 /* ExportKeyword */) { + if (token === 85 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -101814,21 +103056,21 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 91 /* ImportKeyword */) { + else if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 58 /* EqualsToken */) { + if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -101841,11 +103083,11 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 133 /* RequireKeyword */) { + if (token === 134 /* RequireKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // require("mod"); recordModuleName(); } @@ -101856,16 +103098,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 71 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 72 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 19 /* OpenParenToken */) { + if (token !== 20 /* OpenParenToken */) { return true; } token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 26 /* CommaToken */) { + if (token === 27 /* CommaToken */) { token = nextToken(); } else { @@ -101874,15 +103116,15 @@ var ts; } } // should be start of dependency list - if (token !== 21 /* OpenBracketToken */) { + if (token !== 22 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordModuleName(); } token = nextToken(); @@ -101990,14 +103232,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 === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 80 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return getRenameInfoForModule(node, sourceFile, symbol); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 147 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 149 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -102044,7 +103286,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { // Exclude the quotes start += 1; width -= 2; @@ -102053,9 +103295,9 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -102148,13 +103390,13 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 26 /* CommaToken */: { + case 27 /* CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -102200,7 +103442,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 27 /* LessThanToken */ || node.kind === 19 /* OpenParenToken */) { + if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* 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 }; @@ -102253,10 +103495,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 193 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 206 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -102319,24 +103561,24 @@ var ts; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) { - if (startingToken.kind !== 19 /* OpenParenToken */ && startingToken.kind !== 26 /* CommaToken */) + if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 195 /* ParenthesizedExpression */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 19 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* 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) }; } @@ -102368,7 +103610,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 26 /* CommaToken */) { + if (child.kind !== 27 /* CommaToken */) { argumentIndex++; } } @@ -102387,8 +103629,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 !== 26 /* CommaToken */; }); - if (listChildren.length > 0 && ts.last(listChildren).kind === 26 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); + if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -102457,7 +103699,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 === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -102522,10 +103764,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(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(27 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(29 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(26 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; var prefixDisplayParts = callTargetDisplayParts.concat(prefix); @@ -102554,9 +103796,9 @@ var ts; var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(27 /* LessThanToken */)], suffix: [ts.punctuationPart(29 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = candidateSignature.hasRestParameter; @@ -102564,11 +103806,11 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration); })); - printer.writeList(26896 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); } }); var parameters = candidateSignature.parameters.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(19 /* OpenParenToken */)]), suffix: [ts.punctuationPart(20 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -102590,53 +103832,46 @@ var ts; /* @internal */ var ts; (function (ts) { - // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; - var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; - function getSourceMapper(getCanonicalFileName, currentDirectory, log, host, getProgram) { + function getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, getProgram) { + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var sourcemappedFileCache; - return { tryGetOriginalLocation: tryGetOriginalLocation, tryGetGeneratedLocation: tryGetGeneratedLocation, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + return { tryGetSourcePosition: tryGetSourcePosition, tryGetGeneratedPosition: tryGetGeneratedPosition, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + function toPath(fileName) { + return ts.toPath(fileName, currentDirectory, getCanonicalFileName); + } function scanForSourcemapURL(fileName) { - var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var mappedFile = sourcemappedFileCache.get(toPath(fileName)); if (!mappedFile) { return; } - var starts = ts.getLineStarts(mappedFile); - for (var index = starts.length - 1; index >= 0; index--) { - var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); - var comment = sourceMapCommentRegExp.exec(lineText); - if (comment) { - return comment[1]; - } - // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file - else if (!lineText.match(whitespaceOrMapCommentRegExp)) { - break; - } - } + return ts.tryGetSourceMappingURL(mappedFile.text, ts.getLineStarts(mappedFile)); } function convertDocumentToSourceMapper(file, contents, mapFileName) { - var maps; - try { - maps = JSON.parse(contents); - } - catch (_a) { - // swallow error - } - if (!maps || !maps.sources || !maps.file || !maps.mappings) { + var map = ts.tryParseRawSourceMap(contents); + if (!map || !map.sources || !map.file || !map.mappings) { // obviously invalid map - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - return file.sourceMapper = ts.sourcemaps.decode({ - readFile: function (s) { return host.readFile(s); }, - fileExists: function (s) { return host.fileExists(s); }, + var program = getProgram(); + return file.sourceMapper = ts.createDocumentPositionMapper({ + getSourceFileLike: function (s) { + // Lookup file in program, if provided + var file = program && program.getSourceFileByPath(s); + // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file + if (file === undefined || file.resolvedPath !== s) { + // Otherwise check the cache (which may hit disk) + return sourcemappedFileCache.get(s); + } + return file; + }, getCanonicalFileName: getCanonicalFileName, log: log, - }, mapFileName, maps, getProgram(), sourcemappedFileCache); + }, map, mapFileName); } function getSourceMapper(fileName, file) { if (!host.readFile || !host.fileExists) { - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } if (file.sourceMapper) { return file.sourceMapper; @@ -102665,20 +103900,24 @@ var ts; return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217 } } - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - function tryGetOriginalLocation(info) { + function tryGetSourcePosition(info) { if (!ts.isDeclarationFileName(info.fileName)) return undefined; var file = getFile(info.fileName); if (!file) return undefined; - var newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info); - return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc; + var newLoc = getSourceMapper(info.fileName, file).getSourcePosition(info); + return newLoc === info ? undefined : tryGetSourcePosition(newLoc) || newLoc; } - function tryGetGeneratedLocation(info) { + function tryGetGeneratedPosition(info) { var program = getProgram(); - var declarationPath = ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); + var options = program.getCompilerOptions(); + var outPath = options.outFile || options.out; + var declarationPath = outPath ? + ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; var declarationFile = getFile(declarationPath); @@ -102688,18 +103927,45 @@ var ts; return newLoc === info ? undefined : newLoc; } function getFile(fileName) { - return getProgram().getSourceFile(fileName) || sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var path = toPath(fileName); + var file = getProgram().getSourceFileByPath(path); + if (file && file.resolvedPath === path) { + return file; + } + return sourcemappedFileCache.get(path); } function toLineColumnOffset(fileName, position) { - var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217 + var file = getFile(fileName); // TODO: GH#18217 return file.getLineAndCharacterOfPosition(position); } function clearCache() { - sourcemappedFileCache = ts.createSourceFileLikeCache(host); + sourcemappedFileCache = createSourceFileLikeCache(host); } } ts.getSourceMapper = getSourceMapper; + function createSourceFileLikeCache(host) { + var cached = ts.createMap(); + return { + get: function (path) { + if (cached.has(path)) { + return cached.get(path); + } + if (!host.fileExists || !host.readFile || !host.fileExists(path)) + return; + // And failing that, check the disk + var text = host.readFile(path); // TODO: GH#18217 + var file = { + text: text, + lineMap: undefined, + getLineAndCharacterOfPosition: function (pos) { + return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + } + }; + cached.set(path, file); + return file; + } + }; + } })(ts || (ts = {})); /* @internal */ var ts; @@ -102735,7 +104001,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_2 = decl.symbol; @@ -102745,7 +104011,7 @@ var ts; } } // falls through if no diagnostic was created - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -102778,11 +104044,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -102799,58 +104065,42 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 251 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; default: return undefined; } } function addConvertToAsyncFunctionDiagnostics(node, checker, diags) { - if (ts.isAsyncFunction(node) || !node.body) { - return; + if (!ts.isAsyncFunction(node) && + node.body && + ts.isBlock(node.body) && + hasReturnStatementWithPromiseHandler(node.body) && + returnsPromise(node, checker)) { + diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); } + } + function returnsPromise(node, checker) { var functionType = checker.getTypeAtLocation(node); var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; - if (!returnType || !checker.getPromisedTypeOfPromise(returnType)) { - return; - } - // collect all the return statements - // check that a property access expression exists in there and that it is a handler - var returnStatements = getReturnStatementsWithPromiseHandlers(node); - if (returnStatements.length > 0) { - diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); - } + return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - /** @internal */ - function getReturnStatementsWithPromiseHandlers(node) { - var returnStatements = []; - if (ts.isFunctionLike(node)) { - ts.forEachChild(node, visit); - } - else { - visit(node); - } - function visit(child) { - if (ts.isFunctionLike(child)) { - return; - } - if (ts.isReturnStatement(child) && child.expression && isFixablePromiseHandler(child.expression)) { - returnStatements.push(child); - } - ts.forEachChild(child, visit); - } - return returnStatements; + function hasReturnStatementWithPromiseHandler(body) { + return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); } - ts.getReturnStatementsWithPromiseHandlers = getReturnStatementsWithPromiseHandlers; + function isReturnStatementWithFixablePromiseHandler(node) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + } + ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts function isFixablePromiseHandler(node) { // ensure outermost call exists and is a promise handler @@ -102867,17 +104117,18 @@ var ts; } return true; } + ts.isFixablePromiseHandler = isFixablePromiseHandler; function isPromiseHandler(node) { return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") || ts.hasPropertyAccessExpressionWithName(node, "catch")); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 95 /* NullKeyword */: - case 71 /* Identifier */: // identifier includes undefined - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: // identifier includes undefined + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -102897,7 +104148,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 209 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -102934,7 +104185,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 100 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -102985,11 +104236,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 260 /* JsxOpeningElement */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 265 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + return location.kind === 72 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 267 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -103016,13 +104267,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 100 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 99 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(99 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 100 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(100 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -103032,7 +104283,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 187 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 189 /* 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)) { @@ -103053,7 +104304,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 190 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 192 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 98 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -103071,7 +104322,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -103088,14 +104339,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* 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 */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -103108,29 +104359,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 155 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 124 /* ConstructorKeyword */ && location.parent.kind === 157 /* 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 = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 124 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 155 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 157 /* 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 === 155 /* Constructor */) { + if (functionDeclaration_1.kind === 157 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 160 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -103140,7 +104391,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 209 /* 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 @@ -103148,7 +104399,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(75 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(76 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -103156,45 +104407,45 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(109 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(110 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(77 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(83 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(84 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 244 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 72 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 131 /* NamespaceKeyword */ : 130 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -103205,7 +104456,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 148 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 150 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -103213,21 +104464,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 159 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + if (declaration.kind === 161 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 158 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 160 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 240 /* TypeAliasDeclaration */) { + else if (declaration.kind === 242 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -103239,11 +104490,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 276 /* EnumMember */) { + if (declaration.kind === 278 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -103269,41 +104520,41 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 245 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 247 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(131 /* NamespaceKeyword */)); break; - case 252 /* ExportAssignment */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 254 /* ExportAssignment */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 59 /* EqualsToken */ : 80 /* DefaultKeyword */)); break; - case 255 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 257 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(91 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(92 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 246 /* ImportEqualsDeclaration */) { + if (declaration.kind === 248 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(133 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(134 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -103317,7 +104568,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(99 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(100 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -103328,7 +104579,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -103366,10 +104617,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -103412,7 +104663,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(92 /* InKeyword */)); + displayParts.push(ts.keywordPart(93 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -103422,7 +104673,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(55 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -103445,9 +104696,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); return; } } @@ -103456,12 +104707,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(37 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(38 /* 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(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } var docComment = signature.getDocumentationComment(typeChecker); documentation = docComment.length === 0 ? undefined : docComment; @@ -103470,7 +104721,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration); - getPrinter().writeList(26896 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -103482,16 +104733,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 194 /* FunctionExpression */) { + if (declaration.kind === 196 /* FunctionExpression */) { return true; } - if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* FunctionDeclaration */) { + if (declaration.kind !== 237 /* VariableDeclaration */ && declaration.kind !== 239 /* 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 === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { + if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -103706,8 +104957,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 17 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 18 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -103789,11 +105040,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 31 /* GreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -103801,28 +105052,28 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 265 /* JsxAttribute */: - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 267 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* 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 === 71 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 72 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 12 /* RegularExpressionLiteral */; + return container.kind === 13 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 15 /* TemplateMiddle */ || - container.kind === 16 /* TemplateTail */; + return container.kind === 16 /* TemplateMiddle */ || + container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; + return t === 42 /* SlashToken */ || t === 64 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -103892,7 +105143,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -103908,7 +105159,7 @@ var ts; } break; case 3 /* RescanTemplateToken */: - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { lastScanAction = 3 /* RescanTemplateToken */; return scanner.reScanTemplateToken(); } @@ -103981,7 +105232,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 145 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 147 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -103993,255 +105244,255 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 145 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); - var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 145 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; - var unaryPrefixOperators = [43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]; + var keywords = tokenRangeFromRange(73 /* FirstKeyword */, 147 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 71 /* LastBinaryOperator */); + var binaryKeywordOperators = [93 /* InKeyword */, 94 /* InstanceOfKeyword */, 147 /* OfKeyword */, 119 /* AsKeyword */, 128 /* IsKeyword */]; + var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, - 17 /* OpenBraceToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 72 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostincrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; - var unaryPredecrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostdecrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; + var unaryPreincrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostincrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; + var unaryPredecrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostdecrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [71 /* Identifier */].concat(ts.typeKeywords); + var typeNames = [72 /* Identifier */].concat(ts.typeKeywords); // 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([71 /* Identifier */, 3 /* MultiLineCommentTrivia */, 75 /* ClassKeyword */, 84 /* ExportKeyword */, 91 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([72 /* Identifier */, 3 /* MultiLineCommentTrivia */, 76 /* ClassKeyword */, 85 /* ExportKeyword */, 92 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([20 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 81 /* DoKeyword */, 102 /* TryKeyword */, 87 /* FinallyKeyword */, 82 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 82 /* DoKeyword */, 103 /* TryKeyword */, 88 /* FinallyKeyword */, 83 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 56 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 56 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 55 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), + rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), + rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 23 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 23 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 91 /* ImportKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenImportParenInImportType", 92 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), // 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], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 43 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 44 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 43 /* PlusPlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 37 /* PlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 37 /* PlusToken */, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 44 /* MinusMinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 38 /* MinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 38 /* MinusToken */, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 18 /* CloseBraceToken */, [26 /* CommaToken */, 25 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 18 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 18 /* CloseBraceToken */, anyTokenExcept(20 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 18 /* CloseBraceToken */, 82 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 18 /* CloseBraceToken */, 106 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 83 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 107 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), // 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", 20 /* CloseParenToken */, 21 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 89 /* FunctionKeyword */, 39 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 39 /* AsteriskToken */, [71 /* Identifier */, 19 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 89 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 90 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), + rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, [72 /* Identifier */, 20 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), + rule("SpaceAfterFunctionInFuncDecl", 90 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 17 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), // 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", [125 /* GetKeyword */, 136 /* SetKeyword */], 71 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 116 /* YieldKeyword */, 39 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [116 /* YieldKeyword */, 39 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 96 /* ReturnKeyword */, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [104 /* VarKeyword */, 100 /* ThrowKeyword */, 94 /* NewKeyword */, 80 /* DeleteKeyword */, 96 /* ReturnKeyword */, 103 /* TypeOfKeyword */, 121 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [110 /* LetKeyword */, 76 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [126 /* GetKeyword */, 137 /* SetKeyword */], 72 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBetweenYieldKeywordAndStar", 117 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [117 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), + rule("NoSpaceBetweenReturnAndSemicolon", 97 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterCertainKeywords", [105 /* VarKeyword */, 101 /* ThrowKeyword */, 95 /* NewKeyword */, 81 /* DeleteKeyword */, 97 /* ReturnKeyword */, 104 /* TypeOfKeyword */, 122 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterLetConstInVariableDeclaration", [111 /* LetKeyword */, 77 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), // 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], 2 /* Space */), rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 105 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceAfterVoidOperator", 106 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 120 /* AsyncKeyword */, 19 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 120 /* AsyncKeyword */, 89 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 121 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 121 /* AsyncKeyword */, 90 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [71 /* Identifier */, 20 /* CloseParenToken */], [13 /* NoSubstitutionTemplateLiteral */, 14 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [72 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 71 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 41 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 41 /* SlashToken */, 29 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 58 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 58 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 72 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 59 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterEqualInJsxAttribute", 59 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [129 /* ModuleKeyword */, 133 /* RequireKeyword */], 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [130 /* ModuleKeyword */, 134 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 117 /* AbstractKeyword */, - 75 /* ClassKeyword */, - 124 /* DeclareKeyword */, - 79 /* DefaultKeyword */, - 83 /* EnumKeyword */, - 84 /* ExportKeyword */, - 85 /* ExtendsKeyword */, - 125 /* GetKeyword */, - 108 /* ImplementsKeyword */, - 91 /* ImportKeyword */, - 109 /* InterfaceKeyword */, - 129 /* ModuleKeyword */, - 130 /* NamespaceKeyword */, - 112 /* PrivateKeyword */, - 114 /* PublicKeyword */, - 113 /* ProtectedKeyword */, - 132 /* ReadonlyKeyword */, - 136 /* SetKeyword */, - 115 /* StaticKeyword */, - 139 /* TypeKeyword */, - 143 /* FromKeyword */, - 128 /* KeyOfKeyword */, - 126 /* InferKeyword */, + 118 /* AbstractKeyword */, + 76 /* ClassKeyword */, + 125 /* DeclareKeyword */, + 80 /* DefaultKeyword */, + 84 /* EnumKeyword */, + 85 /* ExportKeyword */, + 86 /* ExtendsKeyword */, + 126 /* GetKeyword */, + 109 /* ImplementsKeyword */, + 92 /* ImportKeyword */, + 110 /* InterfaceKeyword */, + 130 /* ModuleKeyword */, + 131 /* NamespaceKeyword */, + 113 /* PrivateKeyword */, + 115 /* PublicKeyword */, + 114 /* ProtectedKeyword */, + 133 /* ReadonlyKeyword */, + 137 /* SetKeyword */, + 116 /* StaticKeyword */, + 140 /* TypeKeyword */, + 144 /* FromKeyword */, + 129 /* KeyOfKeyword */, + 127 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 143 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [86 /* ExtendsKeyword */, 109 /* ImplementsKeyword */, 144 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 9 /* StringLiteral */, 17 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 36 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 36 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 24 /* DotDotDotToken */, 71 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 55 /* QuestionToken */, [20 /* CloseParenToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 72 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 20 /* CloseParenToken */, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 27 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 29 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 29 /* GreaterThanToken */, [19 /* OpenParenToken */, 21 /* OpenBracketToken */, 29 /* GreaterThanToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), // decorators - rule("SpaceBeforeAt", [20 /* CloseParenToken */, 71 /* Identifier */], 57 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 57 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 72 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 117 /* AbstractKeyword */, - 71 /* Identifier */, - 84 /* ExportKeyword */, - 79 /* DefaultKeyword */, - 75 /* ClassKeyword */, - 115 /* StaticKeyword */, - 114 /* PublicKeyword */, - 112 /* PrivateKeyword */, - 113 /* ProtectedKeyword */, - 125 /* GetKeyword */, - 136 /* SetKeyword */, - 21 /* OpenBracketToken */, - 39 /* AsteriskToken */, + 118 /* AbstractKeyword */, + 72 /* Identifier */, + 85 /* ExportKeyword */, + 80 /* DefaultKeyword */, + 76 /* ClassKeyword */, + 116 /* StaticKeyword */, + 115 /* PublicKeyword */, + 113 /* PrivateKeyword */, + 114 /* ProtectedKeyword */, + 126 /* GetKeyword */, + 137 /* SetKeyword */, + 22 /* OpenBracketToken */, + 40 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 51 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 94 /* NewKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 95 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), ]; // 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", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 19 /* OpenParenToken */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 19 /* OpenParenToken */, 20 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 21 /* OpenBracketToken */, 22 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), // Insert space before and after binary operators rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* 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, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), + rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), + rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), ]; // 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, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 26 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(120 /* AsyncKeyword */, 73 /* CaseKeyword */), 21 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 22 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 25 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(121 /* AsyncKeyword */, 74 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 88 /* ForKeyword */, 121 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 89 /* ForKeyword */, 122 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // 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", [20 /* CloseParenToken */, 81 /* DoKeyword */, 82 /* ElseKeyword */, 73 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 82 /* DoKeyword */, 83 /* ElseKeyword */, 74 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [102 /* TryKeyword */, 87 /* FinallyKeyword */], 17 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [103 /* TryKeyword */, 88 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); } @@ -104285,45 +105536,45 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 223 /* ForStatement */; + return context.contextNode.kind === 225 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 173 /* ConditionalType */: - case 210 /* AsExpression */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 161 /* TypePredicate */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 175 /* ConditionalType */: + case 212 /* AsExpression */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 163 /* TypePredicate */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 184 /* BindingElement */: + case 186 /* BindingElement */: // equals in type X = ... - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: // equal in p = 0; - case 149 /* Parameter */: - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; + case 151 /* Parameter */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + return context.currentTokenSpan.kind === 59 /* EqualsToken */ || context.nextTokenSpan.kind === 59 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 148 /* TypeParameter */: - return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; + case 150 /* TypeParameter */: + return context.currentTokenSpan.kind === 93 /* InKeyword */ || context.nextTokenSpan.kind === 93 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 225 /* ForOfStatement */: - return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; + case 227 /* ForOfStatement */: + return context.currentTokenSpan.kind === 147 /* OfKeyword */ || context.nextTokenSpan.kind === 147 /* OfKeyword */; } return false; } @@ -104335,22 +105586,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 152 /* PropertyDeclaration */ || - contextKind === 151 /* PropertySignature */ || - contextKind === 149 /* Parameter */ || - contextKind === 235 /* VariableDeclaration */ || + return contextKind === 154 /* PropertyDeclaration */ || + contextKind === 153 /* PropertySignature */ || + contextKind === 151 /* Parameter */ || + contextKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 203 /* ConditionalExpression */ || - context.contextNode.kind === 173 /* ConditionalType */; + return context.contextNode.kind === 205 /* ConditionalExpression */ || + context.contextNode.kind === 175 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 182 /* ObjectBindingPattern */ || - context.contextNode.kind === 179 /* MappedType */ || + return context.contextNode.kind === 184 /* ObjectBindingPattern */ || + context.contextNode.kind === 181 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -104376,31 +105627,31 @@ var ts; return true; } switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 186 /* ObjectLiteralExpression */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 188 /* ObjectLiteralExpression */: + case 245 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 158 /* CallSignature */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 197 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 241 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -104409,40 +105660,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; + return context.contextNode.kind === 239 /* FunctionDeclaration */ || context.contextNode.kind === 196 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 166 /* TypeLiteral */: - case 242 /* ModuleDeclaration */: - case 253 /* ExportDeclaration */: - case 254 /* NamedExports */: - case 247 /* ImportDeclaration */: - case 250 /* NamedImports */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 168 /* TypeLiteral */: + case 244 /* ModuleDeclaration */: + case 255 /* ExportDeclaration */: + case 256 /* NamedExports */: + case 249 /* ImportDeclaration */: + case 252 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 272 /* CatchClause */: - case 243 /* ModuleBlock */: - case 230 /* SwitchStatement */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 274 /* CatchClause */: + case 245 /* ModuleBlock */: + case 232 /* SwitchStatement */: return true; - case 216 /* Block */: { + case 218 /* 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 !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 197 /* ArrowFunction */ && blockParent.kind !== 196 /* FunctionExpression */) { return true; } } @@ -104451,64 +105702,64 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 229 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 231 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 272 /* CatchClause */: + case 274 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 186 /* ObjectLiteralExpression */; + return context.contextNode.kind === 188 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 189 /* CallExpression */; + return context.contextNode.kind === 191 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 190 /* NewExpression */; + return context.contextNode.kind === 192 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 26 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 195 /* ArrowFunction */; + return context.contextNode.kind === 197 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 181 /* ImportType */; + return context.contextNode.kind === 183 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; + return context.contextNode.kind !== 260 /* JsxElement */ && context.contextNode.kind !== 264 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; + return context.contextNode.kind === 270 /* JsxExpression */ || context.contextNode.kind === 269 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 265 /* JsxAttribute */; + return context.nextTokenParent.kind === 267 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 265 /* JsxAttribute */; + return context.contextNode.kind === 267 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 259 /* JsxSelfClosingElement */; + return context.contextNode.kind === 261 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -104523,45 +105774,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 238 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 242 /* ModuleDeclaration */; + return context.contextNode.kind === 244 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 168 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 159 /* ConstructSignature */; + return context.contextNode.kind === 161 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { + if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 162 /* TypeReference */: - case 192 /* TypeAssertionExpression */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 194 /* TypeAssertionExpression */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -104572,16 +105823,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 192 /* TypeAssertionExpression */; + return context.contextNode.kind === 194 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; + return context.currentTokenSpan.kind === 106 /* VoidKeyword */ && context.currentTokenParent.kind === 200 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 207 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 211 /* NonNullExpression */; + return context.contextNode.kind === 213 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -104632,12 +105883,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 145 /* LastKeyword */ && column <= 145 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 147 /* LastKeyword */ && column <= 147 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 145 /* LastToken */ + 1; + var mapRowLength = 147 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -104726,12 +105977,12 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 25 /* SemicolonToken */, sourceFile); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 17 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -104757,7 +106008,7 @@ var ts; } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 18 /* CloseBraceToken */, sourceFile); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; @@ -104815,17 +106066,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 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 277 /* SourceFile */: - case 216 /* Block */: - case 243 /* ModuleBlock */: + return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 279 /* SourceFile */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -104938,7 +106189,6 @@ var ts; } return 0; } - /* @internal */ function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: 0, end: sourceFileLike.text.length }; 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 @@ -104968,7 +106218,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine; + var indentationOnLastIndentedLine = -1 /* Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -104982,7 +106232,7 @@ var ts; if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); // TODO: GH#18217 + indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); trimTrailingWhitespacesForRemainingRange(); } } @@ -105027,7 +106277,7 @@ var ts; }; } else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 19 /* OpenParenToken */ && startLine === lastIndentedLine) { + if (node.kind === 20 /* 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) }; @@ -105048,19 +106298,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; - case 156 /* GetAccessor */: return 125 /* GetKeyword */; - case 157 /* SetAccessor */: return 136 /* SetKeyword */; - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: return 76 /* ClassKeyword */; + case 241 /* InterfaceDeclaration */: return 110 /* InterfaceKeyword */; + case 239 /* FunctionDeclaration */: return 90 /* FunctionKeyword */; + case 243 /* EnumDeclaration */: return 243 /* EnumDeclaration */; + case 158 /* GetAccessor */: return 126 /* GetKeyword */; + case 159 /* SetAccessor */: return 137 /* SetKeyword */; + case 156 /* MethodDeclaration */: if (node.asteriskToken) { - return 39 /* AsteriskToken */; + return 40 /* AsteriskToken */; } // falls through - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -105075,15 +106325,25 @@ var ts; // .. { // // comment // } - case 18 /* CloseBraceToken */: - case 22 /* CloseBracketToken */: - case 20 /* CloseParenToken */: + case 19 /* CloseBraceToken */: + case 23 /* CloseBracketToken */: + case 21 /* CloseParenToken */: return indentation + getDelta(container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; }, - getIndentationForToken: function (line, kind, container) { - return shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : 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. + // foo.then + // < + // number, + // string, + // >(); + // vs + // var a = xValue + // > yValue; + getIndentationForToken: function (line, kind, container, suppressDelta) { + return !suppressDelta && shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: getDelta, @@ -105097,26 +106357,25 @@ 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 17 /* OpenBraceToken */: - case 18 /* CloseBraceToken */: - case 19 /* OpenParenToken */: - case 20 /* CloseParenToken */: - case 82 /* ElseKeyword */: - case 106 /* WhileKeyword */: - case 57 /* AtToken */: + case 18 /* OpenBraceToken */: + case 19 /* CloseBraceToken */: + case 21 /* CloseParenToken */: + case 83 /* ElseKeyword */: + case 107 /* WhileKeyword */: + case 58 /* AtToken */: return false; - case 41 /* SlashToken */: - case 29 /* GreaterThanToken */: + case 42 /* SlashToken */: + case 30 /* GreaterThanToken */: switch (container.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: return false; } break; - case 21 /* OpenBracketToken */: - case 22 /* CloseBracketToken */: - if (container.kind !== 179 /* MappedType */) { + case 22 /* OpenBracketToken */: + case 23 /* CloseBracketToken */: + if (container.kind !== 181 /* MappedType */) { return false; } break; @@ -105201,22 +106460,22 @@ var ts; return inheritedIndentation; } // JSX text shouldn't affect indenting - if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { + if (ts.isToken(child) && child.kind !== 11 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 150 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 152 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { var range = { pos: child.getStart(), end: child.getEnd() }; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 187 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -105237,9 +106496,20 @@ var ts; else if (tokenInfo.token.kind === listStartToken) { // consume list start token startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_2 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_2.indentation, indentation_2.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); + var indentationOnListStartToken = void 0; + if (indentationOnLastIndentedLine !== -1 /* 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; + // }: {}; + indentationOnListStartToken = indentationOnLastIndentedLine; + } + else { + var startLinePosition = ts.getLineStartPositionForPosition(tokenInfo.token.pos, sourceFile); + indentationOnListStartToken = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, tokenInfo.token.pos, sourceFile, options); + } + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentationOnListStartToken, options.indentSize); // TODO: GH#18217 } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope @@ -105255,7 +106525,7 @@ var ts; var listEndToken = getCloseTokenForOpenToken(listStartToken); if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 26 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { formattingScanner.advance(); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; } @@ -105265,11 +106535,11 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo && tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent, /*isListEndToken*/ true); } } } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container) { + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container, isListEndToken) { ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); var indentToken = false; @@ -105301,32 +106571,12 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) : + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); - switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: - if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); - } - indentNextTokenOrTrivia = false; - break; - case 2 /* SingleLineCommentTrivia */: - if (indentNextTokenOrTrivia && triviaInRange) { - insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); - } - indentNextTokenOrTrivia = false; - break; - case 4 /* NewLineTrivia */: - indentNextTokenOrTrivia = true; - break; - } - } + 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) { @@ -105339,16 +106589,39 @@ var ts; childContextNode = parent; } } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + function indentTriviaItems(trivia, commentIndentation, indentNextTokenOrTrivia, indentSingleLine) { for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { var triviaItem = trivia_1[_i]; + var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); + switch (triviaItem.kind) { + case 3 /* MultiLineCommentTrivia */: + if (triviaInRange) { + indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + } + indentNextTokenOrTrivia = false; + break; + case 2 /* SingleLineCommentTrivia */: + if (indentNextTokenOrTrivia && triviaInRange) { + indentSingleLine(triviaItem); + } + indentNextTokenOrTrivia = false; + break; + case 4 /* NewLineTrivia */: + indentNextTokenOrTrivia = true; + break; + } + } + return indentNextTokenOrTrivia; + } + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0, trivia_2 = trivia; _i < trivia_2.length; _i++) { + var triviaItem = trivia_2[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); } } } - // TODO: GH#18217 use an enum instead of `boolean | undefined` function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAction = 0 /* None */; @@ -105520,7 +106793,10 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - var startPosition = previousRange ? previousRange.end : originalRange.pos; + if (!previousRange) { + return; + } + var startPosition = previousRange.end; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -105620,41 +106896,46 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 197 /* ArrowFunction */: if (node.typeParameters === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.parameters === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.arguments === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 162 /* TypeReference */: + case 164 /* TypeReference */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } + break; + case 168 /* TypeLiteral */: + return 18 /* OpenBraceToken */; } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 19 /* OpenParenToken */: - return 20 /* CloseParenToken */; - case 27 /* LessThanToken */: - return 29 /* GreaterThanToken */; + case 20 /* OpenParenToken */: + return 21 /* CloseParenToken */; + case 28 /* LessThanToken */: + return 30 /* GreaterThanToken */; + case 18 /* OpenBraceToken */: + return 19 /* CloseBraceToken */; } return 0 /* Unknown */; } @@ -105759,13 +107040,18 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 204 /* 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 */) { 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 + } return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options); } SmartIndenter.getIndentation = getIndentation; @@ -105776,12 +107062,12 @@ var ts; if (previousLine <= commentStartLine) { return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); } - var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); - var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + var startPositionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPositionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; if (column === 0) { return column; } - var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { @@ -105814,14 +107100,13 @@ var ts; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + // do not consider parent-child line sharing yet: + // 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 */) { return actualIndentation; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.indentSize; // TODO: GH#18217 - } previous = current; current = current.parent; } @@ -105848,23 +107133,17 @@ var ts; var start = current.getStart(sourceFile); useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; } - if (useActualIndentation) { - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } var containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); var parentAndChildShareLine = containingListOrParentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { - // try to fetch actual indentation for current node from source text - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + // try to fetch actual indentation for current node from source text + actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } @@ -105915,7 +107194,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -105932,11 +107211,11 @@ var ts; if (!nextToken) { return 0 /* Unknown */; } - if (nextToken.kind === 17 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* OpenBraceToken */) { // open braces are always indented at the parent level return 1 /* OpenBrace */; } - else if (nextToken.kind === 18 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* 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 { @@ -105963,8 +107242,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); + if (parent.kind === 222 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 83 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -105972,103 +107251,87 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getListIfStartEndIsInListRange(list, start, end) { - return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; - } function getContainingList(node, sourceFile) { - if (node.parent) { - var end = node.end; - switch (node.parent.kind) { - case 162 /* TypeReference */: - return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 186 /* ObjectLiteralExpression */: - return node.parent.properties; - case 185 /* ArrayLiteralExpression */: - return node.parent.elements; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || - getListIfStartEndIsInListRange(node.parent.parameters, start, end); - } - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: { - var typeParameters = node.parent.typeParameters; - return getListIfStartEndIsInListRange(typeParameters, node.getStart(sourceFile), end); - } - case 190 /* NewExpression */: - case 189 /* CallExpression */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || - getListIfStartEndIsInListRange(node.parent.arguments, start, end); - } - case 236 /* VariableDeclarationList */: - return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - } - } - return undefined; + return node.parent && getListByRange(node.getStart(sourceFile), node.getEnd(), node.parent, sourceFile); } SmartIndenter.getContainingList = getContainingList; - function getActualIndentationForListItem(node, sourceFile, options) { + function getListByPosition(pos, node, sourceFile) { + return node && getListByRange(pos, pos, node, sourceFile); + } + function getListByRange(start, end, node, sourceFile) { + switch (node.kind) { + case 164 /* TypeReference */: + return getList(node.typeArguments); + case 188 /* ObjectLiteralExpression */: + return getList(node.properties); + case 187 /* ArrayLiteralExpression */: + return getList(node.elements); + case 168 /* TypeLiteral */: + return getList(node.members); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: + return getList(node.typeParameters) || getList(node.parameters); + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + return getList(node.typeParameters); + case 192 /* NewExpression */: + case 191 /* CallExpression */: + return getList(node.typeArguments) || getList(node.arguments); + case 238 /* VariableDeclarationList */: + return getList(node.declarations); + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return getList(node.elements); + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + return getList(node.elements); + } + function getList(list) { + return list && ts.rangeContainsStartEnd(getVisualListRange(node, list, sourceFile), start, end) ? list : undefined; + } + } + function getVisualListRange(node, list, sourceFile) { + var children = node.getChildren(sourceFile); + for (var i = 1; i < children.length - 1; i++) { + if (children[i].pos === list.pos && children[i].end === list.end) { + return { pos: children[i - 1].end, end: children[i + 1].getStart(sourceFile) }; + } + } + return list; + } + function getActualIndentationForListStartLine(list, sourceFile, options) { + if (!list) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); + } + function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { + if (node.parent && node.parent.kind === 238 /* VariableDeclarationList */) { + // VariableDeclarationList has no wrapping tokens + return -1 /* Unknown */; + } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { - return deriveActualIndentationFromList(containingList, index, sourceFile, options); - } - } - return -1 /* Unknown */; - } - function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - // actual indentation should not be used when: - // - node is close parenthesis - this is the end of the expression - if (node.kind === 20 /* CloseParenToken */) { - return -1 /* Unknown */; - } - if (node.parent && ts.isCallOrNewExpression(node.parent) && node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1 /* Unknown */; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); - } - return -1 /* Unknown */; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - node = node.expression; - break; - default: - return node; + var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); + if (result !== -1 /* Unknown */) { + return result; } } + return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } + return -1 /* Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -106077,7 +107340,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 === 26 /* CommaToken */) { + if (list[i].kind === 27 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -106126,83 +107389,83 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 219 /* ExpressionStatement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 185 /* ArrayLiteralExpression */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 179 /* MappedType */: - case 168 /* TupleType */: - case 244 /* CaseBlock */: - case 270 /* DefaultClause */: - case 269 /* CaseClause */: - case 193 /* ParenthesizedExpression */: - case 187 /* PropertyAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 217 /* VariableStatement */: - case 252 /* ExportAssignment */: - case 228 /* ReturnStatement */: - case 203 /* ConditionalExpression */: - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: - case 259 /* JsxSelfClosingElement */: - case 268 /* JsxExpression */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 149 /* Parameter */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 175 /* ParenthesizedType */: - case 191 /* TaggedTemplateExpression */: - case 199 /* AwaitExpression */: - case 254 /* NamedExports */: - case 250 /* NamedImports */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 152 /* PropertyDeclaration */: + case 221 /* ExpressionStatement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 187 /* ArrayLiteralExpression */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 181 /* MappedType */: + case 170 /* TupleType */: + case 246 /* CaseBlock */: + case 272 /* DefaultClause */: + case 271 /* CaseClause */: + case 195 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 219 /* VariableStatement */: + case 254 /* ExportAssignment */: + case 230 /* ReturnStatement */: + case 205 /* ConditionalExpression */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: + case 261 /* JsxSelfClosingElement */: + case 270 /* JsxExpression */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 151 /* Parameter */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 177 /* ParenthesizedType */: + case 193 /* TaggedTemplateExpression */: + case 201 /* AwaitExpression */: + case 256 /* NamedExports */: + case 252 /* NamedImports */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 154 /* PropertyDeclaration */: return true; - case 235 /* VariableDeclaration */: - case 273 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 237 /* VariableDeclaration */: + case 275 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 188 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } return true; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return childKind !== 216 /* Block */; - case 253 /* ExportDeclaration */: - return childKind !== 254 /* NamedExports */; - case 247 /* ImportDeclaration */: - return childKind !== 248 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); - case 258 /* JsxElement */: - return childKind !== 261 /* JsxClosingElement */; - case 262 /* JsxFragment */: - return childKind !== 264 /* JsxClosingFragment */; - case 172 /* IntersectionType */: - case 171 /* UnionType */: - if (childKind === 166 /* TypeLiteral */) { + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return childKind !== 218 /* Block */; + case 255 /* ExportDeclaration */: + return childKind !== 256 /* NamedExports */; + case 249 /* ImportDeclaration */: + return childKind !== 250 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 252 /* NamedImports */); + case 260 /* JsxElement */: + return childKind !== 263 /* JsxClosingElement */; + case 264 /* JsxFragment */: + return childKind !== 266 /* JsxClosingFragment */; + case 174 /* IntersectionType */: + case 173 /* UnionType */: + if (childKind === 168 /* TypeLiteral */) { return false; } // falls through @@ -106213,11 +107476,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: - return parent.kind !== 216 /* Block */; + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: + return parent.kind !== 218 /* Block */; default: return false; } @@ -106345,7 +107608,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 === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 188 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -106417,13 +107680,16 @@ var ts; if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, options), newNodes, options); }; + ChangeTracker.prototype.replaceNodeWithText = function (sourceFile, oldNode, text) { + this.replaceRangeWithText(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, textChanges_3.useNonAdjustedPositions), text); + }; ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 26 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -106473,10 +107739,20 @@ var ts; var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); }; - ChangeTracker.prototype.insertCommentThenNewline = function (sourceFile, character, position, commentText) { - var token = ts.getTouchingToken(sourceFile, position); - var text = "/**" + commentText + "*/" + this.newLineCharacter + ts.repeatString(" ", character); - this.insertText(sourceFile, token.getStart(sourceFile), text); + ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { + var fnStart = node.getStart(sourceFile); + if (node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsdoc = _a[_i]; + this.deleteRange(sourceFile, { + pos: ts.getLineStartPositionForPosition(jsdoc.getStart(sourceFile), sourceFile), + end: getAdjustedEndPosition(sourceFile, jsdoc, /*options*/ {}) + }); + } + } + 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 }); }; ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) { this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text }); @@ -106484,28 +107760,11 @@ var ts; ChangeTracker.prototype.insertText = function (sourceFile, pos, text) { this.replaceRangeWithText(sourceFile, ts.createRange(pos), text); }; - ChangeTracker.prototype.tryInsertJSDocParameters = function (sourceFile, parameters) { - if (parameters.length === 0) { - return; - } - var parent = parameters[0].declaration.parent; - var indent = ts.getLineAndCharacterOfPosition(sourceFile, parent.getStart()).character; - var commentText = "\n"; - for (var _i = 0, parameters_3 = parameters; _i < parameters_3.length; _i++) { - var _a = parameters_3[_i], declaration = _a.declaration, typeNode = _a.typeNode, isOptional = _a.isOptional; - if (ts.isIdentifier(declaration.name)) { - var printed = changesToText.getNonformattedText(typeNode, sourceFile, this.newLineCharacter).text; - commentText += this.printJSDocParameter(indent, printed, declaration.name, isOptional); - } - } - commentText += ts.repeatString(" ", indent + 1); - this.insertCommentThenNewline(sourceFile, indent, parent.getStart(), commentText); - }; /** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */ ChangeTracker.prototype.tryInsertTypeAnnotation = function (sourceFile, node, type) { var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 20 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return; // Function missing parentheses, give up @@ -106514,32 +107773,13 @@ var ts; } } else { - endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 237 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; - ChangeTracker.prototype.tryInsertJSDocType = function (sourceFile, node, type) { - var printed = changesToText.getNonformattedText(type, sourceFile, this.newLineCharacter).text; - var commentText; - if (ts.isGetAccessorDeclaration(node)) { - commentText = " @return {" + printed + "} "; - } - else { - commentText = " @type {" + printed + "} "; - node = node.parent; - } - this.insertCommentThenNewline(sourceFile, ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile)).character, node.getStart(sourceFile), commentText); - }; - ChangeTracker.prototype.printJSDocParameter = function (indent, printed, name, isOptionalParameter) { - var printName = ts.unescapeLeadingUnderscores(name.escapedText); - if (isOptionalParameter) { - printName = "[" + printName + "]"; - } - return ts.repeatString(" ", indent) + (" * @param {" + printed + "} " + printName + "\n"); - }; 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, 19 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, doubleNewlines) { @@ -106633,7 +107873,7 @@ var ts; // 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.createToken(25 /* SemicolonToken */)); + this.replaceRange(sourceFile, ts.createRange(after.end), ts.createToken(26 /* SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -106645,18 +107885,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 235 /* VariableDeclaration */: - case 9 /* StringLiteral */: - case 71 /* Identifier */: + case 237 /* VariableDeclaration */: + case 10 /* StringLiteral */: + case 72 /* Identifier */: return { prefix: ", " }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: return { prefix: " " }; - case 149 /* Parameter */: + case 151 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -106665,28 +107905,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 195 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); + if (node.kind === 197 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(90 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 216 /* Block */) { + if (node.body.kind !== 218 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(97 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 196 /* FunctionExpression */ ? 90 /* FunctionKeyword */ : 76 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -106774,12 +108014,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 = 26 /* CommaToken */; + separator = 27 /* 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 : 26 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* 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; @@ -106819,7 +108059,7 @@ var ts; }; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var deletedNodesInLists = new ts.NodeSet(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. var _loop_17 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { @@ -106873,7 +108113,7 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - return [ts.findChildOfKind(cls, 17 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile).end]; + return [ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile).end]; } function getMembersOrProperties(cls) { return ts.isObjectLiteralExpression(cls) ? cls.properties : cls.members; @@ -106916,7 +108156,7 @@ var ts; var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 6 /* ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); - return applyChanges(nonFormattedText, changes); + return applyChanges(nonFormattedText, changes) + newLineCharacter; } changesToText.newFileChangesWorker = newFileChangesWorker; function computeNewText(change, sourceFile, newLineCharacter, formatContext, validate) { @@ -107041,6 +108281,9 @@ var ts; this.writer.write(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeComment = function (s) { + this.writer.writeComment(s); + }; Writer.prototype.writeKeyword = function (s) { this.writer.writeKeyword(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -107053,6 +108296,10 @@ var ts; this.writer.writePunctuation(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeTrailingSemicolon = function (s) { + this.writer.writeTrailingSemicolon(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; Writer.prototype.writeParameter = function (s) { this.writer.writeParameter(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -107073,9 +108320,6 @@ var ts; this.writer.writeSymbol(s, sym); this.setLastNonTriviaPosition(s, /*force*/ false); }; - Writer.prototype.writeTextOfNode = function (text, node) { - this.writer.writeTextOfNode(text, node); - }; Writer.prototype.writeLine = function () { this.writer.writeLine(); }; @@ -107117,10 +108361,25 @@ var ts; }; return Writer; }()); - function getInsertionPositionAtSourceFileTop(_a) { - var text = _a.text; - var shebang = ts.getShebang(text); + function getInsertionPositionAtSourceFileTop(sourceFile) { + var lastPrologue; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + if (ts.isPrologueDirective(node)) { + lastPrologue = node; + } + else { + break; + } + } var position = 0; + var text = sourceFile.text; + if (lastPrologue) { + position = lastPrologue.end; + advancePastLineBreak(); + return position; + } + var shebang = ts.getShebang(text); if (shebang !== undefined) { position = shebang.length; advancePastLineBreak(); @@ -107136,8 +108395,8 @@ var ts; ranges = ranges.slice(1); } // As well as any triple slash references - for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { - var range = ranges_1[_i]; + for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { + var range = ranges_1[_b]; if (range.kind === 2 /* SingleLineCommentTrivia */ && ts.isRecognizedTripleSlashComment(text, range.pos, range.end)) { position = range.end; advancePastLineBreak(); @@ -107159,45 +108418,40 @@ var ts; } } function isValidLocationToAddComment(sourceFile, position) { - return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position); + return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position) && !ts.isInJSXText(sourceFile, position); } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 149 /* 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 149 /* Parameter */: { + case 151 /* Parameter */: { var oldFunction = node.parent; - if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { + if (ts.isArrowFunction(oldFunction) && + oldFunction.parameters.length === 1 && + !ts.findChildOfKind(oldFunction, 20 /* 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`). - var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, // TODO: GH#18217 - oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); - // Drop leading and trailing trivia of the new function because we're only going - // to replace the span (vs the full span) of the old function - the old leading - // and trailing trivia will remain. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); + changes.replaceNodeWithText(sourceFile, node, "()"); } else { deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; } - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 185 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -107205,13 +108459,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -107220,7 +108474,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -107231,7 +108485,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } else { - deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + deleteNode(changes, sourceFile, node, node.kind === 26 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); } } } @@ -107245,7 +108499,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 === 26 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* 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 }); @@ -107267,15 +108521,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 249 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 272 /* CatchClause */) { + if (parent.kind === 274 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -107284,14 +108538,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -107436,6 +108690,32 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addConvertToUnknownForNonOverlappingTypes"; + var errorCodes = [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.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, + }); + function makeChange(changeTracker, sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var replacement = ts.isAsExpression(assertion) + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(143 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(143 /* UnknownKeyword */), assertion.expression); + changeTracker.replaceNode(sourceFile, assertion.expression, replacement); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107503,9 +108783,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(19 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -107515,7 +108795,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(20 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(21 /* CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -107530,26 +108810,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 235 /* VariableDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 237 /* VariableDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 154 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -107571,9 +108851,9 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 288 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -107611,8 +108891,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -107622,6 +108902,754 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "inferFromUsage"; + var errorCodes = [ + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, + ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, + //// Suggestions + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code, + ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var token = ts.getTokenAtPosition(sourceFile, start); + var declaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var markSeen = ts.nodeSeenTracker(); + return codefix.codeFixAll(context, errorCodes, function (changes, err) { + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + }); + }, + }); + function getDiagnostic(errorCode, token) { + switch (errorCode) { + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Infer_parameter_types_from_usage; + default: + return ts.Diagnostics.Infer_type_of_0_from_usage; + } + } + /** Map suggestion code to error code */ + function mapSuggestionDiagnostic(errorCode) { + switch (errorCode) { + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code; + case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code; + case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code; + } + return errorCode; + } + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 72 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 100 /* ThisKeyword */) { + return undefined; + } + var parent = token.parent; + errorCode = mapSuggestionDiagnostic(errorCode); + switch (errorCode) { + // Variable and Property declarations + case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: + if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + return parent; + } + if (ts.isPropertyAccessExpression(parent)) { + var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); + var typeNode = getTypeNodeIfAccessible(type, parent, program, host); + if (typeNode) { + // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags + var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ ""); + addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); + } + return parent; + } + return undefined; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { + var symbol = program.getTypeChecker().getSymbolAtLocation(token); + if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + return symbol.valueDeclaration; + } + return undefined; + } + } + var containingFunction = ts.getContainingFunction(token); + if (containingFunction === undefined) { + return undefined; + } + switch (errorCode) { + // Parameter declarations + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + // falls through + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + if (markSeen(containingFunction)) { + var param = ts.cast(parent, ts.isParameter); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + return param; + } + return undefined; + // Get Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: + case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: + if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + return containingFunction; + } + return undefined; + // Set Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + return undefined; + default: + return ts.Debug.fail(String(errorCode)); + } + } + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + if (ts.isIdentifier(declaration.name)) { + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + } + } + function isApplicableFunctionForInference(declaration) { + switch (declaration.kind) { + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + return true; + case 196 /* FunctionExpression */: + var parent = declaration.parent; + return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; + } + return false; + } + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + return; + } + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || + containingFunction.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + if (ts.isInJSFile(containingFunction)) { + annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); + } + else { + 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) { + annotate(changes, sourceFile, declaration, type, program, host); + } + } + } + } + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); + if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { + var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); + if (type === program.getTypeChecker().getAnyType()) { + type = inferTypeForVariableFromUsage(param.name, program, cancellationToken); + } + if (ts.isInJSFile(setAccessorDeclaration)) { + annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); + } + else { + annotate(changes, sourceFile, param, type, program, host); + } + } + } + function annotate(changes, sourceFile, declaration, type, program, host) { + var typeNode = getTypeNodeIfAccessible(type, declaration, program, host); + if (typeNode) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 153 /* PropertySignature */) { + var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; + if (!parent) { + return; + } + var typeExpression = ts.createJSDocTypeExpression(typeNode); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); + addJSDocTags(changes, sourceFile, parent, [typeTag]); + } + else { + changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); + } + } + } + function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { + var signature = parameterInferences.length && parameterInferences[0].declaration.parent; + if (!signature) { + return; + } + var paramTags = ts.mapDefined(parameterInferences, function (inference) { + var param = inference.declaration; + // only infer parameters that have (1) no type and (2) an accessible inferred type + if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name)) + return; + var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); + var name = ts.getSynthesizedClone(param.name); + ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), ""); + }); + addJSDocTags(changes, sourceFile, signature, paramTags); + } + function addJSDocTags(changes, sourceFile, parent, newTags) { + var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); + var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { + var merged = tryMergeJsdocTags(tag, newTag); + if (merged) + oldTags[i] = merged; + return !!merged; + }); }); + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); + changes.insertJsdocCommentBefore(sourceFile, parent, tag); + } + function tryMergeJsdocTags(oldTag, newTag) { + if (oldTag.kind !== newTag.kind) { + return undefined; + } + switch (oldTag.kind) { + case 299 /* JSDocParameterTag */: { + var oldParam = oldTag; + var newParam = newTag; + return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText + ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) + : undefined; + } + case 300 /* JSDocReturnTag */: + return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); + } + } + function getTypeNodeIfAccessible(type, enclosingScope, program, host) { + var checker = program.getTypeChecker(); + var typeIsAccessible = true; + var notAccessible = function () { typeIsAccessible = false; }; + var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { + trackSymbol: function (symbol, declaration, meaning) { + // TODO: GH#18217 + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + }, + reportInaccessibleThisError: notAccessible, + reportPrivateInBaseOfClassExpression: notAccessible, + reportInaccessibleUniqueSymbolError: notAccessible, + moduleResolverHost: { + readFile: host.readFile, + fileExists: host.fileExists, + directoryExists: host.directoryExists, + getSourceFiles: program.getSourceFiles, + getCurrentDirectory: program.getCurrentDirectory, + getCommonSourceDirectory: program.getCommonSourceDirectory, + } + }); + return typeIsAccessible ? res : undefined; + } + 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; + }); + } + function inferTypeForVariableFromUsage(token, program, cancellationToken) { + var references = getReferences(token, program, cancellationToken); + var checker = program.getTypeChecker(); + var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); + return InferFromReference.unifyFromContext(types, checker); + } + function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { + var searchToken; + switch (containingFunction.kind) { + case 157 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); + break; + case 196 /* FunctionExpression */: + var parent = containingFunction.parent; + searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? + parent.name : + containingFunction.name; + break; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + searchToken = containingFunction.name; + break; + } + if (searchToken) { + return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program, cancellationToken); + } + } + var InferFromReference; + (function (InferFromReference) { + function inferTypesFromReferences(references, checker, cancellationToken) { + var usageContext = {}; + for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { + var reference = references_1[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + return inferFromContext(usageContext, checker); + } + InferFromReference.inferTypesFromReferences = inferTypesFromReferences; + function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { + var checker = program.getTypeChecker(); + if (references.length === 0) { + return undefined; + } + if (!declaration.parameters) { + return undefined; + } + var usageContext = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + var isConstructor = declaration.kind === 157 /* Constructor */; + var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; + return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { + var types = []; + var isRest = ts.isRestParameter(parameter); + var isOptional = false; + for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { + var callContext = callContexts_1[_i]; + if (callContext.argumentTypes.length <= parameterIndex) { + isOptional = ts.isInJSFile(declaration); + types.push(checker.getUndefinedType()); + } + else if (isRest) { + for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + } + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + if (ts.isIdentifier(parameter.name)) { + types.push.apply(types, inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken)); + } + var type = unifyFromContext(types, checker); + return { + type: isRest ? checker.createArrayType(type) : type, + isOptional: isOptional && !isRest, + declaration: parameter + }; + }); + } + InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; + function inferTypeFromContext(node, checker, usageContext) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + switch (node.parent.kind) { + case 203 /* PostfixUnaryExpression */: + usageContext.isNumber = true; + break; + case 202 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + break; + case 204 /* BinaryExpression */: + inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + break; + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + break; + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (node.parent.expression === node) { + inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + } + else { + inferTypeFromContextualType(node, checker, usageContext); + } + break; + case 189 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + break; + case 190 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + break; + case 237 /* 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. + addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + } + break; + } + } + // falls through + default: + return inferTypeFromContextualType(node, checker, usageContext); + } + } + function inferTypeFromContextualType(node, checker, usageContext) { + if (ts.isExpressionNode(node)) { + addCandidateType(usageContext, checker.getContextualType(node)); + } + } + function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + switch (node.operator) { + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + usageContext.isNumber = true; + break; + case 38 /* PlusToken */: + usageContext.isNumber = true; + usageContext.isString = true; + break; + // case SyntaxKind.ExclamationToken: + // no inferences here; + } + } + function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + switch (parent.operatorToken.kind) { + // ExponentiationOperator + case 41 /* AsteriskAsteriskToken */: + // MultiplicativeOperator + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + // ShiftOperator + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // BitwiseOperator + case 49 /* AmpersandToken */: + case 50 /* BarToken */: + case 51 /* CaretToken */: + // CompoundAssignmentOperator + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 70 /* BarEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + // AdditiveOperator + case 39 /* MinusToken */: + // RelationalOperator + case 28 /* LessThanToken */: + case 31 /* LessThanEqualsToken */: + case 30 /* GreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (operandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, operandType); + } + else { + usageContext.isNumber = true; + } + break; + case 60 /* PlusEqualsToken */: + case 38 /* PlusToken */: + var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (otherOperandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, otherOperandType); + } + else if (otherOperandType.flags & 296 /* NumberLike */) { + usageContext.isNumber = true; + } + else if (otherOperandType.flags & 132 /* StringLike */) { + usageContext.isString = true; + } + else { + usageContext.isNumber = true; + usageContext.isString = true; + } + break; + // AssignmentOperators + case 59 /* EqualsToken */: + case 33 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + break; + case 93 /* InKeyword */: + if (node === parent.left) { + usageContext.isString = true; + } + break; + // LogicalOperator + case 55 /* BarBarToken */: + if (node === parent.left && + (node.parent.parent.kind === 237 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + // var x = x || {}; + // TODO: use getFalsyflagsOfType + addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + } + break; + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: + case 94 /* InstanceOfKeyword */: + // nothing to infer here + break; + } + } + function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { + addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + } + function inferTypeFromCallExpressionContext(parent, checker, usageContext) { + var callContext = { + argumentTypes: [], + returnType: {} + }; + if (parent.arguments) { + for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + } + } + inferTypeFromContext(parent, checker, callContext.returnType); + if (parent.kind === 191 /* CallExpression */) { + (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + } + else { + (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + } + } + function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + var name = ts.escapeLeadingUnderscores(parent.name.text); + if (!usageContext.properties) { + usageContext.properties = ts.createUnderscoreEscapedMap(); + } + var propertyUsageContext = usageContext.properties.get(name) || {}; + inferTypeFromContext(parent, checker, propertyUsageContext); + usageContext.properties.set(name, propertyUsageContext); + } + function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + if (node === parent.argumentExpression) { + usageContext.isNumber = true; + usageContext.isString = true; + return; + } + else { + var indexType = checker.getTypeAtLocation(parent.argumentExpression); + var indexUsageContext = {}; + inferTypeFromContext(parent, checker, indexUsageContext); + if (indexType.flags & 296 /* NumberLike */) { + usageContext.numberIndexContext = indexUsageContext; + } + else { + usageContext.stringIndexContext = indexUsageContext; + } + } + } + function unifyFromContext(inferences, checker, fallback) { + if (fallback === void 0) { fallback = checker.getAnyType(); } + if (!inferences.length) + return fallback; + var hasNonVacuousType = inferences.some(function (i) { return !(i.flags & (1 /* Any */ | 16384 /* Void */)); }); + var hasNonVacuousNonAnonymousType = inferences.some(function (i) { return !(i.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); + var anons = inferences.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); + var good = []; + if (!hasNonVacuousNonAnonymousType && anons.length) { + good.push(unifyAnonymousTypes(anons, checker)); + } + good.push.apply(good, inferences.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */) && !(hasNonVacuousType && i.flags & (1 /* Any */ | 16384 /* Void */)); })); + return checker.getWidenedType(checker.getUnionType(good)); + } + InferFromReference.unifyFromContext = unifyFromContext; + function unifyAnonymousTypes(anons, checker) { + if (anons.length === 1) { + return anons[0]; + } + var calls = []; + var constructs = []; + var stringIndices = []; + var numberIndices = []; + var stringIndexReadonly = false; + var numberIndexReadonly = false; + var props = ts.createMultiMap(); + for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) { + var anon = anons_1[_i]; + for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { + var p = _b[_a]; + props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + } + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); + if (anon.stringIndexInfo) { + stringIndices.push(anon.stringIndexInfo.type); + stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly; + } + if (anon.numberIndexInfo) { + numberIndices.push(anon.numberIndexInfo.type); + numberIndexReadonly = numberIndexReadonly || anon.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); + s.type = checker.getUnionType(types); + return [name, s]; + }); + return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); + } + function inferFromContext(usageContext, checker) { + var types = []; + if (usageContext.isNumber) { + types.push(checker.getNumberType()); + } + if (usageContext.isString) { + types.push(checker.getStringType()); + } + types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { + var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 + var types_19 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types_19.push(checker.createPromiseType(types_19.length ? checker.getUnionType(types_19, 2 /* Subtype */) : checker.getAnyType())); + } + else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + } + if (usageContext.numberIndexContext) { + return [checker.createArrayType(recur(usageContext.numberIndexContext))]; + } + else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + var members_6 = ts.createUnderscoreEscapedMap(); + var callSignatures = []; + var constructSignatures = []; + var stringIndexInfo = void 0; + if (usageContext.properties) { + usageContext.properties.forEach(function (context, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = recur(context); + members_6.set(name, symbol); + }); + } + if (usageContext.callContexts) { + for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { + var callContext = _a[_i]; + callSignatures.push(getSignatureFromCallContext(callContext, checker)); + } + } + if (usageContext.constructContexts) { + for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { + var constructContext = _c[_b]; + constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + } + } + if (usageContext.stringIndexContext) { + stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + } + types.push(checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + } + return types; + function recur(innerContext) { + return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + } + function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + var types = []; + if (callContexts) { + for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { + var callContext = callContexts_2[_i]; + if (callContext.argumentTypes.length > parameterIndex) { + if (isRestParameter) { + types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + } + } + if (types.length) { + var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); + return isRestParameter ? checker.createArrayType(type) : type; + } + return undefined; + } + function getSignatureFromCallContext(callContext, checker) { + var parameters = []; + for (var i = 0; i < callContext.argumentTypes.length; i++) { + var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + parameters.push(symbol); + } + var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + // TODO: GH#18217 + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + } + function addCandidateType(context, type) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + (context.candidateTypes || (context.candidateTypes = [])).push(type); + } + } + function hasCallContext(usageContext) { + return !!usageContext && !!usageContext.callContexts; + } + })(InferFromReference || (InferFromReference = {})); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107646,12 +109674,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -107683,7 +109711,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(116 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -107706,7 +109734,7 @@ var ts; 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 === 219 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 221 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -107714,27 +109742,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 195 /* ArrowFunction */: { + case 197 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 216 /* Block */) { + if (arrowFunctionBody.kind === 218 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyComments(assignmentBinaryExpression, method, sourceFile); @@ -107755,17 +109783,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 196 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 71 /* Identifier */) { + if (node.name.kind !== 72 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107776,7 +109804,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107828,13 +109856,13 @@ var ts; var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context, setOfExpressionsToReturn, originalTypeMap, allVarNames); var constIdentifiers = getConstIdentifiers(synthNamesMap); - var returnStatements = ts.getReturnStatementsWithPromiseHandlers(functionToConvertRenamed); + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, allVarNames: allVarNames, setOfExpressionsToReturn: setOfExpressionsToReturn, constIdentifiers: constIdentifiers, originalTypeMap: originalTypeMap, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 120 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 121 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); @@ -107854,6 +109882,14 @@ var ts; _loop_19(statement); } } + function getReturnStatementsWithPromiseHandlers(body) { + var res = []; + ts.forEachReturnStatement(body, function (ret) { + if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + res.push(ret); + }); + return res; + } // Returns the identifiers that are never reassigned in the refactor function getConstIdentifiers(synthNamesMap) { var constIdentifiers = []; @@ -108115,10 +110151,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 71 /* Identifier */: // identifier includes undefined + case 72 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -108140,8 +110176,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -108152,7 +110188,7 @@ var ts; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; } - if (ts.getReturnStatementsWithPromiseHandlers(statement).length) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -108163,7 +110199,7 @@ var ts; removeReturns(refactoredStmts, prevArgName === undefined ? undefined : prevArgName.identifier, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.getReturnStatementsWithPromiseHandlers(ts.createReturn(funcBody)); + var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.createReturn(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -108306,10 +110342,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -108355,29 +110391,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 59 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 189 /* CallExpression */: { + case 191 /* 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 59 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -108417,8 +110453,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: { + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -108426,7 +110462,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: @@ -108469,16 +110505,16 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 274 /* ShorthandPropertyAssignment */: - case 275 /* SpreadAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 277 /* SpreadAssignment */: return undefined; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 154 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); + case 156 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(85 /* ExportKeyword */)], prop); default: ts.Debug.assertNever(prop); } @@ -108527,23 +110563,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.createToken(84 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(85 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* 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, 23 /* DotToken */, sourceFile), [ts.createToken(84 /* ExportKeyword */), ts.createToken(76 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(85 /* ExportKeyword */), ts.createToken(77 /* 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) { - var modifiers = [ts.createToken(84 /* ExportKeyword */)]; + var modifiers = [ts.createToken(85 /* ExportKeyword */)]; switch (exported.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -108551,10 +110587,10 @@ var ts; } } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -108572,7 +110608,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: { + case 184 /* 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 @@ -108583,7 +110619,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 183 /* ArrayBindingPattern */: { + case 185 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -108594,7 +110630,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name); @@ -108666,11 +110702,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node; - case 184 /* BindingElement */: + case 186 /* BindingElement */: return parent.propertyName !== node; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -109009,21 +111045,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 247 /* ImportDeclaration */) + if (declaration.kind !== 249 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 252 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 247 /* ImportDeclaration */) { + if (declaration.kind === 249 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 251 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -109034,7 +111070,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) + return (i.kind === 249 /* ImportDeclaration */ || i.kind === 248 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -109049,7 +111085,7 @@ var ts; }); }); // Sort to keep the shortest paths first - return choicesForEachExportingModule.sort(function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -109057,9 +111093,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 247 /* ImportDeclaration */ + var expression = declaration.kind === 249 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 259 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -109387,12 +111423,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -109447,6 +111483,9 @@ var ts; var errorCodes = [ ts.Diagnostics.Property_0_does_not_exist_on_type_1.code, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code, + ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more.code ]; var fixId = "addMissingMember"; codefix.registerCodeFix({ @@ -109580,7 +111619,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 207 /* ClassExpression */) { + if (classDeclaration.kind === 209 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -109606,13 +111645,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 202 /* BinaryExpression */) { + if (token.parent.parent.kind === 204 /* 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); } - return typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); + else { + var contextualType = checker.getContextualType(token.parent); + typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; + } + return typeNode || ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -109621,7 +111664,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -109645,7 +111688,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(137 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(138 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -109665,7 +111708,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, !ts.isInterfaceDeclaration(typeDecl)); - var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 156 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -109681,7 +111724,7 @@ var ts; */ var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 68 /* StringLike */); + return !!(type && type.flags & 132 /* StringLike */); }); var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); @@ -109930,7 +111973,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 99 /* ThisKeyword */) + if (token.kind !== 100 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -109969,7 +112012,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 124 /* ConstructorKeyword */); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -110007,17 +112050,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 86 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(109 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 85 /* ExtendsKeyword */ && - heritageClauses[1].token === 108 /* ImplementsKeyword */) { + heritageClauses[0].token === 86 /* ExtendsKeyword */ && + heritageClauses[1].token === 109 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(26 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* 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; @@ -110101,7 +112144,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 === 27 /* LessThanToken */) { + if (token.kind === 28 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -110121,7 +112164,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* 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)); @@ -110153,7 +112196,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 126 /* InferKeyword */) + if (token.kind === 127 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -110162,7 +112205,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 27 /* LessThanToken */) { + else if (token.kind === 28 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -110172,7 +112215,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -110183,7 +112226,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(142 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(143 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -110193,13 +112236,13 @@ var ts; } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 92 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { - if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) + if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 149 /* Parameter */) { + if (decl.kind === 151 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -110210,7 +112253,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -110219,7 +112262,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 === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -110228,14 +112271,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 149 /* Parameter */: - case 148 /* TypeParameter */: + case 151 /* Parameter */: + case 150 /* TypeParameter */: return true; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: return true; } } @@ -110249,9 +112292,9 @@ var ts; } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 187 /* PropertyAccessExpression */) + if (ts.isPropertyAccessExpression(ref.parent) && ref.parent.name === ref) ref = ref.parent; - if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + if (ts.isBinaryExpression(ref.parent) && ts.isExpressionStatement(ref.parent.parent) && ref.parent.left === ref) { changes.delete(sourceFile, ref.parent.parent); } }); @@ -110267,33 +112310,41 @@ var ts; } function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { if (mayDeleteParameter(p, checker, isFixAll)) { - changes.delete(sourceFile, p); - deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + if (p.modifiers && p.modifiers.length > 0 + && (!ts.isIdentifier(p.name) || ts.FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) { + p.modifiers.forEach(function (modifier) { + changes.deleteModifier(sourceFile, modifier); + }); + } + else { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + } } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: return true; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 72 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -110333,7 +112384,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 220 /* IfStatement */: + case 222 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -110344,8 +112395,8 @@ var ts; return; } // falls through - case 222 /* WhileStatement */: - case 223 /* ForStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -110394,7 +112445,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, 56 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -110418,10 +112469,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 === 284 /* JSDocNullableType */) { + if (typeNode.kind === 286 /* 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, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -110438,7 +112489,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -110455,22 +112506,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 210 /* AsExpression */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 237 /* FunctionDeclaration */: - case 156 /* GetAccessor */: - case 160 /* IndexSignature */: - case 179 /* MappedType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 192 /* TypeAssertionExpression */: - case 235 /* VariableDeclaration */: + case 212 /* AsExpression */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 239 /* FunctionDeclaration */: + case 158 /* GetAccessor */: + case 162 /* IndexSignature */: + case 181 /* MappedType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 194 /* TypeAssertionExpression */: + case 237 /* VariableDeclaration */: return true; default: return false; @@ -110524,15 +112575,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 90 /* FunctionKeyword */, sourceFile); break; - case 195 /* ArrowFunction */: - insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); + case 197 /* ArrowFunction */: + insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: return; @@ -110546,11 +112597,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 71 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 72 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 120 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 121 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -110640,17 +112691,17 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); switch (declaration.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 151 /* PropertySignature */: - case 152 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 153 /* PropertySignature */: + case 154 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 153 /* MethodSignature */: - case 154 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 156 /* 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 @@ -110668,8 +112719,8 @@ var ts; outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { - var signature = signatures_8[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var signature = signatures_7[_i]; // Need to ensure nodes are fresh each time so they can have different positions. outputMethod(signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } @@ -110690,14 +112741,14 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 156 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(55 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -110713,11 +112764,11 @@ var ts; ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); - var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(119 /* AnyKeyword */); + var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(120 /* AnyKeyword */); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(39 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -110734,8 +112785,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(120 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -110749,8 +112800,8 @@ var ts; var maxArgsSignature = signatures[0]; var minArgumentCount = signatures[0].minArgumentCount; var someSigHasRestParameter = false; - for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) { - var sig = signatures_9[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); if (sig.hasRestParameter) { someSigHasRestParameter = true; @@ -110763,11 +112814,11 @@ 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.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(120 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyArrayType, + /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -110778,7 +112829,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -110787,10 +112838,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(114 /* PublicKeyword */); + return ts.createToken(115 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(113 /* ProtectedKeyword */); + return ts.createToken(114 /* ProtectedKeyword */); } return undefined; } @@ -110798,608 +112849,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - var codefix; - (function (codefix) { - var fixId = "inferFromUsage"; - var errorCodes = [ - // Variable declarations - ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, - // Variable uses - ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, - // Parameter declarations - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, - // Get Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, - ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, - // Set Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, - // Property declarations - ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, - ]; - codefix.registerCodeFix({ - errorCodes: errorCodes, - getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; - var token = ts.getTokenAtPosition(sourceFile, start); - var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); - var name = declaration && ts.getNameOfDeclaration(declaration); - return !name || changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; - }, - fixIds: [fixId], - getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; - var markSeen = ts.nodeSeenTracker(); - return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); - }); - }, - }); - function getDiagnostic(errorCode, token) { - switch (errorCode) { - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - return ts.Diagnostics.Infer_parameter_types_from_usage; - default: - return ts.Diagnostics.Infer_type_of_0_from_usage; - } - } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 71 /* Identifier */ && token.kind !== 24 /* DotDotDotToken */ && token.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var parent = token.parent; - switch (errorCode) { - // Variable and Property declarations - case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: - case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: - if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); - return parent; - } - if (ts.isPropertyAccessExpression(parent)) { - var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); - var typeNode = type && getTypeNodeIfAccessible(type, parent, program, host); - if (typeNode) { - changes.tryInsertJSDocType(sourceFile, parent, typeNode); - } - return parent; - } - return undefined; - case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { - var symbol = program.getTypeChecker().getSymbolAtLocation(token); - if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); - return symbol.valueDeclaration; - } - return undefined; - } - } - var containingFunction = ts.getContainingFunction(token); - if (containingFunction === undefined) { - return undefined; - } - switch (errorCode) { - // Parameter declarations - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - // falls through - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - if (markSeen(containingFunction)) { - var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, param, containingFunction, sourceFile, program, host, cancellationToken); - return param; - } - return undefined; - // Get Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: - case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: - if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); - return containingFunction; - } - return undefined; - // Set Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - return undefined; - default: - return ts.Debug.fail(String(errorCode)); - } - } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { - if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); - } - } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - return true; - case 194 /* FunctionExpression */: - return !!declaration.name; - } - return false; - } - function annotateParameters(changes, parameterDeclaration, containingFunction, sourceFile, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { - return; - } - var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : undefined - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); - if (ts.isInJSFile(containingFunction)) { - annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); - } - else { - 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) { - annotate(changes, sourceFile, declaration, type, program, host); - } - } - } - } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { - var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); - if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { - var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken) || - inferTypeForVariableFromUsage(param.name, program, cancellationToken); - if (ts.isInJSFile(setAccessorDeclaration)) { - annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); - } - else { - annotate(changes, sourceFile, param, type, program, host); - } - } - } - function annotate(changes, sourceFile, declaration, type, program, host) { - var typeNode = type && getTypeNodeIfAccessible(type, declaration, program, host); - if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 151 /* PropertySignature */) { - changes.tryInsertJSDocType(sourceFile, declaration, typeNode); - } - else { - changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); - } - } - } - function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { - var result = ts.mapDefined(parameterInferences, function (inference) { - var param = inference.declaration; - var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); - return typeNode && !param.initializer && !ts.getJSDocType(param) ? __assign({}, inference, { typeNode: typeNode }) : undefined; - }); - changes.tryInsertJSDocParameters(sourceFile, result); - } - function getTypeNodeIfAccessible(type, enclosingScope, program, host) { - var checker = program.getTypeChecker(); - var typeIsAccessible = true; - var notAccessible = function () { typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { - trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; - }, - reportInaccessibleThisError: notAccessible, - reportPrivateInBaseOfClassExpression: notAccessible, - reportInaccessibleUniqueSymbolError: notAccessible, - moduleResolverHost: { - readFile: host.readFile, - fileExists: host.fileExists, - directoryExists: host.directoryExists, - getSourceFiles: program.getSourceFiles, - getCurrentDirectory: program.getCurrentDirectory, - getCommonSourceDirectory: program.getCommonSourceDirectory, - } - }); - return typeIsAccessible ? res : undefined; - } - 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; - }); - } - function inferTypeForVariableFromUsage(token, program, cancellationToken) { - return InferFromReference.inferTypeFromReferences(getReferences(token, program, cancellationToken), program.getTypeChecker(), cancellationToken); - } - function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { - switch (containingFunction.kind) { - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - var isConstructor = containingFunction.kind === 155 /* Constructor */; - var searchToken = isConstructor ? - ts.findChildOfKind(containingFunction, 123 /* ConstructorKeyword */, sourceFile) : - containingFunction.name; - if (searchToken) { - return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program.getTypeChecker(), cancellationToken); - } - } - } - var InferFromReference; - (function (InferFromReference) { - function inferTypeFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { - var reference = references_1[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return getTypeFromUsageContext(usageContext, checker); - } - InferFromReference.inferTypeFromReferences = inferTypeFromReferences; - function inferTypeForParametersFromReferences(references, declaration, checker, cancellationToken) { - if (references.length === 0) { - return undefined; - } - if (!declaration.parameters) { - return undefined; - } - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - var isConstructor = declaration.kind === 155 /* Constructor */; - var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; - return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { - var types = []; - var isRest = ts.isRestParameter(parameter); - var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { - isOptional = ts.isInJSFile(declaration); - continue; - } - if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - } - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - if (!types.length) { - return { declaration: parameter }; - } - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return { - type: isRest ? checker.createArrayType(type) : type, - isOptional: isOptional && !isRest, - declaration: parameter - }; - }); - } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeFromContext(node, checker, usageContext) { - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - switch (node.parent.kind) { - case 201 /* PostfixUnaryExpression */: - usageContext.isNumber = true; - break; - case 200 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); - break; - case 202 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); - break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); - break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); - } - else { - inferTypeFromContextualType(node, checker, usageContext); - } - break; - case 187 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); - break; - case 188 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); - break; - case 235 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); - } - break; - } - } - // falls through - default: - return inferTypeFromContextualType(node, checker, usageContext); - } - } - function inferTypeFromContextualType(node, checker, usageContext) { - if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); - } - } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { - switch (node.operator) { - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - usageContext.isNumber = true; - break; - case 37 /* PlusToken */: - usageContext.isNumberOrString = true; - break; - // case SyntaxKind.ExclamationToken: - // no inferences here; - } - } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { - switch (parent.operatorToken.kind) { - // ExponentiationOperator - case 40 /* AsteriskAsteriskToken */: - // MultiplicativeOperator - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - // ShiftOperator - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - // BitwiseOperator - case 48 /* AmpersandToken */: - case 49 /* BarToken */: - case 50 /* CaretToken */: - // CompoundAssignmentOperator - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 69 /* BarEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - // AdditiveOperator - case 38 /* MinusToken */: - // RelationalOperator - case 27 /* LessThanToken */: - case 30 /* LessThanEqualsToken */: - case 29 /* GreaterThanToken */: - case 31 /* GreaterThanEqualsToken */: - var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, operandType); - } - else { - usageContext.isNumber = true; - } - break; - case 59 /* PlusEqualsToken */: - case 37 /* PlusToken */: - var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); - } - else if (otherOperandType.flags & 168 /* NumberLike */) { - usageContext.isNumber = true; - } - else if (otherOperandType.flags & 68 /* StringLike */) { - usageContext.isString = true; - } - else { - usageContext.isNumberOrString = true; - } - break; - // AssignmentOperators - case 58 /* EqualsToken */: - case 32 /* EqualsEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); - break; - case 92 /* InKeyword */: - if (node === parent.left) { - usageContext.isString = true; - } - break; - // LogicalOperator - case 54 /* BarBarToken */: - if (node === parent.left && - (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { - // var x = x || {}; - // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); - } - break; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: - case 93 /* InstanceOfKeyword */: - // nothing to infer here - break; - } - } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); - } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { - argumentTypes: [], - returnType: {} - }; - if (parent.arguments) { - for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); - } - } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 189 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); - } - else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); - } - } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { - var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); - } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); - } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { - if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; - return; - } - else { - var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 168 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; - } - else { - usageContext.stringIndexContext = indexUsageContext; - } - } - } - function getTypeFromUsageContext(usageContext, checker) { - if (usageContext.isNumberOrString && !usageContext.isNumber && !usageContext.isString) { - return checker.getUnionType([checker.getNumberType(), checker.getStringType()]); - } - else if (usageContext.isNumber) { - return checker.getNumberType(); - } - else if (usageContext.isString) { - return checker.getStringType(); - } - else if (usageContext.candidateTypes) { - return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(function (t) { return checker.getBaseTypeOfLiteralType(t); }), 2 /* Subtype */)); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - return checker.createPromiseType(types.length ? checker.getUnionType(types, 2 /* Subtype */) : checker.getAnyType()); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - return checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker)); - } - else if (usageContext.numberIndexContext) { - return checker.createArrayType(recur(usageContext.numberIndexContext)); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_6 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_6.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 - } - else { - return undefined; - } - function recur(innerContext) { - return getTypeFromUsageContext(innerContext, checker) || checker.getAnyType(); - } - } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { - var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - } - } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; - } - return undefined; - } - function getSignatureFromCallContext(callContext, checker) { - var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - parameters.push(symbol); - } - var returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType(); - // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - } - function addCandidateType(context, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 32768 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); - } - } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); - })(codefix = ts.codefix || (ts.codefix = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var codefix; (function (codefix) { @@ -111432,7 +112881,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 191 /* CallExpression */ : 192 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; @@ -111543,7 +112992,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(51 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -111551,7 +113000,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(141 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -111572,7 +113021,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 512 /* BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.createFalse() : ts.createTrue(); } else if (type.isLiteral()) { @@ -111597,15 +113046,23 @@ var ts; } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/* @internal */ var ts; (function (ts) { function generateTypesForModule(name, moduleValue, formatSettings) { - return valueInfoToDeclarationFileText(ts.inspectValue(name, moduleValue), formatSettings); + return generateTypesForModuleOrGlobal(name, moduleValue, formatSettings, 0 /* ExportEquals */); } ts.generateTypesForModule = generateTypesForModule; - function valueInfoToDeclarationFileText(valueInfo, formatSettings) { - return ts.textChanges.getNewFileText(toStatements(valueInfo, 0 /* ExportEquals */), 3 /* TS */, "\n", ts.formatting.getFormatContext(formatSettings)); + function generateTypesForGlobal(name, globalValue, formatSettings) { + return generateTypesForModuleOrGlobal(name, globalValue, formatSettings, 3 /* Global */); + } + ts.generateTypesForGlobal = generateTypesForGlobal; + function generateTypesForModuleOrGlobal(name, globalValue, formatSettings, outputKind) { + return valueInfoToDeclarationFileText(ts.inspectValue(name, globalValue), formatSettings, outputKind); + } + /* @internal */ + function valueInfoToDeclarationFileText(valueInfo, formatSettings, outputKind) { + if (outputKind === void 0) { outputKind = 0 /* ExportEquals */; } + return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; var OutputKind; @@ -111613,6 +113070,7 @@ var ts; OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; OutputKind[OutputKind["NamedExport"] = 1] = "NamedExport"; OutputKind[OutputKind["NamespaceMember"] = 2] = "NamespaceMember"; + OutputKind[OutputKind["Global"] = 3] = "Global"; })(OutputKind || (OutputKind = {})); function toNamespaceMemberStatements(info) { return toStatements(info, 2 /* NamespaceMember */); @@ -111622,9 +113080,9 @@ var ts; var name = isDefault ? "_default" : info.name; if (!isValidIdentifier(name) || isDefault && kind !== 1 /* NamedExport */) return ts.emptyArray; - var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(84 /* ExportKeyword */), ts.createModifier(79 /* DefaultKeyword */)] - : kind === 0 /* ExportEquals */ ? [ts.createModifier(124 /* DeclareKeyword */)] - : kind === 1 /* NamedExport */ ? [ts.createModifier(84 /* ExportKeyword */)] + var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(85 /* ExportKeyword */), ts.createModifier(80 /* DefaultKeyword */)] + : kind === 3 /* Global */ || kind === 0 /* ExportEquals */ ? [ts.createModifier(125 /* DeclareKeyword */)] + : kind === 1 /* NamedExport */ ? [ts.createModifier(85 /* ExportKeyword */)] : undefined; var exportEquals = function () { return kind === 0 /* ExportEquals */ ? [exportEqualsOrDefault(info.name, /*isExportEquals*/ true)] : ts.emptyArray; }; var exportDefault = function () { return isDefault ? [exportEqualsOrDefault("_default", /*isExportEquals*/ false)] : ts.emptyArray; }; @@ -111632,13 +113090,15 @@ var ts; case 2 /* FunctionOrClass */: return exportEquals().concat(functionOrClassToStatements(modifiers, name, info)); case 3 /* Object */: - var members = info.members; - if (kind === 0 /* ExportEquals */) { - return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); - } - if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { - // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. - return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + var members = info.members, hasNontrivialPrototype = info.hasNontrivialPrototype; + if (!hasNontrivialPrototype) { + if (kind === 0 /* ExportEquals */) { + return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); + } + if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { + // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. + return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + } } // falls through case 0 /* Const */: @@ -111658,8 +113118,20 @@ var ts; var source = _a.source, prototypeMembers = _a.prototypeMembers, namespaceMembers = _a.namespaceMembers; var fnAst = parseClassOrFunctionBody(source); var _b = fnAst === undefined ? { parameters: ts.emptyArray, returnType: anyType() } : getParametersAndReturnType(fnAst), parameters = _b.parameters, returnType = _b.returnType; - var instanceProperties = typeof fnAst === "object" ? getConstructorFunctionInstanceProperties(fnAst) : ts.emptyArray; - var classStaticMembers = instanceProperties.length !== 0 || prototypeMembers.length !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */ ? [] : undefined; + var protoOrInstanceMembers = ts.createMap(); + if (typeof fnAst === "object") + getConstructorFunctionInstanceProperties(fnAst, protoOrInstanceMembers); + for (var _i = 0, prototypeMembers_1 = prototypeMembers; _i < prototypeMembers_1.length; _i++) { + var p = prototypeMembers_1[_i]; + // ignore non-functions on the prototype + if (p.kind === 2 /* FunctionOrClass */) { + var m = tryGetMethod(p); + if (m) { + protoOrInstanceMembers.set(p.name, m); + } + } + } + var classStaticMembers = protoOrInstanceMembers.size !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */ ? [] : undefined; var namespaceStatements = ts.flatMap(namespaceMembers, function (info) { if (!isValidIdentifier(info.name)) return undefined; @@ -111672,16 +113144,19 @@ var ts; // falls through case 1 /* Array */: case 0 /* Const */: - classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(115 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); + classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(116 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); return undefined; case 2 /* FunctionOrClass */: if (!info.namespaceMembers.length) { // Else, can't merge a static method with a namespace. Must make it a function on the namespace. - var sig = tryGetMethod(info, [ts.createModifier(115 /* StaticKeyword */)]); + var sig = tryGetMethod(info, [ts.createModifier(116 /* StaticKeyword */)]); if (sig) { classStaticMembers.push(sig); return undefined; } } + break; + default: + ts.Debug.assertNever(info); } } return toStatements(info, 2 /* NamespaceMember */); @@ -111690,7 +113165,7 @@ var ts; ? ts.createClassDeclaration( /*decorators*/ undefined, modifiers, name, /*typeParameters*/ undefined, - /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), instanceProperties, ts.mapDefined(prototypeMembers, function (info) { return info.kind === 2 /* FunctionOrClass */ ? tryGetMethod(info) : undefined; }))) + /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), ts.arrayFrom(protoOrInstanceMembers.values()))) : ts.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, name, /*typeParameters*/ undefined, parameters, returnType, /*body*/ undefined); return [decl].concat((namespaceStatements.length === 0 ? ts.emptyArray : [createNamespace(modifiers && modifiers.map(function (m) { return ts.getSynthesizedDeepClone(m); }), name, namespaceStatements)])); } @@ -111699,7 +113174,7 @@ var ts; if (!isValidIdentifier(name)) return undefined; var fnAst = parseClassOrFunctionBody(source); - if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */)) + if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */)) return undefined; var sig = getParametersAndReturnType(fnAst); return sig && ts.createMethod( @@ -111718,23 +113193,25 @@ var ts; case 2 /* FunctionOrClass */: return ts.createTypeReferenceNode("Function", /*typeArguments*/ undefined); // Normally we create a FunctionDeclaration, but this can happen for a function in an array. case 3 /* Object */: - return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, m.name, /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); + return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, toPropertyName(m.name), /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); default: return ts.Debug.assertNever(info); } } + function toPropertyName(name) { + return ts.isIdentifierText(name, 6 /* ESNext */) ? ts.createIdentifier(name) : ts.createStringLiteral(name); + } // Parses assignments to "this.x" in the constructor into class property declarations - function getConstructorFunctionInstanceProperties(fnAst) { - var members = []; + function getConstructorFunctionInstanceProperties(fnAst, members) { forEachOwnNodeOfFunction(fnAst, function (node) { if (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && - ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 99 /* ThisKeyword */) { - var name = node.left.name.text; - if (!ts.isJsPrivate(name)) - members.push(ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined)); + ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 100 /* ThisKeyword */) { + var name_6 = node.left.name.text; + if (!ts.isJsPrivate(name_6)) { + ts.getOrUpdate(members, name_6, function () { return ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name_6, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined); }); + } } }); - return members; } function getParametersAndReturnType(fnAst) { if (typeof fnAst === "number") { @@ -111743,16 +113220,16 @@ var ts; var usedArguments = false, hasReturn = false; forEachOwnNodeOfFunction(fnAst, function (node) { usedArguments = usedArguments || ts.isIdentifier(node) && node.text === "arguments"; - hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 198 /* VoidExpression */; + hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 200 /* VoidExpression */; }); var parameters = fnAst.parameters.map(function (p) { return makeParameter("" + p.name.getText(), inferParameterType(fnAst, p)); }).concat((usedArguments ? [makeRestParameter()] : ts.emptyArray)); - return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(105 /* VoidKeyword */) }; + return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(106 /* VoidKeyword */) }; } function makeParameter(name, type) { return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name, /*questionToken*/ undefined, type); } function makeRestParameter() { - return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); + return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); } /** Returns 'undefined' for class with no declared constructor */ function parseClassOrFunctionBody(source) { @@ -111791,7 +113268,7 @@ var ts; return node; } function anyType() { - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createNamespace(modifiers, name, statements) { return ts.createModuleDeclaration(/*decorators*/ undefined, modifiers, ts.createIdentifier(name), ts.createModuleBlock(statements), 16 /* Namespace */); @@ -111893,8 +113370,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 181 /* ImportType */); + ts.Debug.assert(token.kind === 92 /* ImportKeyword */); + ts.Debug.assert(token.parent.kind === 183 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -111946,7 +113423,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(133 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -111966,7 +113443,7 @@ var ts; getAvailableActions: function (context) { var info = getInfo(context); if (!info) - return undefined; + return ts.emptyArray; var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; @@ -111993,16 +113470,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: { + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -112025,17 +113502,17 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 80 /* DefaultKeyword */))); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 85 /* ExportKeyword */)); switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(80 /* DefaultKeyword */)); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. @@ -112043,9 +113520,9 @@ var ts; break; } // falls through - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); @@ -112072,18 +113549,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { + case 253 /* ImportSpecifier */: + case 257 /* 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 248 /* ImportClause */: { + case 250 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref); var spec = makeImportSpecifier(exportName, ref.text); @@ -112092,7 +113569,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 249 /* NamespaceImport */) { + else if (namedBindings.kind === 251 /* 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 */; @@ -112113,36 +113590,33 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { - var spec = parent; - if (spec.kind === 251 /* ImportSpecifier */) { - // `import { foo } from "./a";` --> `import foo from "./a";` - // `import { foo as bar } from "./a";` --> `import bar from "./a";` - var defaultImport = ts.createIdentifier(spec.name.text); - if (spec.parent.elements.length === 1) { - changes.replaceNode(importingSourceFile, spec.parent, defaultImport); - } - else { - changes.delete(importingSourceFile, spec); - changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); - } + case 253 /* ImportSpecifier */: { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(parent.name.text); + if (parent.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, parent.parent, defaultImport); } else { - // `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";` - // (Because `export foo from "./a";` isn't valid syntax.) - changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + changes.delete(importingSourceFile, parent); + changes.insertNodeBefore(importingSourceFile, parent.parent, defaultImport); } break; } + case 257 /* 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";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, parent, makeExportSpecifier("default", parent.name.text)); + break; + } default: - ts.Debug.failBadSyntaxKind(parent); + ts.Debug.assertNever(parent); } } function makeImportSpecifier(propertyName, name) { @@ -112165,9 +113639,9 @@ var ts; getAvailableActions: function (context) { var i = getImportToConvert(context); if (!i) - return undefined; - var description = i.kind === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 249 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return ts.emptyArray; + var description = i.kind === 251 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 251 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { @@ -112189,7 +113663,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 249 /* NamespaceImport */) { + if (toConvert.kind === 251 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -112297,12 +113771,12 @@ var ts; var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context)); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { - return undefined; + return ts.emptyArray; } var extractions = getPossibleExtractions(targetRange, context); if (extractions === undefined) { // No extractions possible - return undefined; + return ts.emptyArray; } var functionActions = []; var usedFunctionNames = ts.createMap(); @@ -112358,7 +113832,7 @@ var ts; actions: constantActions }); } - return infos.length ? infos : undefined; + return infos.length ? infos : ts.emptyArray; } extractSymbol.getAvailableActions = getAvailableActions; /* Exported for tests */ @@ -112532,20 +114006,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 152 /* PropertyDeclaration */) { + if (current.kind === 154 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 149 /* Parameter */) { + else if (current.kind === 151 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 155 /* Constructor */) { + if (ctorOrMethod.kind === 157 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 154 /* MethodDeclaration */) { + else if (current.kind === 156 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -112588,7 +114062,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 235 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 237 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* 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`! @@ -112600,13 +114074,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 97 /* SuperKeyword */: + case 98 /* 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 === 189 /* CallExpression */) { + if (node.parent.kind === 191 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -112621,8 +114095,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -112634,20 +114108,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 220 /* IfStatement */: + case 222 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 216 /* Block */: - if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { + case 218 /* Block */: + if (node.parent && node.parent.kind === 235 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -112659,11 +114133,11 @@ var ts; break; } switch (node.kind) { - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -112671,8 +114145,8 @@ var ts; seenLabels.pop(); break; } - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: { var label = node.label; if (label) { @@ -112682,20 +114156,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 229 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -112749,7 +114223,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 === 149 /* Parameter */) { + if (current.kind === 151 /* 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; } @@ -112760,7 +114234,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 277 /* SourceFile */) { + if (current.kind === 279 /* SourceFile */) { return scopes; } } @@ -112850,32 +114324,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return "arrow function"; - case 154 /* MethodDeclaration */: - return "method '" + scope.name.getText(); - case 156 /* GetAccessor */: + case 156 /* MethodDeclaration */: + return "method '" + scope.name.getText() + "'"; + case 158 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 238 /* ClassDeclaration */ + return scope.kind === 240 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 243 /* ModuleBlock */ + return scope.kind === 245 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -112941,20 +114415,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(112 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(113 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(120 /* AsyncKeyword */)); + modifiers.push(ts.createToken(121 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(121 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* 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; @@ -112971,7 +114445,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -113095,9 +114569,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 140 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 141 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(140 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(141 /* UndefinedKeyword */)]); } } /** @@ -113120,11 +114594,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(112 /* PrivateKeyword */)); + modifiers.push(ts.createToken(113 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } - modifiers.push(ts.createToken(132 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(133 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -113153,7 +114627,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 219 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 221 /* 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.createVariableStatement( @@ -113172,7 +114646,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 219 /* ExpressionStatement */) { + if (node.parent.kind === 221 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -113259,7 +114733,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 230 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -113429,7 +114903,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (4096 /* Void */ | 32768 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -113437,7 +114911,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 239 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -113753,30 +115227,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 276 /* EnumMember */: + case 278 /* EnumMember */: return false; } switch (node.kind) { - case 9 /* StringLiteral */: - return parent.kind !== 247 /* ImportDeclaration */ && - parent.kind !== 251 /* ImportSpecifier */; - case 206 /* SpreadElement */: - case 182 /* ObjectBindingPattern */: - case 184 /* BindingElement */: + case 10 /* StringLiteral */: + return parent.kind !== 249 /* ImportDeclaration */ && + parent.kind !== 253 /* ImportSpecifier */; + case 208 /* SpreadElement */: + case 184 /* ObjectBindingPattern */: + case 186 /* BindingElement */: return false; - case 71 /* Identifier */: - return parent.kind !== 184 /* BindingElement */ && - parent.kind !== 251 /* ImportSpecifier */ && - parent.kind !== 255 /* ExportSpecifier */; + case 72 /* Identifier */: + return parent.kind !== 186 /* BindingElement */ && + parent.kind !== 253 /* ImportSpecifier */ && + parent.kind !== 257 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 216 /* Block */: - case 277 /* SourceFile */: - case 243 /* ModuleBlock */: - case 269 /* CaseClause */: + case 218 /* Block */: + case 279 /* SourceFile */: + case 245 /* ModuleBlock */: + case 271 /* CaseClause */: return true; default: return false; @@ -113797,7 +115271,7 @@ var ts; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { if (!getConvertibleFieldAtPosition(context)) - return undefined; + return ts.emptyArray; return [{ name: actionName, description: actionDescription, @@ -113825,10 +115299,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 114 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 115 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 112 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 113 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -113866,7 +115340,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(115 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(116 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -113889,7 +115363,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 149 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 151 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -113971,7 +115445,7 @@ var ts; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) - return undefined; + return ts.emptyArray; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, @@ -114033,11 +115507,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return true; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -114125,12 +115599,12 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? + case 249 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 251 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -114161,20 +115635,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 249 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 248 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -114244,15 +115718,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -114265,7 +115739,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 251 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -114277,7 +115751,7 @@ var ts; if (namedBindingsUnused) { changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 250 /* NamedImports */) { + else if (namedBindings.kind === 252 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -114290,14 +115764,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: break; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); } @@ -114402,13 +115876,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: return true; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -114420,7 +115894,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -114430,9 +115904,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -114441,7 +115915,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -114451,11 +115925,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return keep(name) ? name : undefined; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return name; - case 182 /* ObjectBindingPattern */: { + case 184 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -114512,13 +115986,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -114526,17 +116000,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return cb(statement); - case 217 /* VariableStatement */: - return ts.forEach(statement.declarationList.declarations, cb); - case 219 /* ExpressionStatement */: { + case 219 /* VariableStatement */: + return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); + case 221 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -114544,11 +116018,29 @@ var ts; } } } + function forEachTopLevelDeclarationInBindingName(name, cb) { + switch (name.kind) { + case 72 /* Identifier */: + return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); + default: + return ts.Debug.assertNever(name); + } + } function nameOfTopLevelDeclaration(d) { - return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return ts.isExpressionStatement(d) ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { - return ts.isVariableDeclaration(d) ? d.parent.parent : d; + switch (d.kind) { + case 237 /* VariableDeclaration */: + return d.parent.parent; + case 186 /* BindingElement */: + return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); + default: + return d; + } } function addExportToChanges(sourceFile, decl, changes, useEs6Exports) { if (isExported(sourceFile, decl, useEs6Exports)) @@ -114575,25 +116067,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(85 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -114604,18 +116096,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -114623,7 +116115,7 @@ var ts; } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 58 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 59 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -114645,7 +116137,7 @@ var ts; var file = context.file, startPosition = context.startPosition; var info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) - return undefined; + return ts.emptyArray; return [{ name: refactorName, description: refactorDescription, @@ -114687,7 +116179,7 @@ var ts; return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { var node = ts.getTokenAtPosition(file, startPosition); @@ -114723,7 +116215,7 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 71 /* Identifier */ ? new IdentifierObject(71 /* Identifier */, pos, end) : + kind === 72 /* Identifier */ ? new IdentifierObject(72 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 12679168 /* ContextFlags */; @@ -114796,8 +116288,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 303 /* LastJSDocNode */; }); - return child.kind < 146 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -114808,7 +116300,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 146 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 148 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -114854,7 +116346,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 71 /* Identifier */) { + if (token === 72 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -114866,7 +116358,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(304 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -114998,7 +116490,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 71 /* Identifier */; + IdentifierObject.prototype.kind = 72 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -115044,25 +116536,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 262144 /* Union */); + return !!(this.flags & 1048576 /* Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 524288 /* Intersection */); + return !!(this.flags & 2097152 /* Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 786432 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 192 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 64 /* StringLiteral */); + return !!(this.flags & 128 /* StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 128 /* NumberLiteral */); + return !!(this.flags & 256 /* NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 65536 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); @@ -115199,10 +116691,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -115222,31 +116714,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 166 /* TypeLiteral */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 168 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: { + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -115257,19 +116749,19 @@ var ts; } } // falls through - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: addDeclaration(node); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -115281,7 +116773,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -115290,7 +116782,7 @@ var ts; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -115603,7 +117095,7 @@ var ts; } var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - var sourceMapper = ts.getSourceMapper(getCanonicalFileName, currentDirectory, log, host, function () { return program; }); + var sourceMapper = ts.getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, function () { return program; }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -115684,11 +117176,11 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }; + compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile); + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -115722,7 +117214,7 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -115879,15 +117371,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return !ts.isLabelName(node); - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 97 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 98 /* SuperKeyword */: return true; default: return false; @@ -115925,7 +117417,7 @@ var ts; var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return ts.Debug.assertDefined(program.getSourceFile(f)); }); + var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -115933,7 +117425,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, position); - if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) { var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); @@ -115994,16 +117486,16 @@ var ts; return undefined; } switch (node.kind) { - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: - case 9 /* StringLiteral */: - case 86 /* FalseKeyword */: - case 101 /* TrueKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 71 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: + case 10 /* StringLiteral */: + case 87 /* FalseKeyword */: + case 102 /* TrueKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 72 /* Identifier */: break; // Cant create the text span default: @@ -116019,7 +117511,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 === 242 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 244 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -116081,10 +117573,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = ts.createMapFromTemplate((_a = {}, - _a[17 /* OpenBraceToken */] = 18 /* CloseBraceToken */, - _a[19 /* OpenParenToken */] = 20 /* CloseParenToken */, - _a[21 /* OpenBracketToken */] = 22 /* CloseBracketToken */, - _a[29 /* GreaterThanToken */] = 27 /* LessThanToken */, + _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, + _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, + _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, + _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -116224,7 +117716,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 29 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -116483,7 +117975,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 257 /* ExternalModuleReference */ || + node.parent.kind === 259 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -116498,15 +117990,15 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 147 /* ComputedPropertyName */) { + if (node.parent.kind === 149 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && + (node.parent.parent.kind === 188 /* ObjectLiteralExpression */ || node.parent.parent.kind === 268 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -116548,7 +118040,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 188 /* ElementAccessExpression */ && + node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -116628,144 +118120,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return spanInVariableDeclaration(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return spanInParameterDeclaration(node); - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanInBlock(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInBlock(node.block); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return spanInForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 233 /* TryStatement */: + case 235 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 184 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 186 /* BindingElement */: // span on complete node return textSpan(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 150 /* Decorator */: + case 152 /* Decorator */: return spanInNodeArray(parent.decorators); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return spanInPreviousNode(node); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 22 /* CloseBracketToken */: + case 23 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return spanInOpenParenToken(node); - case 20 /* CloseParenToken */: + case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 56 /* ColonToken */: + case 57 /* ColonToken */: return spanInColonToken(node); - case 29 /* GreaterThanToken */: - case 27 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 28 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return spanInWhileKeyword(node); - case 82 /* ElseKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 83 /* ElseKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return spanInNextNode(node); - case 145 /* OfKeyword */: + case 147 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -116777,14 +118269,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 === 71 /* Identifier */ || - node.kind === 206 /* SpreadElement */ || - node.kind === 273 /* PropertyAssignment */ || - node.kind === 274 /* ShorthandPropertyAssignment */) && + if ((node.kind === 72 /* Identifier */ || + node.kind === 208 /* SpreadElement */ || + node.kind === 275 /* PropertyAssignment */ || + node.kind === 276 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 202 /* BinaryExpression */) { + if (node.kind === 204 /* 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 @@ -116793,35 +118285,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 58 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 59 /* 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 === 26 /* CommaToken */) { + if (operatorToken.kind === 27 /* CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 150 /* Decorator */: + case 152 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: return textSpan(node); - case 202 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 26 /* CommaToken */) { + case 204 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -116830,21 +118322,21 @@ var ts; } } switch (node.parent.kind) { - case 273 /* PropertyAssignment */: + case 275 /* 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 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: { + case 237 /* VariableDeclaration */: + case 151 /* 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)) { @@ -116852,7 +118344,7 @@ var ts; } break; } - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -116882,7 +118374,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 226 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -116894,7 +118386,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 225 /* ForOfStatement */) { + parent.parent.kind === 227 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -116935,7 +118427,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 240 /* ClassDeclaration */ && functionDeclaration.kind !== 157 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -116958,26 +118450,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 224 /* ForInStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 226 /* 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 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* 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 === 236 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 238 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -117002,21 +118494,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 184 /* BindingElement */) { + if (bindingPattern.parent.kind === 186 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); - var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 185 /* ArrayBindingPattern */ && node.kind !== 184 /* ObjectBindingPattern */); + var elements = node.kind === 187 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -117024,18 +118516,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 === 202 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 204 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -117043,25 +118535,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* EnumDeclaration */: - case 238 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -117069,7 +118561,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); @@ -117085,7 +118577,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 183 /* ArrayBindingPattern */: + case 185 /* 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); @@ -117100,12 +118592,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 189 /* CallExpression */ || - node.parent.kind === 190 /* NewExpression */) { + if (node.parent.kind === 223 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 191 /* CallExpression */ || + node.parent.kind === 192 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 193 /* ParenthesizedExpression */) { + if (node.parent.kind === 195 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -117114,21 +118606,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 193 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 195 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -117138,20 +118630,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ || - node.parent.kind === 149 /* Parameter */) { + node.parent.kind === 275 /* PropertyAssignment */ || + node.parent.kind === 151 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 192 /* TypeAssertionExpression */) { + if (node.parent.kind === 194 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 221 /* DoStatement */) { + if (node.parent.kind === 223 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -117159,7 +118651,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.kind === 227 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -117257,7 +118749,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); // TODO: GH#18217 return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; // TODO: GH#18217 + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } @@ -117267,7 +118759,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); }); // TODO: GH#18217 + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); }; } } diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 6f680858962..8cf2dcddc09 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -27,6 +27,9 @@ declare namespace ts { interface MapLike { [index: string]: T; } + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedArrayBrand": any; + } interface SortedArray extends Array { " __sortedArrayBrand": any; } @@ -70,7 +73,7 @@ declare namespace ts { end: number; } type JsDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.Unknown | KeywordSyntaxKind; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | 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.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | 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 | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; enum SyntaxKind { Unknown = 0, @@ -82,337 +85,339 @@ declare namespace ts { ShebangTrivia = 6, ConflictMarkerTrivia = 7, NumericLiteral = 8, - StringLiteral = 9, - JsxText = 10, - JsxTextAllWhiteSpaces = 11, - RegularExpressionLiteral = 12, - NoSubstitutionTemplateLiteral = 13, - TemplateHead = 14, - TemplateMiddle = 15, - TemplateTail = 16, - OpenBraceToken = 17, - CloseBraceToken = 18, - OpenParenToken = 19, - CloseParenToken = 20, - OpenBracketToken = 21, - CloseBracketToken = 22, - DotToken = 23, - DotDotDotToken = 24, - SemicolonToken = 25, - CommaToken = 26, - LessThanToken = 27, - LessThanSlashToken = 28, - GreaterThanToken = 29, - LessThanEqualsToken = 30, - GreaterThanEqualsToken = 31, - EqualsEqualsToken = 32, - ExclamationEqualsToken = 33, - EqualsEqualsEqualsToken = 34, - ExclamationEqualsEqualsToken = 35, - EqualsGreaterThanToken = 36, - PlusToken = 37, - MinusToken = 38, - AsteriskToken = 39, - AsteriskAsteriskToken = 40, - SlashToken = 41, - PercentToken = 42, - PlusPlusToken = 43, - MinusMinusToken = 44, - LessThanLessThanToken = 45, - GreaterThanGreaterThanToken = 46, - GreaterThanGreaterThanGreaterThanToken = 47, - AmpersandToken = 48, - BarToken = 49, - CaretToken = 50, - ExclamationToken = 51, - TildeToken = 52, - AmpersandAmpersandToken = 53, - BarBarToken = 54, - QuestionToken = 55, - ColonToken = 56, - AtToken = 57, - EqualsToken = 58, - PlusEqualsToken = 59, - MinusEqualsToken = 60, - AsteriskEqualsToken = 61, - AsteriskAsteriskEqualsToken = 62, - SlashEqualsToken = 63, - PercentEqualsToken = 64, - LessThanLessThanEqualsToken = 65, - GreaterThanGreaterThanEqualsToken = 66, - GreaterThanGreaterThanGreaterThanEqualsToken = 67, - AmpersandEqualsToken = 68, - BarEqualsToken = 69, - CaretEqualsToken = 70, - Identifier = 71, - BreakKeyword = 72, - CaseKeyword = 73, - CatchKeyword = 74, - ClassKeyword = 75, - ConstKeyword = 76, - ContinueKeyword = 77, - DebuggerKeyword = 78, - DefaultKeyword = 79, - DeleteKeyword = 80, - DoKeyword = 81, - ElseKeyword = 82, - EnumKeyword = 83, - ExportKeyword = 84, - ExtendsKeyword = 85, - FalseKeyword = 86, - FinallyKeyword = 87, - ForKeyword = 88, - FunctionKeyword = 89, - IfKeyword = 90, - ImportKeyword = 91, - InKeyword = 92, - InstanceOfKeyword = 93, - NewKeyword = 94, - NullKeyword = 95, - ReturnKeyword = 96, - SuperKeyword = 97, - SwitchKeyword = 98, - ThisKeyword = 99, - ThrowKeyword = 100, - TrueKeyword = 101, - TryKeyword = 102, - TypeOfKeyword = 103, - VarKeyword = 104, - VoidKeyword = 105, - WhileKeyword = 106, - WithKeyword = 107, - ImplementsKeyword = 108, - InterfaceKeyword = 109, - LetKeyword = 110, - PackageKeyword = 111, - PrivateKeyword = 112, - ProtectedKeyword = 113, - PublicKeyword = 114, - StaticKeyword = 115, - YieldKeyword = 116, - AbstractKeyword = 117, - AsKeyword = 118, - AnyKeyword = 119, - AsyncKeyword = 120, - AwaitKeyword = 121, - BooleanKeyword = 122, - ConstructorKeyword = 123, - DeclareKeyword = 124, - GetKeyword = 125, - InferKeyword = 126, - IsKeyword = 127, - KeyOfKeyword = 128, - ModuleKeyword = 129, - NamespaceKeyword = 130, - NeverKeyword = 131, - ReadonlyKeyword = 132, - RequireKeyword = 133, - NumberKeyword = 134, - ObjectKeyword = 135, - SetKeyword = 136, - StringKeyword = 137, - SymbolKeyword = 138, - TypeKeyword = 139, - UndefinedKeyword = 140, - UniqueKeyword = 141, - UnknownKeyword = 142, - FromKeyword = 143, - GlobalKeyword = 144, - OfKeyword = 145, - QualifiedName = 146, - ComputedPropertyName = 147, - TypeParameter = 148, - Parameter = 149, - Decorator = 150, - PropertySignature = 151, - PropertyDeclaration = 152, - MethodSignature = 153, - MethodDeclaration = 154, - Constructor = 155, - GetAccessor = 156, - SetAccessor = 157, - CallSignature = 158, - ConstructSignature = 159, - IndexSignature = 160, - TypePredicate = 161, - TypeReference = 162, - FunctionType = 163, - ConstructorType = 164, - TypeQuery = 165, - TypeLiteral = 166, - ArrayType = 167, - TupleType = 168, - OptionalType = 169, - RestType = 170, - UnionType = 171, - IntersectionType = 172, - ConditionalType = 173, - InferType = 174, - ParenthesizedType = 175, - ThisType = 176, - TypeOperator = 177, - IndexedAccessType = 178, - MappedType = 179, - LiteralType = 180, - ImportType = 181, - ObjectBindingPattern = 182, - ArrayBindingPattern = 183, - BindingElement = 184, - ArrayLiteralExpression = 185, - ObjectLiteralExpression = 186, - PropertyAccessExpression = 187, - ElementAccessExpression = 188, - CallExpression = 189, - NewExpression = 190, - TaggedTemplateExpression = 191, - TypeAssertionExpression = 192, - ParenthesizedExpression = 193, - FunctionExpression = 194, - ArrowFunction = 195, - DeleteExpression = 196, - TypeOfExpression = 197, - VoidExpression = 198, - AwaitExpression = 199, - PrefixUnaryExpression = 200, - PostfixUnaryExpression = 201, - BinaryExpression = 202, - ConditionalExpression = 203, - TemplateExpression = 204, - YieldExpression = 205, - SpreadElement = 206, - ClassExpression = 207, - OmittedExpression = 208, - ExpressionWithTypeArguments = 209, - AsExpression = 210, - NonNullExpression = 211, - MetaProperty = 212, - SyntheticExpression = 213, - TemplateSpan = 214, - SemicolonClassElement = 215, - Block = 216, - VariableStatement = 217, - EmptyStatement = 218, - ExpressionStatement = 219, - IfStatement = 220, - DoStatement = 221, - WhileStatement = 222, - ForStatement = 223, - ForInStatement = 224, - ForOfStatement = 225, - ContinueStatement = 226, - BreakStatement = 227, - ReturnStatement = 228, - WithStatement = 229, - SwitchStatement = 230, - LabeledStatement = 231, - ThrowStatement = 232, - TryStatement = 233, - DebuggerStatement = 234, - VariableDeclaration = 235, - VariableDeclarationList = 236, - FunctionDeclaration = 237, - ClassDeclaration = 238, - InterfaceDeclaration = 239, - TypeAliasDeclaration = 240, - EnumDeclaration = 241, - ModuleDeclaration = 242, - ModuleBlock = 243, - CaseBlock = 244, - NamespaceExportDeclaration = 245, - ImportEqualsDeclaration = 246, - ImportDeclaration = 247, - ImportClause = 248, - NamespaceImport = 249, - NamedImports = 250, - ImportSpecifier = 251, - ExportAssignment = 252, - ExportDeclaration = 253, - NamedExports = 254, - ExportSpecifier = 255, - MissingDeclaration = 256, - ExternalModuleReference = 257, - JsxElement = 258, - JsxSelfClosingElement = 259, - JsxOpeningElement = 260, - JsxClosingElement = 261, - JsxFragment = 262, - JsxOpeningFragment = 263, - JsxClosingFragment = 264, - JsxAttribute = 265, - JsxAttributes = 266, - JsxSpreadAttribute = 267, - JsxExpression = 268, - CaseClause = 269, - DefaultClause = 270, - HeritageClause = 271, - CatchClause = 272, - PropertyAssignment = 273, - ShorthandPropertyAssignment = 274, - SpreadAssignment = 275, - EnumMember = 276, - SourceFile = 277, - Bundle = 278, - UnparsedSource = 279, - InputFiles = 280, - JSDocTypeExpression = 281, - JSDocAllType = 282, - JSDocUnknownType = 283, - JSDocNullableType = 284, - JSDocNonNullableType = 285, - JSDocOptionalType = 286, - JSDocFunctionType = 287, - JSDocVariadicType = 288, - JSDocComment = 289, - JSDocTypeLiteral = 290, - JSDocSignature = 291, - JSDocTag = 292, - JSDocAugmentsTag = 293, - JSDocClassTag = 294, - JSDocCallbackTag = 295, - JSDocEnumTag = 296, - JSDocParameterTag = 297, - JSDocReturnTag = 298, - JSDocThisTag = 299, - JSDocTypeTag = 300, - JSDocTemplateTag = 301, - JSDocTypedefTag = 302, - JSDocPropertyTag = 303, - SyntaxList = 304, - NotEmittedStatement = 305, - PartiallyEmittedExpression = 306, - CommaListExpression = 307, - MergeDeclarationMarker = 308, - EndOfDeclarationMarker = 309, - Count = 310, - FirstAssignment = 58, - LastAssignment = 70, - FirstCompoundAssignment = 59, - LastCompoundAssignment = 70, - FirstReservedWord = 72, - LastReservedWord = 107, - FirstKeyword = 72, - LastKeyword = 145, - FirstFutureReservedWord = 108, - LastFutureReservedWord = 116, - FirstTypeNode = 161, - LastTypeNode = 181, - FirstPunctuation = 17, - LastPunctuation = 70, + BigIntLiteral = 9, + StringLiteral = 10, + JsxText = 11, + JsxTextAllWhiteSpaces = 12, + RegularExpressionLiteral = 13, + NoSubstitutionTemplateLiteral = 14, + TemplateHead = 15, + TemplateMiddle = 16, + TemplateTail = 17, + OpenBraceToken = 18, + CloseBraceToken = 19, + OpenParenToken = 20, + CloseParenToken = 21, + OpenBracketToken = 22, + CloseBracketToken = 23, + DotToken = 24, + DotDotDotToken = 25, + SemicolonToken = 26, + CommaToken = 27, + LessThanToken = 28, + LessThanSlashToken = 29, + GreaterThanToken = 30, + LessThanEqualsToken = 31, + GreaterThanEqualsToken = 32, + EqualsEqualsToken = 33, + ExclamationEqualsToken = 34, + EqualsEqualsEqualsToken = 35, + ExclamationEqualsEqualsToken = 36, + EqualsGreaterThanToken = 37, + PlusToken = 38, + MinusToken = 39, + AsteriskToken = 40, + AsteriskAsteriskToken = 41, + SlashToken = 42, + PercentToken = 43, + PlusPlusToken = 44, + MinusMinusToken = 45, + LessThanLessThanToken = 46, + GreaterThanGreaterThanToken = 47, + GreaterThanGreaterThanGreaterThanToken = 48, + AmpersandToken = 49, + BarToken = 50, + CaretToken = 51, + ExclamationToken = 52, + TildeToken = 53, + AmpersandAmpersandToken = 54, + BarBarToken = 55, + QuestionToken = 56, + ColonToken = 57, + AtToken = 58, + EqualsToken = 59, + PlusEqualsToken = 60, + MinusEqualsToken = 61, + AsteriskEqualsToken = 62, + AsteriskAsteriskEqualsToken = 63, + SlashEqualsToken = 64, + PercentEqualsToken = 65, + LessThanLessThanEqualsToken = 66, + GreaterThanGreaterThanEqualsToken = 67, + GreaterThanGreaterThanGreaterThanEqualsToken = 68, + AmpersandEqualsToken = 69, + BarEqualsToken = 70, + CaretEqualsToken = 71, + Identifier = 72, + BreakKeyword = 73, + CaseKeyword = 74, + CatchKeyword = 75, + ClassKeyword = 76, + ConstKeyword = 77, + ContinueKeyword = 78, + DebuggerKeyword = 79, + DefaultKeyword = 80, + DeleteKeyword = 81, + DoKeyword = 82, + ElseKeyword = 83, + EnumKeyword = 84, + ExportKeyword = 85, + ExtendsKeyword = 86, + FalseKeyword = 87, + FinallyKeyword = 88, + ForKeyword = 89, + FunctionKeyword = 90, + IfKeyword = 91, + ImportKeyword = 92, + InKeyword = 93, + InstanceOfKeyword = 94, + NewKeyword = 95, + NullKeyword = 96, + ReturnKeyword = 97, + SuperKeyword = 98, + SwitchKeyword = 99, + ThisKeyword = 100, + ThrowKeyword = 101, + TrueKeyword = 102, + TryKeyword = 103, + TypeOfKeyword = 104, + VarKeyword = 105, + VoidKeyword = 106, + WhileKeyword = 107, + WithKeyword = 108, + ImplementsKeyword = 109, + InterfaceKeyword = 110, + LetKeyword = 111, + PackageKeyword = 112, + PrivateKeyword = 113, + ProtectedKeyword = 114, + PublicKeyword = 115, + StaticKeyword = 116, + YieldKeyword = 117, + AbstractKeyword = 118, + AsKeyword = 119, + AnyKeyword = 120, + AsyncKeyword = 121, + AwaitKeyword = 122, + BooleanKeyword = 123, + ConstructorKeyword = 124, + DeclareKeyword = 125, + GetKeyword = 126, + InferKeyword = 127, + IsKeyword = 128, + KeyOfKeyword = 129, + ModuleKeyword = 130, + NamespaceKeyword = 131, + NeverKeyword = 132, + ReadonlyKeyword = 133, + RequireKeyword = 134, + NumberKeyword = 135, + ObjectKeyword = 136, + SetKeyword = 137, + StringKeyword = 138, + SymbolKeyword = 139, + TypeKeyword = 140, + UndefinedKeyword = 141, + UniqueKeyword = 142, + UnknownKeyword = 143, + FromKeyword = 144, + GlobalKeyword = 145, + BigIntKeyword = 146, + OfKeyword = 147, + QualifiedName = 148, + ComputedPropertyName = 149, + TypeParameter = 150, + Parameter = 151, + Decorator = 152, + PropertySignature = 153, + PropertyDeclaration = 154, + MethodSignature = 155, + MethodDeclaration = 156, + Constructor = 157, + GetAccessor = 158, + SetAccessor = 159, + CallSignature = 160, + ConstructSignature = 161, + IndexSignature = 162, + TypePredicate = 163, + TypeReference = 164, + FunctionType = 165, + ConstructorType = 166, + TypeQuery = 167, + TypeLiteral = 168, + ArrayType = 169, + TupleType = 170, + OptionalType = 171, + RestType = 172, + UnionType = 173, + IntersectionType = 174, + ConditionalType = 175, + InferType = 176, + ParenthesizedType = 177, + ThisType = 178, + TypeOperator = 179, + IndexedAccessType = 180, + MappedType = 181, + LiteralType = 182, + ImportType = 183, + ObjectBindingPattern = 184, + ArrayBindingPattern = 185, + BindingElement = 186, + ArrayLiteralExpression = 187, + ObjectLiteralExpression = 188, + PropertyAccessExpression = 189, + ElementAccessExpression = 190, + CallExpression = 191, + NewExpression = 192, + TaggedTemplateExpression = 193, + TypeAssertionExpression = 194, + ParenthesizedExpression = 195, + FunctionExpression = 196, + ArrowFunction = 197, + DeleteExpression = 198, + TypeOfExpression = 199, + VoidExpression = 200, + AwaitExpression = 201, + PrefixUnaryExpression = 202, + PostfixUnaryExpression = 203, + BinaryExpression = 204, + ConditionalExpression = 205, + TemplateExpression = 206, + YieldExpression = 207, + SpreadElement = 208, + ClassExpression = 209, + OmittedExpression = 210, + ExpressionWithTypeArguments = 211, + AsExpression = 212, + NonNullExpression = 213, + MetaProperty = 214, + SyntheticExpression = 215, + TemplateSpan = 216, + SemicolonClassElement = 217, + Block = 218, + VariableStatement = 219, + EmptyStatement = 220, + ExpressionStatement = 221, + IfStatement = 222, + DoStatement = 223, + WhileStatement = 224, + ForStatement = 225, + ForInStatement = 226, + ForOfStatement = 227, + ContinueStatement = 228, + BreakStatement = 229, + ReturnStatement = 230, + WithStatement = 231, + SwitchStatement = 232, + LabeledStatement = 233, + ThrowStatement = 234, + TryStatement = 235, + DebuggerStatement = 236, + VariableDeclaration = 237, + VariableDeclarationList = 238, + FunctionDeclaration = 239, + ClassDeclaration = 240, + InterfaceDeclaration = 241, + TypeAliasDeclaration = 242, + EnumDeclaration = 243, + ModuleDeclaration = 244, + ModuleBlock = 245, + CaseBlock = 246, + NamespaceExportDeclaration = 247, + ImportEqualsDeclaration = 248, + ImportDeclaration = 249, + ImportClause = 250, + NamespaceImport = 251, + NamedImports = 252, + ImportSpecifier = 253, + ExportAssignment = 254, + ExportDeclaration = 255, + NamedExports = 256, + ExportSpecifier = 257, + MissingDeclaration = 258, + ExternalModuleReference = 259, + JsxElement = 260, + JsxSelfClosingElement = 261, + JsxOpeningElement = 262, + JsxClosingElement = 263, + JsxFragment = 264, + JsxOpeningFragment = 265, + JsxClosingFragment = 266, + JsxAttribute = 267, + JsxAttributes = 268, + JsxSpreadAttribute = 269, + JsxExpression = 270, + CaseClause = 271, + DefaultClause = 272, + HeritageClause = 273, + CatchClause = 274, + PropertyAssignment = 275, + ShorthandPropertyAssignment = 276, + SpreadAssignment = 277, + EnumMember = 278, + SourceFile = 279, + Bundle = 280, + UnparsedSource = 281, + InputFiles = 282, + JSDocTypeExpression = 283, + JSDocAllType = 284, + JSDocUnknownType = 285, + JSDocNullableType = 286, + JSDocNonNullableType = 287, + JSDocOptionalType = 288, + JSDocFunctionType = 289, + JSDocVariadicType = 290, + JSDocComment = 291, + JSDocTypeLiteral = 292, + JSDocSignature = 293, + JSDocTag = 294, + JSDocAugmentsTag = 295, + JSDocClassTag = 296, + JSDocCallbackTag = 297, + JSDocEnumTag = 298, + JSDocParameterTag = 299, + JSDocReturnTag = 300, + JSDocThisTag = 301, + JSDocTypeTag = 302, + JSDocTemplateTag = 303, + JSDocTypedefTag = 304, + JSDocPropertyTag = 305, + SyntaxList = 306, + NotEmittedStatement = 307, + PartiallyEmittedExpression = 308, + CommaListExpression = 309, + MergeDeclarationMarker = 310, + EndOfDeclarationMarker = 311, + Count = 312, + FirstAssignment = 59, + LastAssignment = 71, + FirstCompoundAssignment = 60, + LastCompoundAssignment = 71, + FirstReservedWord = 73, + LastReservedWord = 108, + FirstKeyword = 73, + LastKeyword = 147, + FirstFutureReservedWord = 109, + LastFutureReservedWord = 117, + FirstTypeNode = 163, + LastTypeNode = 183, + FirstPunctuation = 18, + LastPunctuation = 71, FirstToken = 0, - LastToken = 145, + LastToken = 147, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 13, - FirstTemplateToken = 13, - LastTemplateToken = 16, - FirstBinaryOperator = 27, - LastBinaryOperator = 70, - FirstNode = 146, - FirstJSDocNode = 281, - LastJSDocNode = 303, - FirstJSDocTagNode = 292, - LastJSDocTagNode = 303 + LastLiteralToken = 14, + FirstTemplateToken = 14, + LastTemplateToken = 17, + FirstBinaryOperator = 28, + LastBinaryOperator = 71, + FirstNode = 148, + FirstJSDocNode = 283, + LastJSDocNode = 305, + FirstJSDocTagNode = 294, + LastJSDocTagNode = 305 } enum NodeFlags { None = 0, @@ -499,7 +504,6 @@ declare namespace ts { type AsteriskToken = Token; type EqualsGreaterThanToken = Token; type EndOfFileToken = Token & JSDocContainer; - type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; type PlusToken = Token; @@ -526,7 +530,7 @@ declare namespace ts { } type EntityName = Identifier | QualifiedName; type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern; + type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; interface Declaration extends Node { _declarationBrand: any; } @@ -724,7 +728,7 @@ declare namespace ts { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; @@ -996,6 +1000,9 @@ declare namespace ts { interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } + interface BigIntLiteral extends LiteralExpression { + kind: SyntaxKind.BigIntLiteral; + } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; @@ -1543,7 +1550,6 @@ declare namespace ts { } interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; - atToken: AtToken; tagName: Identifier; comment?: string; } @@ -1573,7 +1579,7 @@ declare namespace ts { } interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; - constraint: TypeNode | undefined; + constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } interface JSDocReturnTag extends JSDocTag { @@ -1755,13 +1761,14 @@ declare namespace ts { } interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; + readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. */ fileExists(path: string): boolean; readFile(path: string): string | undefined; + trace?(s: string): void; } /** * Branded string for keeping track of when we've turned an ambiguous path @@ -1813,11 +1820,12 @@ declare namespace ts { isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; + getResolvedProjectReferences(): ReadonlyArray | undefined; } interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; + references?: ReadonlyArray; } interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ @@ -1841,17 +1849,6 @@ declare namespace ts { /** .ts file (index into sources array) associated with this span */ sourceIndex: number; } - interface SourceMapData { - sourceMapFilePath: string; - jsSourceMappingURL: string; - sourceMapFile: string; - sourceMapSourceRoot: string; - sourceMapSources: string[]; - sourceMapSourcesContent?: (string | null)[]; - inputSourceFileNames: string[]; - sourceMapNames?: string[]; - sourceMapMappings: string; - } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { Success = 0, @@ -1923,7 +1920,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): Symbol[]; + getRootSymbols(symbol: Symbol): ReadonlyArray; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -1941,7 +1938,6 @@ declare namespace ts { /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined; getJsxIntrinsicTagNamesAt(location: Node): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; @@ -2160,44 +2156,47 @@ declare namespace ts { Number = 8, Boolean = 16, Enum = 32, - StringLiteral = 64, - NumberLiteral = 128, - BooleanLiteral = 256, - EnumLiteral = 512, - ESSymbol = 1024, - UniqueESSymbol = 2048, - Void = 4096, - Undefined = 8192, - Null = 16384, - Never = 32768, - TypeParameter = 65536, - Object = 131072, - Union = 262144, - Intersection = 524288, - Index = 1048576, - IndexedAccess = 2097152, - Conditional = 4194304, - Substitution = 8388608, - NonPrimitive = 16777216, - Literal = 448, - Unit = 27072, - StringOrNumberLiteral = 192, - PossiblyFalsy = 29148, - StringLike = 68, - NumberLike = 168, - BooleanLike = 272, - EnumLike = 544, - ESSymbolLike = 3072, - VoidLike = 12288, - UnionOrIntersection = 786432, - StructuredType = 917504, - TypeVariable = 2162688, - InstantiableNonPrimitive = 14745600, - InstantiablePrimitive = 1048576, - Instantiable = 15794176, - StructuredOrInstantiable = 16711680, - Narrowable = 33492479, - NotUnionOrUnit = 16909315 + BigInt = 64, + StringLiteral = 128, + NumberLiteral = 256, + BooleanLiteral = 512, + EnumLiteral = 1024, + BigIntLiteral = 2048, + ESSymbol = 4096, + UniqueESSymbol = 8192, + Void = 16384, + Undefined = 32768, + Null = 65536, + Never = 131072, + TypeParameter = 262144, + Object = 524288, + Union = 1048576, + Intersection = 2097152, + Index = 4194304, + IndexedAccess = 8388608, + Conditional = 16777216, + Substitution = 33554432, + NonPrimitive = 67108864, + Literal = 2944, + Unit = 109440, + StringOrNumberLiteral = 384, + PossiblyFalsy = 117724, + StringLike = 132, + NumberLike = 296, + BigIntLike = 2112, + BooleanLike = 528, + EnumLike = 1056, + ESSymbolLike = 12288, + VoidLike = 49152, + UnionOrIntersection = 3145728, + StructuredType = 3670016, + TypeVariable = 8650752, + InstantiableNonPrimitive = 58982400, + InstantiablePrimitive = 4194304, + Instantiable = 63176704, + StructuredOrInstantiable = 66846720, + Narrowable = 133970943, + NotUnionOrUnit = 67637251 } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2208,7 +2207,7 @@ declare namespace ts { aliasTypeArguments?: ReadonlyArray; } interface LiteralType extends Type { - value: string | number; + value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } @@ -2221,6 +2220,9 @@ declare namespace ts { interface NumberLiteralType extends LiteralType { value: number; } + interface BigIntLiteralType extends LiteralType { + value: PseudoBigInt; + } interface EnumType extends Type { } enum ObjectFlags { @@ -2239,6 +2241,7 @@ declare namespace ts { JsxAttributes = 4096, MarkerType = 8192, JSLiteral = 16384, + FreshLiteral = 32768, ClassOrInterface = 3 } interface ObjectType extends Type { @@ -2670,6 +2673,8 @@ declare namespace ts { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; + /** True if `resolvedFileName` comes from `node_modules`. */ + isExternalLibraryImport?: boolean; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; @@ -2688,11 +2693,11 @@ declare namespace ts { useCaseSensitiveFileNames(): boolean; getNewLine(): string; readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; } @@ -2747,7 +2752,8 @@ declare namespace ts { Expression = 1, IdentifierName = 2, MappedTypeParameter = 3, - Unspecified = 4 + Unspecified = 4, + EmbeddedStatement = 5 } interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ @@ -2940,60 +2946,62 @@ declare namespace ts { BarDelimited = 4, AmpersandDelimited = 8, CommaDelimited = 16, - DelimitersMask = 28, - AllowTrailingComma = 32, - Indented = 64, - SpaceBetweenBraces = 128, - SpaceBetweenSiblings = 256, - Braces = 512, - Parenthesis = 1024, - AngleBrackets = 2048, - SquareBrackets = 4096, - BracketsMask = 7680, - OptionalIfUndefined = 8192, - OptionalIfEmpty = 16384, - Optional = 24576, - PreferNewLine = 32768, - NoTrailingNewLine = 65536, - NoInterveningComments = 131072, - NoSpaceIfEmpty = 262144, - SingleElement = 524288, - Modifiers = 131328, - HeritageClauses = 256, - SingleLineTypeLiteralMembers = 384, - MultiLineTypeLiteralMembers = 16449, - TupleTypeElements = 272, - UnionTypeConstituents = 260, - IntersectionTypeConstituents = 264, - ObjectBindingPatternElements = 262576, - ArrayBindingPatternElements = 262448, - ObjectLiteralExpressionProperties = 263122, - ArrayLiteralExpressionElements = 4466, - CommaListElements = 272, - CallExpressionArguments = 1296, - NewExpressionArguments = 9488, - TemplateExpressionSpans = 131072, - SingleLineBlockStatements = 384, - MultiLineBlockStatements = 65, - VariableDeclarationList = 272, - SingleLineFunctionBodyStatements = 384, + AsteriskDelimited = 32, + DelimitersMask = 60, + AllowTrailingComma = 64, + Indented = 128, + SpaceBetweenBraces = 256, + SpaceBetweenSiblings = 512, + Braces = 1024, + Parenthesis = 2048, + AngleBrackets = 4096, + SquareBrackets = 8192, + BracketsMask = 15360, + OptionalIfUndefined = 16384, + OptionalIfEmpty = 32768, + Optional = 49152, + PreferNewLine = 65536, + NoTrailingNewLine = 131072, + NoInterveningComments = 262144, + NoSpaceIfEmpty = 524288, + SingleElement = 1048576, + Modifiers = 262656, + HeritageClauses = 512, + SingleLineTypeLiteralMembers = 768, + MultiLineTypeLiteralMembers = 32897, + TupleTypeElements = 528, + UnionTypeConstituents = 516, + IntersectionTypeConstituents = 520, + ObjectBindingPatternElements = 525136, + ArrayBindingPatternElements = 524880, + ObjectLiteralExpressionProperties = 526226, + ArrayLiteralExpressionElements = 8914, + CommaListElements = 528, + CallExpressionArguments = 2576, + NewExpressionArguments = 18960, + TemplateExpressionSpans = 262144, + SingleLineBlockStatements = 768, + MultiLineBlockStatements = 129, + VariableDeclarationList = 528, + SingleLineFunctionBodyStatements = 768, MultiLineFunctionBodyStatements = 1, ClassHeritageClauses = 0, - ClassMembers = 65, - InterfaceMembers = 65, - EnumMembers = 81, - CaseBlockClauses = 65, - NamedImportsOrExportsElements = 262576, - JsxElementOrFragmentChildren = 131072, - JsxElementAttributes = 131328, - CaseOrDefaultClauseStatements = 81985, - HeritageClauseTypes = 272, - SourceFileStatements = 65537, - Decorators = 24577, - TypeArguments = 26896, - TypeParameters = 26896, - Parameters = 1296, - IndexSignatureParameters = 4432 + ClassMembers = 129, + InterfaceMembers = 129, + EnumMembers = 145, + CaseBlockClauses = 129, + NamedImportsOrExportsElements = 525136, + JsxElementOrFragmentChildren = 262144, + JsxElementAttributes = 262656, + CaseOrDefaultClauseStatements = 163969, + HeritageClauseTypes = 528, + SourceFileStatements = 131073, + Decorators = 49153, + TypeArguments = 53776, + TypeParameters = 53776, + Parameters = 2576, + IndexSignatureParameters = 8848, + JSDocComment = 33 } interface UserPreferences { readonly disableSuggestions?: boolean; @@ -3005,6 +3013,11 @@ declare namespace ts { readonly importModuleSpecifierEnding?: "minimal" | "index" | "js"; readonly allowTextChangesInNewFiles?: boolean; } + /** Represents a bigint literal value without requiring bigint support */ + interface PseudoBigInt { + negative: boolean; + base10Value: string; + } } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -3121,7 +3134,7 @@ declare namespace ts { /** Non-internal stuff goes here */ declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): T[]; + function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3287,6 +3300,7 @@ declare namespace ts { } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; + function isBigIntLiteral(node: Node): node is BigIntLiteral; function isStringLiteral(node: Node): node is StringLiteral; function isJsxText(node: Node): node is JsxText; function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral; @@ -3606,7 +3620,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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -3621,14 +3635,14 @@ declare namespace ts { * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string): Map; + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ interface NonRelativeModuleNameResolutionCache { - getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; + getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; @@ -3636,18 +3650,19 @@ declare namespace ts { } function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; - function createLiteral(value: number): NumericLiteral; + function createLiteral(value: number | PseudoBigInt): NumericLiteral; function createLiteral(value: boolean): BooleanLiteral; - function createLiteral(value: string | number | boolean): PrimaryExpression; + function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression; function createNumericLiteral(value: string): NumericLiteral; + function createBigIntLiteral(value: string): BigIntLiteral; function createStringLiteral(text: string): StringLiteral; function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; function createIdentifier(text: string): Identifier; @@ -4148,7 +4163,7 @@ declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -4384,9 +4399,9 @@ declare namespace ts { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; } /** * Host to create watch with root files and options @@ -4452,9 +4467,6 @@ declare namespace ts.server { type EventBeginInstallTypes = "event::beginInstallTypes"; type EventEndInstallTypes = "event::endInstallTypes"; type EventInitializationFailed = "event::initializationFailed"; - interface SortedReadonlyArray extends ReadonlyArray { - " __sortedArrayBrand": any; - } interface TypingInstallerResponse { readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | ActionValueInspected | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed; } @@ -4654,9 +4666,9 @@ declare namespace ts { realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4666,6 +4678,9 @@ declare namespace ts { installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; } + type WithMetadata = T & { + metadata?: unknown; + }; interface LanguageService { cleanupSemanticCache(): void; getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; @@ -4683,7 +4698,7 @@ declare namespace ts { getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined; + getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): WithMetadata | undefined; getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; @@ -4691,16 +4706,16 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; - getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; + getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -5040,24 +5055,25 @@ declare namespace ts { insertSpaceBeforeTypeAnnotation?: boolean; } interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterConstructor?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceAfterTypeAssertion?: boolean; - insertSpaceBeforeFunctionParenthesis?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; - insertSpaceBeforeTypeAnnotation?: boolean; - indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly insertSpaceAfterCommaDelimiter?: boolean; + readonly insertSpaceAfterSemicolonInForStatements?: boolean; + readonly insertSpaceBeforeAndAfterBinaryOperators?: boolean; + readonly insertSpaceAfterConstructor?: boolean; + readonly insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + readonly insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + readonly insertSpaceAfterTypeAssertion?: boolean; + readonly insertSpaceBeforeFunctionParenthesis?: boolean; + readonly placeOpenBraceOnNewLineForFunctions?: boolean; + readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; + readonly insertSpaceBeforeTypeAnnotation?: boolean; + readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; } + function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { kind: ScriptElementKind; name: string; @@ -5250,8 +5266,9 @@ declare namespace ts { Whitespace = 4, Identifier = 5, NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8 + BigIntLiteral = 7, + StringLiteral = 8, + RegExpLiteral = 9 } interface ClassificationResult { finalLexState: EndOfLineState; @@ -5363,13 +5380,20 @@ declare namespace ts { ambientModifier = "declare", staticModifier = "static", abstractModifier = "abstract", - optionalModifier = "optional" + optionalModifier = "optional", + dtsModifier = ".d.ts", + tsModifier = ".ts", + tsxModifier = ".tsx", + jsModifier = ".js", + jsxModifier = ".jsx", + jsonModifier = ".json" } enum ClassificationTypeNames { comment = "comment", identifier = "identifier", keyword = "keyword", numericLiteral = "number", + bigintLiteral = "bigint", operator = "operator", stringLiteral = "string", whiteSpace = "whitespace", @@ -5414,7 +5438,8 @@ declare namespace ts { jsxSelfClosingTagName = 21, jsxAttribute = 22, jsxText = 23, - jsxAttributeStringLiteralValue = 24 + jsxAttributeStringLiteralValue = 24, + bigintLiteral = 25 } } declare namespace ts { @@ -5506,6 +5531,10 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } +declare namespace ts { + function generateTypesForModule(name: string, moduleValue: unknown, formatSettings: FormatCodeSettings): string; + function generateTypesForGlobal(name: string, globalValue: unknown, formatSettings: FormatCodeSettings): string; +} declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index bb0d451215a..9b296e619a2 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -478,10 +478,33 @@ var ts; return result; } ts.flatten = flatten; + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ function flatMap(array, mapfn) { var result; if (array) { - result = []; + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || ts.emptyArray; + } + ts.flatMap = flatMap; + function flatMapToMutable(array, mapfn) { + var result = []; + if (array) { for (var i = 0; i < array.length; i++) { var v = mapfn(array[i], i); if (v) { @@ -496,7 +519,7 @@ var ts; } return result; } - ts.flatMap = flatMap; + ts.flatMapToMutable = flatMapToMutable; function flatMapIterator(iter, mapfn) { var first = iter.next(); if (first.done) { @@ -735,7 +758,7 @@ var ts; */ function deduplicateSorted(array, comparer) { if (array.length === 0) - return []; + return ts.emptyArray; var last = array[0]; var deduplicated = [last]; for (var i = 1; i < array.length; i++) { @@ -766,7 +789,7 @@ var ts; } ts.insertSorted = insertSorted; function sortAndDeduplicate(array, comparer, equalityComparer) { - return deduplicateSorted(sort(array, comparer), equalityComparer || comparer); + return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive); } ts.sortAndDeduplicate = sortAndDeduplicate; function arrayIsEqualTo(array1, array2, equalityComparer) { @@ -919,7 +942,7 @@ var ts; * Returns a new sorted array. */ function sort(array, comparer) { - return array.slice().sort(comparer); + return (array.length === 0 ? array : array.slice().sort(comparer)); } ts.sort = sort; function arrayIterator(array) { @@ -1025,12 +1048,25 @@ var ts; * @param offset An offset into `array` at which to start the search. */ function binarySearch(array, value, keySelector, keyComparer, offset) { - if (!array || array.length === 0) { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); + } + ts.binarySearch = binarySearch; + /** + * Performs a binary search, finding the index at which an object with `key` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `key`. + * @param array A sorted array whose first element must be no larger than number + * @param key The key to be searched for in the array. + * @param keySelector A callback used to select the search key from each element of `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + */ + function binarySearchKey(array, key, keySelector, keyComparer, offset) { + if (!some(array)) { return -1; } var low = offset || 0; var high = array.length - 1; - var key = keySelector(value); while (low <= high) { var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle]); @@ -1047,7 +1083,7 @@ var ts; } return ~low; } - ts.binarySearch = binarySearch; + ts.binarySearchKey = binarySearchKey; function reduceLeft(array, f, initial, start, count) { if (array && array.length > 0) { var size = array.length; @@ -1971,6 +2007,33 @@ var ts; var counts; var marks; var measures; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; /** * Marks a performance event. * @@ -2425,368 +2488,370 @@ var ts; SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["BigIntLiteral"] = 9] = "BigIntLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 11] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 12] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 13] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 14] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 15] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 16] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 17] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 18] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 19] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 20] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 21] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 22] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 23] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 24] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 59] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 60] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 61] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 62] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 63] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 64] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 65] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 66] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 69] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 70] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 71] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 72] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 73] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 74] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 75] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 76] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 77] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 78] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 79] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 80] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 81] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 82] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 83] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 84] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 85] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 86] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 87] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 88] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 89] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 90] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 91] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 92] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 93] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 94] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 95] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 96] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 97] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 98] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 99] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 100] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 101] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 102] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 103] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 104] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 105] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 106] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 107] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 108] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 109] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 110] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 111] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 112] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 113] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 114] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 115] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 116] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 117] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 126] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 127] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 128] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 129] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 130] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 131] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 132] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 133] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 134] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 135] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 136] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 137] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 138] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 118] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 119] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 120] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 121] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 122] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 123] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 124] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 125] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 126] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 127] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 128] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 129] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 130] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 131] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 132] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 133] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 134] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 135] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 136] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 137] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 138] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 139] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 140] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 141] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 142] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 143] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 144] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 145] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 146] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 147] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 148] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 149] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 150] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 151] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 152] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 153] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 154] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 155] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 156] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 157] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 158] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 159] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 160] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 161] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 162] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 163] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 164] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 165] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 166] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 167] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 168] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 169] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 170] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 171] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 172] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 173] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 174] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 175] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 176] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 177] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 178] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 179] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 180] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 181] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 182] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 183] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 184] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 185] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 186] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 187] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 188] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 189] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 190] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 191] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 192] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 193] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 194] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 195] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 196] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 197] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 198] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 199] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 200] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 201] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 202] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 203] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 204] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 205] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 206] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 207] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 208] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 209] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 210] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 211] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 212] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 213] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 214] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 215] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 216] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 217] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 218] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 219] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 220] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 221] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 222] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 223] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 224] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 225] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 226] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 227] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 228] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 229] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 230] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 231] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 232] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 233] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 234] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 235] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 236] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 237] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 238] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 239] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 240] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 241] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 242] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 243] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 244] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 245] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 246] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 247] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 248] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 249] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 250] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 251] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 252] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 253] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 254] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 255] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 256] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 257] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 258] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 259] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 260] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 261] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 262] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 263] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 264] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 265] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 266] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 267] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 268] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 269] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 270] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 271] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 272] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 273] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 274] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 275] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 276] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 296] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 297] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 298] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 299] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 300] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 301] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 302] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 303] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 304] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 305] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 306] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 307] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 308] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 309] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 310] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 60] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 71] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 73] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 108] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 73] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 147] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 109] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 117] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 163] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 183] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 71] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 147] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 303] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 303] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3076,14 +3141,15 @@ var ts; // of a type, such as the global `Promise` type in lib.d.ts). TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; // with call signatures. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; (function (SymbolFlags) { @@ -3238,29 +3304,27 @@ var ts; TypeFlags[TypeFlags["Number"] = 8] = "Number"; TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 4096] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 16384] = "Null"; - TypeFlags[TypeFlags["Never"] = 32768] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 131072] = "Object"; - TypeFlags[TypeFlags["Union"] = 262144] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; - TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; - /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; - /* @internal */ - TypeFlags[TypeFlags["UnionOfPrimitiveTypes"] = 67108864] = "UnionOfPrimitiveTypes"; + TypeFlags[TypeFlags["BigInt"] = 64] = "BigInt"; + TypeFlags[TypeFlags["StringLiteral"] = 128] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 256] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 512] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 1024] = "EnumLiteral"; + TypeFlags[TypeFlags["BigIntLiteral"] = 2048] = "BigIntLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 4096] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 8192] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 16384] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32768] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 65536] = "Null"; + TypeFlags[TypeFlags["Never"] = 131072] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 262144] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 524288] = "Object"; + TypeFlags[TypeFlags["Union"] = 1048576] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 2097152] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 4194304] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 8388608] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; /* @internal */ TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ @@ -3270,40 +3334,41 @@ var ts; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 98304] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 2944] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 117724] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 67359327] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 131068] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 132] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 296] = "NumberLike"; + TypeFlags[TypeFlags["BigIntLike"] = 2112] = "BigIntLike"; + TypeFlags[TypeFlags["BooleanLike"] = 528] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 1056] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 16748579] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ @@ -3338,6 +3403,7 @@ var ts; ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ @@ -3349,6 +3415,13 @@ var ts; Variance[Variance["Bivariant"] = 3] = "Bivariant"; Variance[Variance["Independent"] = 4] = "Independent"; })(Variance = ts.Variance || (ts.Variance = {})); + /* @internal */ + var JsxReferenceKind; + (function (JsxReferenceKind) { + JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; + JsxReferenceKind[JsxReferenceKind["Function"] = 1] = "Function"; + JsxReferenceKind[JsxReferenceKind["Mixed"] = 2] = "Mixed"; + })(JsxReferenceKind = ts.JsxReferenceKind || (ts.JsxReferenceKind = {})); var SignatureKind; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; @@ -3409,6 +3482,15 @@ var ts; AssignmentDeclarationKind[AssignmentDeclarationKind["Property"] = 5] = "Property"; // F.prototype = { ... } AssignmentDeclarationKind[AssignmentDeclarationKind["Prototype"] = 6] = "Prototype"; + // Object.defineProperty(x, 'name', { value: any, writable?: boolean (false by default) }); + // Object.defineProperty(x, 'name', { get: Function, set: Function }); + // Object.defineProperty(x, 'name', { get: Function }); + // Object.defineProperty(x, 'name', { set: Function }); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyValue"] = 7] = "ObjectDefinePropertyValue"; + // Object.defineProperty(exports || module.exports, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyExports"] = 8] = "ObjectDefinePropertyExports"; + // Object.defineProperty(Foo.prototype, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePrototypeProperty"] = 9] = "ObjectDefinePrototypeProperty"; })(AssignmentDeclarationKind = ts.AssignmentDeclarationKind || (ts.AssignmentDeclarationKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -3776,6 +3858,7 @@ var ts; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; + EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); var ListFormat; (function (ListFormat) { @@ -3790,64 +3873,66 @@ var ts; ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["AsteriskDelimited"] = 32] = "AsteriskDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 60] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 64] = "AllowTrailingComma"; // Whitespace - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Indented"] = 128] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 256] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 512] = "SpaceBetweenSiblings"; // Brackets/Braces - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["Braces"] = 1024] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 2048] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 4096] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 8192] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 15360] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 16384] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 32768] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 49152] = "Optional"; // Other - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; - ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; + ListFormat[ListFormat["PreferNewLine"] = 65536] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 131072] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 262144] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 524288] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 1048576] = "SingleElement"; // Precomputed Formats - ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 384] = "SingleLineTypeLiteralMembers"; - ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 16449] = "MultiLineTypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 272] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 262576] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 262448] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["Modifiers"] = 262656] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 512] = "HeritageClauses"; + ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 768] = "SingleLineTypeLiteralMembers"; + ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 32897] = "MultiLineTypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 528] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 516] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 520] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 525136] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 524880] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 526226] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 8914] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CommaListElements"] = 528] = "CommaListElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 2576] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 18960] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 262144] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 768] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 129] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 528] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 768] = "SingleLineFunctionBodyStatements"; ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; ListFormat[ListFormat["ClassHeritageClauses"] = 0] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 262576] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 131072] = "JsxElementOrFragmentChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26896] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26896] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1296] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + ListFormat[ListFormat["ClassMembers"] = 129] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 129] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 145] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 129] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 525136] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 262144] = "JsxElementOrFragmentChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 262656] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 163969] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 528] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 131073] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 49153] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 53776] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 53776] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 2576] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 8848] = "IndexSignatureParameters"; + ListFormat[ListFormat["JSDocComment"] = 33] = "JSDocComment"; })(ListFormat = ts.ListFormat || (ts.ListFormat = {})); /* @internal */ var PragmaKindFlags; @@ -5151,6 +5236,7 @@ var ts; use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), 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."), @@ -5207,14 +5293,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number' or an enum type."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), @@ -5421,9 +5507,9 @@ var ts; No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), @@ -5521,6 +5607,13 @@ var ts; Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), It_is_highly_likely_that_you_are_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "It_is_highly_likely_that_you_are_missing_a_semicolon_2734", "It is highly likely that you are missing a semicolon."), + Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), + Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), + BigInt_literals_are_not_available_when_targeting_lower_than_ESNext: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ESNext_2737", "BigInt literals are not available when targeting lower than ESNext."), + An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, ts.DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."), + Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."), 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}'."), @@ -5837,6 +5930,9 @@ var ts; Did_you_mean_to_call_this_expression: diag(6212, ts.DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"), Did_you_mean_to_use_new_with_this_expression: diag(6213, ts.DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"), Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, ts.DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."), + Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."), + Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."), + Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5877,6 +5973,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."), Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."), Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."), + Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, ts.DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."), Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."), Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."), Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."), @@ -5904,6 +6001,14 @@ var ts; If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any_7041", "The containing arrow function captures the global value of 'this' which implicitly has type 'any'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), + Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, ts.DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, ts.DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."), + Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, ts.DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."), + _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."), 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_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -6065,6 +6170,8 @@ var ts; Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), Generate_types_for_0: diag(95067, ts.DiagnosticCategory.Message, "Generate_types_for_0_95067", "Generate types for '{0}'"), Generate_types_for_all_packages_without_types: diag(95068, ts.DiagnosticCategory.Message, "Generate_types_for_all_packages_without_types_95068", "Generate types for all packages without types"), + Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), + Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), }; })(ts || (ts = {})); var ts; @@ -6072,93 +6179,94 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 71 /* Identifier */; + return token >= 72 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 117 /* AbstractKeyword */, - any: 119 /* AnyKeyword */, - as: 118 /* AsKeyword */, - boolean: 122 /* BooleanKeyword */, - break: 72 /* BreakKeyword */, - case: 73 /* CaseKeyword */, - catch: 74 /* CatchKeyword */, - class: 75 /* ClassKeyword */, - continue: 77 /* ContinueKeyword */, - const: 76 /* ConstKeyword */ + abstract: 118 /* AbstractKeyword */, + any: 120 /* AnyKeyword */, + as: 119 /* AsKeyword */, + bigint: 146 /* BigIntKeyword */, + boolean: 123 /* BooleanKeyword */, + break: 73 /* BreakKeyword */, + case: 74 /* CaseKeyword */, + catch: 75 /* CatchKeyword */, + class: 76 /* ClassKeyword */, + continue: 78 /* ContinueKeyword */, + const: 77 /* ConstKeyword */ }, - _a["" + "constructor"] = 123 /* ConstructorKeyword */, - _a.debugger = 78 /* DebuggerKeyword */, - _a.declare = 124 /* DeclareKeyword */, - _a.default = 79 /* DefaultKeyword */, - _a.delete = 80 /* DeleteKeyword */, - _a.do = 81 /* DoKeyword */, - _a.else = 82 /* ElseKeyword */, - _a.enum = 83 /* EnumKeyword */, - _a.export = 84 /* ExportKeyword */, - _a.extends = 85 /* ExtendsKeyword */, - _a.false = 86 /* FalseKeyword */, - _a.finally = 87 /* FinallyKeyword */, - _a.for = 88 /* ForKeyword */, - _a.from = 143 /* FromKeyword */, - _a.function = 89 /* FunctionKeyword */, - _a.get = 125 /* GetKeyword */, - _a.if = 90 /* IfKeyword */, - _a.implements = 108 /* ImplementsKeyword */, - _a.import = 91 /* ImportKeyword */, - _a.in = 92 /* InKeyword */, - _a.infer = 126 /* InferKeyword */, - _a.instanceof = 93 /* InstanceOfKeyword */, - _a.interface = 109 /* InterfaceKeyword */, - _a.is = 127 /* IsKeyword */, - _a.keyof = 128 /* KeyOfKeyword */, - _a.let = 110 /* LetKeyword */, - _a.module = 129 /* ModuleKeyword */, - _a.namespace = 130 /* NamespaceKeyword */, - _a.never = 131 /* NeverKeyword */, - _a.new = 94 /* NewKeyword */, - _a.null = 95 /* NullKeyword */, - _a.number = 134 /* NumberKeyword */, - _a.object = 135 /* ObjectKeyword */, - _a.package = 111 /* PackageKeyword */, - _a.private = 112 /* PrivateKeyword */, - _a.protected = 113 /* ProtectedKeyword */, - _a.public = 114 /* PublicKeyword */, - _a.readonly = 132 /* ReadonlyKeyword */, - _a.require = 133 /* RequireKeyword */, - _a.global = 144 /* GlobalKeyword */, - _a.return = 96 /* ReturnKeyword */, - _a.set = 136 /* SetKeyword */, - _a.static = 115 /* StaticKeyword */, - _a.string = 137 /* StringKeyword */, - _a.super = 97 /* SuperKeyword */, - _a.switch = 98 /* SwitchKeyword */, - _a.symbol = 138 /* SymbolKeyword */, - _a.this = 99 /* ThisKeyword */, - _a.throw = 100 /* ThrowKeyword */, - _a.true = 101 /* TrueKeyword */, - _a.try = 102 /* TryKeyword */, - _a.type = 139 /* TypeKeyword */, - _a.typeof = 103 /* TypeOfKeyword */, - _a.undefined = 140 /* UndefinedKeyword */, - _a.unique = 141 /* UniqueKeyword */, - _a.unknown = 142 /* UnknownKeyword */, - _a.var = 104 /* VarKeyword */, - _a.void = 105 /* VoidKeyword */, - _a.while = 106 /* WhileKeyword */, - _a.with = 107 /* WithKeyword */, - _a.yield = 116 /* YieldKeyword */, - _a.async = 120 /* AsyncKeyword */, - _a.await = 121 /* AwaitKeyword */, - _a.of = 145 /* OfKeyword */, + _a["" + "constructor"] = 124 /* ConstructorKeyword */, + _a.debugger = 79 /* DebuggerKeyword */, + _a.declare = 125 /* DeclareKeyword */, + _a.default = 80 /* DefaultKeyword */, + _a.delete = 81 /* DeleteKeyword */, + _a.do = 82 /* DoKeyword */, + _a.else = 83 /* ElseKeyword */, + _a.enum = 84 /* EnumKeyword */, + _a.export = 85 /* ExportKeyword */, + _a.extends = 86 /* ExtendsKeyword */, + _a.false = 87 /* FalseKeyword */, + _a.finally = 88 /* FinallyKeyword */, + _a.for = 89 /* ForKeyword */, + _a.from = 144 /* FromKeyword */, + _a.function = 90 /* FunctionKeyword */, + _a.get = 126 /* GetKeyword */, + _a.if = 91 /* IfKeyword */, + _a.implements = 109 /* ImplementsKeyword */, + _a.import = 92 /* ImportKeyword */, + _a.in = 93 /* InKeyword */, + _a.infer = 127 /* InferKeyword */, + _a.instanceof = 94 /* InstanceOfKeyword */, + _a.interface = 110 /* InterfaceKeyword */, + _a.is = 128 /* IsKeyword */, + _a.keyof = 129 /* KeyOfKeyword */, + _a.let = 111 /* LetKeyword */, + _a.module = 130 /* ModuleKeyword */, + _a.namespace = 131 /* NamespaceKeyword */, + _a.never = 132 /* NeverKeyword */, + _a.new = 95 /* NewKeyword */, + _a.null = 96 /* NullKeyword */, + _a.number = 135 /* NumberKeyword */, + _a.object = 136 /* ObjectKeyword */, + _a.package = 112 /* PackageKeyword */, + _a.private = 113 /* PrivateKeyword */, + _a.protected = 114 /* ProtectedKeyword */, + _a.public = 115 /* PublicKeyword */, + _a.readonly = 133 /* ReadonlyKeyword */, + _a.require = 134 /* RequireKeyword */, + _a.global = 145 /* GlobalKeyword */, + _a.return = 97 /* ReturnKeyword */, + _a.set = 137 /* SetKeyword */, + _a.static = 116 /* StaticKeyword */, + _a.string = 138 /* StringKeyword */, + _a.super = 98 /* SuperKeyword */, + _a.switch = 99 /* SwitchKeyword */, + _a.symbol = 139 /* SymbolKeyword */, + _a.this = 100 /* ThisKeyword */, + _a.throw = 101 /* ThrowKeyword */, + _a.true = 102 /* TrueKeyword */, + _a.try = 103 /* TryKeyword */, + _a.type = 140 /* TypeKeyword */, + _a.typeof = 104 /* TypeOfKeyword */, + _a.undefined = 141 /* UndefinedKeyword */, + _a.unique = 142 /* UniqueKeyword */, + _a.unknown = 143 /* UnknownKeyword */, + _a.var = 105 /* VarKeyword */, + _a.void = 106 /* VoidKeyword */, + _a.while = 107 /* WhileKeyword */, + _a.with = 108 /* WithKeyword */, + _a.yield = 117 /* YieldKeyword */, + _a.async = 121 /* AsyncKeyword */, + _a.await = 122 /* AwaitKeyword */, + _a.of = 147 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 59 /* EqualsToken */, "+=": 60 /* PlusEqualsToken */, "-=": 61 /* MinusEqualsToken */, "*=": 62 /* AsteriskEqualsToken */, "**=": 63 /* AsteriskAsteriskEqualsToken */, "/=": 64 /* SlashEqualsToken */, "%=": 65 /* PercentEqualsToken */, "<<=": 66 /* LessThanLessThanEqualsToken */, ">>=": 67 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 69 /* AmpersandEqualsToken */, "|=": 70 /* BarEqualsToken */, "^=": 71 /* CaretEqualsToken */, "@": 58 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6747,8 +6855,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; }, + isIdentifier: function () { return token === 72 /* Identifier */ || token > 108 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -6842,18 +6950,29 @@ var ts; end = pos; } } + var result; if (tokenFlags & 512 /* ContainsSeparator */) { - var result = mainFragment; + result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; } if (scientificFragment) { result += scientificFragment; } - return "" + +result; } else { - return "" + +(text.substring(start, end)); // No need to use all the fragments; no _ removal needed + result = text.substring(start, end); // No need to use all the fragments; no _ removal needed + } + if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { + return { + type: 8 /* NumericLiteral */, + value: "" + +result // if value is not an integer, it can be safely coerced to a number + }; + } + else { + tokenValue = result; + var type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint + return { type: type, value: tokenValue }; } } function scanOctalDigits() { @@ -6868,21 +6987,21 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count, canHaveSeparators) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + var valueString = scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + return valueString ? parseInt(valueString, 16) : -1; } /** * Scans as many hexadecimal digits as are available in the text, - * returning -1 if the given number of digits was unavailable. + * returning "" if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count, canHaveSeparators) { return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true, canHaveSeparators); } function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) { - var digits = 0; - var value = 0; + var valueChars = []; var allowSeparator = false; var isPreviousTokenSeparator = false; - while (digits < minCount || scanAsManyAsPossible) { + while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); if (canHaveSeparators && ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; @@ -6900,29 +7019,24 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; + if (ch >= 65 /* A */ && ch <= 70 /* F */) { + ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { + else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || + (ch >= 97 /* a */ && ch <= 102 /* f */))) { break; } + valueChars.push(ch); pos++; - digits++; isPreviousTokenSeparator = false; } - if (digits < minCount) { - value = -1; + if (valueChars.length < minCount) { + valueChars = []; } if (text.charCodeAt(pos - 1) === 95 /* _ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } - return value; + return String.fromCharCode.apply(String, valueChars); } function scanString(jsxAttributeString) { if (jsxAttributeString === void 0) { jsxAttributeString = false; } @@ -6974,7 +7088,7 @@ var ts; contents += text.substring(start, pos); tokenFlags |= 4 /* Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -6982,14 +7096,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; break; } // Escape character @@ -7082,7 +7196,8 @@ var ts; } } function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; var isInvalidExtendedEscape = false; // Validate the value of the digit if (escapedValue < 0) { @@ -7170,14 +7285,12 @@ var ts; } } } - return token = 71 /* Identifier */; + return token = 72 /* Identifier */; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; + var value = ""; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. - var numberOfDigits = 0; var separatorAllowed = false; var isPreviousTokenSeparator = false; while (true) { @@ -7199,27 +7312,42 @@ var ts; continue; } separatorAllowed = true; - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { + if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { break; } - value = value * base + valueOfCh; + value += text[pos]; pos++; - numberOfDigits++; isPreviousTokenSeparator = false; } - // Invalid binaryIntegerLiteral or octalIntegerLiteral - if (numberOfDigits === 0) { - return -1; - } if (text.charCodeAt(pos - 1) === 95 /* _ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); - return value; } return value; } + function checkBigIntSuffix() { + if (text.charCodeAt(pos) === 110 /* n */) { + tokenValue += "n"; + // Use base 10 instead of base 2 or base 8 for shorter literals + if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; + } + pos++; + return 9 /* 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 */ + ? parseInt(tokenValue.slice(2), 2) // skip "0b" + : tokenFlags & 256 /* OctalSpecifier */ + ? parseInt(tokenValue.slice(2), 8) // skip "0o" + : +tokenValue; + tokenValue = "" + numericValue; + return 8 /* NumericLiteral */; + } + } function scan() { + var _a; startPos = pos; tokenFlags = 0; var asteriskSeen = false; @@ -7292,48 +7420,48 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 33 /* ExclamationEqualsToken */; + return pos += 2, token = 34 /* ExclamationEqualsToken */; } pos++; - return token = 51 /* ExclamationToken */; + return token = 52 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PercentEqualsToken */; + return pos += 2, token = 65 /* PercentEqualsToken */; } pos++; - return token = 42 /* PercentToken */; + return token = 43 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 53 /* AmpersandAmpersandToken */; + return pos += 2, token = 54 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* AmpersandEqualsToken */; + return pos += 2, token = 69 /* AmpersandEqualsToken */; } pos++; - return token = 48 /* AmpersandToken */; + return token = 49 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 19 /* OpenParenToken */; + return token = 20 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 20 /* CloseParenToken */; + return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* AsteriskEqualsToken */; + return pos += 2, token = 62 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 63 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 40 /* AsteriskAsteriskToken */; + return pos += 2, token = 41 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7341,38 +7469,38 @@ var ts; asteriskSeen = true; continue; } - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 43 /* PlusPlusToken */; + return pos += 2, token = 44 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PlusEqualsToken */; + return pos += 2, token = 60 /* PlusEqualsToken */; } pos++; - return token = 37 /* PlusToken */; + return token = 38 /* PlusToken */; case 44 /* comma */: pos++; - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 44 /* MinusMinusToken */; + return pos += 2, token = 45 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* MinusEqualsToken */; + return pos += 2, token = 61 /* MinusEqualsToken */; } pos++; - return token = 38 /* MinusToken */; + return token = 39 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); + tokenValue = scanNumber().value; return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 24 /* DotDotDotToken */; + return pos += 3, token = 25 /* DotDotDotToken */; } pos++; - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -7423,43 +7551,43 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* SlashEqualsToken */; + return pos += 2, token = 64 /* SlashEqualsToken */; } pos++; - return token = 41 /* SlashToken */; + return token = 42 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; - var value = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); - if (value < 0) { + tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); + if (!tokenValue) { error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0x" + tokenValue; tokenFlags |= 64 /* HexSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 2); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 2); + if (!tokenValue) { error(ts.Diagnostics.Binary_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0b" + tokenValue; tokenFlags |= 128 /* BinarySpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 8); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 8); + if (!tokenValue) { error(ts.Diagnostics.Octal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0o" + tokenValue; tokenFlags |= 256 /* OctalSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -7480,14 +7608,14 @@ var ts; case 55 /* _7 */: case 56 /* _8 */: case 57 /* _9 */: - tokenValue = scanNumber(); - return token = 8 /* NumericLiteral */; + (_a = scanNumber(), token = _a.type, tokenValue = _a.value); + return token; case 58 /* colon */: pos++; - return token = 56 /* ColonToken */; + return token = 57 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 25 /* SemicolonToken */; + return token = 26 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7500,20 +7628,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 66 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 45 /* LessThanLessThanToken */; + return pos += 2, token = 46 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 30 /* LessThanEqualsToken */; + return pos += 2, token = 31 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 28 /* LessThanSlashToken */; + return pos += 2, token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7526,15 +7654,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 34 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 32 /* EqualsEqualsToken */; + return pos += 2, token = 33 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 36 /* EqualsGreaterThanToken */; + return pos += 2, token = 37 /* EqualsGreaterThanToken */; } pos++; - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7546,25 +7674,25 @@ var ts; } } pos++; - return token = 29 /* GreaterThanToken */; + return token = 30 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 55 /* QuestionToken */; + return token = 56 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* CaretEqualsToken */; + return pos += 2, token = 71 /* CaretEqualsToken */; } pos++; - return token = 50 /* CaretToken */; + return token = 51 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 124 /* bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7576,22 +7704,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 54 /* BarBarToken */; + return pos += 2, token = 55 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* BarEqualsToken */; + return pos += 2, token = 70 /* BarEqualsToken */; } pos++; - return token = 49 /* BarToken */; + return token = 50 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 52 /* TildeToken */; + return token = 53 /* TildeToken */; case 64 /* at */: pos++; - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -7629,29 +7757,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* 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 = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 67 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 46 /* GreaterThanGreaterThanToken */; + return token = 47 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 31 /* GreaterThanEqualsToken */; + return token = 32 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) { + if (token === 42 /* SlashToken */ || token === 64 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -7696,7 +7824,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 12 /* RegularExpressionLiteral */; + token = 13 /* RegularExpressionLiteral */; } return token; } @@ -7704,7 +7832,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -7721,14 +7849,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 28 /* LessThanSlashToken */; + return token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -7760,7 +7888,7 @@ var ts; } pos++; } - return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -7786,7 +7914,7 @@ var ts; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -7810,36 +7938,36 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 123 /* openBrace */: - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 91 /* openBracket */: - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 44 /* comma */: - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 46 /* dot */: - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 96 /* backtick */: while (pos < end && text.charCodeAt(pos) !== 96 /* backtick */) { pos++; } tokenValue = text.substring(tokenPos + 1, pos); pos++; - return token = 13 /* NoSubstitutionTemplateLiteral */; + return token = 14 /* NoSubstitutionTemplateLiteral */; } if (isIdentifierStart(ch, 6 /* Latest */)) { while (isIdentifierPart(text.charCodeAt(pos), 6 /* Latest */) && pos < end) { @@ -7992,7 +8120,6 @@ var ts; getText: function () { return str; }, write: writeText, rawWrite: writeText, - writeTextOfNode: writeText, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -8001,7 +8128,9 @@ var ts; writeLiteral: writeText, writeParameter: writeText, writeProperty: writeText, - writeSymbol: writeText, + writeSymbol: function (s, _) { return writeText(s); }, + writeTrailingSemicolon: writeText, + writeComment: writeText, getTextPos: function () { return str.length; }, getLine: function () { return 0; }, getColumn: function () { return 0; }, @@ -8200,7 +8329,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { + while (node && node.kind !== 279 /* SourceFile */) { node = node.parent; } return node; @@ -8208,11 +8337,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return true; } return false; @@ -8346,7 +8475,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 === 304 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8365,7 +8494,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 281 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8407,32 +8536,34 @@ var ts; function getLiteralText(node, sourceFile, neverAsciiEscape) { // 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 (!nodeIsSynthesized(node) && node.parent && !(ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */)) { + if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) || + ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // 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 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.singleQuote) { return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; } else { return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return "`" + escapeText(node.text, 96 /* backtick */) + "`"; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: // tslint:disable-next-line no-invalid-template-strings return "`" + escapeText(node.text, 96 /* backtick */) + "${"; - case 15 /* TemplateMiddle */: + case 16 /* TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings return "}" + escapeText(node.text, 96 /* backtick */) + "${"; - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: + case 9 /* BigIntLiteral */: + case 13 /* RegularExpressionLiteral */: return node.text; } return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -8455,15 +8586,15 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; + return node.kind === 237 /* VariableDeclaration */ && node.parent.kind === 274 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 9 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -8487,11 +8618,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 277 /* SourceFile */ || - node.kind === 242 /* ModuleDeclaration */ || + return node.kind === 279 /* SourceFile */ || + node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8508,9 +8639,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 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node.parent); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8526,22 +8657,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 272 /* CatchClause */: - case 242 /* ModuleDeclaration */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 274 /* CatchClause */: + case 244 /* ModuleDeclaration */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 216 /* Block */: + case 218 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8551,9 +8682,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 291 /* JSDocSignature */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 293 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8563,25 +8694,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -8591,8 +8722,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8601,15 +8732,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 217 /* VariableStatement */: - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 219 /* VariableStatement */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -8639,12 +8770,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isStringOrNumericLiteralLike(name.expression) ? ts.escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: return ts.Debug.assertNever(name); @@ -8653,11 +8785,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8702,7 +8834,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 216 /* Block */) { + if (node.body && node.body.kind === 218 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8716,7 +8848,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* 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 @@ -8725,25 +8857,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: errorNode = node.name; break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8792,11 +8924,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 98 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 92 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { @@ -8804,20 +8936,20 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 219 /* ExpressionStatement */ - && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 221 /* ExpressionStatement */ + && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 149 /* Parameter */ || - node.kind === 148 /* TypeParameter */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 195 /* ArrowFunction */ || - node.kind === 193 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 151 /* Parameter */ || + node.kind === 150 /* TypeParameter */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 197 /* ArrowFunction */ || + node.kind === 195 /* ParenthesizedExpression */) ? 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 '/**/' @@ -8833,47 +8965,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= node.kind && node.kind <= 183 /* LastTypeNode */) { return true; } switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 134 /* NumberKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: return true; - case 105 /* VoidKeyword */: - return node.parent.kind !== 198 /* VoidExpression */; - case 209 /* ExpressionWithTypeArguments */: + case 106 /* VoidKeyword */: + return node.parent.kind !== 200 /* VoidExpression */; + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 148 /* TypeParameter */: - return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; + case 150 /* TypeParameter */: + return node.parent.kind === 181 /* MappedType */ || node.parent.kind === 176 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 71 /* Identifier */: + case 72 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 189 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */ || node.kind === 189 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 146 /* QualifiedName */: - case 187 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: { + case 148 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 100 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 165 /* TypeQuery */) { + if (parent.kind === 167 /* TypeQuery */) { return false; } - if (parent.kind === 181 /* ImportType */) { + if (parent.kind === 183 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8882,40 +9015,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 (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= parent.kind && parent.kind <= 183 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return node === parent.constraint; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return node === parent.constraint; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return node === parent.type; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node === parent.type; - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return node === parent.type; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return node === parent.type; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8940,23 +9073,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitor(node); - case 244 /* CaseBlock */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 246 /* CaseBlock */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8966,26 +9099,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* 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); @@ -9008,10 +9141,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 167 /* ArrayType */) { + if (node && node.kind === 169 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 162 /* TypeReference */) { + else if (node && node.kind === 164 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9021,12 +9154,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 166 /* TypeLiteral */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 168 /* TypeLiteral */: return node.members; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return node.properties; } } @@ -9034,14 +9167,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 184 /* BindingElement */: - case 276 /* EnumMember */: - case 149 /* Parameter */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 274 /* ShorthandPropertyAssignment */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 278 /* EnumMember */: + case 151 /* Parameter */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 276 /* ShorthandPropertyAssignment */: + case 237 /* VariableDeclaration */: return true; } } @@ -9053,8 +9186,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 236 /* VariableDeclarationList */ - && node.parent.parent.kind === 217 /* VariableStatement */; + return node.parent.kind === 238 /* VariableDeclarationList */ + && node.parent.parent.kind === 219 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9065,13 +9198,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return true; } return false; @@ -9082,7 +9215,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 231 /* LabeledStatement */) { + if (node.statement.kind !== 233 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9090,17 +9223,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 218 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; + return node && node.kind === 156 /* MethodDeclaration */ && node.parent.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 186 /* ObjectLiteralExpression */ || - node.parent.kind === 207 /* ClassExpression */); + return node.kind === 156 /* MethodDeclaration */ && + (node.parent.kind === 188 /* ObjectLiteralExpression */ || + node.parent.kind === 209 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9113,7 +9246,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 273 /* PropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9150,14 +9283,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 277 /* SourceFile */); + ts.Debug.assert(node.kind !== 279 /* 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 147 /* ComputedPropertyName */: + case 149 /* 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 @@ -9172,9 +9305,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9185,26 +9318,26 @@ var ts; node = node.parent; } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 242 /* ModuleDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 241 /* EnumDeclaration */: - case 277 /* SourceFile */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 244 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 243 /* EnumDeclaration */: + case 279 /* SourceFile */: return node; } } @@ -9214,9 +9347,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return container; } } @@ -9238,27 +9371,27 @@ var ts; return node; } switch (node.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: node = node.parent; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9274,14 +9407,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { + if (func.kind === 196 /* FunctionExpression */ || func.kind === 197 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 193 /* ParenthesizedExpression */) { + while (parent.kind === 195 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 191 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9292,8 +9425,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 97 /* SuperKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 98 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9301,20 +9434,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 99 /* ThisKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 100 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: return node; } return undefined; @@ -9322,10 +9455,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return node.tag; - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9334,25 +9467,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // classes are valid targets return true; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 238 /* ClassDeclaration */; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + return parent.kind === 240 /* ClassDeclaration */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* 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 === 238 /* ClassDeclaration */; - case 149 /* Parameter */: + && parent.kind === 240 /* ClassDeclaration */; + case 151 /* 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 === 155 /* Constructor */ - || parent.kind === 154 /* MethodDeclaration */ - || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 238 /* ClassDeclaration */; + && (parent.kind === 157 /* Constructor */ + || parent.kind === 156 /* MethodDeclaration */ + || parent.kind === 159 /* SetAccessor */) + && grandparent.kind === 240 /* ClassDeclaration */; } return false; } @@ -9368,10 +9501,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 154 /* MethodDeclaration */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 159 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -9380,9 +9513,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 260 /* JsxOpeningElement */ || - parent.kind === 259 /* JsxSelfClosingElement */ || - parent.kind === 261 /* JsxClosingElement */) { + if (parent.kind === 262 /* JsxOpeningElement */ || + parent.kind === 261 /* JsxSelfClosingElement */ || + parent.kind === 263 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9390,56 +9523,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 12 /* RegularExpressionLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 210 /* AsExpression */: - case 192 /* TypeAssertionExpression */: - case 211 /* NonNullExpression */: - case 193 /* ParenthesizedExpression */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 206 /* SpreadElement */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 208 /* OmittedExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 205 /* YieldExpression */: - case 199 /* AwaitExpression */: - case 212 /* MetaProperty */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 13 /* RegularExpressionLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 212 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 213 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 208 /* SpreadElement */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 210 /* OmittedExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 207 /* YieldExpression */: + case 201 /* AwaitExpression */: + case 214 /* MetaProperty */: return true; - case 146 /* QualifiedName */: - while (node.parent.kind === 146 /* QualifiedName */) { + case 148 /* QualifiedName */: + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); - case 71 /* Identifier */: - if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node); + case 72 /* Identifier */: + if (node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -9449,49 +9583,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 186 /* BindingElement */: return parent.initializer === node; - case 219 /* ExpressionStatement */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 228 /* ReturnStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 232 /* ThrowStatement */: + case 221 /* ExpressionStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 230 /* ReturnStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 234 /* ThrowStatement */: return parent.expression === node; - case 223 /* ForStatement */: + case 225 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forInStatement.expression === node; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return node === parent.expression; - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return node === parent.expression; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return node === parent.expression; - case 150 /* Decorator */: - case 268 /* JsxExpression */: - case 267 /* JsxSpreadAttribute */: - case 275 /* SpreadAssignment */: + case 152 /* Decorator */: + case 270 /* JsxExpression */: + case 269 /* JsxSpreadAttribute */: + case 277 /* SpreadAssignment */: return true; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -9499,7 +9633,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9508,7 +9642,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 259 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -9536,15 +9670,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 137 /* StringKeyword */ || node.typeArguments[0].kind === 134 /* NumberKeyword */); + (node.typeArguments[0].kind === 138 /* StringKeyword */ || node.typeArguments[0].kind === 135 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 189 /* CallExpression */) { + if (callExpression.kind !== 191 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 71 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 72 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -9575,16 +9709,16 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.right === node) { name = node.parent.left; decl = name; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { name = node.parent.parent.name; decl = node.parent.parent; } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.parent.right === node.parent) { name = node.parent.parent.left; decl = name; } @@ -9599,13 +9733,13 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl); + return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -9618,16 +9752,25 @@ var ts; return init && getExpandoInitializer(init, isPrototypeAccess(node.name)); } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; + function hasExpandoValueProperty(node, isPrototypeAssignment) { + return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); } + if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) { + var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype"); + if (result) { + return result; + } + } } ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer; /** @@ -9643,11 +9786,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 196 /* FunctionExpression */ || e.kind === 197 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 194 /* FunctionExpression */ || - initializer.kind === 207 /* ClassExpression */ || - initializer.kind === 195 /* ArrowFunction */) { + if (initializer.kind === 196 /* FunctionExpression */ || + initializer.kind === 209 /* ClassExpression */ || + initializer.kind === 197 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9664,14 +9807,14 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 54 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -9679,8 +9822,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 === 54 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 58 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 59 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -9703,7 +9846,7 @@ var ts; return name.escapedText === initializer.escapedText; } if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 99 /* ThisKeyword */ || + return (initializer.expression.kind === 100 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -9737,8 +9880,31 @@ var ts; return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; + function isBindableObjectDefinePropertyCall(expr) { + return ts.length(expr.arguments) === 3 && + ts.isPropertyAccessExpression(expr.expression) && + ts.isIdentifier(expr.expression.expression) && + ts.idText(expr.expression.expression) === "Object" && + ts.idText(expr.expression.name) === "defineProperty" && + isStringOrNumericLiteralLike(expr.arguments[1]) && + isEntityNameExpression(expr.arguments[0]); + } + ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; function getAssignmentDeclarationKindWorker(expr) { - if (expr.operatorToken.kind !== 58 /* EqualsToken */ || + if (ts.isCallExpression(expr)) { + if (!isBindableObjectDefinePropertyCall(expr)) { + return 0 /* None */; + } + var entityName = expr.arguments[0]; + if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + return 8 /* ObjectDefinePropertyExports */; + } + if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + return 9 /* ObjectDefinePrototypeProperty */; + } + return 7 /* ObjectDefinePropertyValue */; + } + if (expr.operatorToken.kind !== 59 /* EqualsToken */ || !ts.isPropertyAccessExpression(expr.left)) { return 0 /* None */; } @@ -9750,10 +9916,10 @@ var ts; return getAssignmentDeclarationPropertyAccessKind(lhs); } function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 99 /* ThisKeyword */) { + if (lhs.expression.kind === 100 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (ts.isIdentifier(lhs.expression) && lhs.expression.escapedText === "module" && lhs.name.escapedText === "exports") { + else if (isModuleExportsPropertyAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } @@ -9792,7 +9958,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 221 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9801,7 +9967,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 237 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 239 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -9810,14 +9976,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.parent; - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return node.parent.parent; - case 189 /* CallExpression */: - return node.parent; - case 180 /* LiteralType */: + case 191 /* CallExpression */: + return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; + case 182 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9827,12 +9993,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.moduleSpecifier; - case 246 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 181 /* ImportType */: + case 248 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 259 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 183 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9841,11 +10007,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9853,19 +10019,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 249 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 149 /* Parameter */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 274 /* ShorthandPropertyAssignment */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 151 /* Parameter */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 276 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -9873,14 +10039,13 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 287 /* JSDocFunctionType */ && - node.parameters.length > 0 && - node.parameters[0].name && - node.parameters[0].name.escapedText === "new"; + var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined; + var name = ts.tryCast(param && param.name, ts.isIdentifier); + return !!name && name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 302 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9890,7 +10055,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ + node.expression.operatorToken.kind === 59 /* EqualsToken */ ? node.expression.right : undefined; } @@ -9899,18 +10064,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + node.expression.right.operatorToken.kind === 55 /* BarBarToken */ ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return node.initializer; } } @@ -9920,7 +10085,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 242 /* ModuleDeclaration */ + node.body.kind === 244 /* ModuleDeclaration */ ? node.body : undefined; } @@ -9935,11 +10100,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 148 /* TypeParameter */) { + if (node.kind === 150 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -9950,11 +10115,11 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 273 /* PropertyAssignment */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + if (parent.kind === 275 /* PropertyAssignment */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 221 /* ExpressionStatement */ && node.kind === 189 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 59 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -9965,7 +10130,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -9988,7 +10153,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 71 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 72 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10023,7 +10188,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 === 288 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10036,31 +10201,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 59 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 193 /* ParenthesizedExpression */: - case 185 /* ArrayLiteralExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 187 /* ArrayLiteralExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: node = parent; break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10087,22 +10252,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 216 /* Block */: - case 217 /* VariableStatement */: - case 229 /* WithStatement */: - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 218 /* Block */: + case 219 /* VariableStatement */: + case 231 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return true; } return false; @@ -10119,33 +10284,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 175 /* ParenthesizedType */); + return walkUp(node, 177 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 193 /* ParenthesizedExpression */); + return walkUp(node, 195 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 196 /* DeleteExpression */; + return node && node.kind === 198 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10166,12 +10331,12 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10194,8 +10359,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 147 /* ComputedPropertyName */ && + return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + node.parent.kind === 149 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10203,32 +10368,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 187 /* PropertyAccessExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 189 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 146 /* QualifiedName */) { + while (parent.kind === 148 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; + return parent.kind === 167 /* TypeQuery */ || parent.kind === 164 /* TypeReference */; } return false; - case 184 /* BindingElement */: - case 251 /* ImportSpecifier */: + case 186 /* BindingElement */: + case 253 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 255 /* ExportSpecifier */: - case 265 /* JsxAttribute */: + case 257 /* ExportSpecifier */: + case 267 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10243,15 +10408,16 @@ var ts; // export { x as } from ... // export = // export default + // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 245 /* NamespaceExportDeclaration */ || - node.kind === 248 /* ImportClause */ && !!node.name || - node.kind === 249 /* NamespaceImport */ || - node.kind === 251 /* ImportSpecifier */ || - node.kind === 255 /* ExportSpecifier */ || - node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */; + return node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 247 /* NamespaceExportDeclaration */ || + node.kind === 250 /* ImportClause */ && !!node.name || + node.kind === 251 /* NamespaceImport */ || + node.kind === 253 /* ImportSpecifier */ || + node.kind === 257 /* ExportSpecifier */ || + node.kind === 254 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -10271,12 +10437,12 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 109 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; @@ -10288,7 +10454,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -10322,11 +10488,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; + return 73 /* FirstKeyword */ <= token && token <= 147 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; + return 118 /* FirstContextualKeyword */ <= token && token <= 147 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10338,6 +10504,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isIdentifierANonContextualKeyword(_a) { + var originalKeywordKind = _a.originalKeywordKind; + return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); + } + ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } @@ -10356,14 +10527,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10377,10 +10548,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10405,7 +10576,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 147 /* ComputedPropertyName */ && + return name.kind === 149 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10421,12 +10592,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10442,9 +10613,9 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: return true; default: @@ -10453,11 +10624,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 72 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 72 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -10472,7 +10643,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 72 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -10481,11 +10652,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 149 /* Parameter */; + return root.kind === 151 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 184 /* BindingElement */) { + while (node.kind === 186 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10493,15 +10664,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 194 /* FunctionExpression */ - || kind === 237 /* FunctionDeclaration */ - || kind === 195 /* ArrowFunction */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 242 /* ModuleDeclaration */ - || kind === 277 /* SourceFile */; + return kind === 157 /* Constructor */ + || kind === 196 /* FunctionExpression */ + || kind === 239 /* FunctionDeclaration */ + || kind === 197 /* ArrowFunction */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 244 /* ModuleDeclaration */ + || kind === 279 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10520,38 +10691,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: return 1 /* Right */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operator) { - case 40 /* AsteriskAsteriskToken */: - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 41 /* AsteriskAsteriskToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 1 /* Right */; } } @@ -10560,15 +10731,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 202 /* BinaryExpression */) { + if (expression.kind === 204 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { + else if (expression.kind === 202 /* PrefixUnaryExpression */ || expression.kind === 203 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10578,116 +10749,116 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return 0; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return 1; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return 2; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return 4; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operatorKind) { - case 26 /* CommaToken */: + case 27 /* CommaToken */: return 0; - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: return 16; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return 17; - case 189 /* CallExpression */: + case 191 /* CallExpression */: return 18; - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 19 : 18; - case 191 /* TaggedTemplateExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 193 /* TaggedTemplateExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 19; - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 71 /* Identifier */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 72 /* Identifier */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 193 /* ParenthesizedExpression */: - case 208 /* OmittedExpression */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 195 /* ParenthesizedExpression */: + case 210 /* OmittedExpression */: return 20; default: return -1; } } ts.getOperatorPrecedence = getOperatorPrecedence; - /* @internal */ function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: return 5; - case 53 /* AmpersandAmpersandToken */: + case 54 /* AmpersandAmpersandToken */: return 6; - case 49 /* BarToken */: + case 50 /* BarToken */: return 7; - case 50 /* CaretToken */: + case 51 /* CaretToken */: return 8; - case 48 /* AmpersandToken */: + case 49 /* AmpersandToken */: return 9; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return 10; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: return 11; - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 37 /* PlusToken */: - case 38 /* MinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: return 13; - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: return 14; - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -10755,7 +10926,7 @@ var ts; if (fileName) { return fileDiagnostics.get(fileName) || []; } - var fileDiags = ts.flatMap(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); + var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); if (!nonFileDiagnostics.length) { return fileDiags; } @@ -10813,7 +10984,7 @@ var ts; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || name.indexOf("-") > -1; + return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { @@ -10896,16 +11067,10 @@ var ts; lineStart = true; } } - function writeTextOfNode(text, node) { - var s = getTextOfNodeFromSourceText(text, node); - write(s); - updateLineCountAndPosFor(s); - } reset(); return { write: write, rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, writeLiteral: writeLiteral, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -10928,10 +11093,77 @@ var ts; writePunctuation: write, writeSpace: write, writeStringLiteral: write, - writeSymbol: write + writeSymbol: function (s, _) { return write(s); }, + writeTrailingSemicolon: write, + writeComment: write }; } ts.createTextWriter = createTextWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var pendingTrailingSemicolon = false; + function commitPendingTrailingSemicolon() { + if (pendingTrailingSemicolon) { + writer.writeTrailingSemicolon(";"); + pendingTrailingSemicolon = false; + } + } + return __assign({}, writer, { writeTrailingSemicolon: function () { + pendingTrailingSemicolon = true; + }, + writeLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeLiteral(s); + }, + writeStringLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeStringLiteral(s); + }, + writeSymbol: function (s, sym) { + commitPendingTrailingSemicolon(); + writer.writeSymbol(s, sym); + }, + writePunctuation: function (s) { + commitPendingTrailingSemicolon(); + writer.writePunctuation(s); + }, + writeKeyword: function (s) { + commitPendingTrailingSemicolon(); + writer.writeKeyword(s); + }, + writeOperator: function (s) { + commitPendingTrailingSemicolon(); + writer.writeOperator(s); + }, + writeParameter: function (s) { + commitPendingTrailingSemicolon(); + writer.writeParameter(s); + }, + writeSpace: function (s) { + commitPendingTrailingSemicolon(); + writer.writeSpace(s); + }, + writeProperty: function (s) { + commitPendingTrailingSemicolon(); + writer.writeProperty(s); + }, + writeComment: function (s) { + commitPendingTrailingSemicolon(); + writer.writeComment(s); + }, + writeLine: function () { + commitPendingTrailingSemicolon(); + writer.writeLine(); + }, + increaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.increaseIndent(); + }, + decreaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.decreaseIndent(); + } }); + } + ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11067,11 +11299,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 72 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 99 /* ThisKeyword */; + return id.originalKeywordKind === 100 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11082,10 +11314,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 157 /* SetAccessor */) { + else if (accessor.kind === 159 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11105,10 +11337,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 156 /* GetAccessor */ && !getAccessor) { + if (member.kind === 158 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 157 /* SetAccessor */ && !setAccessor) { + if (member.kind === 159 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11154,7 +11386,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 === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -11188,13 +11420,13 @@ var ts; function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { if (comments && comments.length > 0) { if (leadingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } var emitInterveningSeparator = false; for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var comment = comments_1[_i]; if (emitInterveningSeparator) { - writer.write(" "); + writer.writeSpace(" "); emitInterveningSeparator = false; } writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); @@ -11206,7 +11438,7 @@ var ts; } } if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } } } @@ -11324,7 +11556,7 @@ var ts; } else { // Single line comment of style //.... - writer.write(text.substring(commentPos, commentEnd)); + writer.writeComment(text.substring(commentPos, commentEnd)); } } ts.writeCommentRange = writeCommentRange; @@ -11333,14 +11565,14 @@ var ts; var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text - writer.write(currentLineText); + writer.writeComment(currentLineText); if (end !== commentEnd) { writer.writeLine(); } } else { // Empty string - make sure we write empty line - writer.writeLiteral(newLine); + writer.rawWrite(newLine); } } function calculateIndent(text, pos, end) { @@ -11394,7 +11626,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 72 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -11402,29 +11634,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 115 /* StaticKeyword */: return 32 /* Static */; - case 114 /* PublicKeyword */: return 4 /* Public */; - case 113 /* ProtectedKeyword */: return 16 /* Protected */; - case 112 /* PrivateKeyword */: return 8 /* Private */; - case 117 /* AbstractKeyword */: return 128 /* Abstract */; - case 84 /* ExportKeyword */: return 1 /* Export */; - case 124 /* DeclareKeyword */: return 2 /* Ambient */; - case 76 /* ConstKeyword */: return 2048 /* Const */; - case 79 /* DefaultKeyword */: return 512 /* Default */; - case 120 /* AsyncKeyword */: return 256 /* Async */; - case 132 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 116 /* StaticKeyword */: return 32 /* Static */; + case 115 /* PublicKeyword */: return 4 /* Public */; + case 114 /* ProtectedKeyword */: return 16 /* Protected */; + case 113 /* PrivateKeyword */: return 8 /* Private */; + case 118 /* AbstractKeyword */: return 128 /* Abstract */; + case 85 /* ExportKeyword */: return 1 /* Export */; + case 125 /* DeclareKeyword */: return 2 /* Ambient */; + case 77 /* ConstKeyword */: return 2048 /* Const */; + case 80 /* DefaultKeyword */: return 512 /* Default */; + case 121 /* AsyncKeyword */: return 256 /* Async */; + case 133 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 54 /* BarBarToken */ - || token === 53 /* AmpersandAmpersandToken */ - || token === 51 /* ExclamationToken */; + return token === 55 /* BarBarToken */ + || token === 54 /* AmpersandAmpersandToken */ + || token === 52 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */; + return token >= 59 /* FirstAssignment */ && token <= 71 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -11437,14 +11669,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 108 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 109 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 58 /* EqualsToken */ + ? node.operatorToken.kind === 59 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -11452,8 +11684,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 186 /* ObjectLiteralExpression */ - || kind === 185 /* ArrayLiteralExpression */; + return kind === 188 /* ObjectLiteralExpression */ + || kind === 187 /* ArrayLiteralExpression */; } return false; } @@ -11463,7 +11695,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 71 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 72 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function isPropertyAccessEntityNameExpression(node) { @@ -11475,17 +11707,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 186 /* ObjectLiteralExpression */ && + return expression.kind === 188 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 185 /* ArrayLiteralExpression */ && + return expression.kind === 187 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11850,8 +12082,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11928,35 +12160,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return accessKind(parent); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 202 /* BinaryExpression */: + return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 204 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 58 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 59 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 273 /* PropertyAssignment */: { + case 275 /* 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 274 /* ShorthandPropertyAssignment */: + case 276 /* 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 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 221 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12059,7 +12291,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 131072 /* Object */ ? type.objectFlags : 0; + return type.flags & 524288 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12330,9 +12562,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 148 /* TypeParameter */) { + if (d && d.kind === 150 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 241 /* InterfaceDeclaration */) { return current; } } @@ -12340,7 +12572,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 157 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12370,14 +12602,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 235 /* VariableDeclaration */) { + if (node.kind === 237 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 236 /* VariableDeclarationList */) { + if (node && node.kind === 238 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 217 /* VariableStatement */) { + if (node && node.kind === 219 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12523,27 +12755,27 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return expr.name; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 193 /* ParenthesizedExpression */: { + case 195 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 231 /* LabeledStatement */: { + case 233 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12567,17 +12799,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return declaration; - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: { + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 146 /* QualifiedName */) { + if (name.kind === 148 /* QualifiedName */) { return name.right; } break; } - case 202 /* BinaryExpression */: { + case 191 /* CallExpression */: + case 204 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -12585,13 +12818,17 @@ var ts; case 5 /* Property */: case 3 /* PrototypeProperty */: return expr.left.name; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return expr.arguments[1]; default: return undefined; } } - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 252 /* ExportAssignment */: { + case 254 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -12793,7 +13030,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12827,684 +13064,688 @@ var ts; return node.kind === 8 /* NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; + function isBigIntLiteral(node) { + return node.kind === 9 /* BigIntLiteral */; + } + ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 9 /* StringLiteral */; + return node.kind === 10 /* StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 12 /* RegularExpressionLiteral */; + return node.kind === 13 /* RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 14 /* TemplateHead */; + return node.kind === 15 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 15 /* TemplateMiddle */; + return node.kind === 16 /* TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 16 /* TemplateTail */; + return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 71 /* Identifier */; + return node.kind === 72 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 146 /* QualifiedName */; + return node.kind === 148 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 147 /* ComputedPropertyName */; + return node.kind === 149 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 148 /* TypeParameter */; + return node.kind === 150 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 149 /* Parameter */; + return node.kind === 151 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 151 /* PropertySignature */; + return node.kind === 153 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 152 /* PropertyDeclaration */; + return node.kind === 154 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 153 /* MethodSignature */; + return node.kind === 155 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 155 /* Constructor */; + return node.kind === 157 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 158 /* CallSignature */; + return node.kind === 160 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 159 /* ConstructSignature */; + return node.kind === 161 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 160 /* IndexSignature */; + return node.kind === 162 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; + return node.kind === 159 /* SetAccessor */ || node.kind === 158 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 161 /* TypePredicate */; + return node.kind === 163 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 162 /* TypeReference */; + return node.kind === 164 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 163 /* FunctionType */; + return node.kind === 165 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 164 /* ConstructorType */; + return node.kind === 166 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 165 /* TypeQuery */; + return node.kind === 167 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 166 /* TypeLiteral */; + return node.kind === 168 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 167 /* ArrayType */; + return node.kind === 169 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 168 /* TupleType */; + return node.kind === 170 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 171 /* UnionType */; + return node.kind === 173 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 172 /* IntersectionType */; + return node.kind === 174 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 173 /* ConditionalType */; + return node.kind === 175 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 174 /* InferType */; + return node.kind === 176 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 175 /* ParenthesizedType */; + return node.kind === 177 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 176 /* ThisType */; + return node.kind === 178 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 177 /* TypeOperator */; + return node.kind === 179 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 178 /* IndexedAccessType */; + return node.kind === 180 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 179 /* MappedType */; + return node.kind === 181 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 180 /* LiteralType */; + return node.kind === 182 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 181 /* ImportType */; + return node.kind === 183 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 182 /* ObjectBindingPattern */; + return node.kind === 184 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 183 /* ArrayBindingPattern */; + return node.kind === 185 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 184 /* BindingElement */; + return node.kind === 186 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 185 /* ArrayLiteralExpression */; + return node.kind === 187 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 186 /* ObjectLiteralExpression */; + return node.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 187 /* PropertyAccessExpression */; + return node.kind === 189 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 188 /* ElementAccessExpression */; + return node.kind === 190 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 189 /* CallExpression */; + return node.kind === 191 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 190 /* NewExpression */; + return node.kind === 192 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 191 /* TaggedTemplateExpression */; + return node.kind === 193 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 192 /* TypeAssertionExpression */; + return node.kind === 194 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 193 /* ParenthesizedExpression */; + return node.kind === 195 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 306 /* PartiallyEmittedExpression */) { + while (node.kind === 308 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 194 /* FunctionExpression */; + return node.kind === 196 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 195 /* ArrowFunction */; + return node.kind === 197 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 196 /* DeleteExpression */; + return node.kind === 198 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 197 /* TypeOfExpression */; + return node.kind === 199 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 198 /* VoidExpression */; + return node.kind === 200 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 199 /* AwaitExpression */; + return node.kind === 201 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 200 /* PrefixUnaryExpression */; + return node.kind === 202 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 201 /* PostfixUnaryExpression */; + return node.kind === 203 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 202 /* BinaryExpression */; + return node.kind === 204 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 203 /* ConditionalExpression */; + return node.kind === 205 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 204 /* TemplateExpression */; + return node.kind === 206 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 205 /* YieldExpression */; + return node.kind === 207 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 206 /* SpreadElement */; + return node.kind === 208 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 207 /* ClassExpression */; + return node.kind === 209 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 208 /* OmittedExpression */; + return node.kind === 210 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 210 /* AsExpression */; + return node.kind === 212 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 211 /* NonNullExpression */; + return node.kind === 213 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 212 /* MetaProperty */; + return node.kind === 214 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 214 /* TemplateSpan */; + return node.kind === 216 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 215 /* SemicolonClassElement */; + return node.kind === 217 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 216 /* Block */; + return node.kind === 218 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 217 /* VariableStatement */; + return node.kind === 219 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 218 /* EmptyStatement */; + return node.kind === 220 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 219 /* ExpressionStatement */; + return node.kind === 221 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 220 /* IfStatement */; + return node.kind === 222 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 221 /* DoStatement */; + return node.kind === 223 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 222 /* WhileStatement */; + return node.kind === 224 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 223 /* ForStatement */; + return node.kind === 225 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 224 /* ForInStatement */; + return node.kind === 226 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 225 /* ForOfStatement */; + return node.kind === 227 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 226 /* ContinueStatement */; + return node.kind === 228 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 227 /* BreakStatement */; + return node.kind === 229 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; + return node.kind === 229 /* BreakStatement */ || node.kind === 228 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 228 /* ReturnStatement */; + return node.kind === 230 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 229 /* WithStatement */; + return node.kind === 231 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 230 /* SwitchStatement */; + return node.kind === 232 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 231 /* LabeledStatement */; + return node.kind === 233 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 232 /* ThrowStatement */; + return node.kind === 234 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 233 /* TryStatement */; + return node.kind === 235 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 234 /* DebuggerStatement */; + return node.kind === 236 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 235 /* VariableDeclaration */; + return node.kind === 237 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 236 /* VariableDeclarationList */; + return node.kind === 238 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 237 /* FunctionDeclaration */; + return node.kind === 239 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 238 /* ClassDeclaration */; + return node.kind === 240 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 239 /* InterfaceDeclaration */; + return node.kind === 241 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 240 /* TypeAliasDeclaration */; + return node.kind === 242 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 241 /* EnumDeclaration */; + return node.kind === 243 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */; + return node.kind === 244 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 243 /* ModuleBlock */; + return node.kind === 245 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 244 /* CaseBlock */; + return node.kind === 246 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 245 /* NamespaceExportDeclaration */; + return node.kind === 247 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */; + return node.kind === 248 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 247 /* ImportDeclaration */; + return node.kind === 249 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 248 /* ImportClause */; + return node.kind === 250 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 249 /* NamespaceImport */; + return node.kind === 251 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 250 /* NamedImports */; + return node.kind === 252 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 251 /* ImportSpecifier */; + return node.kind === 253 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 252 /* ExportAssignment */; + return node.kind === 254 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 253 /* ExportDeclaration */; + return node.kind === 255 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 254 /* NamedExports */; + return node.kind === 256 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 255 /* ExportSpecifier */; + return node.kind === 257 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 256 /* MissingDeclaration */; + return node.kind === 258 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 257 /* ExternalModuleReference */; + return node.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 258 /* JsxElement */; + return node.kind === 260 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 259 /* JsxSelfClosingElement */; + return node.kind === 261 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 260 /* JsxOpeningElement */; + return node.kind === 262 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 261 /* JsxClosingElement */; + return node.kind === 263 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 262 /* JsxFragment */; + return node.kind === 264 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 263 /* JsxOpeningFragment */; + return node.kind === 265 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 264 /* JsxClosingFragment */; + return node.kind === 266 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 265 /* JsxAttribute */; + return node.kind === 267 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 266 /* JsxAttributes */; + return node.kind === 268 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 267 /* JsxSpreadAttribute */; + return node.kind === 269 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 268 /* JsxExpression */; + return node.kind === 270 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 269 /* CaseClause */; + return node.kind === 271 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 270 /* DefaultClause */; + return node.kind === 272 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 271 /* HeritageClause */; + return node.kind === 273 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 272 /* CatchClause */; + return node.kind === 274 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 273 /* PropertyAssignment */; + return node.kind === 275 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 274 /* ShorthandPropertyAssignment */; + return node.kind === 276 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 275 /* SpreadAssignment */; + return node.kind === 277 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 277 /* SourceFile */; + return node.kind === 279 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 278 /* Bundle */; + return node.kind === 280 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 279 /* UnparsedSource */; + return node.kind === 281 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 281 /* JSDocTypeExpression */; + return node.kind === 283 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 282 /* JSDocAllType */; + return node.kind === 284 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 283 /* JSDocUnknownType */; + return node.kind === 285 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 284 /* JSDocNullableType */; + return node.kind === 286 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 285 /* JSDocNonNullableType */; + return node.kind === 287 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 286 /* JSDocOptionalType */; + return node.kind === 288 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 287 /* JSDocFunctionType */; + return node.kind === 289 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 288 /* JSDocVariadicType */; + return node.kind === 290 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 289 /* JSDocComment */; + return node.kind === 291 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 293 /* JSDocAugmentsTag */; + return node.kind === 295 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 294 /* JSDocClassTag */; + return node.kind === 296 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 296 /* JSDocEnumTag */; + return node.kind === 298 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 299 /* JSDocThisTag */; + return node.kind === 301 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 297 /* JSDocParameterTag */; + return node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 298 /* JSDocReturnTag */; + return node.kind === 300 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 300 /* JSDocTypeTag */; + return node.kind === 302 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 301 /* JSDocTemplateTag */; + return node.kind === 303 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 302 /* JSDocTypedefTag */; + return node.kind === 304 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 303 /* JSDocPropertyTag */; + return node.kind === 305 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 303 /* JSDocPropertyTag */ || node.kind === 297 /* JSDocParameterTag */; + return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 290 /* JSDocTypeLiteral */; + return node.kind === 292 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 291 /* JSDocSignature */; + return node.kind === 293 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13515,7 +13756,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 304 /* SyntaxList */; + return n.kind === 306 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13525,7 +13766,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 146 /* FirstNode */; + return kind >= 148 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13534,7 +13775,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 147 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13546,7 +13787,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13556,7 +13797,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; + return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13565,12 +13806,12 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 15 /* TemplateMiddle */ - || kind === 16 /* TemplateTail */; + return kind === 16 /* TemplateMiddle */ + || kind === 17 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isStringTextContainingNode(node) { - return node.kind === 9 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers @@ -13583,17 +13824,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 79 /* DefaultKeyword */: - case 84 /* ExportKeyword */: - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 115 /* StaticKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 80 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 116 /* StaticKeyword */: return true; } return false; @@ -13606,7 +13847,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 115 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 116 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13615,23 +13856,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 9 /* StringLiteral */ + return kind === 72 /* Identifier */ + || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 147 /* ComputedPropertyName */; + || kind === 149 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 182 /* ObjectBindingPattern */ - || kind === 183 /* ArrayBindingPattern */; + return kind === 72 /* Identifier */ + || kind === 184 /* ObjectBindingPattern */ + || kind === 185 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13646,13 +13887,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -13661,14 +13902,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 164 /* ConstructorType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 166 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13683,29 +13924,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 152 /* PropertyDeclaration */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 160 /* IndexSignature */ - || kind === 215 /* SemicolonClassElement */; + return kind === 157 /* Constructor */ + || kind === 154 /* PropertyDeclaration */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 162 /* IndexSignature */ + || kind === 217 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); + return node && (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); + return node && (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; default: return false; @@ -13715,11 +13956,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 159 /* ConstructSignature */ - || kind === 158 /* CallSignature */ - || kind === 151 /* PropertySignature */ - || kind === 153 /* MethodSignature */ - || kind === 160 /* IndexSignature */; + return kind === 161 /* ConstructSignature */ + || kind === 160 /* CallSignature */ + || kind === 153 /* PropertySignature */ + || kind === 155 /* MethodSignature */ + || kind === 162 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13728,37 +13969,38 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 273 /* PropertyAssignment */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 275 /* SpreadAssignment */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 275 /* PropertyAssignment */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 277 /* SpreadAssignment */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) - || kind === 119 /* AnyKeyword */ - || kind === 142 /* UnknownKeyword */ - || kind === 134 /* NumberKeyword */ - || kind === 135 /* ObjectKeyword */ - || kind === 122 /* BooleanKeyword */ - || kind === 137 /* StringKeyword */ - || kind === 138 /* SymbolKeyword */ - || kind === 99 /* ThisKeyword */ - || kind === 105 /* VoidKeyword */ - || kind === 140 /* UndefinedKeyword */ - || kind === 95 /* NullKeyword */ - || kind === 131 /* NeverKeyword */ - || kind === 209 /* ExpressionWithTypeArguments */ - || kind === 282 /* JSDocAllType */ - || kind === 283 /* JSDocUnknownType */ - || kind === 284 /* JSDocNullableType */ - || kind === 285 /* JSDocNonNullableType */ - || kind === 286 /* JSDocOptionalType */ - || kind === 287 /* JSDocFunctionType */ - || kind === 288 /* JSDocVariadicType */; + return (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) + || kind === 120 /* AnyKeyword */ + || kind === 143 /* UnknownKeyword */ + || kind === 135 /* NumberKeyword */ + || kind === 146 /* BigIntKeyword */ + || kind === 136 /* ObjectKeyword */ + || kind === 123 /* BooleanKeyword */ + || kind === 138 /* StringKeyword */ + || kind === 139 /* SymbolKeyword */ + || kind === 100 /* ThisKeyword */ + || kind === 106 /* VoidKeyword */ + || kind === 141 /* UndefinedKeyword */ + || kind === 96 /* NullKeyword */ + || kind === 132 /* NeverKeyword */ + || kind === 211 /* ExpressionWithTypeArguments */ + || kind === 284 /* JSDocAllType */ + || kind === 285 /* JSDocUnknownType */ + || kind === 286 /* JSDocNullableType */ + || kind === 287 /* JSDocNonNullableType */ + || kind === 288 /* JSDocOptionalType */ + || kind === 289 /* JSDocFunctionType */ + || kind === 290 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13771,8 +14013,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return true; } return false; @@ -13783,8 +14025,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 183 /* ArrayBindingPattern */ - || kind === 182 /* ObjectBindingPattern */; + return kind === 185 /* ArrayBindingPattern */ + || kind === 184 /* ObjectBindingPattern */; } return false; } @@ -13792,15 +14034,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 185 /* ArrayLiteralExpression */ - || kind === 186 /* ObjectLiteralExpression */; + return kind === 187 /* ArrayLiteralExpression */ + || kind === 188 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 184 /* BindingElement */ - || kind === 208 /* OmittedExpression */; + return kind === 186 /* BindingElement */ + || kind === 210 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13809,9 +14051,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: return true; } return false; @@ -13832,8 +14074,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return true; } return false; @@ -13845,8 +14087,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return true; } return false; @@ -13855,26 +14097,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */ - || kind === 181 /* ImportType */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */ + || kind === 183 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 150 /* Decorator */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 152 /* Decorator */: return true; default: return false; @@ -13882,13 +14124,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; + return node.kind === 191 /* CallExpression */ || node.kind === 192 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 204 /* TemplateExpression */ - || kind === 13 /* NoSubstitutionTemplateLiteral */; + return kind === 206 /* TemplateExpression */ + || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13898,33 +14140,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 190 /* NewExpression */: - case 189 /* CallExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 191 /* TaggedTemplateExpression */: - case 185 /* ArrayLiteralExpression */: - case 193 /* ParenthesizedExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 71 /* Identifier */: - case 12 /* RegularExpressionLiteral */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 192 /* NewExpression */: + case 191 /* CallExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 193 /* TaggedTemplateExpression */: + case 187 /* ArrayLiteralExpression */: + case 195 /* ParenthesizedExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 72 /* Identifier */: + case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 101 /* TrueKeyword */: - case 97 /* SuperKeyword */: - case 211 /* NonNullExpression */: - case 212 /* MetaProperty */: - case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 102 /* TrueKeyword */: + case 98 /* SuperKeyword */: + case 213 /* NonNullExpression */: + case 214 /* MetaProperty */: + case 92 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13937,13 +14180,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 192 /* TypeAssertionExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 194 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13952,11 +14195,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 43 /* PlusPlusToken */ || - expr.operator === 44 /* MinusMinusToken */; + case 202 /* PrefixUnaryExpression */: + return expr.operator === 44 /* PlusPlusToken */ || + expr.operator === 45 /* MinusMinusToken */; default: return false; } @@ -13973,15 +14216,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: - case 195 /* ArrowFunction */: - case 202 /* BinaryExpression */: - case 206 /* SpreadElement */: - case 210 /* AsExpression */: - case 208 /* OmittedExpression */: - case 307 /* CommaListExpression */: - case 306 /* PartiallyEmittedExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: + case 197 /* ArrowFunction */: + case 204 /* BinaryExpression */: + case 208 /* SpreadElement */: + case 212 /* AsExpression */: + case 210 /* OmittedExpression */: + case 309 /* CommaListExpression */: + case 308 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13989,18 +14232,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 192 /* TypeAssertionExpression */ - || kind === 210 /* AsExpression */; + return kind === 194 /* TypeAssertionExpression */ + || kind === 212 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 306 /* PartiallyEmittedExpression */; + return node.kind === 308 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 305 /* NotEmittedStatement */; + return node.kind === 307 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14011,13 +14254,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return true; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14025,7 +14268,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; + return node.kind === 226 /* ForInStatement */ || node.kind === 227 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14049,113 +14292,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */ - || kind === 71 /* Identifier */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */ + || kind === 72 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 242 /* ModuleDeclaration */; + return kind === 72 /* Identifier */ + || kind === 244 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 250 /* NamedImports */ - || kind === 249 /* NamespaceImport */; + return kind === 252 /* NamedImports */ + || kind === 251 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; + return node.kind === 244 /* ModuleDeclaration */ || node.kind === 243 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 195 /* ArrowFunction */ - || kind === 184 /* BindingElement */ - || kind === 238 /* ClassDeclaration */ - || kind === 207 /* ClassExpression */ - || kind === 155 /* Constructor */ - || kind === 241 /* EnumDeclaration */ - || kind === 276 /* EnumMember */ - || kind === 255 /* ExportSpecifier */ - || kind === 237 /* FunctionDeclaration */ - || kind === 194 /* FunctionExpression */ - || kind === 156 /* GetAccessor */ - || kind === 248 /* ImportClause */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 251 /* ImportSpecifier */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 265 /* JsxAttribute */ - || kind === 154 /* MethodDeclaration */ - || kind === 153 /* MethodSignature */ - || kind === 242 /* ModuleDeclaration */ - || kind === 245 /* NamespaceExportDeclaration */ - || kind === 249 /* NamespaceImport */ - || kind === 149 /* Parameter */ - || kind === 273 /* PropertyAssignment */ - || kind === 152 /* PropertyDeclaration */ - || kind === 151 /* PropertySignature */ - || kind === 157 /* SetAccessor */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 148 /* TypeParameter */ - || kind === 235 /* VariableDeclaration */ - || kind === 302 /* JSDocTypedefTag */ - || kind === 295 /* JSDocCallbackTag */ - || kind === 303 /* JSDocPropertyTag */; + return kind === 197 /* ArrowFunction */ + || kind === 186 /* BindingElement */ + || kind === 240 /* ClassDeclaration */ + || kind === 209 /* ClassExpression */ + || kind === 157 /* Constructor */ + || kind === 243 /* EnumDeclaration */ + || kind === 278 /* EnumMember */ + || kind === 257 /* ExportSpecifier */ + || kind === 239 /* FunctionDeclaration */ + || kind === 196 /* FunctionExpression */ + || kind === 158 /* GetAccessor */ + || kind === 250 /* ImportClause */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 253 /* ImportSpecifier */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 267 /* JsxAttribute */ + || kind === 156 /* MethodDeclaration */ + || kind === 155 /* MethodSignature */ + || kind === 244 /* ModuleDeclaration */ + || kind === 247 /* NamespaceExportDeclaration */ + || kind === 251 /* NamespaceImport */ + || kind === 151 /* Parameter */ + || kind === 275 /* PropertyAssignment */ + || kind === 154 /* PropertyDeclaration */ + || kind === 153 /* PropertySignature */ + || kind === 159 /* SetAccessor */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 150 /* TypeParameter */ + || kind === 237 /* VariableDeclaration */ + || kind === 304 /* JSDocTypedefTag */ + || kind === 297 /* JSDocCallbackTag */ + || kind === 305 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 237 /* FunctionDeclaration */ - || kind === 256 /* MissingDeclaration */ - || kind === 238 /* ClassDeclaration */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 241 /* EnumDeclaration */ - || kind === 242 /* ModuleDeclaration */ - || kind === 247 /* ImportDeclaration */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 253 /* ExportDeclaration */ - || kind === 252 /* ExportAssignment */ - || kind === 245 /* NamespaceExportDeclaration */; + return kind === 239 /* FunctionDeclaration */ + || kind === 258 /* MissingDeclaration */ + || kind === 240 /* ClassDeclaration */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 243 /* EnumDeclaration */ + || kind === 244 /* ModuleDeclaration */ + || kind === 249 /* ImportDeclaration */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 255 /* ExportDeclaration */ + || kind === 254 /* ExportAssignment */ + || kind === 247 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 227 /* BreakStatement */ - || kind === 226 /* ContinueStatement */ - || kind === 234 /* DebuggerStatement */ - || kind === 221 /* DoStatement */ - || kind === 219 /* ExpressionStatement */ - || kind === 218 /* EmptyStatement */ - || kind === 224 /* ForInStatement */ - || kind === 225 /* ForOfStatement */ - || kind === 223 /* ForStatement */ - || kind === 220 /* IfStatement */ - || kind === 231 /* LabeledStatement */ - || kind === 228 /* ReturnStatement */ - || kind === 230 /* SwitchStatement */ - || kind === 232 /* ThrowStatement */ - || kind === 233 /* TryStatement */ - || kind === 217 /* VariableStatement */ - || kind === 222 /* WhileStatement */ - || kind === 229 /* WithStatement */ - || kind === 305 /* NotEmittedStatement */ - || kind === 309 /* EndOfDeclarationMarker */ - || kind === 308 /* MergeDeclarationMarker */; + return kind === 229 /* BreakStatement */ + || kind === 228 /* ContinueStatement */ + || kind === 236 /* DebuggerStatement */ + || kind === 223 /* DoStatement */ + || kind === 221 /* ExpressionStatement */ + || kind === 220 /* EmptyStatement */ + || kind === 226 /* ForInStatement */ + || kind === 227 /* ForOfStatement */ + || kind === 225 /* ForStatement */ + || kind === 222 /* IfStatement */ + || kind === 233 /* LabeledStatement */ + || kind === 230 /* ReturnStatement */ + || kind === 232 /* SwitchStatement */ + || kind === 234 /* ThrowStatement */ + || kind === 235 /* TryStatement */ + || kind === 219 /* VariableStatement */ + || kind === 224 /* WhileStatement */ + || kind === 231 /* WithStatement */ + || kind === 307 /* NotEmittedStatement */ + || kind === 311 /* EndOfDeclarationMarker */ + || kind === 310 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 301 /* JSDocTemplateTag */ || ts.isInJSFile(node); + if (node.kind === 150 /* TypeParameter */) { + return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14182,10 +14425,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 216 /* Block */) + if (node.kind !== 218 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { + if (node.parent.kind === 235 /* TryStatement */ || node.parent.kind === 274 /* CatchClause */) { return false; } } @@ -14195,81 +14438,81 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 257 /* ExternalModuleReference */ - || kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 259 /* ExternalModuleReference */ + || kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 99 /* ThisKeyword */ - || kind === 71 /* Identifier */ - || kind === 187 /* PropertyAccessExpression */; + return kind === 100 /* ThisKeyword */ + || kind === 72 /* Identifier */ + || kind === 189 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 258 /* JsxElement */ - || kind === 268 /* JsxExpression */ - || kind === 259 /* JsxSelfClosingElement */ - || kind === 10 /* JsxText */ - || kind === 262 /* JsxFragment */; + return kind === 260 /* JsxElement */ + || kind === 270 /* JsxExpression */ + || kind === 261 /* JsxSelfClosingElement */ + || kind === 11 /* JsxText */ + || kind === 264 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 265 /* JsxAttribute */ - || kind === 267 /* JsxSpreadAttribute */; + return kind === 267 /* JsxAttribute */ + || kind === 269 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ - || kind === 268 /* JsxExpression */; + return kind === 10 /* StringLiteral */ + || kind === 270 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 260 /* JsxOpeningElement */ - || kind === 259 /* JsxSelfClosingElement */; + return kind === 262 /* JsxOpeningElement */ + || kind === 261 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 269 /* CaseClause */ - || kind === 270 /* DefaultClause */; + return kind === 271 /* CaseClause */ + || kind === 272 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 303 /* LastJSDocNode */; + return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 303 /* LastJSDocTagNode */; + return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14299,12 +14542,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 265 /* JsxAttribute */ || node.kind === 267 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 267 /* JsxAttribute */ || node.kind === 269 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 164 /* TypeReference */ || node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14333,15 +14576,14 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 9 /* StringLiteral */ || node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; })(ts || (ts = {})); /* @internal */ (function (ts) { - /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; + return node.kind === 252 /* NamedImports */ || node.kind === 256 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -14386,10 +14628,9 @@ var ts; getSignatureConstructor: function () { return Signature; }, getSourceMapSourceConstructor: function () { return SourceMapSource; }, }; - /* @internal */ function formatStringFromArgs(text, args, baseIndex) { if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return ts.Debug.assertDefined(args[+index + baseIndex]); }); + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; function getLocaleSpecificMessage(message) { @@ -14418,7 +14659,6 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; - /* @internal */ function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -14443,7 +14683,6 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; - /* @internal */ function createCompilerDiagnosticFromMessageChain(chain) { return { file: undefined, @@ -14480,14 +14719,12 @@ var ts; function getDiagnosticFilePath(diagnostic) { return diagnostic.file ? diagnostic.file.path : undefined; } - /* @internal */ function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; - /* @internal */ function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || @@ -14791,7 +15028,6 @@ var ts; return rootLength > 0 && rootLength === path.length; } ts.isDiskPathRoot = isDiskPathRoot; - /* @internal */ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { return !isRootedDiskPath(absoluteOrRelativePath) ? absoluteOrRelativePath @@ -15756,6 +15992,82 @@ var ts; } } ts.getOrUpdate = getOrUpdate; + /** + * Converts a bigint literal string, e.g. `0x1234n`, + * to its decimal string representation, e.g. `4660`. + */ + function parsePseudoBigInt(stringValue) { + var log2Base; + switch (stringValue.charCodeAt(1)) { // "x" in "0x123" + case 98 /* b */: + case 66 /* B */: // 0b or 0B + log2Base = 1; + break; + case 111 /* o */: + case 79 /* O */: // 0o or 0O + log2Base = 3; + break; + case 120 /* x */: + case 88 /* 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 */) { + nonZeroStart++; + } + return stringValue.slice(nonZeroStart, nIndex) || "0"; + } + // Omit leading "0b", "0o", or "0x", and trailing "n" + var startIndex = 2, endIndex = stringValue.length - 1; + var bitsNeeded = (endIndex - startIndex) * log2Base; + // Stores the value specified by the string as a LE array of 16-bit integers + // using Uint16 instead of Uint32 so combining steps can use bitwise operators + var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0)); + // Add the digits, one at a time + for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) { + 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 */ + : 10 + digitChar - + (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + var shiftedDigit = digit << (bitOffset & 15); + segments[segment] |= shiftedDigit; + var residual = shiftedDigit >>> 16; + if (residual) + segments[segment + 1] |= residual; // overflows segment + } + // Repeatedly divide segments by 10 and add remainder to base10Value + var base10Value = ""; + var firstNonzeroSegment = segments.length - 1; + var segmentsRemaining = true; + while (segmentsRemaining) { + var mod10 = 0; + segmentsRemaining = false; + for (var segment = firstNonzeroSegment; segment >= 0; segment--) { + var newSegment = mod10 << 16 | segments[segment]; + var segmentValue = (newSegment / 10) | 0; + segments[segment] = segmentValue; + mod10 = newSegment - segmentValue * 10; + if (segmentValue && !segmentsRemaining) { + firstNonzeroSegment = segment; + segmentsRemaining = true; + } + } + base10Value = mod10 + base10Value; + } + return base10Value; + } + ts.parsePseudoBigInt = parsePseudoBigInt; + function pseudoBigIntToString(_a) { + var negative = _a.negative, base10Value = _a.base10Value; + return (negative && base10Value !== "0" ? "-" : "") + base10Value; + } + ts.pseudoBigIntToString = pseudoBigIntToString; })(ts || (ts = {})); var ts; (function (ts) { @@ -15775,10 +16087,10 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 277 /* SourceFile */) { + if (kind === 279 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 71 /* Identifier */) { + else if (kind === 72 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -15827,19 +16139,19 @@ 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 <= 145 /* LastToken */) { + if (!node || node.kind <= 147 /* LastToken */) { return; } switch (node.kind) { - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15847,9 +16159,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15857,7 +16169,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15865,51 +16177,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertySignature */: + case 153 /* 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 273 /* PropertyAssignment */: + case 275 /* 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 235 /* VariableDeclaration */: + case 237 /* 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 184 /* BindingElement */: + case 186 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15921,302 +16233,302 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 168 /* TupleType */: + case 170 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 174 /* InferType */: + case 176 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 181 /* ImportType */: + case 183 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 175 /* ParenthesizedType */: - case 177 /* TypeOperator */: + case 177 /* ParenthesizedType */: + case 179 /* TypeOperator */: return visitNode(cbNode, node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 179 /* MappedType */: + case 181 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return visitNode(cbNode, node.literal); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitNode(cbNode, node.name); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return visitNode(cbNode, node.label); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 150 /* Decorator */: + case 152 /* Decorator */: return visitNode(cbNode, node.expression); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 239 /* InterfaceDeclaration */: + case 241 /* 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 240 /* TypeAliasDeclaration */: + case 242 /* 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 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 169 /* OptionalType */: - case 170 /* RestType */: - case 281 /* JSDocTypeExpression */: - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 286 /* JSDocOptionalType */: - case 288 /* JSDocVariadicType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 283 /* JSDocTypeExpression */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 288 /* JSDocOptionalType */: + case 290 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 289 /* JSDocComment */: + case 291 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -16225,17 +16537,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 281 /* JSDocTypeExpression */) { + node.typeExpression.kind === 283 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -16243,20 +16555,20 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 295 /* JSDocCallbackTag */: + case 297 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocThisTag */: + case 301 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocEnumTag */: + case 298 /* JSDocEnumTag */: return visitNode(cbNode, node.typeExpression); - case 291 /* JSDocSignature */: + case 293 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 290 /* JSDocTypeLiteral */: + case 292 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -16264,7 +16576,7 @@ var ts; } } return; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -16482,18 +16794,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(219 /* ExpressionStatement */); + var statement = createNode(221 /* ExpressionStatement */); switch (token()) { - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 38 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 56 /* ColonToken */; })) { + case 39 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -16501,8 +16813,8 @@ var ts; } break; case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 56 /* ColonToken */; })) { + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -16638,7 +16950,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16843,20 +17155,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 71 /* Identifier */) { + if (token() === 72 /* 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() === 116 /* YieldKeyword */ && inYieldContext()) { + if (token() === 117 /* 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() === 121 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 122 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 107 /* LastReservedWord */; + return token() > 108 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -16899,29 +17211,29 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(25 /* SemicolonToken */); + return parseExpected(26 /* SemicolonToken */); } } function createNode(kind, pos) { nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 72 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -16963,7 +17275,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 71 /* Identifier */) { + if (kind === 72 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -16984,9 +17296,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(71 /* Identifier */); + var node = createNode(72 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 71 /* Identifier */) { + if (token() !== 72 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -16995,7 +17307,7 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17005,16 +17317,16 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -17026,13 +17338,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(147 /* ComputedPropertyName */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(149 /* ComputedPropertyName */); + parseExpected(22 /* 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. node.expression = allowInAnd(parseExpression); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -17047,20 +17359,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 83 /* EnumKeyword */; - case 84 /* ExportKeyword */: + return nextToken() === 84 /* EnumKeyword */; + case 85 /* ExportKeyword */: nextToken(); - if (token() === 79 /* DefaultKeyword */) { + if (token() === 80 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier(); - case 79 /* DefaultKeyword */: + return token() !== 40 /* AsteriskToken */ && token() !== 119 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 80 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 115 /* StaticKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -17071,18 +17383,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 21 /* OpenBracketToken */ - || token() === 17 /* OpenBraceToken */ - || token() === 39 /* AsteriskToken */ - || token() === 24 /* DotDotDotToken */ + return token() === 22 /* OpenBracketToken */ + || token() === 18 /* OpenBraceToken */ + || token() === 40 /* AsteriskToken */ + || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ || - token() === 109 /* InterfaceKeyword */ || - (token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 76 /* ClassKeyword */ || token() === 90 /* FunctionKeyword */ || + token() === 110 /* InterfaceKeyword */ || + (token() === 118 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 121 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -17100,9 +17412,9 @@ var ts; // 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() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -17110,17 +17422,17 @@ var ts; // 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() === 25 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: switch (token()) { - case 21 /* OpenBracketToken */: - case 39 /* AsteriskToken */: - case 24 /* DotDotDotToken */: - case 23 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* OpenBracketToken */: + case 40 /* 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`) return true; default: return isLiteralPropertyName(); @@ -17128,11 +17440,11 @@ var ts; case 18 /* RestProperties */: return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* 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() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -17147,37 +17459,39 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern(); case 19 /* TypeParameters */: return isIdentifier(); case 15 /* ArrayLiteralMembers */: - if (token() === 26 /* CommaToken */) { - return true; + 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`) + return true; } // falls through case 11 /* ArgumentExpressions */: - return token() === 24 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); case 17 /* JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); case 20 /* TypeArguments */: case 21 /* TupleElementTypes */: - return token() === 26 /* CommaToken */ || isStartOfType(); + return token() === 27 /* CommaToken */ || isStartOfType(); case 22 /* HeritageClauses */: return isHeritageClause(); case 23 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 17 /* OpenBraceToken */); - if (nextToken() === 18 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* OpenBraceToken */); + if (nextToken() === 19 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -17186,7 +17500,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 86 /* ExtendsKeyword */ || next === 109 /* ImplementsKeyword */; } return true; } @@ -17203,8 +17517,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 108 /* ImplementsKeyword */ || - token() === 85 /* ExtendsKeyword */) { + if (token() === 109 /* ImplementsKeyword */ || + token() === 86 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -17232,37 +17546,37 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 23 /* ImportOrExportSpecifiers */: - return token() === 18 /* CloseBraceToken */; + return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */; + return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 21 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 22 /* CloseBracketToken */; + return token() === 23 /* CloseBracketToken */; case 17 /* JSDocParameters */: case 16 /* Parameters */: case 18 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 20 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 26 /* CommaToken */; + return token() !== 27 /* CommaToken */; case 22 /* HeritageClauses */: - return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */; + return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; + return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -17282,7 +17596,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() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -17452,20 +17766,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 155 /* Constructor */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 215 /* SemicolonClassElement */: + case 157 /* Constructor */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 217 /* SemicolonClassElement */: return true; - case 154 /* MethodDeclaration */: + case 156 /* 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 === 71 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 72 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 124 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -17474,8 +17788,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: return true; } } @@ -17484,58 +17798,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 217 /* VariableStatement */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 219 /* ExpressionStatement */: - case 232 /* ThrowStatement */: - case 228 /* ReturnStatement */: - case 230 /* SwitchStatement */: - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 218 /* EmptyStatement */: - case 233 /* TryStatement */: - case 231 /* LabeledStatement */: - case 221 /* DoStatement */: - case 234 /* DebuggerStatement */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 219 /* VariableStatement */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 221 /* ExpressionStatement */: + case 234 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 232 /* SwitchStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 220 /* EmptyStatement */: + case 235 /* TryStatement */: + case 233 /* LabeledStatement */: + case 223 /* DoStatement */: + case 236 /* DebuggerStatement */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 151 /* PropertySignature */: - case 158 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 153 /* PropertySignature */: + case 160 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 235 /* VariableDeclaration */) { + if (node.kind !== 237 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -17556,7 +17870,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 149 /* Parameter */) { + if (node.kind !== 151 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -17613,7 +17927,7 @@ var ts; var startPos = scanner.getStartPos(); list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -17623,13 +17937,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(26 /* CommaToken */); + parseExpected(27 /* CommaToken */); // 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() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -17680,8 +17994,8 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); - while (parseOptional(23 /* DotToken */)) { - if (token() === 27 /* LessThanToken */) { + while (parseOptional(24 /* DotToken */)) { + if (token() === 28 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -17692,7 +18006,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(146 /* QualifiedName */, entity.pos); + var node = createNode(148 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -17723,33 +18037,33 @@ 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(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(204 /* TemplateExpression */); + var template = createNode(206 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 16 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(214 /* TemplateSpan */); + var span = createNode(216 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 18 /* CloseBraceToken */) { + if (token() === 19 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(16 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */)); + literal = parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -17759,18 +18073,17 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind) { var node = createNode(kind); - var text = scanner.getTokenValue(); - node.text = text; + node.text = scanner.getTokenValue(); if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -17792,24 +18105,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 28 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: { + case 165 /* FunctionType */: + case 166 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17817,20 +18130,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(161 /* TypePredicate */, lhs.pos); + var node = createNode(163 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(176 /* ThisType */); + var node = createNode(178 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(282 /* JSDocAllType */); + var result = createNode(284 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(286 /* JSDocOptionalType */, result); + return createPostfixType(288 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17838,7 +18151,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(285 /* JSDocNonNullableType */); + var result = createNode(287 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17856,66 +18169,66 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 26 /* CommaToken */ || - token() === 18 /* CloseBraceToken */ || - token() === 20 /* CloseParenToken */ || - token() === 29 /* GreaterThanToken */ || - token() === 58 /* EqualsToken */ || - token() === 49 /* BarToken */) { - var result = createNode(283 /* JSDocUnknownType */, pos); + if (token() === 27 /* CommaToken */ || + token() === 19 /* CloseBraceToken */ || + token() === 21 /* CloseParenToken */ || + token() === 30 /* GreaterThanToken */ || + token() === 59 /* EqualsToken */ || + token() === 50 /* BarToken */) { + var result = createNode(285 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(284 /* JSDocNullableType */, pos); + var result = createNode(286 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); nextToken(); - fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { + var parameter = createNode(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */ || token() === 95 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); + var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 58 /* EqualsToken */) { - return createPostfixType(286 /* JSDocOptionalType */, type); + if (token() === 59 /* EqualsToken */) { + return createPostfixType(288 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(165 /* TypeQuery */); - parseExpected(103 /* TypeOfKeyword */); + var node = createNode(167 /* TypeQuery */); + parseExpected(104 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(85 /* ExtendsKeyword */)) { + if (parseOptional(86 /* 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 @@ -17934,39 +18247,39 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(58 /* EqualsToken */)) { + if (parseOptional(59 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 27 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (token() === 28 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(56 /* ColonToken */)) { + if (parseOptional(57 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter(isJSDocParameter) { - return token() === 24 /* DotDotDotToken */ || + return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 /* AtToken */ || + token() === 58 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */) { + var node = createNodeWithJSDoc(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -17981,7 +18294,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(55 /* QuestionToken */); + node.questionToken = parseOptionalToken(56 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18003,16 +18316,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 36 /* EqualsGreaterThanToken */) { + if (returnToken === 37 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(56 /* ColonToken */)) { + else if (parseOptional(57 /* ColonToken */)) { return true; } - else if (isType && token() === 36 /* EqualsGreaterThanToken */) { + else if (isType && token() === 37 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); nextToken(); return true; } @@ -18033,7 +18346,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(19 /* OpenParenToken */)) { + if (!parseExpected(20 /* OpenParenToken */)) { signature.parameters = createMissingList(); return false; } @@ -18046,12 +18359,12 @@ var ts; parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - return parseExpected(20 /* CloseParenToken */); + return parseExpected(21 /* CloseParenToken */); } 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(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -18059,15 +18372,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 159 /* ConstructSignature */) { - parseExpected(94 /* NewKeyword */); + if (kind === 161 /* ConstructSignature */) { + parseExpected(95 /* NewKeyword */); } - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - return token() === 21 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -18087,7 +18400,7 @@ var ts; // [] // nextToken(); - if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) { + if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -18106,39 +18419,39 @@ 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* 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() !== 55 /* QuestionToken */) { + if (token() !== 56 /* 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; + return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 160 /* IndexSignature */; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.kind = 162 /* IndexSignature */; + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 153 /* MethodSignature */; + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.kind = 155 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 151 /* PropertySignature */; + node.kind = 153 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { // 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. @@ -18150,7 +18463,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return true; } var idToken = false; @@ -18160,7 +18473,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -18171,21 +18484,21 @@ 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() === 19 /* OpenParenToken */ || - token() === 27 /* LessThanToken */ || - token() === 55 /* QuestionToken */ || - token() === 56 /* ColonToken */ || - token() === 26 /* CommaToken */ || + return token() === 20 /* OpenParenToken */ || + token() === 28 /* LessThanToken */ || + token() === 56 /* QuestionToken */ || + token() === 57 /* ColonToken */ || + token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(158 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + return parseSignatureMember(160 /* CallSignature */); } - if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(159 /* ConstructSignature */); + if (token() === 95 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(161 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -18196,30 +18509,30 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 23 /* DotToken */; + return nextToken() === 24 /* DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 19 /* OpenParenToken */: - case 27 /* LessThanToken */: - case 23 /* DotToken */: + case 20 /* OpenParenToken */: + case 28 /* LessThanToken */: + case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(166 /* TypeLiteral */); + var node = createNode(168 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { members = createMissingList(); @@ -18228,89 +18541,89 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { - return nextToken() === 132 /* ReadonlyKeyword */; + if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + return nextToken() === 133 /* ReadonlyKeyword */; } - if (token() === 132 /* ReadonlyKeyword */) { + if (token() === 133 /* ReadonlyKeyword */) { nextToken(); } - return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 93 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(92 /* InKeyword */); + parseExpected(93 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(179 /* MappedType */); - parseExpected(17 /* OpenBraceToken */); - if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + var node = createNode(181 /* MappedType */); + parseExpected(18 /* OpenBraceToken */); + if (token() === 133 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { - parseExpectedToken(132 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { + parseExpectedToken(133 /* ReadonlyKeyword */); } } - parseExpected(21 /* OpenBracketToken */); + parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); - parseExpected(22 /* CloseBracketToken */); - if (token() === 55 /* QuestionToken */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + parseExpected(23 /* CloseBracketToken */); + if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 55 /* QuestionToken */) { - parseExpectedToken(55 /* QuestionToken */); + if (node.questionToken.kind !== 56 /* QuestionToken */) { + parseExpectedToken(56 /* QuestionToken */); } } node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(24 /* DotDotDotToken */)) { - var node = createNode(170 /* RestType */, pos); + if (parseOptional(25 /* DotDotDotToken */)) { + var node = createNode(172 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 169 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 171 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + var node = createNode(170 /* TupleType */); + node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(175 /* ParenthesizedType */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(177 /* ParenthesizedType */); + parseExpected(20 /* OpenParenToken */); node.type = parseType(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(94 /* NewKeyword */) ? 164 /* ConstructorType */ : 163 /* FunctionType */; + var kind = parseOptional(95 /* NewKeyword */) ? 166 /* ConstructorType */ : 165 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 23 /* DotToken */ ? undefined : node; + return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(180 /* LiteralType */); + var node = createNode(182 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 38 /* MinusToken */; + unaryMinusExpression = createNode(202 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } - var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */ + var expression = token() === 102 /* TrueKeyword */ || token() === 87 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -18323,79 +18636,82 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 91 /* ImportKeyword */; + return token() === 92 /* ImportKeyword */; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(181 /* ImportType */); - if (parseOptional(103 /* TypeOfKeyword */)) { + var node = createNode(183 /* ImportType */); + if (parseOptional(104 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(91 /* ImportKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(92 /* ImportKeyword */); + parseExpected(20 /* OpenParenToken */); node.argument = parseType(); - parseExpected(20 /* CloseParenToken */); - if (parseOptional(23 /* DotToken */)) { + parseExpected(21 /* CloseParenToken */); + if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } node.typeArguments = tryParseTypeArguments(); return finishNode(node); } - function nextTokenIsNumericLiteral() { - return nextToken() === 8 /* NumericLiteral */; + function nextTokenIsNumericOrBigIntLiteral() { + nextToken(); + return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 138 /* SymbolKeyword */: - case 122 /* BooleanKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 139 /* SymbolKeyword */: + case 123 /* BooleanKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 61 /* AsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 51 /* ExclamationToken */: + case 52 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseLiteralTypeNode(); - case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 105 /* VoidKeyword */: - case 95 /* NullKeyword */: + case 39 /* MinusToken */: + return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); + case 106 /* VoidKeyword */: + case 96 /* NullKeyword */: return parseTokenNode(); - case 99 /* ThisKeyword */: { + case 100 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseTupleType(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportType(); default: return parseTypeReference(); @@ -18403,42 +18719,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 141 /* UniqueKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 103 /* TypeOfKeyword */: - case 131 /* NeverKeyword */: - case 17 /* OpenBraceToken */: - case 21 /* OpenBracketToken */: - case 27 /* LessThanToken */: - case 49 /* BarToken */: - case 48 /* AmpersandToken */: - case 94 /* NewKeyword */: - case 9 /* StringLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 142 /* UniqueKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 104 /* TypeOfKeyword */: + case 132 /* NeverKeyword */: + case 18 /* OpenBraceToken */: + case 22 /* OpenBracketToken */: + case 28 /* LessThanToken */: + case 50 /* BarToken */: + case 49 /* AmpersandToken */: + case 95 /* NewKeyword */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 135 /* ObjectKeyword */: - case 39 /* AsteriskToken */: - case 55 /* QuestionToken */: - case 51 /* ExclamationToken */: - case 24 /* DotDotDotToken */: - case 126 /* InferKeyword */: - case 91 /* ImportKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 136 /* ObjectKeyword */: + case 40 /* AsteriskToken */: + case 56 /* QuestionToken */: + case 52 /* ExclamationToken */: + case 25 /* DotDotDotToken */: + case 127 /* InferKeyword */: + case 92 /* ImportKeyword */: return true; - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return !inStartOfParameter; - case 38 /* MinusToken */: - return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); - case 19 /* OpenParenToken */: + case 39 /* MinusToken */: + return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); + case 20 /* 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); @@ -18448,35 +18766,35 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 20 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 51 /* ExclamationToken */: - type = createPostfixType(285 /* JSDocNonNullableType */, type); + case 52 /* ExclamationToken */: + type = createPostfixType(287 /* JSDocNonNullableType */, type); break; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(284 /* JSDocNullableType */, type); + type = createPostfixType(286 /* JSDocNullableType */, type); break; - case 21 /* OpenBracketToken */: - parseExpected(21 /* OpenBracketToken */); + case 22 /* OpenBracketToken */: + parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(178 /* IndexedAccessType */, type.pos); + var node = createNode(180 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(167 /* ArrayType */, type.pos); + var node = createNode(169 /* ArrayType */, type.pos); node.elementType = type; - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } break; @@ -18493,16 +18811,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(177 /* TypeOperator */); + var node = createNode(179 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(174 /* InferType */); - parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(148 /* TypeParameter */); + var node = createNode(176 /* InferType */); + parseExpected(127 /* InferKeyword */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -18510,10 +18828,10 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 128 /* KeyOfKeyword */: - case 141 /* UniqueKeyword */: + case 129 /* KeyOfKeyword */: + case 142 /* UniqueKeyword */: return parseTypeOperator(operator); - case 126 /* InferKeyword */: + case 127 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -18533,27 +18851,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(174 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(173 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { return true; } - return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 99 /* ThisKeyword */) { + if (isIdentifier() || token() === 100 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) { + if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -18563,7 +18881,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) { + if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -18571,17 +18889,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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || - token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 56 /* QuestionToken */ || token() === 59 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 20 /* CloseParenToken */) { + if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -18593,7 +18911,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(163 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -18604,7 +18922,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -18615,49 +18933,50 @@ var ts; return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 94 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 95 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(173 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(86 /* ExtendsKeyword */)) { + var node = createNode(175 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(55 /* QuestionToken */); + parseExpected(56 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(56 /* ColonToken */) ? parseType() : undefined; + return parseOptional(57 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 19 /* OpenParenToken */: - case 21 /* OpenBracketToken */: - case 17 /* OpenBraceToken */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 94 /* NewKeyword */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 71 /* Identifier */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 20 /* OpenParenToken */: + case 22 /* OpenBracketToken */: + case 18 /* OpenBraceToken */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 95 /* NewKeyword */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 72 /* Identifier */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -18668,18 +18987,18 @@ var ts; return true; } switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 27 /* LessThanToken */: - case 121 /* AwaitKeyword */: - case 116 /* YieldKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 28 /* LessThanToken */: + case 122 /* AwaitKeyword */: + case 117 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -18697,10 +19016,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 17 /* OpenBraceToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && - token() !== 57 /* AtToken */ && + return token() !== 18 /* OpenBraceToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && + token() !== 58 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -18714,7 +19033,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -18723,7 +19042,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(58 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(59 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -18768,7 +19087,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -18784,7 +19103,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 116 /* YieldKeyword */) { + if (token() === 117 /* 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()) { @@ -18813,15 +19132,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(205 /* YieldExpression */); + var node = createNode(207 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 39 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -18832,20 +19151,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(195 /* ArrowFunction */, asyncModifier.pos); + node = createNode(197 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(195 /* ArrowFunction */, identifier.pos); + node = createNode(197 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(149 /* Parameter */, identifier.pos); + var parameter = createNode(151 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -18870,8 +19189,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -18881,10 +19200,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 121 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* 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. @@ -18894,28 +19213,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 19 /* OpenParenToken */) { - if (second === 20 /* CloseParenToken */) { + if (first === 20 /* OpenParenToken */) { + if (second === 21 /* 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 36 /* EqualsGreaterThanToken */: - case 56 /* ColonToken */: - case 17 /* OpenBraceToken */: + case 37 /* EqualsGreaterThanToken */: + case 57 /* ColonToken */: + case 18 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -18927,42 +19246,42 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) { + if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 24 /* DotDotDotToken */) { + if (second === 25 /* DotDotDotToken */) { return 1 /* 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 !== 120 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 121 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 99 /* ThisKeyword */) { + if (!isIdentifier() && second !== 100 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 56 /* ColonToken */: + case 57 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 58 /* EqualsToken */ || token() === 20 /* CloseParenToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 59 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; - case 26 /* CommaToken */: - case 58 /* EqualsToken */: - case 20 /* CloseParenToken */: + case 27 /* CommaToken */: + case 59 /* EqualsToken */: + case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; } @@ -18970,7 +19289,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 27 /* LessThanToken */); + ts.Debug.assert(first === 28 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -18980,17 +19299,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 85 /* ExtendsKeyword */) { + if (third === 86 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 58 /* EqualsToken */: - case 29 /* GreaterThanToken */: + case 59 /* EqualsToken */: + case 30 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 26 /* CommaToken */) { + else if (third === 27 /* CommaToken */) { return true; } return false; @@ -19009,7 +19328,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19022,23 +19341,23 @@ 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() === 120 /* AsyncKeyword */) { + if (token() === 121 /* 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() === 36 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(195 /* ArrowFunction */); + var node = createNodeWithJSDoc(197 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19048,7 +19367,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(56 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -19059,19 +19378,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && token() !== 18 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } - if (token() !== 25 /* SemicolonToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && + if (token() !== 26 /* SemicolonToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -19096,20 +19415,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(55 /* QuestionToken */); + var questionToken = parseOptionalToken(56 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(205 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(56 /* ColonToken */); + node.colonToken = parseExpectedToken(57 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + : createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -19117,7 +19436,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; + return t === 93 /* InKeyword */ || t === 147 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -19146,16 +19465,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() === 40 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 92 /* InKeyword */ && inDisallowInContext()) { + if (token() === 93 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -19176,51 +19495,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 92 /* InKeyword */) { + if (inDisallowInContext() && token() === 93 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(202 /* BinaryExpression */, left.pos); + var node = createNode(204 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(210 /* AsExpression */, left.pos); + var node = createNode(212 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(200 /* PrefixUnaryExpression */); + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(196 /* DeleteExpression */); + var node = createNode(198 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(197 /* TypeOfExpression */); + var node = createNode(199 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(198 /* VoidExpression */); + var node = createNode(200 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 121 /* AwaitKeyword */) { + if (token() === 122 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -19230,7 +19549,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(199 /* AwaitExpression */); + var node = createNode(201 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -19254,7 +19573,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 40 /* AsteriskAsteriskToken */ ? + return token() === 41 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -19271,10 +19590,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 40 /* AsteriskAsteriskToken */) { + if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 194 /* 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 { @@ -19299,23 +19618,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 80 /* DeleteKeyword */: + case 81 /* DeleteKeyword */: return parseDeleteExpression(); - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return parseVoidExpression(); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 121 /* AwaitKeyword */: + case 122 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -19338,16 +19657,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 121 /* AwaitKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 122 /* AwaitKeyword */: return false; - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -19370,21 +19689,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(200 /* PrefixUnaryExpression */); + if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(203 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -19425,7 +19744,7 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 91 /* ImportKeyword */) { + if (token() === 92 /* 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: @@ -19440,8 +19759,8 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(212 /* MetaProperty */, fullStart); - node.keywordToken = 91 /* ImportKeyword */; + var node = createNode(214 /* MetaProperty */, fullStart); + node.keywordToken = 92 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; @@ -19451,7 +19770,7 @@ var ts; } } else { - expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 98 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression. As such, we need to consume the rest of it here to be complete. @@ -19510,22 +19829,22 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* 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. - var node = createNode(187 /* PropertyAccessExpression */, expression.pos); + var node = createNode(189 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 260 /* JsxOpeningElement */) { - var node = createNode(258 /* JsxElement */, opening.pos); + if (opening.kind === 262 /* JsxOpeningElement */) { + var node = createNode(260 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -19534,15 +19853,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 263 /* JsxOpeningFragment */) { - var node = createNode(262 /* JsxFragment */, opening.pos); + else if (opening.kind === 265 /* JsxOpeningFragment */) { + var node = createNode(264 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 261 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -19553,15 +19872,15 @@ 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() === 27 /* LessThanToken */) { + if (inExpressionContext && token() === 28 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(202 /* BinaryExpression */, result.pos); + var badNode = createNode(204 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 + badNode.operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -19569,8 +19888,8 @@ var ts; return result; } function parseJsxText() { - var node = createNode(10 /* JsxText */); - node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */; + var node = createNode(11 /* JsxText */); + node.containsOnlyWhiteSpaces = currentToken === 12 /* JsxTextAllWhiteSpaces */; currentToken = scanner.scanJsxToken(); return finishNode(node); } @@ -19586,15 +19905,15 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 28 /* LessThanSlashToken */: + case 29 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; - case 10 /* JsxText */: - case 11 /* JsxTextAllWhiteSpaces */: + case 11 /* JsxText */: + case 12 /* JsxTextAllWhiteSpaces */: return parseJsxText(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -19615,16 +19934,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(266 /* JsxAttributes */); + var jsxAttributes = createNode(268 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(27 /* LessThanToken */); - if (token() === 29 /* GreaterThanToken */) { + parseExpected(28 /* LessThanToken */); + if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(265 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -19632,23 +19951,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 29 /* GreaterThanToken */) { + if (token() === 30 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(260 /* JsxOpeningElement */, fullStart); + node = createNode(262 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(41 /* SlashToken */); + parseExpected(42 /* SlashToken */); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(259 /* JsxSelfClosingElement */, fullStart); + node = createNode(261 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -19662,10 +19981,10 @@ 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() === 99 /* ThisKeyword */ ? + var expression = token() === 100 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(24 /* DotToken */)) { + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -19673,33 +19992,33 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(268 /* JsxExpression */); - if (!parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(270 /* JsxExpression */); + if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } - if (token() !== 18 /* CloseBraceToken */) { - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + if (token() !== 19 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { - parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(265 /* JsxAttribute */); + var node = createNode(267 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { switch (scanJsxAttributeValue()) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: @@ -19710,72 +20029,72 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(267 /* JsxSpreadAttribute */); - parseExpected(17 /* OpenBraceToken */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(269 /* JsxSpreadAttribute */); + parseExpected(18 /* OpenBraceToken */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(261 /* JsxClosingElement */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(263 /* JsxClosingElement */); + parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(264 /* JsxClosingFragment */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(266 /* JsxClosingFragment */); + parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(192 /* TypeAssertionExpression */); - parseExpected(27 /* LessThanToken */); + var node = createNode(194 /* TypeAssertionExpression */); + parseExpected(28 /* LessThanToken */); node.type = parseType(); - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(23 /* DotToken */); + var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(211 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(213 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { + var indexedAccess = createNode(190 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; - if (token() === 22 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -19784,7 +20103,7 @@ var ts; } indexedAccess.argumentExpression = argument; } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } @@ -19796,13 +20115,13 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; + return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(193 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; - tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); return finishNode(tagExpression); @@ -19810,7 +20129,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { // 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 @@ -19823,15 +20142,15 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(189 /* CallExpression */, expression.pos); + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(189 /* CallExpression */, expression.pos); + else if (token() === 20 /* OpenParenToken */) { + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19841,17 +20160,17 @@ var ts; } } function parseArgumentList() { - parseExpected(19 /* OpenParenToken */); + parseExpected(20 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(27 /* LessThanToken */)) { + if (!parseOptional(28 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(29 /* GreaterThanToken */)) { + if (!parseExpected(30 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -19863,34 +20182,34 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 19 /* OpenParenToken */: // foo( - case 13 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 14 /* TemplateHead */: // foo `...${100}...` + case 20 /* OpenParenToken */: // foo( + case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. - case 23 /* DotToken */: // foo. - case 20 /* CloseParenToken */: // foo) - case 22 /* CloseBracketToken */: // foo] - case 56 /* ColonToken */: // foo: - case 25 /* SemicolonToken */: // foo; - case 55 /* QuestionToken */: // foo? - case 32 /* EqualsEqualsToken */: // foo == - case 34 /* EqualsEqualsEqualsToken */: // foo === - case 33 /* ExclamationEqualsToken */: // foo != - case 35 /* ExclamationEqualsEqualsToken */: // foo !== - case 53 /* AmpersandAmpersandToken */: // foo && - case 54 /* BarBarToken */: // foo || - case 50 /* CaretToken */: // foo ^ - case 48 /* AmpersandToken */: // foo & - case 49 /* BarToken */: // foo | - case 18 /* CloseBraceToken */: // foo } + case 24 /* DotToken */: // foo. + case 21 /* CloseParenToken */: // foo) + case 23 /* CloseBracketToken */: // foo] + case 57 /* ColonToken */: // foo: + case 26 /* SemicolonToken */: // foo; + case 56 /* QuestionToken */: // foo? + case 33 /* EqualsEqualsToken */: // foo == + case 35 /* EqualsEqualsEqualsToken */: // foo === + case 34 /* ExclamationEqualsToken */: // foo != + case 36 /* ExclamationEqualsEqualsToken */: // foo !== + case 54 /* AmpersandAmpersandToken */: // foo && + case 55 /* BarBarToken */: // foo || + case 51 /* CaretToken */: // foo ^ + case 49 /* AmpersandToken */: // foo & + case 50 /* BarToken */: // foo | + case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // 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. return true; - case 26 /* CommaToken */: // foo, - case 17 /* OpenBraceToken */: // foo { + case 27 /* CommaToken */: // foo, + case 18 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -19902,22 +20221,23 @@ var ts; function parsePrimaryExpression() { switch (token()) { case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseTokenNode(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedExpression(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 120 /* AsyncKeyword */: + case 121 /* 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. @@ -19925,76 +20245,76 @@ var ts; break; } return parseFunctionExpression(); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassExpression(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionExpression(); - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) { + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); - parseExpected(19 /* OpenParenToken */); + var node = createNodeWithJSDoc(195 /* ParenthesizedExpression */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(206 /* SpreadElement */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(208 /* SpreadElement */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : + return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* CommaToken */ ? createNode(210 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(185 /* ArrayLiteralExpression */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(187 /* ArrayLiteralExpression */); + parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); - if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 275 /* SpreadAssignment */; + if (parseOptionalToken(25 /* DotDotDotToken */)) { + node.kind = 277 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(51 /* ExclamationToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20002,30 +20322,30 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 274 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(58 /* EqualsToken */); + node.kind = 276 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(59 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 273 /* PropertyAssignment */; - parseExpected(56 /* ColonToken */); + node.kind = 275 /* PropertyAssignment */; + parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(186 /* ObjectLiteralExpression */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(188 /* ObjectLiteralExpression */); + parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -20038,10 +20358,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(194 /* FunctionExpression */); + var node = createNodeWithJSDoc(196 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -20049,7 +20369,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -20061,10 +20381,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(94 /* NewKeyword */); - if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(212 /* MetaProperty */, fullStart); - node_2.keywordToken = 94 /* NewKeyword */; + parseExpected(95 /* NewKeyword */); + if (parseOptional(24 /* DotToken */)) { + var node_2 = createNode(214 /* MetaProperty */, fullStart); + node_2.keywordToken = 95 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } @@ -20080,23 +20400,23 @@ var ts; } break; } - var node = createNode(190 /* NewExpression */, fullStart); + var node = createNode(192 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; - if (node.typeArguments || token() === 19 /* OpenParenToken */) { + if (node.typeArguments || token() === 20 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(216 /* Block */); - if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(218 /* Block */); + if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -20123,52 +20443,52 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(218 /* EmptyStatement */); - parseExpected(25 /* SemicolonToken */); + var node = createNode(220 /* EmptyStatement */); + parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(220 /* IfStatement */); - parseExpected(90 /* IfKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(222 /* IfStatement */); + parseExpected(91 /* IfKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(83 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(221 /* DoStatement */); - parseExpected(81 /* DoKeyword */); + var node = createNode(223 /* DoStatement */); + parseExpected(82 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); // 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(25 /* SemicolonToken */); + parseOptional(26 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(222 /* WhileStatement */); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(224 /* WhileStatement */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(88 /* ForKeyword */); - var awaitToken = parseOptionalToken(121 /* AwaitKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(89 /* ForKeyword */); + var awaitToken = parseOptionalToken(122 /* AwaitKeyword */); + parseExpected(20 /* OpenParenToken */); var initializer; - if (token() !== 25 /* SemicolonToken */) { - if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) { + if (token() !== 26 /* SemicolonToken */) { + if (token() === 105 /* VarKeyword */ || token() === 111 /* LetKeyword */ || token() === 77 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -20176,33 +20496,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(225 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(147 /* OfKeyword */) : parseOptional(147 /* OfKeyword */)) { + var forOfStatement = createNode(227 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(224 /* ForInStatement */, pos); + else if (parseOptional(93 /* InKeyword */)) { + var forInStatement = createNode(226 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(223 /* ForStatement */, pos); + var forStatement = createNode(225 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(25 /* SemicolonToken */); - if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(25 /* SemicolonToken */); - if (token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 21 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -20210,7 +20530,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 229 /* BreakStatement */ ? 73 /* BreakKeyword */ : 78 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -20218,8 +20538,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(228 /* ReturnStatement */); - parseExpected(96 /* ReturnKeyword */); + var node = createNode(230 /* ReturnStatement */); + parseExpected(97 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -20227,42 +20547,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(229 /* WithStatement */); - parseExpected(107 /* WithKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(231 /* WithStatement */); + parseExpected(108 /* WithKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(269 /* CaseClause */); - parseExpected(73 /* CaseKeyword */); + var node = createNode(271 /* CaseClause */); + parseExpected(74 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(270 /* DefaultClause */); - parseExpected(79 /* DefaultKeyword */); - parseExpected(56 /* ColonToken */); + var node = createNode(272 /* DefaultClause */); + parseExpected(80 /* DefaultKeyword */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 74 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(230 /* SwitchStatement */); - parseExpected(98 /* SwitchKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(232 /* SwitchStatement */); + parseExpected(99 /* SwitchKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(244 /* CaseBlock */); - parseExpected(17 /* OpenBraceToken */); + parseExpected(21 /* CloseParenToken */); + var caseBlock = createNode(246 /* CaseBlock */); + parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -20274,32 +20594,32 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(232 /* ThrowStatement */); - parseExpected(100 /* ThrowKeyword */); + var node = createNode(234 /* ThrowStatement */); + parseExpected(101 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(233 /* TryStatement */); - parseExpected(102 /* TryKeyword */); + var node = createNode(235 /* TryStatement */); + parseExpected(103 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 75 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 87 /* FinallyKeyword */) { - parseExpected(87 /* FinallyKeyword */); + if (!node.catchClause || token() === 88 /* FinallyKeyword */) { + parseExpected(88 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(272 /* CatchClause */); - parseExpected(74 /* CatchKeyword */); - if (parseOptional(19 /* OpenParenToken */)) { + var result = createNode(274 /* CatchClause */); + parseExpected(75 /* CatchKeyword */); + if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -20309,8 +20629,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(234 /* DebuggerStatement */); - parseExpected(78 /* DebuggerKeyword */); + var node = createNode(236 /* DebuggerStatement */); + parseExpected(79 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -20320,13 +20640,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 231 /* LabeledStatement */; + if (expression.kind === 72 /* Identifier */ && parseOptional(57 /* ColonToken */)) { + node.kind = 233 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 219 /* ExpressionStatement */; + node.kind = 221 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -20338,25 +20658,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 76 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 90 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* 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 @@ -20379,41 +20699,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 132 /* ReadonlyKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 133 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 144 /* GlobalKeyword */: + case 145 /* GlobalKeyword */: nextToken(); - return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; - case 91 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 72 /* Identifier */ || token() === 85 /* ExportKeyword */; + case 92 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 84 /* ExportKeyword */: + return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 85 /* ExportKeyword */: nextToken(); - if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ || - token() === 118 /* AsKeyword */) { + if (token() === 59 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 80 /* DefaultKeyword */ || + token() === 119 /* AsKeyword */) { return true; } continue; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: nextToken(); continue; default: @@ -20426,50 +20746,50 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 57 /* AtToken */: - case 25 /* SemicolonToken */: - case 17 /* OpenBraceToken */: - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 90 /* IfKeyword */: - case 81 /* DoKeyword */: - case 106 /* WhileKeyword */: - case 88 /* ForKeyword */: - case 77 /* ContinueKeyword */: - case 72 /* BreakKeyword */: - case 96 /* ReturnKeyword */: - case 107 /* WithKeyword */: - case 98 /* SwitchKeyword */: - case 100 /* ThrowKeyword */: - case 102 /* TryKeyword */: - case 78 /* DebuggerKeyword */: + case 58 /* AtToken */: + case 26 /* SemicolonToken */: + case 18 /* OpenBraceToken */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 91 /* IfKeyword */: + case 82 /* DoKeyword */: + case 107 /* WhileKeyword */: + case 89 /* ForKeyword */: + case 78 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 97 /* ReturnKeyword */: + case 108 /* WithKeyword */: + case 99 /* SwitchKeyword */: + case 101 /* ThrowKeyword */: + case 103 /* TryKeyword */: + case 79 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 76 /* ConstKeyword */: - case 84 /* ExportKeyword */: + case 77 /* ConstKeyword */: + case 85 /* ExportKeyword */: return isStartOfDeclaration(); - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 109 /* InterfaceKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 139 /* TypeKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 110 /* InterfaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 140 /* TypeKeyword */: + case 145 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 116 /* StaticKeyword */: + case 133 /* 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); @@ -20479,7 +20799,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */; + return isIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -20488,67 +20808,67 @@ var ts; } function parseStatement() { switch (token()) { - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: return parseEmptyStatement(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); - case 110 /* LetKeyword */: + case 105 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); + case 111 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); } break; - case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); - case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); - case 90 /* IfKeyword */: + case 90 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(239 /* FunctionDeclaration */)); + case 76 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(240 /* ClassDeclaration */)); + case 91 /* IfKeyword */: return parseIfStatement(); - case 81 /* DoKeyword */: + case 82 /* DoKeyword */: return parseDoStatement(); - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return parseWhileStatement(); - case 88 /* ForKeyword */: + case 89 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(226 /* ContinueStatement */); - case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(227 /* BreakStatement */); - case 96 /* ReturnKeyword */: + case 78 /* ContinueKeyword */: + return parseBreakOrContinueStatement(228 /* ContinueStatement */); + case 73 /* BreakKeyword */: + return parseBreakOrContinueStatement(229 /* BreakStatement */); + case 97 /* ReturnKeyword */: return parseReturnStatement(); - case 107 /* WithKeyword */: + case 108 /* WithKeyword */: return parseWithStatement(); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return parseSwitchStatement(); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return parseThrowStatement(); - case 102 /* TryKeyword */: + case 103 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return parseTryStatement(); - case 78 /* DebuggerKeyword */: + case 79 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 57 /* AtToken */: + case 58 /* AtToken */: return parseDeclaration(); - case 120 /* AsyncKeyword */: - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 83 /* EnumKeyword */: - case 84 /* ExportKeyword */: - case 91 /* ImportKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 117 /* AbstractKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 84 /* EnumKeyword */: + case 85 /* ExportKeyword */: + case 92 /* ImportKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 118 /* AbstractKeyword */: + case 116 /* StaticKeyword */: + case 133 /* ReadonlyKeyword */: + case 145 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -20557,7 +20877,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 124 /* DeclareKeyword */; + return modifier.kind === 125 /* DeclareKeyword */; } function parseDeclaration() { var node = createNodeWithJSDoc(0 /* Unknown */); @@ -20576,33 +20896,33 @@ var ts; } function parseDeclarationWorker(node) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: return parseVariableStatement(node); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassDeclaration(node); - case 109 /* InterfaceKeyword */: + case 110 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 139 /* TypeKeyword */: + case 140 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 83 /* EnumKeyword */: + case 84 /* EnumKeyword */: return parseEnumDeclaration(node); - case 144 /* GlobalKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 145 /* GlobalKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: nextToken(); switch (token()) { - case 79 /* DefaultKeyword */: - case 58 /* EqualsToken */: + case 80 /* DefaultKeyword */: + case 59 /* EqualsToken */: return parseExportAssignment(node); - case 118 /* AsKeyword */: + case 119 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -20611,7 +20931,7 @@ var ts; if (node.decorators || node.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(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(258 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -20622,10 +20942,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -20633,25 +20953,25 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 26 /* CommaToken */) { - return createNode(208 /* OmittedExpression */); + if (token() === 27 /* CommaToken */) { + return createNode(210 /* OmittedExpression */); } - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 56 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -20659,27 +20979,27 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(182 /* ObjectBindingPattern */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(184 /* ObjectBindingPattern */); + parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(183 /* ArrayBindingPattern */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(185 /* ArrayBindingPattern */); + parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier(); + return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); @@ -20688,10 +21008,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(235 /* VariableDeclaration */); + var node = createNode(237 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 71 /* Identifier */ && - token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 72 /* Identifier */ && + token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20701,14 +21021,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(236 /* VariableDeclarationList */); + var node = createNode(238 /* VariableDeclarationList */); switch (token()) { - case 104 /* VarKeyword */: + case 105 /* VarKeyword */: break; - case 110 /* LetKeyword */: + case 111 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -20724,7 +21044,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 147 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -20736,44 +21056,44 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 217 /* VariableStatement */; + node.kind = 219 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 237 /* FunctionDeclaration */; - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + node.kind = 239 /* FunctionDeclaration */; + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 155 /* Constructor */; - parseExpected(123 /* ConstructorKeyword */); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + node.kind = 157 /* Constructor */; + parseExpected(124 /* ConstructorKeyword */); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 154 /* MethodDeclaration */; + node.kind = 156 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 152 /* PropertyDeclaration */; - if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 154 /* PropertyDeclaration */; + if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20793,12 +21113,12 @@ var ts; return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.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. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -20806,13 +21126,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 57 /* AtToken */) { + if (token() === 58 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -20829,7 +21149,7 @@ var ts; } nextToken(); } - if (token() === 39 /* AsteriskToken */) { + if (token() === 40 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -20839,24 +21159,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* 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 === 136 /* SetKeyword */ || idToken === 125 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 137 /* SetKeyword */ || idToken === 126 /* 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 19 /* OpenParenToken */: // Method declaration - case 27 /* LessThanToken */: // Generic Method declaration - case 51 /* ExclamationToken */: // Non-null assertion on property name - case 56 /* ColonToken */: // Type Annotation for declaration - case 58 /* EqualsToken */: // Initializer for declaration - case 55 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* OpenParenToken */: // Method declaration + case 28 /* LessThanToken */: // Generic Method declaration + case 52 /* ExclamationToken */: // Non-null assertion on property name + case 57 /* ColonToken */: // Type Annotation for declaration + case 59 /* EqualsToken */: // Initializer for declaration + case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -20874,10 +21194,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(57 /* AtToken */)) { + if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(150 /* Decorator */, decoratorStart); + var decorator = createNode(152 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -20897,7 +21217,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 77 /* 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)) { @@ -20916,7 +21236,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -20926,21 +21246,21 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 25 /* SemicolonToken */) { - var result = createNode(215 /* SemicolonClassElement */); + if (token() === 26 /* SemicolonToken */) { + var result = createNode(217 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - if (token() === 123 /* ConstructorKeyword */) { + if (token() === 124 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); } if (isIndexSignature()) { @@ -20949,37 +21269,37 @@ 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() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 39 /* AsteriskToken */ || - token() === 21 /* OpenBracketToken */) { + token() === 40 /* AsteriskToken */ || + token() === 22 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(node); } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // '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(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 209 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 240 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(75 /* ClassKeyword */); + parseExpected(76 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -20997,7 +21317,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 109 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21009,33 +21329,33 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(271 /* HeritageClause */); + ts.Debug.assert(tok === 86 /* ExtendsKeyword */ || tok === 109 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(273 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(209 /* ExpressionWithTypeArguments */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 27 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */) + return token() === 28 /* LessThanToken */ + ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 239 /* InterfaceDeclaration */; - parseExpected(109 /* InterfaceKeyword */); + node.kind = 241 /* InterfaceDeclaration */; + parseExpected(110 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21043,11 +21363,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 240 /* TypeAliasDeclaration */; - parseExpected(139 /* TypeKeyword */); + node.kind = 242 /* TypeAliasDeclaration */; + parseExpected(140 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -21057,18 +21377,18 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(276 /* EnumMember */); + var node = createNodeWithJSDoc(278 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 241 /* EnumDeclaration */; - parseExpected(83 /* EnumKeyword */); + node.kind = 243 /* EnumDeclaration */; + parseExpected(84 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21076,10 +21396,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(243 /* ModuleBlock */); - if (parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(245 /* ModuleBlock */); + if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -21087,20 +21407,20 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 242 /* ModuleDeclaration */; + node.kind = 244 /* ModuleDeclaration */; // 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 */; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(23 /* DotToken */) + node.body = parseOptional(24 /* DotToken */) ? parseModuleOrNamespaceDeclaration(createNode(0 /* Unknown */), 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 242 /* ModuleDeclaration */; - if (token() === 144 /* GlobalKeyword */) { + node.kind = 244 /* ModuleDeclaration */; + if (token() === 145 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -21109,7 +21429,7 @@ var ts; node.name = parseLiteralNode(); node.name.text = internIdentifier(node.name.text); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -21119,68 +21439,68 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 144 /* GlobalKeyword */) { + if (token() === 145 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(130 /* NamespaceKeyword */)) { + else if (parseOptional(131 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(129 /* ModuleKeyword */); - if (token() === 9 /* StringLiteral */) { + parseExpected(130 /* ModuleKeyword */); + if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } } return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 133 /* RequireKeyword */ && + return token() === 134 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 19 /* OpenParenToken */; + return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 41 /* SlashToken */; + return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 245 /* NamespaceExportDeclaration */; - parseExpected(118 /* AsKeyword */); - parseExpected(130 /* NamespaceKeyword */); + node.kind = 247 /* NamespaceExportDeclaration */; + parseExpected(119 /* AsKeyword */); + parseExpected(131 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(91 /* ImportKeyword */); + parseExpected(92 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 144 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 247 /* ImportDeclaration */; + node.kind = 249 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 39 /* AsteriskToken */ || // import * - token() === 17 /* OpenBraceToken */) { // import { + token() === 40 /* AsteriskToken */ || // import * + token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(143 /* FromKeyword */); + parseExpected(144 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 246 /* ImportEqualsDeclaration */; + node.kind = 248 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -21192,7 +21512,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(248 /* ImportClause */, fullStart); + var importClause = createNode(250 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -21201,8 +21521,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); + parseOptional(27 /* CommaToken */)) { + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(252 /* NamedImports */); } return finishNode(importClause); } @@ -21212,15 +21532,15 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(257 /* ExternalModuleReference */); - parseExpected(133 /* RequireKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(259 /* ExternalModuleReference */); + parseExpected(134 /* RequireKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { - if (token() === 9 /* StringLiteral */) { + if (token() === 10 /* StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -21235,9 +21555,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(249 /* NamespaceImport */); - parseExpected(39 /* AsteriskToken */); - parseExpected(118 /* AsKeyword */); + var namespaceImport = createNode(251 /* NamespaceImport */); + parseExpected(40 /* AsteriskToken */); + parseExpected(119 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -21250,14 +21570,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 252 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(255 /* ExportSpecifier */); + return parseImportOrExportSpecifier(257 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(251 /* ImportSpecifier */); + return parseImportOrExportSpecifier(253 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -21271,9 +21591,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(118 /* AsKeyword */); + parseExpected(119 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -21282,24 +21602,24 @@ var ts; else { node.name = identifierName; } - if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 253 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 253 /* ExportDeclaration */; - if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(143 /* FromKeyword */); + node.kind = 255 /* ExportDeclaration */; + if (parseOptional(40 /* AsteriskToken */)) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(254 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(256 /* 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() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(143 /* FromKeyword */); + if (token() === 144 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -21307,12 +21627,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 252 /* ExportAssignment */; - if (parseOptional(58 /* EqualsToken */)) { + node.kind = 254 /* ExportAssignment */; + if (parseOptional(59 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(79 /* DefaultKeyword */); + parseExpected(80 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -21327,10 +21647,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ - || node.kind === 247 /* ImportDeclaration */ - || node.kind === 252 /* ExportAssignment */ - || node.kind === 253 /* ExportDeclaration */ + || node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */ + || node.kind === 249 /* ImportDeclaration */ + || node.kind === 254 /* ExportAssignment */ + || node.kind === 255 /* ExportDeclaration */ ? node : undefined; } @@ -21343,7 +21663,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 91 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 92 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -21394,11 +21714,11 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); + var result = createNode(283 /* JSDocTypeExpression */); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } fixupParentReferences(result); return finishNode(result); @@ -21486,7 +21806,7 @@ var ts; } loop: while (true) { switch (token()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -21506,7 +21826,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -21557,7 +21877,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(289 /* JSDocComment */, start); + var result = createNode(291 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -21591,20 +21911,19 @@ var ts; } } var precedingLineBreak = scanner.hasPrecedingLineBreak(); - while ((precedingLineBreak && token() === 39 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; } - else if (token() === 39 /* AsteriskToken */) { + else if (token() === 40 /* AsteriskToken */) { precedingLineBreak = false; } nextJSDocToken(); } } function parseTag(indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getTokenPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); skipWhitespaceOrAsterisk(); @@ -21612,40 +21931,40 @@ var ts; switch (tagName.escapedText) { case "augments": case "extends": - tag = parseAugmentsTag(atToken, tagName); + tag = parseAugmentsTag(start, tagName); break; case "class": case "constructor": - tag = parseClassTag(atToken, tagName); + tag = parseClassTag(start, tagName); break; case "this": - tag = parseThisTag(atToken, tagName); + tag = parseThisTag(start, tagName); break; case "enum": - tag = parseEnumTag(atToken, tagName); + tag = parseEnumTag(start, tagName); break; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent); + return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, indent); case "return": case "returns": - tag = parseReturnTag(atToken, tagName); + tag = parseReturnTag(start, tagName); break; case "template": - tag = parseTemplateTag(atToken, tagName); + tag = parseTemplateTag(start, tagName); break; case "type": - tag = parseTypeTag(atToken, tagName); + tag = parseTypeTag(start, tagName); break; case "typedef": - tag = parseTypedefTag(atToken, tagName, indent); + tag = parseTypedefTag(start, tagName, indent); break; case "callback": - tag = parseCallbackTag(atToken, tagName, indent); + tag = parseCallbackTag(start, tagName, indent); break; default: - tag = parseUnknownTag(atToken, tagName); + tag = parseUnknownTag(start, tagName); break; } if (!tag.comment) { @@ -21675,7 +21994,7 @@ var ts; } indent = 0; break; - case 57 /* AtToken */: + case 58 /* AtToken */: scanner.setTextPos(scanner.getTextPos() - 1); // falls through case 1 /* EndOfFileToken */: @@ -21694,9 +22013,9 @@ var ts; indent += whitespace.length; } break; - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextJSDocToken() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextJSDocToken(); pushComment(scanner.getTokenText()); @@ -21704,7 +22023,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -21724,9 +22043,8 @@ var ts; removeTrailingWhitespace(comments); return comments.length === 0 ? undefined : comments.join(""); } - function parseUnknownTag(atToken, tagName) { - var result = createNode(292 /* JSDocTag */, atToken.pos); - result.atToken = atToken; + function parseUnknownTag(start, tagName) { + var result = createNode(294 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -21745,37 +22063,37 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { - if (token() === 13 /* NoSubstitutionTemplateLiteral */) { + if (token() === 14 /* NoSubstitutionTemplateLiteral */) { // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild return { name: createIdentifier(/*isIdentifier*/ true), isBracketed: false }; } // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptional(21 /* OpenBracketToken */); + var isBracketed = parseOptional(22 /* OpenBracketToken */); var name = parseJSDocEntityName(); if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(58 /* EqualsToken */)) { + if (parseOptionalToken(59 /* EqualsToken */)) { parseExpression(); } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; } } - function parseParameterOrPropertyTag(atToken, tagName, target, indent) { + function parseParameterOrPropertyTag(start, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); @@ -21785,15 +22103,14 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(303 /* JSDocPropertyTag */, atToken.pos) : - createNode(297 /* JSDocParameterTag */, atToken.pos); - var comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); + createNode(305 /* JSDocPropertyTag */, start) : + createNode(299 /* JSDocParameterTag */, start); + var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; result.name = name; @@ -21804,20 +22121,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) { + if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -21825,81 +22142,74 @@ var ts; } } } - function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 298 /* JSDocReturnTag */; })) { + function parseReturnTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(298 /* JSDocReturnTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(300 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } - function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocTypeTag */; })) { + function parseTypeTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocTypeTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(302 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } - function parseAugmentsTag(atToken, tagName) { - var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); - result.atToken = atToken; + function parseAugmentsTag(start, tagName) { + var result = createNode(295 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(209 /* ExpressionWithTypeArguments */); + var usedBrace = parseOptional(18 /* OpenBraceToken */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); if (usedBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var prop = createNode(187 /* PropertyAccessExpression */, node.pos); + while (parseOptional(24 /* DotToken */)) { + var prop = createNode(189 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); } return node; } - function parseClassTag(atToken, tagName) { - var tag = createNode(294 /* JSDocClassTag */, atToken.pos); - tag.atToken = atToken; + function parseClassTag(start, tagName) { + var tag = createNode(296 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } - function parseThisTag(atToken, tagName) { - var tag = createNode(299 /* JSDocThisTag */, atToken.pos); - tag.atToken = atToken; + function parseThisTag(start, tagName) { + var tag = createNode(301 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseEnumTag(atToken, tagName) { - var tag = createNode(296 /* JSDocEnumTag */, atToken.pos); - tag.atToken = atToken; + function parseEnumTag(start, tagName) { + var tag = createNode(298 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseTypedefTag(atToken, tagName, indent) { + function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); - typedefTag.atToken = atToken; + var typedefTag = createNode(304 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -21911,12 +22221,11 @@ var ts; var child = void 0; var jsdocTypeLiteral = void 0; var childTypeTag = void 0; - var start_3 = atToken.pos; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); } - if (child.kind === 300 /* JSDocTypeTag */) { + if (child.kind === 302 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21929,7 +22238,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -21947,8 +22256,8 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); + if (parseOptional(24 /* DotToken */)) { + var jsDocNamespaceNode = createNode(244 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21961,25 +22270,23 @@ var ts; } return typeNameOrNamespaceName; } - function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); - callbackTag.atToken = atToken; + function parseCallbackTag(start, tagName, indent) { + var callbackTag = createNode(297 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var start = scanner.getStartPos(); - var jsdocSignature = createNode(291 /* JSDocSignature */, start); + var jsdocSignature = createNode(293 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(57 /* AtToken */)) { + if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 298 /* JSDocReturnTag */) { + if (tag && tag.kind === 300 /* JSDocReturnTag */) { return tag; } } @@ -22021,10 +22328,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextJSDocToken()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) && + if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22037,13 +22344,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -22052,16 +22359,15 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getStartPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); skipWhitespace(); var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(atToken, tagName); + return target === 1 /* Property */ && parseTypeTag(start, tagName); case "prop": case "property": t = 1 /* Property */; @@ -22077,26 +22383,25 @@ var ts; if (!(target & t)) { return false; } - return parseParameterOrPropertyTag(atToken, tagName, target, indent); + return parseParameterOrPropertyTag(start, tagName, target, indent); } - function parseTemplateTag(atToken, tagName) { + function parseTemplateTag(start, tagName) { // the template tag looks like '@template {Constraint} T,U,V' var constraint; - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(148 /* TypeParameter */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); - } while (parseOptionalJsdoc(26 /* CommaToken */)); - var result = createNode(301 /* JSDocTemplateTag */, atToken.pos); - result.atToken = atToken; + } while (parseOptionalJsdoc(27 /* CommaToken */)); + var result = createNode(303 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22115,16 +22420,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* 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(23 /* DotToken */)) { + while (parseOptional(24 /* DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -22132,11 +22437,11 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(71 /* Identifier */, pos); + var result = createNode(72 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); nextJSDocToken(); @@ -22262,9 +22567,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 71 /* Identifier */: + case 72 /* Identifier */: return true; } return false; @@ -22842,10 +23147,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 71 /* Identifier */) { + if (lhs.kind === 72 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 99 /* ThisKeyword */) { + if (lhs.kind === 100 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -22902,7 +23207,8 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], - ["esnext.intl", "lib.esnext.intl.d.ts"] + ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.bigint", "lib.esnext.bigint.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -22959,6 +23265,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, { name: "traceResolution", type: "boolean", @@ -23009,11 +23322,11 @@ var ts; description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date }, { - name: "pretty", + name: "showConfig", type: "boolean", - showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + isCommandLineOnly: true, + description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, // Basic { @@ -23606,7 +23919,7 @@ var ts; { name: "maxNodeModuleJsDepth", type: "number", - // TODO: GH#27108 affectsModuleResolution: true, + affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, @@ -24062,6 +24375,9 @@ var ts; } var result = ts.parseJsonText(configFileName, configFileText); var cwd = host.getCurrentDirectory(); + result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd)); } ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile; @@ -24201,7 +24517,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 273 /* PropertyAssignment */) { + if (element.kind !== 275 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -24257,16 +24573,16 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 101 /* TrueKeyword */: + case 102 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -24283,13 +24599,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 200 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 202 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -24306,7 +24622,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -24346,6 +24662,115 @@ var ts; } return false; } + /** + * Generate an uncommented, complete tsconfig for use with "--showConfig" + * @param configParseResult options to be generated into tsconfig.json + * @param configFileName name of the parsed config file - output paths will be generated relative to this + * @param host provides current directory and case sensitivity services + */ + /** @internal */ + function convertToTSConfig(configParseResult, configFileName, host) { + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var files = ts.map(ts.filter(configParseResult.fileNames, !configParseResult.configFileSpecs ? function (_) { return false; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), f, getCanonicalFileName); }); + var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); + var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var _a; + return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), + exclude: configParseResult.configFileSpecs.validatedExcludeSpecs + } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + return config; + } + ts.convertToTSConfig = convertToTSConfig; + function filterSameAsDefaultInclude(specs) { + if (!ts.length(specs)) + return undefined; + if (ts.length(specs) !== 1) + return specs; + if (specs[0] === "**/*") + return undefined; + return specs; + } + function matchesSpecs(path, includeSpecs, excludeSpecs) { + if (!includeSpecs) + return function (_) { return false; }; + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + if (includeRe) { + if (excludeRe) { + return function (path) { return includeRe.test(path) && !excludeRe.test(path); }; + } + return function (path) { return includeRe.test(path); }; + } + if (excludeRe) { + return function (path) { return !excludeRe.test(path); }; + } + return function (_) { return false; }; + } + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + // this is of a type CommandLineOptionOfPrimitiveType + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + // There is a typeMap associated with this command-line option so use it to map value back to its name + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options, pathOptions) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); + var _loop_3 = function (name) { + if (ts.hasProperty(options, name)) { + // tsconfig only options cannot be specified via command line, + // so we can assume that only types that can appear here string | number | boolean + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + return "continue"; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap_1) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + if (pathOptions && optionDefinition.isFilePath) { + result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)); + } + else { + result.set(name, value); + } + } + else { + if (optionDefinition.type === "list") { + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 + } + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); + } + } + } + } + }; + for (var name in options) { + _loop_3(name); + } + return result; + } /** * Generate tsconfig configuration when running command line "--init" * @param options commandlineOptions to be generated into tsconfig.json @@ -24356,62 +24781,6 @@ var ts; var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var compilerOptionsMap = serializeCompilerOptions(compilerOptions); return writeConfigurations(); - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - // this is of a type CommandLineOptionOfPrimitiveType - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - // There is a typeMap associated with this command-line option so use it to map value back to its name - return ts.forEachEntry(customTypeMap, function (mapValue, key) { - if (mapValue === value) { - return key; - } - }); - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - var _loop_3 = function (name) { - if (ts.hasProperty(options, name)) { - // tsconfig only options cannot be specified via command line, - // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { - return "continue"; - } - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap_1) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result.set(name, value); - } - else { - if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); - } - } - } - } - }; - for (var name in options) { - _loop_3(name); - } - return result; - } function getDefaultValueForOption(option) { switch (option.type) { case "number": @@ -24800,20 +25169,24 @@ var ts; } function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) { extendedConfig = ts.normalizeSlashes(extendedConfig); - // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../"))) { - errors.push(createDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return undefined; - } - var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return undefined; + 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 */)) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; + } } + return extendedConfigPath; } - return extendedConfigPath; + // If the path isn't a rooted or relative path, resolve like a module + var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, /*cache*/ undefined, /*projectRefs*/ undefined, /*lookupConfig*/ true); + if (resolved.resolvedModule) { + return resolved.resolvedModule.resolvedFileName; + } + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; } function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors) { var _a; @@ -25263,7 +25636,7 @@ var ts; } } /** - * Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed. + * Produces a cleaned version of compiler options with personally identifying info (aka, paths) removed. * Also converts enum values back to strings. */ /* @internal */ @@ -25334,7 +25707,8 @@ var ts; Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; - Extensions[Extensions["DtsOnly"] = 3] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -25380,6 +25754,9 @@ var ts; return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state) || readPackageJsonPathField(jsonContent, "types", baseDirectory, state); } + function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) { + return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state); + } function readPackageJsonMainField(jsonContent, baseDirectory, state) { return readPackageJsonPathField(jsonContent, "main", baseDirectory, state); } @@ -25479,8 +25856,11 @@ var 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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { var traceEnabled = isTraceEnabled(options, host); + if (redirectedReference) { + options = redirectedReference.commandLine.options; + } var failedLookupLocations = []; var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -25501,6 +25881,9 @@ var ts; trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); } } + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var resolved = primaryLookup(); var primary = true; @@ -25510,13 +25893,12 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - if (!options.preserveSymlinks) { - resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); - } + var fileName = resolved.fileName, packageId = resolved.packageId; + var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -25525,7 +25907,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - return ts.forEach(typeRoots, function (typeRoot) { + return ts.firstDefined(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); var directoryExists = ts.directoryProbablyExists(candidateDirectory, host); @@ -25550,13 +25932,14 @@ var ts; } var result = void 0; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { - result = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined); + var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); + result = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = toSearchResult(nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true)); + result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - var resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25616,29 +25999,56 @@ var ts; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { - return createModuleResolutionCacheWithMaps(ts.createMap(), ts.createMap(), currentDirectory, getCanonicalFileName); + return createModuleResolutionCacheWithMaps(createCacheWithRedirects(), createCacheWithRedirects(), currentDirectory, getCanonicalFileName); } ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ + function createCacheWithRedirects() { + var ownMap = ts.createMap(); + var redirectsMap = ts.createMap(); + return { + ownMap: ownMap, + redirectsMap: redirectsMap, + getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, + clear: clear + }; + function getOrCreateMapOfCacheRedirects(redirectedReference) { + if (!redirectedReference) { + return ownMap; + } + var path = redirectedReference.sourceFile.path; + var redirects = redirectsMap.get(path); + if (!redirects) { + redirects = ts.createMap(); + redirectsMap.set(path, redirects); + } + return redirects; + } + function clear() { + ownMap.clear(); + redirectsMap.clear(); + } + } + ts.createCacheWithRedirects = createCacheWithRedirects; + /*@internal*/ function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; - function getOrCreateCacheForDirectory(directoryName) { + function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - var perFolderCache = directoryToModuleNameMap.get(path); - if (!perFolderCache) { - perFolderCache = ts.createMap(); - directoryToModuleNameMap.set(path, perFolderCache); - } - return perFolderCache; + return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap); } - function getOrCreateCacheForModuleName(nonRelativeModuleName) { + function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); - if (!perModuleNameCache) { - perModuleNameCache = createPerModuleNameCache(); - moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); } - return perModuleNameCache; + return result; } function createPerModuleNameCache() { var directoryPathMap = ts.createMap(); @@ -25713,13 +26123,19 @@ var ts; return perFolderCache && perFolderCache.get(moduleName); } ts.resolveModuleNameFromCache = resolveModuleNameFromCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); + if (redirectedReference) { + compilerOptions = redirectedReference.commandLine.options; + } if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var containingDirectory = ts.getDirectoryPath(containingFile); - var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference); var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -25741,10 +26157,10 @@ var ts; } switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); @@ -25753,7 +26169,7 @@ var ts; perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { // put result in per-module name cache - cache.getOrCreateCacheForModuleName(moduleName).set(containingDirectory, result); + cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result); } } } @@ -25829,6 +26245,9 @@ var ts; * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. */ function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) { + var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state); + if (resolved) + return resolved.value; if (!ts.isExternalModuleNameRelative(moduleName)) { return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state); } @@ -25836,6 +26255,16 @@ var ts; return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state); } } + function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { + var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + if (baseUrl && paths && !ts.pathIsRelative(moduleName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); + } + } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { if (!state.compilerOptions.rootDirs) { return undefined; @@ -25905,22 +26334,13 @@ var ts; return undefined; } function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var baseUrl = state.compilerOptions.baseUrl; if (!baseUrl) { return undefined; } if (state.traceEnabled) { trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); } - if (paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - var resolved = tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); - if (resolved) { - return resolved.value; - } - } var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName)); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate); @@ -25947,22 +26367,22 @@ var ts; return resolvedModule && resolvedModule.resolvedFileName; } ts.tryResolveJSModule = tryResolveJSModule; + var jsOnlyExtensions = [Extensions.JavaScript]; + var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; + var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { - return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true); + return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false); + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { + return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, jsOnly) { + function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; - var result = jsOnly ? - tryResolve(Extensions.JavaScript) : - (tryResolve(Extensions.TypeScript) || - tryResolve(Extensions.JavaScript) || - (compilerOptions.resolveJsonModule ? tryResolve(Extensions.Json) : undefined)); + var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); @@ -25972,13 +26392,13 @@ var ts; var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); if (resolved) { - return toSearchResult({ resolved: resolved, isExternalLibraryImport: ts.stringContains(resolved.path, ts.nodeModulesPathPart) }); + return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) }); } if (!ts.isExternalModuleNameRelative(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache); + var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved_1) return undefined; var resolvedValue = resolved_1.value; @@ -26044,6 +26464,11 @@ var ts; } /*@internal*/ ts.nodeModulesPathPart = "/node_modules/"; + /*@internal*/ + function pathContainsNodeModules(path) { + return ts.stringContains(path, ts.nodeModulesPathPart); + } + ts.pathContainsNodeModules = pathContainsNodeModules; /** * This will be called on the successfully resolved path from `loadModuleFromFile`. * (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.) @@ -26094,9 +26519,9 @@ var ts; * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { - if (extensions === Extensions.Json) { + if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, onlyRecordFailures, state); + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); @@ -26130,6 +26555,7 @@ var ts; return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); case Extensions.JavaScript: return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + case Extensions.TSConfig: case Extensions.Json: return tryExtension(".json" /* Json */); } @@ -26214,11 +26640,27 @@ var ts; } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { - var packageFile = jsonContent && (extensions !== Extensions.JavaScript && extensions !== Extensions.Json - ? readPackageJsonTypesFields(jsonContent, candidate, state) || - // When resolving typescript modules, try resolving using main field as well - (extensions === Extensions.TypeScript ? readPackageJsonMainField(jsonContent, candidate, state) : undefined) - : readPackageJsonMainField(jsonContent, candidate, state)); + var packageFile; + if (jsonContent) { + switch (extensions) { + case Extensions.JavaScript: + case Extensions.Json: + packageFile = readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.TypeScript: + // When resolving typescript modules, try resolving using main field as well + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.DtsOnly: + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state); + break; + case Extensions.TSConfig: + packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state); + break; + default: + return ts.Debug.assertNever(extensions); + } + } var loader = function (extensions, candidate, onlyRecordFailures, state) { var fromFile = tryFile(candidate, onlyRecordFailures, state); if (fromFile) { @@ -26237,7 +26679,7 @@ var ts; }; var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined; var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host); - var indexPath = ts.combinePaths(candidate, "index"); + var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index"); if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) { var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, /*ignoreCase*/ false); if (state.traceEnabled) { @@ -26264,6 +26706,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + case Extensions.TSConfig: case Extensions.Json: return extension === ".json" /* Json */; case Extensions.TypeScript: @@ -26281,15 +26724,15 @@ var ts; return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } ts.parsePackageName = parsePackageName; - function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache) { - return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache); + function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) { + return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference); } function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined); + return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined); } - function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state); @@ -26310,7 +26753,7 @@ var ts; if (packageResult) { return packageResult; } - if (extensions !== Extensions.JavaScript && extensions !== Extensions.Json) { + if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) { var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); var nodeModulesAtTypesExists = nodeModulesFolderExists; if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { @@ -26443,7 +26886,7 @@ var ts; return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + 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 }; @@ -26457,7 +26900,7 @@ var ts; return { value: resolvedUsingSettings }; } if (!ts.isExternalModuleNameRelative(moduleName)) { - var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName); + var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); // Climb up parent directories looking for a module. var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); @@ -26523,24 +26966,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 243 /* ModuleBlock */: { + case 245 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -26562,9 +27005,9 @@ var ts; }); return state_1; } - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(node); - case 71 /* Identifier */: + case 72 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -26725,7 +27168,7 @@ var ts; // 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 === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -26734,7 +27177,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -26746,36 +27189,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "__constructor" /* Constructor */; - case 163 /* FunctionType */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: return "__call" /* Call */; - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return "__new" /* New */; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "__index" /* Index */; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 149 /* Parameter */: + case 151 /* 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 === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (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; @@ -26873,7 +27316,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 === 252 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 254 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; } @@ -26900,7 +27343,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 257 /* ExportSpecifier */ || (node.kind === 248 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -26967,7 +27410,7 @@ var ts; // 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 !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -26999,7 +27442,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property intialization checks. - currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 157 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -27012,13 +27455,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -27061,8 +27504,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -27095,78 +27538,78 @@ var ts; return; } switch (node.kind) { - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: bindWhileStatement(node); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: bindDoStatement(node); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: bindForStatement(node); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: bindIfStatement(node); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: bindTryStatement(node); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: bindSwitchStatement(node); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: bindCaseBlock(node); break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: bindCaseClause(node); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: bindLabeledStatement(node); break; - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 277 /* SourceFile */: { + case 279 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -27177,26 +27620,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return hasNarrowableArgument(expr); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 200 /* PrefixUnaryExpression */: - return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 197 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 199 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || + return expr.kind === 72 /* Identifier */ || expr.kind === 100 /* ThisKeyword */ || expr.kind === 98 /* SuperKeyword */ || ts.isPropertyAccessExpression(expr) && isNarrowableReference(expr.expression) || ts.isElementAccessExpression(expr) && expr.argumentExpression && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && @@ -27211,7 +27654,7 @@ var ts; } } } - if (expr.expression.kind === 187 /* PropertyAccessExpression */ && + if (expr.expression.kind === 189 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -27225,32 +27668,32 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableReference(expr.left); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -27285,8 +27728,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 101 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 86 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 102 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 87 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -27324,34 +27767,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return parent.expression === node; - case 223 /* ForStatement */: - case 203 /* ConditionalExpression */: + case 225 /* ForStatement */: + case 205 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 193 /* ParenthesizedExpression */) { + if (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 202 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 54 /* BarBarToken */); + return node.kind === 204 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 193 /* ParenthesizedExpression */ || - node.parent.kind === 200 /* PrefixUnaryExpression */ && - node.parent.operator === 51 /* ExclamationToken */) { + while (node.parent.kind === 195 /* ParenthesizedExpression */ || + node.parent.kind === 202 /* PrefixUnaryExpression */ && + node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -27392,7 +27835,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 233 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -27426,13 +27869,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 225 /* ForOfStatement */) { + if (node.kind === 227 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 236 /* VariableDeclarationList */) { + if (node.initializer.kind !== 238 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -27454,7 +27897,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 228 /* ReturnStatement */) { + if (node.kind === 230 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -27474,7 +27917,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 229 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -27570,7 +28013,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 272 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -27637,14 +28080,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 223 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -27655,10 +28098,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 185 /* ArrayLiteralExpression */) { + else if (node.kind === 187 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 206 /* SpreadElement */) { + if (e.kind === 208 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -27666,16 +28109,16 @@ var ts; } } } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 273 /* PropertyAssignment */) { + if (p.kind === 275 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 274 /* ShorthandPropertyAssignment */) { + else if (p.kind === 276 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 275 /* SpreadAssignment */) { + else if (p.kind === 277 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -27683,7 +28126,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -27694,7 +28137,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 51 /* ExclamationToken */) { + if (node.operator === 52 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -27704,20 +28147,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -27731,7 +28174,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { + if (operator === 59 /* EqualsToken */ && node.left.kind === 190 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27742,7 +28185,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -27789,10 +28232,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 193 /* ParenthesizedExpression */) { + while (expr.kind === 195 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { + if (expr.kind === 196 /* FunctionExpression */ || expr.kind === 197 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -27800,7 +28243,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27809,54 +28252,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 266 /* JsxAttributes */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 268 /* JsxAttributes */: return 1 /* IsContainer */; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 287 /* JSDocFunctionType */: - case 163 /* FunctionType */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 164 /* ConstructorType */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 289 /* JSDocFunctionType */: + case 165 /* FunctionType */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 166 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 272 /* CatchClause */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 244 /* CaseBlock */: + case 274 /* CatchClause */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 246 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 216 /* Block */: + case 218 /* 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 @@ -27889,45 +28332,45 @@ 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 186 /* ObjectLiteralExpression */: - case 239 /* InterfaceDeclaration */: - case 266 /* JsxAttributes */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 188 /* ObjectLiteralExpression */: + case 241 /* InterfaceDeclaration */: + case 268 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 291 /* JSDocSignature */: - case 160 /* IndexSignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 287 /* JSDocFunctionType */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 293 /* JSDocSignature */: + case 162 /* IndexSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 242 /* TypeAliasDeclaration */: + case 181 /* 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 @@ -27948,11 +28391,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 277 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { + var body = node.kind === 279 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { + if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { return true; } } @@ -27980,7 +28423,7 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 9 /* StringLiteral */) { + if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; if (ts.hasZeroOrOneAsteriskCharacter(text)) { pattern = ts.tryParsePattern(text); @@ -28036,7 +28479,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 277 /* SpreadAssignment */ || prop.name.kind !== 72 /* Identifier */) { continue; } var identifier = prop.name; @@ -28048,7 +28491,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 275 /* PropertyAssignment */ || prop.kind === 276 /* ShorthandPropertyAssignment */ || prop.kind === 156 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -28080,10 +28523,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28114,7 +28557,7 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) { + if (!typeAlias.fullName || typeAlias.fullName.kind === 72 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); } @@ -28132,8 +28575,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 108 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 116 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 109 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 117 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !(node.flags & 4194304 /* Ambient */)) { // Report error only if there are no parse errors in file @@ -28169,7 +28612,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 71 /* Identifier */) { + if (inStrictMode && node.expression.kind === 72 /* 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); @@ -28180,7 +28623,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 71 /* Identifier */) { + if (name && name.kind === 72 /* 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 @@ -28221,8 +28664,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 277 /* SourceFile */ && - blockScopeContainer.kind !== 242 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 279 /* SourceFile */ && + blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -28248,7 +28691,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -28317,7 +28760,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 145 /* LastToken */) { + if (node.kind > 147 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -28379,7 +28822,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 71 /* Identifier */: + case 72 /* 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. @@ -28392,13 +28835,13 @@ var ts; break; } // falls through - case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { + case 100 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 276 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -28412,7 +28855,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -28437,142 +28880,155 @@ var ts; // Nothing to do break; default: - ts.Debug.fail("Unknown special property assignment kind"); + ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return checkStrictModeCatchClause(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkStrictModeWithStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 176 /* ThisType */: + case 178 /* ThisType */: seenThisKeyword = true; return; - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: break; // Binding the children will handle everything - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return bindTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return bindParameter(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return bindPropertyWorker(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* 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 */ : 67212223 /* MethodExcludes */); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: + case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 179 /* MappedType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 181 /* MappedType */: return bindAnonymousTypeWorker(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return bindFunctionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: + var assignmentKind = ts.getAssignmentDeclarationKind(node); + switch (assignmentKind) { + case 7 /* ObjectDefinePropertyValue */: + return bindObjectDefinePropertyAssignment(node); + case 8 /* ObjectDefinePropertyExports */: + return bindObjectDefinePropertyExport(node); + case 9 /* ObjectDefinePrototypeProperty */: + return bindObjectDefinePrototypeProperty(node); + case 0 /* None */: + break; // Nothing to do + default: + return ts.Debug.fail("Unknown call expression assignment declaration kind"); + } if (ts.isInJSFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return bindJsxAttributes(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return bindImportClause(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return bindExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 277 /* SourceFile */: + case 279 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 216 /* Block */: + case 218 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 297 /* JSDocParameterTag */: - if (node.parent.kind === 291 /* JSDocSignature */) { + case 299 /* JSDocParameterTag */: + if (node.parent.kind === 293 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { break; } // falls through - case 303 /* JSDocPropertyTag */: + case 305 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -28659,6 +29115,21 @@ var ts; } return true; } + function bindObjectDefinePropertyExport(node) { + if (!setCommonJsModuleIndicator(node)) { + return; + } + var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + } + return symbol; + }); + if (symbol) { + var flags = 4 /* Property */ | 1048576 /* ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + } + } function bindExportsPropertyAssignment(node) { // When we create a property via 'exports.foo = bar', the 'exports.foo' property access // expression is the declaration @@ -28695,17 +29166,17 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 58 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 59 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -28718,18 +29189,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -28738,10 +29209,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 99 /* ThisKeyword */) { + if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -28757,6 +29228,10 @@ var ts; var lhs = node.left; bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); } + function bindObjectDefinePrototypeProperty(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); + } /** * For `x.prototype.y = z`, declare a member `y` on `x` if `x` is a function or class, or not declared. * Note that jsdoc preceding an ExpressionStatement like `x.prototype.y;` is also treated as a declaration. @@ -28772,6 +29247,12 @@ var ts; classPrototype.parent = lhs; bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); } + function bindObjectDefinePropertyAssignment(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); + var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); + } function bindSpecialPropertyAssignment(node) { var lhs = node.left; // Class declarations in Typescript do not allow property declarations @@ -28800,16 +29281,12 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ - : propertyAccess.parent.parent.kind === 277 /* SourceFile */; + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; - namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_1); return symbol; @@ -28821,6 +29298,9 @@ var ts; } }); } + return namespaceSymbol; + } + function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) { return; } @@ -28828,10 +29308,18 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(propertyAccess)); + var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var isToplevel = ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ + : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** * Javascript expando values are: @@ -28848,6 +29336,9 @@ var ts; return true; } var node = symbol.valueDeclaration; + if (ts.isCallExpression(node)) { + return !!ts.getAssignedExpandoInitializer(node); + } var init = !node ? undefined : ts.isVariableDeclaration(node) ? node.initializer : ts.isBinaryExpression(node) ? node.right : @@ -28856,7 +29347,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 === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); } return false; } @@ -28898,7 +29389,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 238 /* ClassDeclaration */) { + if (node.kind === 240 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -28964,7 +29455,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 297 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { + if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -29041,7 +29532,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 174 /* InferType */) { + else if (node.parent.kind === 176 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -29069,11 +29560,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 220 /* EmptyStatement */) || // report error on class declarations - node.kind === 238 /* ClassDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 244 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -29117,18 +29608,17 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; } } - /* @internal */ function isExportsOrModuleExportsOrAlias(sourceFile, node) { return ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node) || @@ -29163,58 +29653,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 149 /* Parameter */: + case 151 /* Parameter */: return computeParameter(node, subtreeFlags); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 155 /* Constructor */: + case 157 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -29238,7 +29728,7 @@ var ts; transformFlags |= 8192 /* ContainsLexicalThis */; } } - if (expression.kind === 91 /* ImportKeyword */) { + if (expression.kind === 92 /* ImportKeyword */) { transformFlags |= 16777216 /* ContainsDynamicImport */; // A dynamic 'import()' call that contains a lexical 'this' will // require a captured 'this' when emitting down-level. @@ -29266,17 +29756,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 188 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 187 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 40 /* AsteriskAsteriskToken */ - || operatorTokenKind === 62 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ + || operatorTokenKind === 63 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 32 /* AssertES2016 */; } @@ -29320,8 +29810,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 210 /* AsExpression */ - || expressionKind === 192 /* TypeAssertionExpression */) { + if (expressionKind === 212 /* AsExpression */ + || expressionKind === 194 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -29378,11 +29868,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 85 /* ExtendsKeyword */: + case 86 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 108 /* ImplementsKeyword */: + case 109 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -29701,59 +30191,59 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 637535553 /* NodeExcludes */; switch (kind) { - case 120 /* AsyncKeyword */: - case 199 /* AwaitExpression */: + case 121 /* AsyncKeyword */: + case 201 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; break; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 211 /* NonNullExpression */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 213 /* NonNullExpression */: + case 133 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: - case 10 /* JsxText */: - case 261 /* JsxClosingElement */: - case 262 /* JsxFragment */: - case 263 /* JsxOpeningFragment */: - case 264 /* JsxClosingFragment */: - case 265 /* JsxAttribute */: - case 266 /* JsxAttributes */: - case 267 /* JsxSpreadAttribute */: - case 268 /* JsxExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 11 /* JsxText */: + case 263 /* JsxClosingElement */: + case 264 /* JsxFragment */: + case 265 /* JsxOpeningFragment */: + case 266 /* JsxClosingFragment */: + case 267 /* JsxAttribute */: + case 268 /* JsxAttributes */: + case 269 /* JsxSpreadAttribute */: + case 270 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - case 274 /* ShorthandPropertyAssignment */: - case 115 /* StaticKeyword */: - case 212 /* MetaProperty */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + case 276 /* ShorthandPropertyAssignment */: + case 116 /* StaticKeyword */: + case 214 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.hasExtendedUnicodeEscape) { transformFlags |= 192 /* AssertES2015 */; } @@ -29763,60 +30253,64 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ForOfStatement */: + case 9 /* BigIntLiteral */: + transformFlags |= 8 /* AssertESNext */; + break; + case 227 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 4194304 /* ContainsYield */; break; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 161 /* TypePredicate */: - case 162 /* TypeReference */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 165 /* TypeQuery */: - case 166 /* TypeLiteral */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 174 /* InferType */: - case 175 /* ParenthesizedType */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: - case 245 /* NamespaceExportDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 163 /* TypePredicate */: + case 164 /* TypeReference */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 167 /* TypeQuery */: + case 168 /* TypeLiteral */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 176 /* InferType */: + case 177 /* ParenthesizedType */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: + case 247 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -29833,43 +30327,43 @@ var ts; transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 131072 /* ContainsRestOrSpread */; break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; break; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 33554432 /* Super */; excludeFlags = 536872257 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 8192 /* ContainsLexicalThis */; break; - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; } excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 131072 /* ContainsRestOrSpread */; } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: excludeFlags = 638358849 /* ObjectLiteralExcludes */; if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -29887,8 +30381,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 185 /* ArrayLiteralExpression */: - case 190 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: + case 192 /* NewExpression */: excludeFlags = 637666625 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -29896,26 +30390,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -29929,68 +30423,68 @@ var ts; * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather * than calling this function. */ - /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { + if (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 185 /* ArrayLiteralExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: return 637666625 /* ArrayLiteralOrCallOrNewExcludes */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return 647001409 /* ModuleExcludes */; - case 149 /* Parameter */: + case 151 /* Parameter */: return 637535553 /* ParameterExcludes */; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return 653604161 /* ArrowFunctionExcludes */; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return 653620545 /* FunctionExcludes */; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return 639894849 /* VariableDeclarationListExcludes */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 638121281 /* ClassExcludes */; - case 155 /* Constructor */: + case 157 /* Constructor */: return 653616449 /* ConstructorExcludes */; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return 653616449 /* MethodOrAccessorExcludes */; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 137 /* StringKeyword */: - case 135 /* ObjectKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 138 /* StringKeyword */: + case 136 /* ObjectKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return 638358849 /* ObjectLiteralExcludes */; - case 272 /* CatchClause */: + case 274 /* CatchClause */: return 637797697 /* CatchClauseExcludes */; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return 637666625 /* BindingPatternExcludes */; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: - case 193 /* ParenthesizedExpression */: - case 97 /* SuperKeyword */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: + case 195 /* ParenthesizedExpression */: + case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 570426689 /* PropertyAccessExcludes */; default: return 637535553 /* NodeExcludes */; @@ -30051,7 +30545,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -30067,16 +30561,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { visitIndexType(type); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -30165,7 +30659,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 === 165 /* TypeQuery */) { + if (d.type && d.type.kind === 167 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -30255,6 +30749,7 @@ var ts; var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); @@ -30430,10 +30925,6 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { - var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); - return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; - }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isParameter); @@ -30466,6 +30957,7 @@ var ts; getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, + getObjectFlags: ts.getObjectFlags, isArrayLikeType: isArrayLikeType, isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, @@ -30473,7 +30965,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentExport: function (node, target) { return getSuggestionForNonexistentExport(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -30551,21 +31043,24 @@ var ts; var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(16384 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(65536 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */ | 134217728 /* ContainsWideningType */, "null"); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); - var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - falseType.flags |= 33554432 /* FreshLiteral */; - trueType.flags |= 33554432 /* FreshLiteral */; + 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"); trueType.regularType = regularTrueType; + trueType.freshType = trueType; + regularTrueType.regularType = regularTrueType; regularTrueType.freshType = trueType; falseType.regularType = regularFalseType; + falseType.freshType = falseType; + regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = createBooleanType([regularFalseType, regularTrueType]); // Also mark all combinations of fresh/regular booleans as "Boolean" so they print as `boolean` instead of `true | false` @@ -30573,15 +31068,18 @@ var ts; createBooleanType([regularFalseType, trueType]); createBooleanType([falseType, regularTrueType]); createBooleanType([falseType, trueType]); - var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(4096 /* Void */, "void"); - var neverType = createIntrinsicType(32768 /* Never */, "never"); - var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); + 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 implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; + var numberOrBigIntType = getUnionType([numberType, bigintType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -30594,16 +31092,15 @@ var ts; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var markerSuperType = createType(65536 /* TypeParameter */); - var markerSubType = createType(65536 /* TypeParameter */); + var markerSuperType = createType(262144 /* TypeParameter */); + var markerSubType = createType(262144 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(65536 /* TypeParameter */); + var markerOtherType = createType(262144 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignaturesArray = [resolvingSignature]; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var globals = ts.createSymbolTable(); /** Key is "/path/to/a.ts|/path/to/b.ts". */ @@ -30650,6 +31147,9 @@ var ts; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; var deferredGlobalExtractSymbol; + var deferredGlobalExcludeSymbol; + var deferredGlobalPickSymbol; + var deferredGlobalBigIntType; var allPotentiallyUnusedIdentifiers = ts.createMap(); // key is file name var flowLoopStart = 0; var flowLoopCount = 0; @@ -30657,6 +31157,7 @@ var ts; var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); + var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -30682,86 +31183,99 @@ var ts; TypeFacts[TypeFacts["None"] = 0] = "None"; TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["All"] = 4194303] = "All"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; // The following members encode facts about particular kinds of types for use in the getTypeFacts function. // The presence of a particular fact means that the given test is true for some (and possibly all) values // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 1972176] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 4184016] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 1970144] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 4181984] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 4079615] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 4194303] = "EmptyObjectFacts"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMapFromTemplate({ string: 1 /* TypeofEQString */, number: 2 /* TypeofEQNumber */, - boolean: 4 /* TypeofEQBoolean */, - symbol: 8 /* TypeofEQSymbol */, - undefined: 16384 /* EQUndefined */, - object: 16 /* TypeofEQObject */, - function: 32 /* TypeofEQFunction */ + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ }); var typeofNEFacts = ts.createMapFromTemplate({ - string: 128 /* TypeofNEString */, - number: 256 /* TypeofNENumber */, - boolean: 512 /* TypeofNEBoolean */, - symbol: 1024 /* TypeofNESymbol */, - undefined: 131072 /* NEUndefined */, - object: 2048 /* TypeofNEObject */, - function: 4096 /* TypeofNEFunction */ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ }); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, + bigint: bigintType, boolean: booleanType, symbol: esSymbolType, undefined: undefinedType @@ -30983,7 +31497,7 @@ var ts; (source.flags | target.flags) & 67108864 /* Assignment */) { ts.Debug.assert(source !== target); if (!(target.flags & 33554432 /* Transient */)) { - target = cloneSymbol(target); + target = cloneSymbol(resolveSymbol(target)); } // 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) { @@ -31014,7 +31528,7 @@ var ts; else if (target.flags & 1024 /* NamespaceModule */) { error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } - else { + else { // error var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); var message = isEitherEnum @@ -31079,7 +31593,8 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); + var targetSymbol = target.get(id); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -31141,7 +31656,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -31199,17 +31714,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 184 /* BindingElement */) { + if (declaration.kind === 186 /* 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, 184 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 186 /* 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, 235 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 237 /* VariableDeclaration */), usage); } - else if (declaration.kind === 235 /* VariableDeclaration */) { + else if (declaration.kind === 237 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -31228,12 +31743,12 @@ 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 === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 257 /* ExportSpecifier */ || (usage.parent.kind === 254 /* 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 === 252 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 254 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -31241,9 +31756,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 217 /* VariableStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 219 /* VariableStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -31264,16 +31779,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 152 /* PropertyDeclaration */ && + current.parent.kind === 154 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 154 /* MethodDeclaration */) { + if (declaration.kind === 156 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -31315,12 +31830,12 @@ 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 & 67897832 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 149 /* Parameter */ || - lastLocation.kind === 148 /* TypeParameter */ + lastLocation.kind === 151 /* Parameter */ || + lastLocation.kind === 150 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -31337,13 +31852,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 151 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 173 /* ConditionalType */) { + else if (location.kind === 175 /* 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; @@ -31357,14 +31872,14 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -31388,7 +31903,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 257 /* ExportSpecifier */)) { break; } } @@ -31402,13 +31917,13 @@ var ts; } } break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -31425,9 +31940,9 @@ var ts; } } break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* 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! @@ -31446,7 +31961,7 @@ var ts; } break loop; } - if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 209 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -31454,9 +31969,9 @@ var ts; } } break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 86 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { if (nameNotFoundMessage) { @@ -31474,9 +31989,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 241 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -31484,19 +31999,19 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -31509,7 +32024,7 @@ var ts; } } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -31518,7 +32033,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 === 149 /* Parameter */) { + if (location.parent && location.parent.kind === 151 /* Parameter */) { location = location.parent; } // @@ -31531,8 +32046,8 @@ var ts; location = location.parent; } break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -31551,7 +32066,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -31624,8 +32139,7 @@ var ts; } // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { - var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { + if (ts.some(result.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -31634,12 +32148,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: // For `namespace N { N; }` + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -31651,7 +32165,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 148 /* TypeParameter */) { + if (decl.kind === 150 /* 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 @@ -31706,10 +32220,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -31776,7 +32290,7 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 243 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -31811,13 +32325,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 248 /* ImportClause */: + case 250 /* ImportClause */: return node.parent; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -31827,7 +32341,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -32019,20 +32533,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 252 /* ExportAssignment */: - case 202 /* BinaryExpression */: + case 254 /* ExportAssignment */: + case 204 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -32093,11 +32607,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 255 /* ExportSpecifier */) { + else if (node.kind === 257 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -32115,17 +32629,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 71 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 72 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* QualifiedName */) { + if (entityName.kind === 72 /* Identifier */ || entityName.parent.kind === 148 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 248 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -32141,7 +32655,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); var symbol; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name).escapedText); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -32149,9 +32663,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { - var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 148 /* QualifiedName */ || name.kind === 189 /* PropertyAccessExpression */) { + var left = name.kind === 148 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 148 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -32234,6 +32748,9 @@ var ts; } function getDeclarationOfJSPrototypeContainer(symbol) { var decl = symbol.parent.valueDeclaration; + if (!decl) { + return undefined; + } var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) : ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) : undefined; @@ -32352,10 +32869,15 @@ var ts; return getPackagesSet().has(ts.getTypesPackageName(packageName)); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; + if (moduleSymbol) { + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + return getMergedSymbol(exported) || moduleSymbol; + } + return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || moduleSymbol.exports.size === 1) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } var merged = cloneSymbol(exported); @@ -32376,7 +32898,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -32444,7 +32966,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -32589,7 +33111,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 157 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -32612,7 +33134,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(131072 /* Object */); + var type = createType(524288 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -32667,12 +33189,12 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -32736,7 +33258,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 255 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -32772,7 +33294,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, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -32787,10 +33309,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: continue; default: return false; @@ -32907,10 +33429,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -32957,14 +33479,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 165 /* TypeQuery */ || + if (entityName.parent.kind === 167 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 147 /* ComputedPropertyName */) { + entityName.parent.kind === 149 /* ComputedPropertyName */) { // Typeof value meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || - entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 148 /* QualifiedName */ || entityName.kind === 189 /* PropertyAccessExpression */ || + entityName.parent.kind === 248 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -33013,15 +33535,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 166 /* ConstructorType */ : 165 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 161 /* ConstructSignature */ : 160 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 return writer; } } @@ -33086,7 +33608,8 @@ var ts; getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) } : undefined }, encounteredError: false, - visitedSymbols: undefined, + visitedTypes: undefined, + symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; @@ -33110,48 +33633,55 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + return ts.createKeywordTypeNode(143 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* StringKeyword */); + return ts.createKeywordTypeNode(138 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(134 /* NumberKeyword */); + return ts.createKeywordTypeNode(135 /* NumberKeyword */); + } + if (type.flags & 64 /* BigInt */) { + context.approximateLength += 6; + return ts.createKeywordTypeNode(146 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(122 /* BooleanKeyword */); + return ts.createKeywordTypeNode(123 /* BooleanKeyword */); } - if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { + if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToName(parentSymbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); + var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type + ? parentName + : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); + return enumLiteralName; } - if (type.flags & 544 /* EnumLike */) { - var name = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + if (type.flags & 1056 /* EnumLike */) { + return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); } - if (type.flags & 64 /* StringLiteral */) { + if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & 128 /* NumberLiteral */) { + if (type.flags & 256 /* NumberLiteral */) { context.approximateLength += (("" + type.value).length); return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 2048 /* BigIntLiteral */) { + context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; + return ts.createLiteralTypeNode((ts.createLiteral(type.value))); + } + if (type.flags & 512 /* BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; @@ -33162,33 +33692,33 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(142 /* UniqueKeyword */, ts.createKeywordTypeNode(139 /* SymbolKeyword */)); } - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(105 /* VoidKeyword */); + return ts.createKeywordTypeNode(106 /* VoidKeyword */); } - if (type.flags & 8192 /* Undefined */) { + if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(141 /* UndefinedKeyword */); } - if (type.flags & 16384 /* Null */) { + if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(95 /* NullKeyword */); + return ts.createKeywordTypeNode(96 /* NullKeyword */); } - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(131 /* NeverKeyword */); + return ts.createKeywordTypeNode(132 /* NeverKeyword */); } - if (type.flags & 1024 /* ESSymbol */) { + if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(138 /* SymbolKeyword */); + return ts.createKeywordTypeNode(139 /* SymbolKeyword */); } - if (type.flags & 16777216 /* NonPrimitive */) { + if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(135 /* ObjectKeyword */); + return ts.createKeywordTypeNode(136 /* ObjectKeyword */); } - if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { + if (type.flags & 262144 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -33202,16 +33732,16 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 65536 /* TypeParameter */ && + type.flags & 262144 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && @@ -33231,14 +33761,14 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); } - if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { - var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { + var types = type.flags & 1048576 /* 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) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 173 /* UnionType */ : 174 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -33249,23 +33779,23 @@ var ts; } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 4194304 /* Conditional */) { + if (type.flags & 16777216 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -33276,12 +33806,12 @@ var ts; context.approximateLength += 15; return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 8388608 /* Substitution */) { + if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -33300,6 +33830,7 @@ var ts; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); } function createAnonymousTypeNode(type) { + var typeId = "" + type.id; var symbol = type.symbol; var id; if (symbol) { @@ -33311,12 +33842,12 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 209 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67220415 /* Value */); } - else if (context.visitedSymbols && context.visitedSymbols.has(id)) { + else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { @@ -33325,18 +33856,34 @@ var ts; } else { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } } else { // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedSymbols) { - context.visitedSymbols = ts.createMap(); + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); } - context.visitedSymbols.set(id, true); + if (!context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + context.approximateLength += 3; + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); + } + context.symbolDepth.set(id, depth + 1); + context.visitedTypes.set(typeId, true); var result = createTypeNodeFromObjectType(type); - context.visitedSymbols.delete(id); + context.visitedTypes.delete(typeId); + context.symbolDepth.set(id, depth); return result; } } @@ -33350,11 +33897,11 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; + return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively + return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } @@ -33371,12 +33918,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 165 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* ConstructorType */, context); return signatureNode; } } @@ -33508,11 +34055,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 160 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -33563,12 +34110,12 @@ var ts; var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(55 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length) { var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 155 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -33581,9 +34128,9 @@ var ts; else { var savedFlags = context.flags; context.flags |= !!(ts.getCheckFlags(propertySymbol) & 2048 /* ReverseMapped */) ? 33554432 /* InReverseMappedType */ : 0; - var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(120 /* AnyKeyword */); context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -33634,7 +34181,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 137 /* StringKeyword */ : 134 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 138 /* StringKeyword */ : 135 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -33647,7 +34194,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -33658,7 +34205,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 157 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -33677,12 +34224,12 @@ var ts; returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 119 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 120 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(119 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(120 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -33711,9 +34258,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 297 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -33722,16 +34269,16 @@ var ts; var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; - var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; + var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 72 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 148 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -33745,7 +34292,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 184 /* BindingElement */) { + if (clone.kind === 186 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -33844,7 +34391,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -34044,10 +34591,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 24576 /* Nullable */)) { - if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { - var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 262144 /* Union */) { + 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 */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -34059,9 +34606,9 @@ var ts; result.push(t); } } - if (flags & 16384 /* Null */) + if (flags & 65536 /* Null */) result.push(nullType); - if (flags & 8192 /* Undefined */) + if (flags & 32768 /* Undefined */) result.push(undefinedType); return result || types; } @@ -34076,8 +34623,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); - if (node.kind === 240 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 177 /* ParenthesizedType */; }); + if (node.kind === 242 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -34085,11 +34632,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 243 /* ModuleBlock */ && + node.parent.kind === 245 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -34112,27 +34659,30 @@ var ts; var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { + if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + return ts.symbolName(symbol); + } return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 237 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 209 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 128 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 8192 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -34149,27 +34699,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: // 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 184 /* BindingElement */: + case 186 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 235 /* VariableDeclaration */: + case 237 /* 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 237 /* FunctionDeclaration */: - case 241 /* EnumDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 243 /* EnumDeclaration */: + case 248 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -34177,53 +34727,53 @@ var ts; 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 !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 155 /* Constructor */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 149 /* Parameter */: - case 243 /* ModuleBlock */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 162 /* TypeReference */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 175 /* ParenthesizedType */: + case 157 /* Constructor */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 151 /* Parameter */: + case 245 /* ModuleBlock */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 164 /* TypeReference */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 177 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: return false; // Type parameters are always visible - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 277 /* SourceFile */: - case 245 /* NamespaceExportDeclaration */: + case 279 /* SourceFile */: + case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return false; default: return false; @@ -34232,10 +34782,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 254 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 255 /* ExportSpecifier */) { + else if (node.parent.kind === 257 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -34331,12 +34881,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 235 /* VariableDeclaration */: - case 236 /* VariableDeclarationList */: - case 251 /* ImportSpecifier */: - case 250 /* NamedImports */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 237 /* VariableDeclaration */: + case 238 /* VariableDeclarationList */: + case 253 /* ImportSpecifier */: + case 252 /* NamedImports */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: return false; default: return true; @@ -34366,28 +34916,36 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 149 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); - if (source.flags & 32768 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); + if (source.flags & 131072 /* Never */) { return emptyObjectType; } - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } - var members = ts.createSymbolTable(); - var names = ts.createUnderscoreEscapedMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; - names.set(ts.getTextOfPropertyName(name), true); + var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); + if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) { + if (omitKeyType.flags & 131072 /* Never */) { + return source; + } + var pickTypeAlias = getGlobalPickSymbol(); + var excludeTypeAlias = getGlobalExcludeSymbol(); + if (!pickTypeAlias || !excludeTypeAlias) { + return errorType; + } + var pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]); + return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]); } - for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { - var prop = _b[_a]; - if (!names.has(prop.escapedName) + var members = ts.createSymbolTable(); + for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), omitKeyType) && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { - members.set(prop.escapedName, getNonReadonlySymbol(prop)); + members.set(prop.escapedName, getSpreadSymbol(prop)); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -34411,8 +34969,12 @@ var ts; if (isTypeAny(parentType)) { return parentType; } + // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation + if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + parentType = getNonNullableType(parentType); + } var type; - if (pattern.kind === 182 /* ObjectBindingPattern */) { + if (pattern.kind === 184 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -34430,51 +34992,9 @@ var ts; else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; - var isLate = isLateBindableName(name); - var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); - if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { - var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); - } - return anyType; - } - var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); - if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { - if (getIndexTypeOfType(parentType, 1 /* Number */)) { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); - } - else { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(parentType)); - } - } - return indexerType || anyType; - } - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - var nameType = isLate ? checkComputedPropertyName(name) : undefined; - var text = isLate ? getLateBoundNameFromType(nameType) : - isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : - ts.getTextOfPropertyName(name); - // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { - parentType = getNonNullableType(parentType); - } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); - } - return anyType; - } - var declaredType = getConstraintForLocation(getTypeOfPropertyOfType(parentType, text), declaration.name); - type = declaredType && getFlowTypeOfReference(declaration, declaredType) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return errorType; - } + var exprType = getLiteralTypeFromPropertyName(name); + var declaredType = checkIndexedAccessIndexType(getIndexedAccessType(parentType, exprType, name), name); + type = getFlowTypeOfReference(declaration, getConstraintForLocation(declaredType, declaration.name)); } } else { @@ -34510,8 +35030,8 @@ var ts; } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 8192 /* Undefined */)) { - type = getTypeWithFacts(type, 131072 /* NEUndefined */); + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */)) { + type = getTypeWithFacts(type, 524288 /* NEUndefined */); } return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkDeclarationInitializer(declaration)], 2 /* Subtype */) : @@ -34526,11 +35046,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 95 /* NullKeyword */ || expr.kind === 71 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 96 /* NullKeyword */ || expr.kind === 72 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 187 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -34540,11 +35060,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 224 /* ForInStatement */) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 226 /* ForInStatement */) { + var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); + return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* 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, @@ -34563,7 +35083,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 237 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* 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 @@ -34577,11 +35097,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); + if (func.kind === 159 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 158 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -34645,7 +35165,7 @@ var ts; var types; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - var expression = ts.isBinaryExpression(declaration) ? declaration : + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { @@ -34660,9 +35180,11 @@ var ts; definedInMethod = true; } } - jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + if (!ts.isCallExpression(expression)) { + jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } if (!jsdocType) { - (types || (types = [])).push(ts.isBinaryExpression(expression) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } var type = jsdocType; @@ -34676,11 +35198,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(98304 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -34721,8 +35243,33 @@ var ts; } /** If we don't have an explicit JSDoc type, get the type from the initializer. */ function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) { + if (ts.isCallExpression(expression)) { + if (resolvedSymbol) { + return getTypeOfSymbol(resolvedSymbol); // This shouldn't happen except under some hopefully forbidden merges of export assignments and object define assignments + } + var objectLitType = checkExpressionCached(expression.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + return valueType; + } + var getFunc = getTypeOfPropertyOfType(objectLitType, "get"); + if (getFunc) { + var getSig = getSingleCallSignature(getFunc); + if (getSig) { + return getReturnTypeOfSignature(getSig); + } + } + var setFunc = getTypeOfPropertyOfType(objectLitType, "set"); + if (setFunc) { + var setSig = getSingleCallSignature(setFunc); + if (setSig) { + return getTypeOfFirstParameterOfSignature(setSig); + } + } + return anyType; + } var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 131072 /* Object */ && + if (type.flags & 524288 /* Object */ && kind === 2 /* ModuleExports */ && symbol.escapedName === "export=" /* ExportEquals */) { var exportedType_1 = resolveStructuredTypeMembers(type); @@ -34756,9 +35303,9 @@ var ts; 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 === 155 /* Constructor */ || - thisContainer.kind === 237 /* FunctionDeclaration */ || - (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 157 /* Constructor */ || + thisContainer.kind === 239 /* FunctionDeclaration */ || + (thisContainer.kind === 196 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -34833,7 +35380,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 186 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -34856,7 +35403,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 182 /* ObjectBindingPattern */ + return pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -34878,7 +35425,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -34895,7 +35442,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 151 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -34935,12 +35482,12 @@ var ts; return emptyObjectType; } var type_1 = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression)); - if (type_1.flags & 131072 /* Object */) { + if (type_1.flags & 524288 /* Object */) { return getRegularTypeOfObjectLiteral(type_1); } return type_1; } - if (declaration.kind === 252 /* ExportAssignment */) { + if (declaration.kind === 254 /* ExportAssignment */) { return widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } // Handle variable, parameter or property @@ -34949,7 +35496,7 @@ var ts; } var type; if (ts.isInJSFile(declaration) && - (ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { type = getWidenedTypeFromAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) @@ -34986,6 +35533,14 @@ var ts; || ts.isBindingElement(declaration)) { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); } + // getTypeOfSymbol dispatches some JS merges incorrectly because their symbol flags are not mutually exclusive. + // Re-dispatch based on valueDeclaration.kind instead. + else if (ts.isEnumDeclaration(declaration)) { + type = getTypeOfFuncClassEnumModule(symbol); + } + else if (ts.isEnumMember(declaration)) { + type = getTypeOfEnumMember(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } @@ -34996,7 +35551,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -35023,8 +35578,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 159 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -35067,7 +35622,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -35075,7 +35630,7 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -35107,8 +35662,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 202 /* BinaryExpression */ || - declaration.kind === 187 /* PropertyAccessExpression */ && declaration.parent.kind === 202 /* BinaryExpression */) { + else if (declaration.kind === 204 /* BinaryExpression */ || + declaration.kind === 189 /* PropertyAccessExpression */ && declaration.parent.kind === 204 /* BinaryExpression */) { return getWidenedTypeFromAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -35220,7 +35775,7 @@ var ts; var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, check); } return false; @@ -35244,35 +35799,35 @@ var ts; return undefined; } switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 179 /* MappedType */: - case 173 /* ConditionalType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 181 /* MappedType */: + case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 179 /* MappedType */) { + if (node.kind === 181 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 173 /* ConditionalType */) { + else if (node.kind === 175 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && + (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */ || node.kind === 241 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -35280,7 +35835,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, 239 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -35289,9 +35844,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 238 /* ClassDeclaration */ || - node.kind === 207 /* ClassExpression */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || + node.kind === 209 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -35318,7 +35873,7 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } @@ -35361,7 +35916,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 & (131072 /* Object */ | 524288 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* 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); @@ -35371,7 +35926,18 @@ var ts; return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + if (baseConstructorType.flags & 262144 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(baseConstructorType); + var ctorReturn = unknownType; + if (constraint) { + var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + if (ctorSig[0]) { + ctorReturn = getReturnTypeOfSignature(ctorSig[0]); + } + } + addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; @@ -35400,7 +35966,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -35467,14 +36033,14 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || - !!(type.flags & 524288 /* Intersection */) && ts.every(type.types, isValidBaseType); + return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 241 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -35510,7 +36076,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */) { + if (declaration.kind === 241 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -35551,7 +36117,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -35568,7 +36134,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 242 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -35592,10 +36158,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 9 /* StringLiteral */) { + if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 202 /* BinaryExpression */) { + else if (expr.kind === 204 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -35606,15 +36172,15 @@ var ts; return !(member.flags & 4194304 /* Ambient */); } switch (expr.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 38 /* MinusToken */ && + case 202 /* PrefixUnaryExpression */: + return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -35628,10 +36194,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { + if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -35643,7 +36209,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -35655,7 +36221,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getFreshTypeOfLiteralType(getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member))); // TODO: GH#18217 @@ -35666,8 +36232,8 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 262144 /* Union */) { - enumType_1.flags |= 512 /* EnumLiteral */; + if (enumType_1.flags & 1048576 /* Union */) { + enumType_1.flags |= 1024 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; @@ -35690,7 +36256,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(65536 /* TypeParameter */); + var type = createType(262144 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -35734,22 +36300,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: - case 180 /* LiteralType */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: + case 182 /* LiteralType */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isThislessType(node.elementType); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -35775,7 +36342,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 157 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -35791,12 +36358,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -35840,7 +36407,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -35883,10 +36450,10 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -36051,7 +36618,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -36180,7 +36747,7 @@ var ts; function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { var s = signatureList_1[_i]; - if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { + if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) { return s; } } @@ -36214,8 +36781,7 @@ var ts; // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional // parameters and may differ in return types. When signatures differ in return types, the resulting return // type is the union of the constituent return types. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + function getUnionSignatures(signatureLists) { var result; for (var i = 0; i < signatureLists.length; i++) { for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { @@ -36261,8 +36827,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(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 0 /* Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -36358,7 +36924,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -36392,7 +36958,7 @@ var ts; var modifiers = getMappedTypeModifiers(type.mappedType); var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; - var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType), readonlyMask && indexInfo.isReadonly); + var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly); var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -36402,6 +36968,7 @@ var ts; inferredProp.nameType = prop.nameType; inferredProp.propertyType = getTypeOfSymbol(prop); inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -36420,12 +36987,12 @@ 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 ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; - addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include)); + addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); } if (modifiersType.flags & 1 /* Any */ || getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); @@ -36435,11 +37002,9 @@ var ts; } } else { - // First, if the constraint type is a type parameter, obtain the base constraint. Then, - // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. - // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + // If the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. + // Then iterate over the constituents of the key type. + var iterationType = constraintType.flags & 4194304 /* Index */ ? getIndexType(getApparentType(constraintType.type)) : constraintType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -36451,7 +37016,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 8576 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -36463,7 +37028,7 @@ var ts; // 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. prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; @@ -36499,8 +37064,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 177 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; + return constraintDeclaration.kind === 179 /* TypeOperator */ && + constraintDeclaration.operator === 129 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -36516,16 +37081,16 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 38 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 38 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -36544,7 +37109,7 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -36561,10 +37126,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 262144 /* Union */) { + else if (type.flags & 1048576 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -36572,7 +37137,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -36581,7 +37146,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -36605,7 +37170,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 - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { break; } } @@ -36615,12 +37180,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 786432 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { - return obj.properties.some(function (property) { + var list = obj.properties; + return list.some(function (property) { var name = property.name && ts.getTextOfPropertyName(property.name); var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && typeIsLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); @@ -36628,7 +37194,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 262144 /* Union */)) { + if (!(unionType.flags & 1048576 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -36647,9 +37213,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -36669,7 +37235,11 @@ var ts; function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = !(rootTrueType.flags & 33554432 /* Substitution */) + ? rootTrueType + : (rootTrueType.substitute).flags & 3 /* AnyOrUnknown */ + ? rootTrueType.typeVariable + : getIntersectionType([rootTrueType.substitute, rootTrueType.typeVariable]); type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -36686,7 +37256,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 32768 /* Never */)) { + if (!(instantiated.flags & 131072 /* Never */)) { return instantiated; } } @@ -36701,23 +37271,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 15794176 /* Instantiable */) { + if (t.flags & 63176704 /* 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 & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 262144 /* Union */)) { + if (!(constraint.flags & 1048576 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 16809468 /* DisjointDomains */) { + else if (t.flags & 67238908 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -36729,7 +37299,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 16809468 /* DisjointDomains */) { + if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -36739,11 +37309,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { + if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 1048576 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -36792,13 +37362,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 65536 /* TypeParameter */) { + if (t.flags & 262144 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 786432 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -36808,24 +37378,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 1048576 /* Index */) { + if (t.flags & 4194304 /* Index */) { return keyofConstraintType; } - if (t.flags & 2097152 /* IndexedAccess */) { + if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType, /*accessNode*/ undefined, errorType) : undefined; return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 4194304 /* Conditional */) { + if (t.flags & 16777216 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 8388608 /* Substitution */) { + if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -36897,21 +37467,22 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + var t = type.flags & 63176704 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 68 /* StringLike */ ? globalStringType : - t.flags & 168 /* NumberLike */ ? globalNumberType : - t.flags & 272 /* BooleanLike */ ? globalBooleanType : - t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : - t.flags & 1048576 /* Index */ ? keyofConstraintType : - t; + t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 132 /* StringLike */ ? globalStringType : + t.flags & 296 /* NumberLike */ ? globalNumberType : + t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 6 /* ESNext */) : + 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; } function createUnionOrIntersectionProperty(containingType, name) { var props; var indexTypes; - var isUnion = containingType.flags & 262144 /* Union */; + var isUnion = containingType.flags & 1048576 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -37024,7 +37595,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -37042,13 +37613,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -37062,7 +37633,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -37118,10 +37689,10 @@ 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 === 286 /* JSDocOptionalType */ + node.type && node.type.kind === 288 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -37155,7 +37726,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -37180,30 +37751,32 @@ var ts; } function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); - if (numTypeParameters) { - var numTypeArguments = ts.length(typeArguments); - if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { - if (!typeArguments) { - typeArguments = []; - } - // Map an unsatisfied type parameter with a default type. - // If a type parameter does not have a default type, or if the default type - // is a forward reference, the empty object type is used. - for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - for (var i = numTypeArguments; i < numTypeParameters; i++) { - var mapper = createTypeMapper(typeParameters, typeArguments); - var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { - defaultType = anyType; - } - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - typeArguments.length = typeParameters.length; - } + if (!numTypeParameters) { + return []; } - return typeArguments; + var numTypeArguments = ts.length(typeArguments); + if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { + var result = typeArguments ? typeArguments.slice() : []; + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + var baseDefaultType_1 = getDefaultTypeArgumentType(isJavaScriptImplicitAny); + var circularityMapper = createTypeMapper(typeParameters, ts.map(typeParameters, function () { return baseDefaultType_1; })); + for (var i = numTypeArguments; i < numTypeParameters; i++) { + result[i] = instantiateType(getConstraintFromTypeParameter(typeParameters[i]) || baseDefaultType_1, circularityMapper); + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, result); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { + defaultType = anyType; + } + result[i] = defaultType ? instantiateType(defaultType, mapper) : baseDefaultType_1; + } + result.length = typeParameters.length; + return result; + } + return typeArguments && typeArguments.slice(); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); @@ -37239,7 +37812,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 180 /* LiteralType */) { + if (type && type.kind === 182 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -37253,16 +37826,16 @@ 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 === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && + if ((declaration.kind === 158 /* GetAccessor */ || declaration.kind === 159 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = declaration.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 155 /* Constructor */ ? + var classType = declaration.kind === 157 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -37320,13 +37893,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return node.name.kind === 147 /* ComputedPropertyName */ + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return node.name.kind === 149 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -37401,7 +37974,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, func) { var parameterName = node.parameterName; var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 71 /* Identifier */) { + if (parameterName.kind === 72 /* Identifier */) { return createIdentifierTypePredicate(parameterName.escapedText, getTypePredicateParameterIndex(func.parameters, parameterName), type); } else { @@ -37411,7 +37984,7 @@ var ts; function getTypePredicateParameterIndex(parameterList, parameter) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 71 /* Identifier */ && param.name.escapedText === parameter.escapedText) { + if (param.name.kind === 72 /* Identifier */ && param.name.escapedText === parameter.escapedText) { return i; } } @@ -37451,7 +38024,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 155 /* Constructor */) { + if (declaration.kind === 157 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -37461,12 +38034,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 158 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 159 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -37544,7 +38117,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 + var isConstructor = signature.declaration.kind === 157 /* Constructor */ || signature.declaration.kind === 161 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -37558,7 +38131,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 134 /* NumberKeyword */ : 137 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 135 /* NumberKeyword */ : 138 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -37585,7 +38158,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 150 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -37593,13 +38166,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 174 /* InferType */) { + if (declaration.parent.kind === 176 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 162 /* TypeReference */) { + if (grandParent.kind === 164 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -37624,7 +38197,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 151 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -37648,7 +38221,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 150 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -37781,9 +38354,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -37827,7 +38400,7 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : + res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { @@ -37884,13 +38457,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(8388608 /* Substitution */); + var result = createType(33554432 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 170 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -37899,9 +38472,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -37912,7 +38485,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 162 /* TypeReference */ || node.kind === 181 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 164 /* TypeReference */ || node.kind === 183 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -37970,7 +38543,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -38013,9 +38586,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return declaration; } } @@ -38024,7 +38597,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 131072 /* Object */)) { + if (!(type.flags & 524288 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -38101,6 +38674,15 @@ var ts; function getGlobalExtractSymbol() { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } + function getGlobalExcludeSymbol() { + return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalPickSymbol() { + return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalBigIntType(reportErrors) { + return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors)) || emptyObjectType; + } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -38149,7 +38731,7 @@ var ts; if (arity) { typeParameters = new Array(arity); for (var i = 0; i < arity; i++) { - var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + var typeParameter = typeParameters[i] = createType(262144 /* TypeParameter */); if (i < maxLength) { var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); property.type = typeParameter; @@ -38171,7 +38753,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -38206,8 +38788,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 172 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 171 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -38254,16 +38836,17 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { + if (t.flags & 109440 /* Unit */ && combined & 109440 /* Unit */) { return true; } combined |= t.flags; - if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || - combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || - combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || - combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || - combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || - combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { + if (combined & 98304 /* Nullable */ && combined & (524288 /* Object */ | 67108864 /* NonPrimitive */) || + combined & 67108864 /* NonPrimitive */ && combined & (67238908 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || + combined & 132 /* StringLike */ && combined & (67238908 /* DisjointDomains */ & ~132 /* StringLike */) || + combined & 296 /* NumberLike */ && combined & (67238908 /* DisjointDomains */ & ~296 /* NumberLike */) || + combined & 2112 /* BigIntLike */ && combined & (67238908 /* DisjointDomains */ & ~2112 /* BigIntLike */) || + combined & 12288 /* ESSymbolLike */ && combined & (67238908 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || + combined & 49152 /* VoidLike */ && combined & (67238908 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return true; } } @@ -38271,20 +38854,18 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Union */) { + if (flags & 1048576 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + if (!(flags & 131072 /* Never */ || flags & 2097152 /* Intersection */ && isEmptyIntersectionType(type))) { includes |= flags & ~939524096 /* ConstructionFlags */; - if (flags & 3 /* AnyOrUnknown */) { - if (type === wildcardType) - includes |= 268435456 /* Wildcard */; - } - else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (type === wildcardType) + includes |= 268435456 /* Wildcard */; + if (!strictNullChecks && flags & 98304 /* Nullable */) { if (!(flags & 134217728 /* ContainsWideningType */)) includes |= 134217728 /* NonWideningType */; } @@ -38320,11 +38901,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 512 /* EnumLiteral */) { + if (first.flags & 1024 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -38349,10 +38930,11 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || - t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || - t.flags & 448 /* Literal */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 128 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || + t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38375,25 +38957,27 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + if (unionReduction !== 0 /* None */) { + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + } + switch (unionReduction) { + case 1 /* Literal */: + if (includes & 8576 /* StringOrNumberLiteralOrUnique */ | 512 /* BooleanLiteral */) { + removeRedundantLiteralTypes(typeSet, includes); + } + break; + case 2 /* Subtype */: + removeSubtypes(typeSet); + break; + } + if (typeSet.length === 0) { + return includes & 65536 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : + neverType; + } } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & 2240 /* StringOrNumberLiteralOrUnique */ | 256 /* BooleanLiteral */) { - removeRedundantLiteralTypes(typeSet, includes); - } - break; - case 2 /* Subtype */: - removeSubtypes(typeSet); - break; - } - if (typeSet.length === 0) { - return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : - includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : - neverType; - } - return getUnionTypeFromSortedList(typeSet, includes & 16748579 /* NotPrimitiveUnion */ ? 0 : 67108864 /* UnionOfPrimitiveTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, !(includes & 66994211 /* NotPrimitiveUnion */), aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -38430,7 +39014,7 @@ var ts; : !ts.isIdentifierTypePredicate(b); } // This function assumes the constituent type list is sorted and deduplicated. - function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) { + function getUnionTypeFromSortedList(types, primitiveTypesOnly, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { return neverType; } @@ -38440,10 +39024,11 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* Union */ | propagatedFlags); unionTypes.set(id, type); type.types = types; + type.primitiveTypesOnly = primitiveTypesOnly; /* Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. @@ -38465,11 +39050,14 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 536870912 /* EmptyObject */; + if (isEmptyAnonymousObjectType(type)) { + if (!(includes & 536870912 /* EmptyObject */)) { + includes |= 536870912 /* EmptyObject */; + typeSet.push(type); + } } else { includes |= flags & ~939524096 /* ConstructionFlags */; @@ -38477,7 +39065,7 @@ var ts; if (type === wildcardType) includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type)) { + else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !ts.contains(typeSet, type)) { typeSet.push(type); } } @@ -38497,9 +39085,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; + 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 */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38512,10 +39101,11 @@ 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 & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - undefined; + var primitive = type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + undefined; if (!primitive || !containsType(u.types, primitive)) { return false; } @@ -38528,13 +39118,16 @@ 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 (t.flags & 67108864 /* UnionOfPrimitiveTypes */) !== 0; }); + var index = ts.findIndex(types, function (t) { return !!(t.flags & 1048576 /* Union */) && t.primitiveTypesOnly; }); + if (index < 0) { + return false; + } var i = index + 1; // Remove all but the first union of primitive types and collect them in // the unionTypes array. while (i < types.length) { var t = types[i]; - if (t.flags & 67108864 /* UnionOfPrimitiveTypes */) { + if (t.flags & 1048576 /* Union */ && t.primitiveTypesOnly) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -38563,7 +39156,7 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 67108864 /* UnionOfPrimitiveTypes */); + types[index] = getUnionTypeFromSortedList(result, /*primitiveTypesOnly*/ true); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -38579,22 +39172,23 @@ var ts; function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 32768 /* Never */) { + if (includes & 131072 /* Never */) { return neverType; } if (includes & 1 /* Any */) { return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 24576 /* Nullable */) { - return includes & 8192 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* Nullable */) { + return includes & 32768 /* Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { + 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 */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { - typeSet.push(emptyObjectType); + if (includes & 536870912 /* EmptyObject */ && includes & 524288 /* Object */) { + ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { return unknownType; @@ -38602,8 +39196,8 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 262144 /* Union */) { - if (includes & 67108864 /* UnionOfPrimitiveTypes */ && intersectUnionsOfPrimitiveTypes(typeSet)) { + if (includes & 1048576 /* 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. @@ -38611,15 +39205,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(524288 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(2097152 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -38636,7 +39230,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(1048576 /* Index */); + var result = createType(4194304 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -38646,14 +39240,22 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } - function getLiteralTypeFromPropertyName(prop, include) { + function getLiteralTypeFromPropertyName(name) { + return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : + getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); + } + function getBigIntLiteralType(node) { + return getLiteralType({ + negative: false, + base10Value: ts.parsePseudoBigInt(node.text) + }); + } + function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : - getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { return type; @@ -38661,8 +39263,8 @@ var ts; } return neverType; } - function getLiteralTypeFromPropertyNames(type, include) { - return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromPropertyName(t, include); })); + function getLiteralTypeFromProperties(type, include) { + return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromProperty(t, include); })); } function getNonEnumNumberIndexInfo(type) { var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); @@ -38670,16 +39272,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromProperties(type, 128 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 /* StringLiteral */ | 8192 /* UniqueESSymbol */)]) : + getLiteralTypeFromProperties(type, 8576 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -38690,17 +39292,17 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 32768 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 128 /* KeyOfKeyword */: + case 129 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 141 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ + case 142 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 139 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; @@ -38709,7 +39311,7 @@ var ts; return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(2097152 /* IndexedAccess */); + var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; @@ -38730,28 +39332,32 @@ var ts; if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { return true; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { return isJSLiteralType(getResolvedBaseConstraint(type)); } return false; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol, missingType) { - var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; - var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - undefined; + var accessExpression = accessNode && accessNode.kind === 190 /* ElementAccessExpression */ ? accessNode : undefined; + var propName = isTypeUsableAsLateBoundName(indexType) + ? getLateBoundNameFromType(indexType) + : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) + ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) + : accessNode && ts.isPropertyName(accessNode) + // late bound names are handled in the first branch, so here we only need to handle normal names + ? ts.getPropertyNameForPropertyNameNode(accessNode) + : undefined; if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 100 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); return missingType; @@ -38767,22 +39373,22 @@ var ts; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; })) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; }); } } - if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 32768 /* Never */)) { + if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { + if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -38790,7 +39396,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 32768 /* Never */) { + if (indexType.flags & 131072 /* Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -38823,8 +39429,8 @@ var ts; return anyType; } if (accessNode) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + var indexNode = getIndexNodeForAccessExpression(accessNode); + if (indexType.flags & (128 /* StringLiteral */ | 256 /* 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 */)) { @@ -38839,14 +39445,33 @@ var ts; } return missingType; } + function getIndexNodeForAccessExpression(accessNode) { + return accessNode.kind === 190 /* ElementAccessExpression */ + ? accessNode.argumentExpression + : accessNode.kind === 180 /* IndexedAccessType */ + ? accessNode.indexType + : accessNode.kind === 149 /* ComputedPropertyName */ + ? accessNode.expression + : accessNode; + } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */); } function getSimplifiedType(type) { - return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + } + function distributeIndexOverObjectType(objectType, indexType) { + // (T | U)[K] -> T[K] | U[K] + if (objectType.flags & 1048576 /* Union */) { + return mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); + } + // (T & U)[K] -> T[K] & U[K] + if (objectType.flags & 2097152 /* Intersection */) { + return getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + } } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -38860,18 +39485,14 @@ var ts; var objectType = getSimplifiedType(type.objectType); var indexType = getSimplifiedType(type.indexType); // T[A | B] -> T[A] | T[B] - if (indexType.flags & 262144 /* Union */) { + if (indexType.flags & 1048576 /* Union */) { return type.simplified = mapType(indexType, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t)); }); } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 15794176 /* Instantiable */)) { - // (T | U)[K] -> T[K] | U[K] - if (objectType.flags & 262144 /* Union */) { - return type.simplified = mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); - } - // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 524288 /* Intersection */) { - return type.simplified = getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + if (!(indexType.flags & 63176704 /* Instantiable */)) { + var simplified = distributeIndexOverObjectType(objectType, indexType); + if (simplified) { + return type.simplified = simplified; } } // So ultimately: @@ -38883,7 +39504,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 65536 /* TypeParameter */) { + if (objectType.flags & 262144 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -38906,7 +39527,7 @@ var ts; // 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 === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 180 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -38922,7 +39543,7 @@ 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 = getApparentType(objectType); - if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { @@ -38953,7 +39574,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -38975,7 +39596,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; + return type.flags & 33554432 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -38986,7 +39607,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 63176704 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -39025,7 +39646,7 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(4194304 /* Conditional */); + var result = createType(16777216 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -39057,7 +39678,7 @@ var ts; return true; } while (node) { - if (node.kind === 173 /* ConditionalType */) { + if (node.kind === 175 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -39080,7 +39701,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -39200,6 +39821,9 @@ var ts; function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } + function isNonGenericObjectType(type) { + return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + } /** * Since the source of spread types are object literals, which are not binary, * this function should be called in a left folding style, with left = previous result of getSpreadType @@ -39212,21 +39836,37 @@ var ts; if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { return unknownType; } - if (left.flags & 32768 /* Never */) { + if (left.flags & 131072 /* Never */) { return right; } - if (right.flags & 32768 /* Never */) { + if (right.flags & 131072 /* Never */) { return left; } - if (left.flags & 262144 /* Union */) { + if (left.flags & 1048576 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 262144 /* Union */) { + if (right.flags & 1048576 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { + if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { return left; } + if (isGenericObjectType(left) || isGenericObjectType(right)) { + if (isEmptyObjectType(left)) { + return right; + } + // 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 */) { + var types = left.types; + var lastLeft = types[types.length - 1]; + if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { + return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, typeFlags, objectFlags)])); + } + } + return getIntersectionType([left, right]); + } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); var stringIndexInfo; @@ -39246,7 +39886,7 @@ var ts; skippedPrivateMembers.set(rightProp.escapedName, true); } else if (isSpreadableProperty(rightProp)) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSpreadSymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -39261,7 +39901,7 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -39270,27 +39910,28 @@ var ts; } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSpreadSymbol(leftProp)); } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; - spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); + spread.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 1024 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */) - ? !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }) - : !(prop.flags & 65536 /* SetAccessor */); // Setter without getter is not spreadable + return !(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }); } - function getNonReadonlySymbol(prop) { - if (!isReadonlySymbol(prop)) { + function getSpreadSymbol(prop) { + var isReadonly = isReadonlySymbol(prop); + var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (!isReadonly && !isSetonlyAccessor) { return prop; } var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); var result = createSymbol(flags, prop.escapedName); - result.type = getTypeOfSymbol(prop); + result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = prop.nameType; result.syntheticOrigin = prop; @@ -39309,10 +39950,11 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 448 /* Literal */ && !(type.flags & 33554432 /* FreshLiteral */)) { - if (!type.freshType) { // NOTE: Safe because all freshable intrinsics always have fresh types already - var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); + if (type.flags & 2944 /* Literal */) { + if (!type.freshType) { + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; + freshType.freshType = freshType; type.freshType = freshType; } return type.freshType; @@ -39320,21 +39962,27 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + return type.flags & 2944 /* Literal */ ? type.regularType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : type; } + function isFreshLiteralType(type) { + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', // where NNN is the text representation of a numeric literal and SSS are the characters // of a string literal. For literal enum members we use 'EEE#NNN' and 'EEE@SSS', where // EEE is a unique id for the containing enum type. - var qualifier = typeof value === "number" ? "#" : "@"; - var key = enumId ? enumId + qualifier + value : qualifier + value; + var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; + var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value); var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 256 /* NumberLiteral */ : + typeof value === "string" ? 128 /* StringLiteral */ : 2048 /* BigIntLiteral */) | + (enumId ? 1024 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); + type.regularType = type; } return type; } @@ -39346,7 +39994,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(2048 /* UniqueESSymbol */); + var type = createType(8192 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -39361,9 +40009,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 241 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 157 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -39379,87 +40027,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 120 /* AnyKeyword */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return anyType; - case 142 /* UnknownKeyword */: + case 143 /* UnknownKeyword */: return unknownType; - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return stringType; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return numberType; - case 122 /* BooleanKeyword */: + case 146 /* BigIntKeyword */: + return bigintType; + case 123 /* BooleanKeyword */: return booleanType; - case 138 /* SymbolKeyword */: + case 139 /* SymbolKeyword */: return esSymbolType; - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return voidType; - case 140 /* UndefinedKeyword */: + case 141 /* UndefinedKeyword */: return undefinedType; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullType; - case 131 /* NeverKeyword */: + case 132 /* NeverKeyword */: return neverType; - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return getTypeFromTypeReference(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return booleanType; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 175 /* ParenthesizedType */: - case 170 /* RestType */: - case 285 /* JSDocNonNullableType */: - case 281 /* JSDocTypeExpression */: + case 177 /* ParenthesizedType */: + case 172 /* RestType */: + case 287 /* JSDocNonNullableType */: + case 283 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 174 /* InferType */: + case 176 /* InferType */: return getTypeFromInferTypeNode(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -39540,10 +40190,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; + return type.flags & 262144 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(65536 /* TypeParameter */); + var result = createType(262144 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -39589,7 +40239,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -39669,8 +40319,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 146 /* QualifiedName */ || - node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 148 /* QualifiedName */ || + node.parent.kind === 164 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -39678,19 +40328,19 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 218 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 176 /* ThisType */: + case 178 /* ThisType */: return !!tp.isThisType; - case 71 /* Identifier */: + case 72 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -39698,9 +40348,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 1048576 /* Index */) { + if (constraintType.flags & 4194304 /* Index */) { var typeVariable = constraintType.type; - if (typeVariable.flags & 65536 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeParameter */) { return typeVariable; } } @@ -39730,7 +40380,7 @@ var ts; } type.instantiating = true; var result = mapType(mappedTypeVariable, function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */) && t !== wildcardType) { + if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType) { var replacementMapper = createReplacementMapper(typeVariable, t, mapper); return isArrayType(t) ? createArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : isReadonlyArrayType(t) ? createReadonlyArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : @@ -39761,7 +40411,7 @@ var ts; var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper) { @@ -39806,7 +40456,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -39829,10 +40479,10 @@ var ts; } function instantiateTypeWorker(type, mapper) { var flags = type.flags; - if (flags & 65536 /* TypeParameter */) { + if (flags & 262144 /* TypeParameter */) { return mapper(type); } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or @@ -39851,32 +40501,32 @@ var ts; } return type; } - if (flags & 262144 /* Union */ && !(flags & 32764 /* Primitive */)) { + if (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 1048576 /* Index */) { + if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } return type; } function getWildcardInstantiation(type) { - return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : + return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -39885,34 +40535,34 @@ 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 !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 202 /* BinaryExpression */: - return node.operatorToken.kind === 54 /* BarBarToken */ && + case 204 /* BinaryExpression */: + return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 266 /* JsxAttributes */: - return ts.some(node.properties, isContextSensitive); - case 265 /* JsxAttribute */: { + case 268 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); + case 267 /* 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 268 /* JsxExpression */: { + case 270 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -39929,7 +40579,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* 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); @@ -39942,14 +40592,14 @@ var ts; function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 216 /* Block */ ? false : isContextSensitive(body); + return body.kind === 218 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -39960,7 +40610,7 @@ var ts; return result; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -39975,6 +40625,9 @@ var ts; function compareTypesAssignable(source, target) { return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; } + function compareTypesSubtypeOf(source, target) { + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); } @@ -39990,11 +40643,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : - target === globalObjectType ? !!(source.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 131072 /* Object */) && isFunctionObjectType(source) : + 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) || emptyObjectType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)); } /** @@ -40032,7 +40685,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 4194304 /* Conditional */ || (type.flags & 524288 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage) { if (!node || isOrHasGenericConditional(target)) @@ -40041,23 +40694,23 @@ var ts; return true; } switch (node.kind) { - case 268 /* JsxExpression */: - case 193 /* ParenthesizedExpression */: + case 270 /* JsxExpression */: + case 195 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage); } break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return elaborateJsxAttributes(node, source, target, relation); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation); } return false; @@ -40069,7 +40722,7 @@ var ts; var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 32768 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = {}; checkTypeAssignableTo(source, target, node, headMessage, /*containingChain*/ undefined, resultObj); @@ -40126,8 +40779,10 @@ var ts; var reportedError = false; 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 sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); var targetPropType = getIndexedAccessType(target, nameType, /*accessNode*/ undefined, errorType); + if (targetPropType === errorType || targetPropType.flags & 8388608 /* IndexedAccess */) + continue; // Don't elaborate on indexes on generic variables + var sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); if (sourcePropType !== errorType && targetPropType !== errorType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined); if (elaborated) { @@ -40149,7 +40804,7 @@ var ts; var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; var issuedElaboration = false; if (!targetProp) { - var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(nameType, 296 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || getIndexInfoOfType(target, 0 /* String */) || undefined; if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) { @@ -40160,7 +40815,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) { - addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + 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))); } } } @@ -40253,17 +40908,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 32768 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 157 /* SetAccessor */: return [3 /*break*/, 2]; - case 156 /* GetAccessor */: return [3 /*break*/, 2]; - case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 159 /* SetAccessor */: return [3 /*break*/, 2]; + case 158 /* GetAccessor */: return [3 /*break*/, 2]; + case 156 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 276 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 275 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -40322,8 +40977,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && - kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 156 /* MethodDeclaration */ && + kind !== 155 /* MethodSignature */ && kind !== 157 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -40357,7 +41012,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : @@ -40449,12 +41104,15 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 16777216 /* NonPrimitive */ ? true : - type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 524288 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* Object */ ? 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) : false; } + function isEmptyAnonymousObjectType(type) { + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && isEmptyObjectType(type); + } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { if (sourceSymbol === targetSymbol) { return true; @@ -40491,43 +41149,45 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) return true; - if (t & 32768 /* Never */) + if (t & 131072 /* Never */) return false; - if (s & 68 /* StringLike */ && t & 4 /* String */) + if (s & 132 /* StringLike */ && t & 4 /* String */) return true; - if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && - t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && + t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 168 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && - t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && + t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true; - if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) + if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + return true; + if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true; if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { - if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { + if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 448 /* Literal */ && t & 448 /* Literal */ && + if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) + if (s & 32768 /* Undefined */ && (!strictNullChecks || t & (32768 /* Undefined */ | 16384 /* Void */))) return true; - if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) + if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */)) return true; - if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) + if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) return true; - if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) + if (s & 8192 /* UniqueESSymbol */ || t & 8192 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -40535,30 +41195,30 @@ var ts; // 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 */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { + if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { + if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -40578,6 +41238,7 @@ var ts; */ function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; + var relatedInfo; var maybeKeys; var sourceStack; var targetStack; @@ -40585,7 +41246,7 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var isIntersectionConstituent = false; + var suppressNextError = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { @@ -40612,15 +41273,27 @@ var ts; } } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (relatedInfo) { + addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + } if (errorOutputContainer) { errorOutputContainer.error = diag; } diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { + function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); + } + function associateRelatedInfo(info) { + ts.Debug.assert(!!errorInfo); + if (!relatedInfo) { + relatedInfo = [info]; + } + else { + relatedInfo.push(info); + } } function reportRelationError(message, source, target) { var sourceType = typeToString(source); @@ -40653,7 +41326,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 786432 /* UnionOrIntersection */)) { + if (!(type.flags & 3145728 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -40661,7 +41334,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 24576 /* Nullable */) { + if (t.flags & 98304 /* Nullable */) { continue; } if (seenNonNullable) { @@ -40677,24 +41350,24 @@ var ts; * * Ternary.Maybe if they are related with assumptions of other relationships, or * * Ternary.False if they are not related. */ - function isRelatedTo(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage, isApparentIntersectionConstituent) { if (reportErrors === void 0) { reportErrors = false; } - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } - if (source.flags & 8388608 /* Substitution */) { + if (source.flags & 33554432 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 8388608 /* Substitution */) { + if (target.flags & 33554432 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8388608 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 2097152 /* IndexedAccess */) { + if (target.flags & 8388608 /* IndexedAccess */) { target = getSimplifiedType(target); } // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. @@ -40706,10 +41379,10 @@ var ts; // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" // when dealing with generics. // * We also don't deal with primitive source types, since we already halt elaboration below. - if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && - target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { - var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); - if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); + if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { target = nullStrippedTarget; } } @@ -40719,11 +41392,12 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { - var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + if (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */) { + var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -40738,11 +41412,11 @@ var ts; source = getRegularTypeOfObjectLiteral(source); } } - if (relation !== comparableRelation && !isIntersectionConstituent && - source.flags & (32764 /* Primitive */ | 131072 /* Object */ | 524288 /* Intersection */) && source !== globalObjectType && - target.flags & (131072 /* Object */ | 524288 /* Intersection */) && isWeakType(target) && + if (relation !== comparableRelation && !isApparentIntersectionConstituent && + source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && + target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target)) { + !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -40758,25 +41432,24 @@ var ts; } var result = 0 /* False */; var saveErrorInfo = errorInfo; - var saveIsIntersectionConstituent = isIntersectionConstituent; - isIntersectionConstituent = false; + var isIntersectionConstituent = !!isApparentIntersectionConstituent; // 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 & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { - if (target.flags & 262144 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); + if (target.flags & 1048576 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); } - else if (target.flags & 524288 /* Intersection */) { - isIntersectionConstituent = true; + else if (target.flags & 2097152 /* Intersection */) { + isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 524288 /* Intersection */) { + else if (source.flags & 2097152 /* Intersection */) { // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually @@ -40792,13 +41465,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { - if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { + if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 524288 /* Intersection */) { + if (!result && source.flags & 2097152 /* Intersection */) { // 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 @@ -40808,22 +41481,23 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { + if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { + var maybeSuppress = suppressNextError; + suppressNextError = false; + if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* 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) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -40833,6 +41507,10 @@ var ts; return result; } } + if (!headMessage && maybeSuppress) { + // Used by, eg, missing property checking to replace the top-level message with a more informative one + return result; + } reportRelationError(headMessage, source, target); } return result; @@ -40840,10 +41518,10 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 131072 /* Object */ || flags & 2097152 /* IndexedAccess */ || flags & 4194304 /* Conditional */ || flags & 1048576 /* Index */ || flags & 8388608 /* Substitution */) { - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); + if (flags & 524288 /* Object */ || flags & 8388608 /* IndexedAccess */ || flags & 16777216 /* Conditional */ || flags & 4194304 /* Index */ || flags & 33554432 /* Substitution */) { + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); } - if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { + if (flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -40856,7 +41534,7 @@ var ts; if (!noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 524288 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -40867,16 +41545,17 @@ var ts; return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } var _loop_6 = function (prop) { - if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. if (!errorNode) return { value: ts.Debug.fail() }; - if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. + // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -40912,8 +41591,8 @@ var ts; } return false; } - function isPropertyFromSpread(prop, container) { - return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + function shouldCheckAsExcessProperty(prop, container) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration; } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; @@ -40930,7 +41609,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -40951,9 +41630,9 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 131072 /* Object */) { + if (target.flags & 524288 /* Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); if (overlapObjFlags & 4 /* Reference */) { return source.target === target.target; @@ -40981,11 +41660,13 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - if (sourceProperties) { - var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); - if (sourcePropertiesFiltered) { - return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + if (target.flags & 1048576 /* Union */) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (sourcePropertiesFiltered) { + return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + } } } return undefined; @@ -40995,7 +41676,7 @@ var ts; 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, reportErrors); + var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, /*isIntersectionConstituent*/ true); if (!related) { return 0 /* False */; } @@ -41005,7 +41686,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -41030,9 +41711,10 @@ var ts; } return result; } - function typeArgumentsRelatedTo(source, target, variances, reportErrors) { - var sources = source.typeArguments || ts.emptyArray; - var targets = target.typeArguments || ts.emptyArray; + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + if (sources === void 0) { sources = ts.emptyArray; } + if (targets === void 0) { targets = ts.emptyArray; } + if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { return 0 /* False */; } @@ -41086,7 +41768,7 @@ var ts; // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function recursiveTypeRelatedTo(source, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0 /* False */; } @@ -41129,7 +41811,7 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; - var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -41152,21 +41834,21 @@ var ts; function getConstraintForRelation(type) { return relation === definitelyAssignableRelation ? undefined : getConstraintOfType(type); } - function structuredTypeRelatedTo(source, target, reportErrors) { + function structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { var flags = source.flags & target.flags; - if (relation === identityRelation && !(flags & 131072 /* Object */)) { - if (flags & 1048576 /* Index */) { + if (relation === identityRelation && !(flags & 524288 /* Object */)) { + if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } var result_2 = 0 /* False */; - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { if (result_2 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result_2; } } } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result_2 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -41179,7 +41861,7 @@ var ts; } } } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; @@ -41187,9 +41869,22 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 65536 /* TypeParameter */) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + // 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 (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && + source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && + !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { + var variances = getAliasVariances(source.aliasSymbol); + if (result = typeArgumentsRelatedTo(source.aliasTypeArguments, target.aliasTypeArguments, variances, reportErrors)) { + return result; + } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; + } + if (target.flags & 262144 /* 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 */ && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); @@ -41199,9 +41894,9 @@ var ts; } } } - else if (target.flags & 1048576 /* Index */) { + else if (target.flags & 4194304 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 1048576 /* Index */) { + if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -41222,7 +41917,7 @@ var ts; } } } - else if (target.flags & 2097152 /* IndexedAccess */) { + else if (target.flags & 8388608 /* IndexedAccess */) { // A type S is related to a type T[K], where T and K aren't both type variables, if S is related to C, // where C is the base constraint of T[K] if (relation !== identityRelation && !(isGenericObjectType(target.objectType) && isGenericIndexType(target.indexType))) { @@ -41239,22 +41934,24 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 8388608 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (!isGenericMappedType(source) && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + // A source type T is related to a target type { [P in Q]: X } if Q is related to keyof T and T[Q] is related to X. + if (!isGenericMappedType(source) && isRelatedTo(getConstraintTypeFromMappedType(target), getIndexType(source))) { var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { return result; } } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; } } - if (source.flags & 2162688 /* TypeVariable */) { - if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8650752 /* TypeVariable */) { + if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { // 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, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); @@ -41265,29 +41962,32 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { + if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } } - else { - var instantiated = getTypeWithThisArgument(constraint, source); - if (result = isRelatedTo(instantiated, target, reportErrors)) { - errorInfo = 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, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = 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, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = saveErrorInfo; + return result; } } - else if (source.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 4194304 /* Conditional */) { - if (target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */) { + if (target.flags & 16777216 /* 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. @@ -41336,7 +42036,7 @@ var ts; if (relation === definitelyAssignableRelation && isGenericMappedType(source)) { return 0 /* False */; } - var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } @@ -41346,7 +42046,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - if (result = typeArgumentsRelatedTo(source, target, variances, reportErrors)) { + if (result = typeArgumentsRelatedTo(source.typeArguments, target.typeArguments, variances, reportErrors)) { return result; } // The type arguments did not relate appropriately, but it may be because we have no variance @@ -41381,7 +42081,7 @@ var ts; // 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 (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors); @@ -41431,7 +42131,24 @@ var ts; var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties)); + if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code && + headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) { + suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it + } + if (props.length === 1) { + var propName = symbolToString(unmatchedProperty); + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, typeToString(source), typeToString(target)); + if (ts.length(unmatchedProperty.declarations)) { + associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); + } + } + else if (props.length > 5) { // arbitrary cutoff for too-long list form + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, typeToString(source), typeToString(target), ts.map(props.slice(0, 4), function (p) { return symbolToString(p); }).join(", "), props.length - 4); + } + else { + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); + } } return 0 /* False */; } @@ -41478,8 +42195,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { - var targetProp = properties_3[_b]; + for (var _b = 0, properties_2 = properties; _b < properties_2.length; _b++) { + var targetProp = properties_2[_b]; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { @@ -41550,7 +42267,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { + if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -41678,7 +42395,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 8192 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -41797,20 +42514,19 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; } - function hasCommonProperties(source, target) { - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + function hasCommonProperties(source, target, isComparingJsxAttributes) { for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { @@ -41826,62 +42542,71 @@ var ts; result.objectFlags |= 8192 /* MarkerType */; return result; } + 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 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 if we're not in strictFunctionTypes mode or if the function // has been invoked recursively for the given generic type. + function getVariancesWorker(typeParameters, cache, createMarkerType) { + if (typeParameters === void 0) { typeParameters = ts.emptyArray; } + var variances = cache.variances; + if (!variances) { + // The emptyArray singleton is used to signal a recursive invocation. + cache.variances = ts.emptyArray; + variances = []; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var tp = typeParameters_1[_i]; + // 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 */; + } + variances.push(variance); + } + cache.variances = variances; + } + return variances; + } function getVariances(type) { if (!strictFunctionTypes) { return ts.emptyArray; } - var typeParameters = type.typeParameters || ts.emptyArray; - var variances = type.variances; - if (!variances) { - if (type === globalArrayType || type === globalReadonlyArrayType) { - // Arrays are known to be covariant, no need to spend time computing this - variances = [1 /* Covariant */]; - } - else { - // The emptyArray singleton is used to signal a recursive invocation. - type.variances = ts.emptyArray; - variances = []; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - // 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 = getMarkerTypeReference(type, tp, markerSuperType); - var typeWithSub = getMarkerTypeReference(type, 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(getMarkerTypeReference(type, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; - } - variances.push(variance); - } - } - type.variances = variances; + if (type === globalArrayType || type === globalReadonlyArrayType) { + // Arrays are known to be covariant, no need to spend time computing this (emptyArray implies covariance for all parameters) + return ts.emptyArray; } - return variances; + return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference); } // 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(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 16384 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 65536 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); @@ -41974,13 +42699,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 131072 /* Object */) { + if (depth >= 5 && type.flags & 524288 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 131072 /* Object */ && t.symbol === symbol) { + if (t.flags & 524288 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -42086,7 +42811,7 @@ var ts; for (var i = 0; i < targetLen; i++) { var s = getTypeAtPosition(source, i); var t = getTypeAtPosition(target, i); - var related = compareTypes(s, t); + var related = compareTypes(t, s); if (!related) { return 0 /* False */; } @@ -42131,9 +42856,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -42150,7 +42875,7 @@ var ts; // 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 return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -42170,35 +42895,37 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); + return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 27072 /* Unit */); + return !!(type.flags & 109440 /* Unit */); } function isLiteralType(type) { return type.flags & 16 /* Boolean */ ? true : - type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : - type; + return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 512 /* BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type; } function getWidenedLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, 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 */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -42224,6 +42951,10 @@ var ts; function getLengthOfTupleType(type) { return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); } + function isZeroBigInt(_a) { + var value = _a.value; + return value.base10Value === "0"; + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -42236,15 +42967,16 @@ 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 & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : - type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : - type.flags & 256 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 256 /* BooleanLiteral */ : 0 : - type.flags & 29148 /* PossiblyFalsy */; + 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 */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { @@ -42253,12 +42985,14 @@ var ts; function getDefinitelyFalsyPartOfType(type) { return type.flags & 4 /* String */ ? emptyStringType : type.flags & 8 /* Number */ ? zeroType : - type === regularFalseType || - type === falseType || - type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || - type.flags & 64 /* StringLiteral */ && type.value === "" || - type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : - neverType; + type.flags & 64 /* BigInt */ ? zeroBigIntType : + type === regularFalseType || + type === falseType || + type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */) || + type.flags & 128 /* StringLiteral */ && type.value === "" || + type.flags & 256 /* NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + neverType; } /** * Add undefined or null or both to a type if they are missing. @@ -42266,15 +43000,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); return missing === 0 ? type : - missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 16384 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -42284,7 +43018,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -42327,7 +43061,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -42337,7 +43071,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; + regularNew.flags = resolved.flags; regularNew.objectFlags |= 128 /* ObjectLiteral */ | (ts.getObjectFlags(resolved) & 16384 /* JSLiteral */); type.regularType = regularNew; return regularNew; @@ -42425,15 +43159,15 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (type.flags & 402653184 /* RequiresWidening */) { - if (type.flags & 24576 /* Nullable */) { + if (type.flags & 98304 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* 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 {}). @@ -42459,7 +43193,7 @@ var ts; function reportWideningErrorsInType(type) { var errorReported = false; if (type.flags & 134217728 /* ContainsWideningType */) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -42503,39 +43237,42 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 202 /* BinaryExpression */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + case 204 /* BinaryExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* 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 149 /* Parameter */: + case 151 /* Parameter */: diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + 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 184 /* BindingElement */: + case 186 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + diagnostic = noImplicitAny ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type : ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage; break; - case 179 /* MappedType */: + case 181 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } return; default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + diagnostic = noImplicitAny ? ts.Diagnostics.Variable_0_implicitly_has_an_1_type : ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; } errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } @@ -42614,11 +43351,11 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 15794176 /* Instantiable */ || + return !!(type.flags & 63176704 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -42627,13 +43364,13 @@ var ts; return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 3145728 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, 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 & 64 /* StringLiteral */)) { + if (!(t.flags & 128 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -42654,25 +43391,25 @@ var ts; * property is computed by inferring from the source property type to X for the type * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ - function inferTypeForHomomorphicMappedType(source, target) { - var key = source.id + "," + target.id; + function inferTypeForHomomorphicMappedType(source, target, constraint) { + var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } reverseMappedCache.set(key, undefined); - var type = createReverseMappedType(source, target); + var type = createReverseMappedType(source, target, constraint); reverseMappedCache.set(key, type); return type; } - function createReverseMappedType(source, target) { + function createReverseMappedType(source, target, constraint) { var properties = getPropertiesOfType(source); if (properties.length === 0 && !getIndexInfoOfType(source, 0 /* String */)) { return undefined; } // If any property contains context sensitive functions that have been skipped, the source type // is incomplete and we can't infer a meaningful input type. - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var prop = properties_3[_i]; if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } @@ -42680,13 +43417,13 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isReadonlyArrayType(source)) { - return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target); }); + var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.associatedNames); @@ -42696,30 +43433,46 @@ var ts; var reversed = createObjectType(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; + reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType); + return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); } - function inferReverseMappedType(sourceType, target) { - var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target)); + function inferReverseMappedType(sourceType, target, constraint) { + var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); var inference = createInferenceInfo(typeParameter); inferTypes([inference], sourceType, templateType); return getTypeFromInference(inference); } - function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; - if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (!sourceProp) { - return targetProp; - } + function getUnmatchedProperties(source, target, requireOptionalProperties) { + var properties, _i, properties_4, targetProp, sourceProp; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + properties = target.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + _i = 0, properties_4 = properties; + _a.label = 1; + case 1: + if (!(_i < properties_4.length)) return [3 /*break*/, 4]; + targetProp = properties_4[_i]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */))) return [3 /*break*/, 3]; + sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (!!sourceProp) return [3 /*break*/, 3]; + return [4 /*yield*/, targetProp]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; } - } - return undefined; + }); + } + function getUnmatchedProperty(source, target, requireOptionalProperties) { + return getUnmatchedProperties(source, target, requireOptionalProperties).next().value; } function tupleTypesDefinitelyUnrelated(source, target) { return target.target.minLength > source.target.minLength || @@ -42769,8 +43522,8 @@ var ts; } return; } - if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || - source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { + if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || + source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -42793,7 +43546,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { + else if (t.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -42808,7 +43561,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 2162688 /* TypeVariable */) { + if (target.flags & 8650752 /* 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 @@ -42816,7 +43569,7 @@ 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.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType || (priority & 8 /* ReturnType */ && (source === autoType || source === autoArrayType))) { return; } var inference = getInferenceInfoForType(target); @@ -42838,12 +43591,30 @@ var ts; inference.candidates = ts.appendIfUnique(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } return; } + else { + // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine + var simplified = getSimplifiedType(target); + if (simplified !== target) { + inferFromTypesOnce(source, simplified); + } + else if (target.flags & 8388608 /* IndexedAccess */) { + var indexType = getSimplifiedType(target.indexType); + // 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 & 63176704 /* Instantiable */) { + var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType), indexType); + if (simplified_1 && simplified_1 !== target) { + inferFromTypesOnce(source, simplified_1); + } + } + } + } } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments @@ -42860,12 +43631,12 @@ var ts; } } } - else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -42874,20 +43645,20 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */ && target.flags & 16777216 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 4194304 /* Conditional */) { + else if (target.flags & 16777216 /* Conditional */) { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } - else if (target.flags & 786432 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -42912,7 +43683,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 262144 /* Union */) { + else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -42921,12 +43692,12 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 63176704 /* 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 & (131072 /* Object */ | 524288 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* 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 @@ -42939,7 +43710,7 @@ var ts; } source = apparentSource; } - if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -42949,7 +43720,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 131072 /* Object */ && + var isNonConstructorObject = target.flags & 524288 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -42965,6 +43736,13 @@ var ts; } } } + function inferFromTypesOnce(source, target) { + var key = source.id + "," + target.id; + if (!visited || !visited.get(key)) { + (visited || (visited = ts.createMap())).set(key, true); + inferFromTypes(source, target); + } + } } function inferFromContravariantTypes(source, target) { if (strictFunctionTypes || priority & 64 /* AlwaysStrict */) { @@ -42977,7 +43755,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -42987,6 +43765,44 @@ var ts; } return undefined; } + function inferFromMappedTypeConstraint(source, target, constraintType) { + if (constraintType.flags & 1048576 /* Union */) { + var result = false; + for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { + var type = _a[_i]; + result = inferFromMappedTypeConstraint(source, target, type) || result; + } + return result; + } + if (constraintType.flags & 4194304 /* 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 + // such that direct inferences to T get priority over inferences to Partial, for example. + var inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + var savePriority = priority; + priority |= 2 /* HomomorphicMappedType */; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + return true; + } + if (constraintType.flags & 262144 /* TypeParameter */) { + // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type + // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. + var savePriority = priority; + priority |= 4 /* MappedTypeConstraint */; + inferFromTypes(getIndexType(source), constraintType); + priority = savePriority; + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return true; + } + return false; + } function inferFromObjectTypes(source, target) { if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer @@ -42996,31 +43812,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 1048576 /* 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 - // such that direct inferences to T get priority over inferences to Partial, for example. - var inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - var inferredType = inferTypeForHomomorphicMappedType(source, target); - if (inferredType) { - var savePriority = priority; - priority |= 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - return; - } - if (constraintType.flags & 65536 /* TypeParameter */) { - // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type - // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. - var savePriority = priority; - priority |= 4 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; - inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + if (inferFromMappedTypeConstraint(source, target, constraintType)) { return; } } @@ -43060,8 +43852,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -43084,7 +43876,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ || kind === 155 /* Constructor */; + bivariant = bivariant || kind === 156 /* MethodDeclaration */ || kind === 155 /* MethodSignature */ || kind === 157 /* Constructor */; forEachMatchingParameterType(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -43138,11 +43930,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 4194304 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 32764 /* Primitive */ | 1048576 /* Index */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -43191,7 +43983,7 @@ var ts; var inferredContravariantType = getContravariantInference(inference); // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype and not 'never'. - inferredType = inferredCovariantType && !(inferredCovariantType.flags & 32768 /* Never */) && + inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ? inferredCovariantType : inferredContravariantType; } @@ -43250,17 +44042,17 @@ var ts; case "console": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; case "$": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig; case "describe": case "suite": case "it": case "test": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig; case "process": case "require": case "Buffer": case "module": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig; case "Map": case "Set": case "Promise": @@ -43286,7 +44078,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 === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 167 /* TypeQuery */ ? true : n.kind === 72 /* Identifier */ || n.kind === 148 /* 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 @@ -43295,20 +44087,20 @@ var ts; // occurring in an apparent type position with '@' because the control flow type // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; } - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { return "0"; } - if (node.kind === 187 /* PropertyAccessExpression */) { + if (node.kind === 189 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 184 /* BindingElement */) { + if (node.kind === 186 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 186 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -43317,14 +44109,14 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 182 /* ObjectBindingPattern */) { + if (parent.kind === 184 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; default: @@ -43338,29 +44130,29 @@ var ts; } function isMatchingReference(source, target) { switch (source.kind) { - case 71 /* Identifier */: - return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && + case 72 /* Identifier */: + return target.kind === 72 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 237 /* VariableDeclaration */ || target.kind === 186 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 99 /* ThisKeyword */: - return target.kind === 99 /* ThisKeyword */; - case 97 /* SuperKeyword */: - return target.kind === 97 /* SuperKeyword */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 100 /* ThisKeyword */: + return target.kind === 100 /* ThisKeyword */; + case 98 /* SuperKeyword */: + return target.kind === 98 /* SuperKeyword */; + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return (ts.isPropertyAccessExpression(target) || ts.isElementAccessExpression(target)) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 184 /* BindingElement */: - if (target.kind !== 187 /* PropertyAccessExpression */) + case 186 /* BindingElement */: + if (target.kind !== 189 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 186 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 235 /* VariableDeclaration */) { + if (source.parent.parent.kind === 237 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -43373,7 +44165,7 @@ var ts; undefined; } function containsMatchingReference(source, target) { - while (source.kind === 187 /* PropertyAccessExpression */) { + while (source.kind === 189 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -43386,23 +44178,23 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 187 /* PropertyAccessExpression */ && + return target.kind === 189 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 71 /* Identifier */) { + if (expr.kind === 72 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 187 /* PropertyAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantType(type) { - if (type.flags & 262144 /* Union */) { - if (type.flags & (16 /* Boolean */ | 512 /* EnumLiteral */)) { + if (type.flags & 1048576 /* Union */) { + if (type.flags & (16 /* Boolean */ | 1024 /* EnumLiteral */)) { return true; } var combined = 0; @@ -43410,14 +44202,14 @@ var ts; var t = _a[_i]; combined |= t.flags; } - if (combined & 27072 /* Unit */ && !(combined & 15794176 /* Instantiable */)) { + if (combined & 109440 /* Unit */ && !(combined & 63176704 /* Instantiable */)) { return true; } } return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 262144 /* Union */) { + if (type && type.flags & 1048576 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { @@ -43428,6 +44220,10 @@ var ts; } return false; } + function hasNarrowableDeclaredType(expr) { + var type = getDeclaredTypeOfReference(expr); + return !!(type && type.flags & 1048576 /* Union */); + } function findDiscriminantProperties(sourceProperties, target) { var result; for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { @@ -43454,7 +44250,7 @@ var ts; } } } - if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 189 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -43468,7 +44264,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 262144 /* Union */)) { + if (!(source.flags & 1048576 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -43484,11 +44280,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 32768 /* Never */) { + if (assignedType.flags & 131072 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 33554432 /* FreshLiteral */ && assignedType.flags & 256 /* BooleanLiteral */) { + if (assignedType.flags & 512 /* 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. @@ -43519,57 +44315,66 @@ var ts; function getTypeFacts(type) { var flags = type.flags; if (flags & 4 /* String */) { - return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; + return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; } - if (flags & 64 /* StringLiteral */) { + if (flags & 128 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : - isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; } if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; + return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; } - if (flags & 128 /* NumberLiteral */) { + if (flags & 256 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : - isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; + isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + } + if (flags & 64 /* BigInt */) { + return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + } + if (flags & 2048 /* BigIntLiteral */) { + var isZero = isZeroBigInt(type); + return strictNullChecks ? + isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; } if (flags & 16 /* Boolean */) { - return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; + return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; } - if (flags & 272 /* BooleanLike */) { + if (flags & 528 /* BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 4079615 /* EmptyObjectStrictFacts */ : 4194303 /* EmptyObjectFacts */ : + strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : - strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : + strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { - return 2457472 /* UndefinedFacts */; + if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { + return 9830144 /* UndefinedFacts */; } - if (flags & 16384 /* Null */) { - return 2340752 /* NullFacts */; + if (flags & 65536 /* Null */) { + return 9363232 /* NullFacts */; } - if (flags & 3072 /* ESSymbolLike */) { - return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; + if (flags & 12288 /* ESSymbolLike */) { + return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; } - if (flags & 16777216 /* NonPrimitive */) { - return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + if (flags & 67108864 /* NonPrimitive */) { + return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & 15794176 /* Instantiable */) { + if (flags & 63176704 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 786432 /* UnionOrIntersection */) { + if (flags & 3145728 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } - return 4194303 /* All */; + return 16777215 /* All */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -43577,7 +44382,7 @@ var ts; function getTypeWithDefault(type, defaultExpression) { if (defaultExpression) { var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 131072 /* NEUndefined */), defaultType]); + return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); } return type; } @@ -43597,15 +44402,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 187 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 275 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 204 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 227 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -43622,21 +44427,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return stringType; - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return undefinedType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -43644,7 +44449,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 182 /* ObjectBindingPattern */ ? + var type = pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -43662,39 +44467,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 224 /* ForInStatement */) { + if (node.parent.parent.kind === 226 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.parent.kind === 227 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 235 /* VariableDeclaration */ ? + return node.kind === 237 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 235 /* VariableDeclaration */ && node.initializer && + return node.kind === 237 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && + node.kind !== 186 /* BindingElement */ && node.parent.kind === 204 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return getReferenceCandidate(node.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return getReferenceCandidate(node.right); } } @@ -43702,13 +44507,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 193 /* ParenthesizedExpression */ || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 195 /* ParenthesizedExpression */ || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */ && parent.left === node || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -43730,8 +44535,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 269 /* CaseClause */) { - if (clause.expression.kind === 9 /* StringLiteral */) { + if (clause.kind === 271 /* CaseClause */) { + if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; } @@ -43742,13 +44547,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* 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 & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -43757,30 +44562,30 @@ var ts; } return true; } - if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 262144 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfPrimitiveTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.primitiveTypesOnly); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return type; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return mapper(type); } var types = type.types; @@ -43810,12 +44615,14 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) || + isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : - t; + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : + t; }); } return typeWithPrimitives; @@ -43849,9 +44656,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 32768 /* Never */ ? + return elementType.flags & 131072 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 262144 /* Union */ ? + createArrayType(elementType.flags & 1048576 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -43869,7 +44676,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - if (!(t.flags & 32768 /* Never */)) { + if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -43891,15 +44698,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 189 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 191 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 190 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 202 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 58 /* EqualsToken */ && + parent.parent.kind === 204 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 59 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -43910,7 +44717,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 97 /* SuperKeyword */) { + if (node.expression.kind !== 98 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -43932,7 +44739,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -43942,8 +44749,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent && reference.parent.kind === 213 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -44015,9 +44822,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 187 /* PropertyAccessExpression */ && - reference.kind !== 188 /* ElementAccessExpression */ && - reference.kind !== 99 /* ThisKeyword */) { + reference.kind !== 189 /* PropertyAccessExpression */ && + reference.kind !== 190 /* ElementAccessExpression */ && + reference.kind !== 100 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -44055,7 +44862,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 262144 /* Union */) { + if (declaredType.flags & 1048576 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); } return declaredType; @@ -44069,19 +44876,23 @@ 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 === 194 /* FunctionExpression */ || init.kind === 195 /* ArrowFunction */)) { + if (init && (init.kind === 196 /* FunctionExpression */ || init.kind === 197 /* 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 === 226 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + } // Assignment doesn't affect reference return undefined; } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 189 /* CallExpression */ ? + var expr = node.kind === 191 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -44089,7 +44900,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -44098,7 +44909,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, 168 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -44112,7 +44923,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -44129,7 +44940,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 131072 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -44145,7 +44956,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 197 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 199 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } return createFlowType(type, isIncomplete(flowType)); @@ -44261,8 +45072,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 262144 /* Union */) || - expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (!(computedType.flags & 1048576 /* Union */) || + expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { return false; } var access = expr; @@ -44283,10 +45094,10 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); + return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } if (isMatchingReferenceDiscriminant(expr, declaredType)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); }); + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; @@ -44304,7 +45115,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -44312,19 +45123,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -44343,15 +45154,15 @@ var ts; return declaredType; } break; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 92 /* InKeyword */: + case 93 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); } break; - case 26 /* CommaToken */: + case 27 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -44360,28 +45171,28 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 24576 /* Nullable */) { + if (valueType.flags & 98304 /* Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; + var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 16384 /* Null */ ? - assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : - assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; + assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : + valueType.flags & 65536 /* Null */ ? + assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : + assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 16909315 /* NotUnionOrUnit */) { + if (type.flags & 67637251 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 131072 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -44393,22 +45204,22 @@ var ts; // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { - // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, target)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, a + // 'typeof x === ...' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, target) && hasNarrowableDeclaredType(target)) { return declaredType; } return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); function narrowTypeForTypeof(type) { if (type.flags & 2 /* Unknown */ && literal.text === "object") { @@ -44425,7 +45236,7 @@ var ts; if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -44444,13 +45255,37 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + } + function getImpliedTypeFromTypeofCase(type, text) { + switch (text) { + case "function": + return type.flags & 1 /* Any */ ? type : globalFunctionType; + case "object": + return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + default: + return typeofTypesByName.get(text) || type; + } + } + function narrowTypeForTypeofSwitch(candidate) { + return function (type) { + if (isTypeSubtypeOf(candidate, type)) { + return candidate; + } + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(candidate, constraint)) { + return getIntersectionType([type, candidate]); + } + } + return type; + }; } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); @@ -44469,7 +45304,7 @@ var ts; // that we don't have to worry about undefined // in the witness array. var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; }); - // The adjust clause start and end after removing the `default` statement. + // The adjusted clause start and end after removing the `default` statement. var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart; var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd; clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd); @@ -44479,6 +45314,9 @@ var ts; clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); } + if (hasDefaultClause) { + return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }); + } /* The implied type is the raw type suggested by a value being caught in this clause. @@ -44507,33 +45345,18 @@ var ts; boolean. We know that number cannot be selected because it is caught in the first clause. */ - if (!(hasDefaultClause || (type.flags & 262144 /* Union */))) { - var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return typeofTypesByName.get(text) || neverType; })), switchFacts); - if (impliedType.flags & 262144 /* Union */) { - impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOfType(type) || type); - } - if (!(impliedType.flags & 32768 /* Never */)) { - if (isTypeSubtypeOf(impliedType, type)) { - return impliedType; - } - if (type.flags & 15794176 /* Instantiable */) { - var constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(impliedType, constraint)) { - return getIntersectionType([type, impliedType]); - } - } - } + var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts); + if (impliedType.flags & 1048576 /* Union */) { + impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type)); } - return hasDefaultClause ? - filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }) : - getTypeWithFacts(type, switchFacts); + return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { - // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, left)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, an + // 'x instanceof T' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, left) && hasNarrowableDeclaredType(left)) { return declaredType; } return type; @@ -44570,9 +45393,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 & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 32768 /* Never */)) { + if (!(assignableType.flags & 131072 /* Never */)) { return assignableType; } } @@ -44612,7 +45435,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 190 /* ElementAccessExpression */ || invokedExpression.kind === 189 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -44629,20 +45452,20 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 200 /* PrefixUnaryExpression */: - if (expr.operator === 51 /* ExclamationToken */) { + case 202 /* PrefixUnaryExpression */: + if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -44656,7 +45479,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 === 71 /* Identifier */) { + if (location.kind === 72 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -44677,9 +45500,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 243 /* ModuleBlock */ || - node.kind === 277 /* SourceFile */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 245 /* ModuleBlock */ || + node.kind === 279 /* SourceFile */ || + node.kind === 154 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -44698,10 +45521,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 151 /* Parameter */) { symbol.isAssigned = true; } } @@ -44716,21 +45539,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 149 /* Parameter */ && + declaration.kind === 151 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 8192 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; + getFalsyFlags(declaredType) & 32768 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 187 /* PropertyAccessExpression */ || - parent.kind === 189 /* CallExpression */ && parent.expression === node || - parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 189 /* PropertyAccessExpression */ || + parent.kind === 191 /* CallExpression */ && parent.expression === node || + parent.kind === 190 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 186 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); + return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 98304 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -44761,7 +45584,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -44782,7 +45605,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 238 /* ClassDeclaration */ + if (declaration.kind === 240 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -44794,14 +45617,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 207 /* ClassExpression */) { + else if (declaration.kind === 209 /* 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 !== 277 /* SourceFile */) { + while (container.kind !== 279 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -44845,7 +45668,7 @@ 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 === 149 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 151 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -44854,8 +45677,8 @@ var ts; // 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 === 194 /* FunctionExpression */ || - flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 196 /* FunctionExpression */ || + flowContainer.kind === 197 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -44864,9 +45687,9 @@ var ts; // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || - node.parent.kind === 211 /* NonNullExpression */ || - declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 257 /* ExportSpecifier */) || + node.parent.kind === 213 /* NonNullExpression */ || + declaration.kind === 237 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -44875,7 +45698,7 @@ var ts; // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType || type === autoArrayType) { + if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) { if (flowType === autoType || flowType === autoArrayType) { if (noImplicitAny) { error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); @@ -44884,7 +45707,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* 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; @@ -44900,7 +45723,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -44923,7 +45746,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -44941,8 +45764,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 223 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && + if (container.kind === 225 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -44960,7 +45783,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 193 /* ParenthesizedExpression */) { + while (current.parent.kind === 195 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -44968,9 +45791,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 202 /* PrefixUnaryExpression */ || current.parent.kind === 203 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; + isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -44981,7 +45804,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { + if (container.kind === 154 /* PropertyDeclaration */ || container.kind === 157 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -45049,37 +45872,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 155 /* Constructor */) { + if (container.kind === 157 /* 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 === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* 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 241 /* EnumDeclaration */: + case 243 /* 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 155 /* Constructor */: + case 157 /* 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 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -45090,9 +45913,15 @@ var ts; var type = tryGetThisTypeAt(node, container); if (!type && noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' - error(node, capturedByArrowFunction && container.kind === 277 /* SourceFile */ ? + var diag = error(node, capturedByArrowFunction && container.kind === 279 /* SourceFile */ ? ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + if (!ts.isSourceFile(container)) { + var outsideThis = tryGetThisTypeAt(container); + if (outsideThis) { + addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + } + } } return type || anyType; } @@ -45118,7 +45947,7 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 194 /* FunctionExpression */ || container.kind === 237 /* FunctionDeclaration */) && + (container.kind === 196 /* FunctionExpression */ || container.kind === 239 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { var classType = getJSClassType(container.symbol); if (classType) { @@ -45144,7 +45973,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 194 /* FunctionExpression */ && + if (container.kind === 196 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -45154,24 +45983,49 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 154 /* MethodDeclaration */ && - container.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 156 /* MethodDeclaration */ && + container.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 194 /* FunctionExpression */ && - container.parent.kind === 273 /* PropertyAssignment */ && - container.parent.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 196 /* FunctionExpression */ && + container.parent.kind === 275 /* PropertyAssignment */ && + container.parent.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* 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 === 196 /* 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 */) { + return container.parent.parent.parent.arguments[0].expression; + } + // Object.defineProperty(x, "method", { value() { } }); + // Object.defineProperty(x, "method", { set(x: () => void) {} }); + // Object.defineProperty(x, "method", { get() { return () => {} } }); + else if (ts.isMethodDeclaration(container) && + ts.isIdentifier(container.name) && + (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") && + ts.isObjectLiteralExpression(container.parent) && + ts.isCallExpression(container.parent.parent) && + container.parent.parent.arguments[2] === container.parent && + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + return container.parent.parent.arguments[0].expression; + } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -45185,15 +46039,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 151 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 189 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 191 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 195 /* ArrowFunction */) { + while (container && container.kind === 197 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -45206,14 +46060,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); - if (current && current.kind === 147 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 149 /* ComputedPropertyName */; }); + if (current && current.kind === 149 /* 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 === 186 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -45221,7 +46075,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 155 /* Constructor */) { + if (!isCallExpression && container.kind === 157 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -45290,7 +46144,7 @@ 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 === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 156 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -45304,7 +46158,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (container.parent.kind === 188 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -45325,7 +46179,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 155 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 157 /* 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; @@ -45340,7 +46194,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 === 155 /* Constructor */; + return container.kind === 157 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -45348,21 +46202,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */; } else { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */ || - container.kind === 152 /* PropertyDeclaration */ || - container.kind === 151 /* PropertySignature */ || - container.kind === 155 /* Constructor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */ || + container.kind === 154 /* PropertyDeclaration */ || + container.kind === 153 /* PropertySignature */ || + container.kind === 157 /* Constructor */; } } } @@ -45370,10 +46224,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 154 /* MethodDeclaration */ || - func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 156 /* MethodDeclaration */ || + func.kind === 158 /* GetAccessor */ || + func.kind === 159 /* SetAccessor */) && func.parent.kind === 188 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 196 /* FunctionExpression */ && func.parent.kind === 275 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -45381,11 +46235,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -45412,7 +46266,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 273 /* PropertyAssignment */) { + if (literal.parent.kind !== 275 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -45426,9 +46280,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */) { var target = parent.left; - if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { + if (target.kind === 189 /* PropertyAccessExpression */ || target.kind === 190 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -45488,7 +46342,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -45500,7 +46354,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 184 /* BindingElement */) { + if (parentDeclaration.kind !== 186 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -45590,10 +46444,13 @@ var ts; // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); + if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { + return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 191 /* TaggedTemplateExpression */) { + if (template.parent.kind === 193 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -45602,7 +46459,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: if (node !== right) { return undefined; } @@ -45611,15 +46468,15 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); return !type && node === right && !ts.isDefaultedExpandoInitializer(binaryExpression) ? getTypeOfExpression(left) : type; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression) : undefined; default: return undefined; @@ -45686,13 +46543,17 @@ var ts; } var thisType = checkThisExpression(thisAccess.expression); return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - if (t.flags & 917504 /* StructuredType */) { + if (t.flags & 3670016 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -45703,8 +46564,8 @@ var ts; return restType; } } - return isNumericLiteralName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); + return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1 /* Number */) || + getIndexTypeOfContextualType(t, 0 /* String */); } return undefined; }, /*noReductions*/ true); @@ -45748,7 +46609,6 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || getIndexTypeOfContextualType(arrayContextualType, 1 /* Number */) || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -45790,35 +46650,36 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 71 /* Identifier */: - case 140 /* UndefinedKeyword */: + case 9 /* BigIntLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: + case 141 /* UndefinedKeyword */: return true; - case 187 /* PropertyAccessExpression */: - case 193 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 195 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 273 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 275 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 265 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 267 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (contextualType && contextualType.flags & 262144 /* Union */) { + if (contextualType && contextualType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, contextualType); } @@ -45855,54 +46716,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 186 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 195 /* ArrowFunction */: - case 228 /* ReturnStatement */: + case 197 /* ArrowFunction */: + case 230 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 185 /* ArrayLiteralExpression */: { + case 187 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 214 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); + case 216 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 206 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 193 /* ParenthesizedExpression */: { + case 195 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -45918,67 +46779,10 @@ var ts; // (as below) instead! return node.parent.contextualType; } - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - var valueType = checkExpression(node.tagName); - if (isTypeAny(valueType)) { - // Short-circuit if the class tag is using an element type 'any' - return anyType; - } - var isJs = ts.isInJSFile(node); - return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); + return getContextualTypeForArgumentAtIndex(node, 0); } - function getJsxSignaturesParameterTypes(valueType, isJs, context) { - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 4 /* String */) { - return anyType; - } - else if (valueType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = valueType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - } - return anyType; - } - // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(valueType, 1 /* Construct */); - var ctor = true; - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(valueType, 0 /* Call */); - ctor = false; - if (signatures.length === 0) { - // We found no signatures at all, which is an error - return errorType; - } - } - var links = getNodeLinks(context); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(valueType); - var cachedResolved = links.resolvedSignatures.get(cacheKey); - if (cachedResolved && cachedResolved !== resolvingSignaturesArray) { - signatures = cachedResolved; - } - else if (!cachedResolved) { - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); - links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures)); - } - return getUnionType(ts.map(signatures, ctor ? function (t) { return getJsxPropsTypeFromClassType(t, isJs, context, /*reportErrors*/ false); } : function (t) { return getJsxPropsTypeFromCallSignature(t, context); }), 0 /* None */); + function getEffectiveFirstArgumentForJsxSignature(signature, node) { + return getJsxReferenceKind(node) !== 0 /* Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); @@ -45993,22 +46797,40 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getStaticTypeOfReferencedJsxConstructor(context) { + if (isJsxIntrinsicIdentifier(context.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context); + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + var tagType = checkExpressionCached(context.tagName); + if (tagType.flags & 128 /* StringLiteral */) { + var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); + if (!result) { + return errorType; + } + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + return tagType; + } function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var ctorType = getStaticTypeOfReferencedJsxConstructor(context); if (ts.length(declaredManagedType.typeParameters) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); } } return attributesType; } - function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { + function getJsxPropsTypeFromClassType(sig, context) { var ns = getJsxNamespaceAt(context); var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined @@ -46021,7 +46843,7 @@ var ts; : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation); if (!attributesType) { // There is no property named 'props' on this instance type - if (reportErrors && !!forcedLookupLocation && !!ts.length(context.attributes.properties)) { + if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) { error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation)); } return emptyObjectType; @@ -46039,7 +46861,7 @@ var ts; var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams - ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isJs)) + ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context))) : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); @@ -46075,7 +46897,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; + return node.kind === 196 /* FunctionExpression */ || node.kind === 197 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -46094,7 +46916,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -46103,7 +46925,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -46142,8 +46964,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 184 /* BindingElement */ && !!node.initializer) || - (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 186 /* BindingElement */ && !!node.initializer) || + (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -46154,7 +46976,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 208 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -46179,12 +47001,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 208 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 208 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -46211,15 +47033,15 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 185 /* ArrayBindingPattern */ || pattern.kind === 187 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementCount; i < patternElements.length; i++) { var e = patternElements[i]; if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { - if (e.kind !== 208 /* OmittedExpression */) { + else if (i < patternElements.length - 1 || !(e.kind === 186 /* BindingElement */ && e.dotDotDotToken || e.kind === 208 /* SpreadElement */)) { + if (e.kind !== 210 /* OmittedExpression */) { error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -46237,12 +47059,12 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isNumericComputedName(name); - case 71 /* Identifier */: + case 72 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return isNumericLiteralName(name.text); default: return false; @@ -46251,7 +47073,7 @@ 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), 168 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -46286,8 +47108,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 24576 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -46314,10 +47136,10 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 33554432 /* FreshLiteral */; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 184 /* ObjectBindingPattern */ || contextualType.pattern.kind === 188 /* ObjectLiteralExpression */); var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -46330,13 +47152,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 149 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 273 /* PropertyAssignment */ || - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 275 /* PropertyAssignment */ || + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 275 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -46349,7 +47171,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -46360,8 +47182,8 @@ var ts; 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 === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 275 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 276 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -46386,12 +47208,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 275 /* SpreadAssignment */) { + else if (memberDecl.kind === 277 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); propertiesArray = []; propertiesTable = ts.createSymbolTable(); hasComputedStringProperty = false; @@ -46403,7 +47225,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 32768 /* FreshLiteral */); offset = i + 1; continue; } @@ -46413,10 +47235,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 === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 158 /* GetAccessor */ || memberDecl.kind === 159 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -46450,7 +47272,7 @@ var ts; } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); } return spread; } @@ -46459,9 +47281,8 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; - result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); - result.objectFlags |= 128 /* ObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags & 939524096 /* PropagatingFlags */; + result.objectFlags |= 128 /* ObjectLiteral */ | freshObjectLiteralFlag; if (isJSObjectLiteral) { result.objectFlags |= 16384 /* JSLiteral */; } @@ -46471,20 +47292,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 24576 /* Nullable */)) { - propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); - } + propagatedFlags |= result.flags & 939524096 /* PropagatingFlags */; return result; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || - getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 131072 /* Object */ && !isGenericMappedType(type) || - type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); + return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { - checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node); } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); @@ -46492,7 +47310,7 @@ var ts; } function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -46500,18 +47318,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } + checkJsxChildren(node); } function checkJsxElement(node, _checkMode) { checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxFragment(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment, checkMode); + function checkJsxFragment(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment); if (compilerOptions.jsx === 2 /* React */ && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) { error(node, compilerOptions.jsxFactory ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma); } + checkJsxChildren(node); return getJsxElementTypeAt(node) || anyType; } /** @@ -46525,7 +47345,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 === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 72 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -46544,18 +47364,19 @@ var ts; function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createSymbolTable(); - var spread = emptyObjectType; + var spread = emptyJsxObjectType; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var propagatingFlags = 0; + var typeFlags = 0; + var objectFlags = 4096 /* 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); - propagatingFlags |= (exprType.flags & 939524096 /* PropagatingFlags */); + typeFlags |= exprType.flags & 939524096 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | 33554432 /* Transient */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -46570,9 +47391,9 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 269 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); attributesTable = ts.createSymbolTable(); } var exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -46580,7 +47401,7 @@ var ts; hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, openingLikeElement.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, exprType, attributes.symbol, typeFlags, objectFlags); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -46589,11 +47410,11 @@ var ts; } if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 260 /* 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); @@ -46613,25 +47434,26 @@ var ts; (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, /*hasRestElement*/ false) || createArrayType(getUnionType(childrenTypes))); var childPropMap = ts.createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); - spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, typeFlags, objectFlags); } } if (hasSpreadAnyType) { return anyType; } - if (typeToIntersect && spread !== emptyObjectType) { + if (typeToIntersect && spread !== emptyJsxObjectType) { return getIntersectionType([typeToIntersect, spread]); } - return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); + return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread); /** * Create anonymous type from given attributes symbol table. * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable * @param attributesTable a symbol table of attributes property */ function createJsxAttributesType() { + objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= (propagatingFlags |= 268435456 /* ContainsObjectLiteral */); - result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + result.objectFlags |= 128 /* ObjectLiteral */ | objectFlags; return result; } } @@ -46641,7 +47463,7 @@ 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 === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { if (!child.containsOnlyWhiteSpaces) { childrenTypes.push(stringType); } @@ -46704,57 +47526,6 @@ var ts; } return links.resolvedSymbol; } - function instantiateJsxSignatures(node, signatures) { - var instantiatedSignatures = []; - var candidateForTypeArgumentError; - var hasTypeArgumentError = !!node.typeArguments; - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; - if (signature.typeParameters) { - var isJavascript = ts.isInJSFile(node); - var typeArgumentInstantiated = getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, /*reportErrors*/ false); - if (typeArgumentInstantiated) { - hasTypeArgumentError = false; - instantiatedSignatures.push(typeArgumentInstantiated); - } - else { - if (node.typeArguments && hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - candidateForTypeArgumentError = signature; - } - var inferenceContext = createInferenceContext(signature.typeParameters, signature, /*flags*/ isJavascript ? 2 /* AnyDefault */ : 0 /* None */); - var typeArguments = inferJsxTypeArguments(signature, node, inferenceContext); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); - } - } - else { - instantiatedSignatures.push(signature); - } - } - if (node.typeArguments && hasTypeArgumentError) { - if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true); - } - // Length check to avoid issuing an arity error on length=0, the "Type argument list cannot be empty" grammar error alone is fine - else if (node.typeArguments.length !== 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, node.typeArguments)); - } - } - return instantiatedSignatures; - } - function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { - if (reportErrors === void 0) { reportErrors = false; } - if (!node.typeArguments) { - return; - } - if (!hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - return; - } - var args = checkTypeArguments(signature, node.typeArguments, reportErrors); - if (!args) { - return; - } - return getSignatureInstantiation(signature, args, isJavascript); - } function getJsxNamespaceAt(location) { var links = location && getNodeLinks(location); if (links && links.jsxNamespace) { @@ -46825,217 +47596,63 @@ var ts; function getJsxElementChildrenPropertyName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } - function getApparentTypeOfJsxPropsType(propsType) { - if (!propsType) { - return undefined; - } - if (propsType.flags & 524288 /* Intersection */) { - var propsApparentType = []; - for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { - var t = _a[_i]; - propsApparentType.push(getApparentType(t)); - } - return getIntersectionType(propsApparentType); - } - return getApparentType(propsType); - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return only attributes type of successfully resolved call signature. - * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) - * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. - var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined, /*isForSignatureHelp*/ false); - if (callSignature !== unknownSignature) { - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } - } - } - return undefined; - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return all attributes type of resolved call signature including candidate signatures. - * This function assumes that the caller handled other possible element type of the JSX element. - * This function is a behavior used by language service when looking up completion in JSX element. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. - var candidatesOutArray = []; - getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, /*isForSignatureHelp*/ false); - var result = void 0; - var allMatchingAttributesType = void 0; - for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { - var candidate = candidatesOutArray_1[_i]; - var callReturnType = getReturnTypeOfSignature(candidate); - // TODO: GH#18217: callReturnType should always be defined... - var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - var shouldBeCandidate = true; - for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { - var attribute = _b[_a]; - if (ts.isJsxAttribute(attribute) && - isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 - shouldBeCandidate = false; - break; - } - } - if (shouldBeCandidate) { - result = intersectTypes(result, paramType); - } - allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); - } - } - // If we can't find any matching, just return everything. - if (!result) { - result = allMatchingAttributesType; - } - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - result = intersectTypes(intrinsicAttributes, result); - } - return result; - } - } - return undefined; - } - function getInstantiatedJsxSignatures(openingLikeElement, elementType, reportErrors) { - var links = getNodeLinks(openingLikeElement); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(elementType); - if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) === resolvingSignaturesArray) { - return; - } - else if (links.resolvedSignatures.get(cacheKey)) { - return links.resolvedSignatures.get(cacheKey); - } - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + function getUninstantiatedJsxSignaturesOfType(elementType) { // Resolve the signatures, preferring constructor var signatures = getSignaturesOfType(elementType, 1 /* Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures signatures = getSignaturesOfType(elementType, 0 /* Call */); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - if (reportErrors) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(openingLikeElement.tagName)); - } + } + if (signatures.length === 0 && elementType.flags & 1048576 /* Union */) { + // If each member has some combination of new/call signatures; make a union signature list for those + signatures = getUnionSignatures(ts.map(elementType.types, getUninstantiatedJsxSignaturesOfType)); + } + return signatures; + } + function getIntrinsicAttributesTypeFromStringLiteralType(type, location) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location); + if (intrinsicElementsType !== errorType) { + var stringLiteralTypeName = type.value; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + return indexSignatureType; + } + return undefined; + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } + function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { + if (refKind === 1 /* Function */) { + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + if (sfcReturnConstraint) { + checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else if (refKind === 0 /* Component */) { + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (classConstraint) { + // Issue an error if this return type isn't assignable to JSX.ElementClass or JSX.Element, failing that + checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else { // Mixed + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (!sfcReturnConstraint || !classConstraint) { return; } + var combined = getUnionType([sfcReturnConstraint, classConstraint]); + checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } - // Instantiate in context of source type - var results = instantiateJsxSignatures(openingLikeElement, signatures); - links.resolvedSignatures.set(cacheKey, results); - return results; - } - /** - * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. - * For instance: - * declare function Foo(attr: { p1: string}): JSX.Element; - * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" - * - * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. - * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component - * - * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement - * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature - * @param sourceAttributesType Is the attributes type the user passed, and is used to create inferences in the target type if present - * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) - * @return attributes type if able to resolve the type of node - * anyType if there is no type ElementAttributesProperty or there is an error - * emptyObjectType if there is no "prop" in the element instance type - */ - function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 262144 /* Union */) { - var types = elementType.types; - return getUnionType(types.map(function (type) { - return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); - }), 2 /* Subtype */); - } - // Shortcircuit any - if (isTypeAny(elementType)) { - return elementType; - } - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 4 /* String */) { - return anyType; - } - else if (elementType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = elementType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); - } - // If we need to report an error, we already done so here. So just return any to prevent any more error downstream - return anyType; - } - // Get the element instance type (the result of newing or invoking this tag) - var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); - if (!ts.length(instantiatedSignatures)) { - return errorType; - } - var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); - // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. - // Otherwise get only attributes type from the signature picked by choose-overload logic. - var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? - tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : - defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); - if (statelessAttributesType) { - return statelessAttributesType; - } - // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elementClassType) { - checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - var isJs = ts.isInJSFile(openingLikeElement); - return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -47059,53 +47676,6 @@ var ts; } return links.resolvedJsxElementAttributesType; } - /** - * Get attributes type of the given custom opening-like JSX element. - * This function is intended to be called from a caller that handles intrinsic JSX element already. - * @param node a custom JSX opening-like element - * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component - */ - function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { - return resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, checkExpression(node.tagName), getJsxElementClassTypeAt(node)); - } - /** - * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. - * This function is called by language service (see: completions-tryGetGlobalSymbols). - * @param node a JSX opening-like element to get attributes type for - */ - function getAllAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - // Because in language service, the given JSX opening-like element may be incomplete and therefore, - // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); - } - } - /** - * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. - * @param node a JSXOpeningLikeElement node - * @return an attributes type of the given node - */ - function getAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); - } - } - /** - * Given a JSX attribute, returns the symbol for the corresponds property - * of the element attributes type. Will return unknownSymbol for attributes - * that have no matching element attributes type property. - */ - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); - var prop = getPropertyOfType(attributesType, attrib.name.escapedText); - return prop || unknownSymbol; - } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); if (type === errorType) @@ -47139,7 +47709,7 @@ var ts; } } } - function checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode) { + function checkJsxOpeningLikeElementOrOpeningFragment(node) { var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node); if (isNodeOpeningLikeElement) { checkGrammarJsxElement(node); @@ -47161,10 +47731,8 @@ var ts; } } if (isNodeOpeningLikeElement) { - checkJsxAttributesAssignableToTagNameAttributes(node, checkMode); - } - else { - checkJsxChildren(node.parent); + var sig = getResolvedSignature(node); + checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(node), getReturnTypeOfSignature(sig), node); } } /** @@ -47181,7 +47749,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 131072 /* Object */) { + if (targetType.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -47191,7 +47759,7 @@ var ts; return true; } } - else if (targetType.flags & 786432 /* UnionOrIntersection */) { + else if (targetType.flags & 3145728 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -47199,55 +47767,12 @@ var ts; } } } - else if (targetType.flags & 4194304 /* Conditional */) { + else if (targetType.flags & 16777216 /* Conditional */) { return isKnownProperty(targetType.root.trueType, name, isComparingJsxAttributes) || isKnownProperty(targetType.root.falseType, name, isComparingJsxAttributes); } return false; } - /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ - function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement, checkMode) { - // The function involves following steps: - // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. - // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) - // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. - // 3. Check if the two are assignable to each other - // targetAttributesType is a type of an attribute from resolving tagName of an opening-like JSX element. - var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? - getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : - getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); - // sourceAttributesType is a type of an attributes properties. - // i.e
- // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); - // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties - var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); - // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. - // This will allow excess properties in spread type as it is very common pattern to spread outer attributes into React component in its render method. - if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { - for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { - var attribute = _a[_i]; - if (!ts.isJsxAttribute(attribute)) { - continue; - } - var attrName = attribute.name; - var isNotIgnoredJsxProperty = (isUnhyphenatedJsxName(ts.idText(attrName)) || !!(getPropertyOfType(targetAttributesType, attrName.escapedText))); - if (isNotIgnoredJsxProperty && !isKnownProperty(targetAttributesType, attrName.escapedText, /*isComparingJsxAttributes*/ true)) { - error(attribute, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(attrName), typeToString(targetAttributesType)); - // We break here so that errors won't be cascading - break; - } - } - } - else if (!isSourceAttributeTypeAssignableToTarget) { - checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); - } - } function checkJsxExpression(node, checkMode) { if (node.expression) { var type = checkExpression(node.expression, checkMode); @@ -47287,7 +47812,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 146 /* QualifiedName */ ? node.right : node.kind === 181 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 148 /* QualifiedName */ ? node.right : node.kind === 183 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -47359,13 +47884,13 @@ var ts; return false; } var thisType = getTypeFromTypeNode(thisParameter.type); - enclosingClass = ((thisType.flags & 65536 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); + enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); } // No further restrictions for static properties if (flags & 32 /* Static */) { return true; } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -47385,19 +47910,26 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function getNonNullableTypeIfNeeded(type) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + if (kind) { + return getNonNullableType(type); + } + return type; + } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? + error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; + return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } @@ -47430,7 +47962,7 @@ var ts; return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } return errorType; } @@ -47441,9 +47973,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 100 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 97 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 98 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); @@ -47455,9 +47987,9 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 187 /* PropertyAccessExpression */ || + if (node.kind !== 189 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -47465,11 +47997,11 @@ 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 && left.kind === 99 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && left.kind === 100 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 157 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -47481,7 +48013,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { error(right, 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; @@ -47500,8 +48032,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && - node.parent.kind !== 162 /* TypeReference */ && + else if (valueDeclaration.kind === 240 /* ClassDeclaration */ && + node.parent.kind !== 164 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -47513,9 +48045,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -47553,7 +48085,7 @@ var ts; function reportNonexistentProperty(propNode, containingType) { var errorInfo; var relatedInfo; - if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { + if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -47662,16 +48194,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 97 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 98 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 148 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 181 /* ImportType */: + case 183 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind !== 181 /* ImportType */ && node.expression.kind === 97 /* SuperKeyword */, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind !== 183 /* ImportType */ && node.expression.kind === 98 /* SuperKeyword */, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -47698,20 +48230,20 @@ var ts; var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, isSuper, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJSFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); + : ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer.kind === 238 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 71 /* Identifier */) { + else if (initializer.kind === 72 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -47728,13 +48260,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 71 /* Identifier */) { + if (e.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 224 /* ForInStatement */ && + if (node.kind === 226 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -47752,7 +48284,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 190 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 192 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -47768,7 +48300,7 @@ var ts; if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -47783,7 +48315,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -47810,8 +48342,7 @@ var ts; return true; } function callLikeExpressionMayHaveTypeArguments(node) { - // TODO: Also include tagged templates (https://github.com/Microsoft/TypeScript/issues/11947) - return ts.isCallOrNewExpression(node); + return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); } function resolveUntypedCall(node) { if (callLikeExpressionMayHaveTypeArguments(node)) { @@ -47819,10 +48350,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 150 /* Decorator */) { + else if (ts.isJsxOpeningLikeElement(node)) { + checkExpression(node.attributes); + } + else if (node.kind !== 152 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -47849,8 +48383,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var signature = signatures_4[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -47886,22 +48420,23 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 208 /* SpreadElement */ || arg.kind === 215 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } + function acceptsVoid(t) { + return !!(t.flags & 16384 /* Void */); + } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } - if (ts.isJsxOpeningLikeElement(node)) { - // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". - return true; - } var argCount; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 191 /* TaggedTemplateExpression */) { + var effectiveParameterCount = getParameterCount(signature); + var effectiveMinimumArguments = getMinArgumentCount(signature); + if (node.kind === 193 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 204 /* TemplateExpression */) { + if (node.template.kind === 206 /* 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. @@ -47912,17 +48447,26 @@ 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 === 13 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 150 /* Decorator */) { + else if (node.kind === 152 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } + else if (ts.isJsxOpeningLikeElement(node)) { + callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + argCount = effectiveMinimumArguments === 0 ? args.length : 1; + effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1; // class may have argumentless ctor functions - still resolve ctor and compare vs props member type + effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1); // sfc may specify context argument - handled by framework and not typechecked + } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 190 /* NewExpression */); + ts.Debug.assert(node.kind === 192 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -47935,12 +48479,21 @@ var ts; } } // Too many arguments implies incorrect arity. - if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { + if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= getMinArgumentCount(signature); - return callIsIncomplete || hasEnoughArguments; + // JSX signatures can have extra parameters provided by the library which we don't check + if (callIsIncomplete || argCount >= effectiveMinimumArguments) { + return true; + } + for (var i = argCount; i < effectiveMinimumArguments; i++) { + var type = getTypeAtPosition(signature, i); + if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + return false; + } + } + return true; } function hasCorrectTypeArgumentArity(signature, typeArguments) { // If the user supplied type arguments, but the number of type arguments does not match @@ -47952,7 +48505,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -47974,14 +48527,9 @@ var ts; } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); } - function inferJsxTypeArguments(signature, node, context) { - // Skip context sensitive pass - var skipContextParamType = getTypeAtPosition(signature, 0); - var checkAttrTypeSkipContextSensitive = checkExpressionWithContextualType(node.attributes, skipContextParamType, identityMapper); - inferTypes(context.inferences, checkAttrTypeSkipContextSensitive, skipContextParamType); - // Standard pass - var paramType = getTypeAtPosition(signature, 0); - var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context); + function inferJsxTypeArguments(node, signature, excludeArgument, context) { + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] !== undefined ? identityMapper : context); inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } @@ -47997,11 +48545,14 @@ var ts; inference.inferredType = undefined; } } + if (ts.isJsxOpeningLikeElement(node)) { + return inferJsxTypeArguments(node, signature, excludeArgument, context); + } // If a contextual type is available, infer from that type to the return type of the call expression. For // example, given a 'function wrap(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 !== 150 /* Decorator */) { + if (node.kind !== 152 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -48034,7 +48585,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards @@ -48050,7 +48601,7 @@ var ts; return getInferredTypes(context); } function getArrayifiedType(type) { - if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 15794176 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { + if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 63176704 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { return createArrayType(getIndexTypeOfType(type, 1 /* Number */) || errorType); } return type; @@ -48061,13 +48612,13 @@ 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 arg.kind === 213 /* SyntheticExpression */ ? + return arg.kind === 215 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context)); } } var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */); var types = []; var spreadIndex = -1; for (var i = index; i < argCount; i++) { @@ -48103,6 +48654,19 @@ var ts; } return typeArgumentTypes; } + function getJsxReferenceKind(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return 2 /* Mixed */; + } + var tagType = getApparentType(checkExpression(node.tagName)); + if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { + return 0 /* Component */; + } + if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { + return 1 /* Function */; + } + return 2 /* Mixed */; + } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. * @param node a JSX opening-like element we are trying to figure its call signature @@ -48110,37 +48674,20 @@ var ts; * @param relation a relationship to check parameter and argument type * @param excludeArgument */ - function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { - // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: - // 1. callIsIncomplete - // 2. attributes property has same number of properties as the parameter object type. - // We can figure that out by resolving attributes property and check number of properties in the resolved type - // If the call has correct arity, we will then check if the argument type and parameter type is assignable - var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete - if (callIsIncomplete) { - return true; - } - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors) { // Stateless function components can have maximum of three arguments: "props", "context", and "updater". // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, // can be specified by users through attributes property. - var paramType = getTypeAtPosition(signature, 0); - var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); - var argProperties = getPropertiesOfType(attributesType); - for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { - var arg = argProperties_1[_i]; - if (!getPropertyOfType(paramType, arg.escapedName) && isUnhyphenatedJsxName(arg.escapedName)) { - return false; - } - } - return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] ? identityMapper : undefined); + return checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes); } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { if (ts.isJsxOpeningLikeElement(node)) { - return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 190 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 192 /* 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. @@ -48157,7 +48704,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), @@ -48180,15 +48727,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { + if (callee.kind === 189 /* PropertyAccessExpression */ || callee.kind === 190 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(213 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(215 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -48198,21 +48745,21 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - if (node.kind === 150 /* Decorator */) { + if (node.kind === 152 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { - return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; + return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray; } var args = node.arguments || ts.emptyArray; var length = args.length; @@ -48238,30 +48785,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 149 /* Parameter */: + case 151 /* 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 === 155 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 157 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 !== 152 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 154 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -48275,17 +48822,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 1; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return 2; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 149 /* Parameter */: + case 151 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -48298,8 +48845,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -48343,8 +48890,8 @@ var ts; function getTypeArgumentArityError(node, signatures, typeArguments) { var min = Infinity; var max = -Infinity; - for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { - var sig = signatures_6[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); max = Math.max(max, ts.length(sig.typeParameters)); } @@ -48352,14 +48899,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp, fallbackError) { - var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 150 /* Decorator */; + var isTaggedTemplate = node.kind === 193 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 152 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); + 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 !== 97 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 98 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -48367,7 +48915,9 @@ var ts; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + if (reportErrors) { + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + } return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -48412,7 +48962,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 = isForSignatureHelp && node.kind === 189 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = isForSignatureHelp && node.kind === 191 /* 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 @@ -48436,34 +48986,32 @@ var ts; // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. - if (candidateForArgumentError) { - if (isJsxOpeningOrSelfClosingElement) { - // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". - return candidateForArgumentError; + if (reportErrors) { + if (candidateForArgumentError) { + // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] + // The importance of excludeArgument is to prevent us from typing function expression parameters + // in arguments too early. If possible, we'd like to only type them once we know the correct + // overload. However, this matters for the case where the call is correct. When the call is + // an error, we don't need to exclude any arguments, although it would cause no harm to do so. + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } - // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] - // The importance of excludeArgument is to prevent us from typing function expression parameters - // in arguments too early. If possible, we'd like to only type them once we know the correct - // overload. However, this matters for the case where the call is correct. When the call is - // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); - } - else if (candidateForArgumentArityError) { - diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); - } - else if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); - } - else { - var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); - if (signaturesWithCorrectTypeArgumentArity.length === 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + else if (candidateForArgumentArityError) { + diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); } - else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + else if (candidateForTypeArgumentError) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); } - else if (fallbackError) { - diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + else { + var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); + if (signaturesWithCorrectTypeArgumentArity.length === 0) { + diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + } + else if (!isDecorator) { + diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + } + else if (fallbackError) { + diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + } } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); @@ -48666,7 +49214,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, isForSignatureHelp) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -48721,7 +49269,7 @@ var ts; } else { var relatedInformation = void 0; - if (node.arguments.length === 1 && isTypeAssertion(ts.first(node.arguments))) { + if (node.arguments.length === 1) { var text = ts.getSourceFileOfNode(node).text; if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); @@ -48745,8 +49293,8 @@ 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 & 65536 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 262144 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 /* Union */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, isForSignatureHelp) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -48824,7 +49372,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 524288 /* Intersection */) { + if (firstBase.flags & 2097152 /* Intersection */) { var types = firstBase.types; var mixinCount = ts.countWhere(types, isMixinConstructorType); var i = 0; @@ -48924,16 +49472,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -48969,6 +49517,58 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp, 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, 67897832 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(120 /* AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + parameterSymbol.type = result; + return createSignature(declaration, + /*typeParameters*/ undefined, + /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, + /*returnTypePredicate*/ undefined, 1, + /*hasRestparameter*/ false, + /*hasLiteralTypes*/ false); + } + function resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + var fakeSignature = createSignatureForJSXIntrinsic(node, result); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), result, node.tagName, node.attributes); + return fakeSignature; + } + var exprTypes = checkExpression(node.tagName); + var apparentType = getApparentType(exprTypes); + if (apparentType === errorType) { + return resolveErrorCall(node); + } + if (exprTypes.flags & 128 /* StringLiteral */) { + var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(exprTypes, node); + if (!intrinsicType) { + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, exprTypes.value, "JSX." + JsxNames.IntrinsicElements); + return resolveUntypedCall(node); + } + else { + var fakeSignature = createSignatureForJSXIntrinsic(node, intrinsicType); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), intrinsicType, node.tagName, node.attributes); + return fakeSignature; + } + } + var signatures = getUninstantiatedJsxSignaturesOfType(apparentType); + if (exprTypes.flags & 4 /* String */ || isUntypedFunctionCall(exprTypes, apparentType, signatures.length, /*constructSignatures*/ 0)) { + return resolveUntypedCall(node); + } + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return resolveErrorCall(node); + } + return resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp); + } /** * Sometimes, we have a decorator that could accept zero arguments, * but is receiving too many arguments as part of the decorator invocation. @@ -48981,49 +49581,19 @@ var ts; signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } - /** - * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. - * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName - * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) - * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. - * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function - * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. - * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; - * the function will fill it up with appropriate candidate signatures - */ - function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, isForSignatureHelp) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); - if (callSignatures && callSignatures.length > 0) { - return resolveCall(openingLikeElement, callSignatures, candidatesOutArray, isForSignatureHelp); - } - return undefined; - } function resolveSignature(node, candidatesOutArray, isForSignatureHelp) { switch (node.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, isForSignatureHelp); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, isForSignatureHelp); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, isForSignatureHelp); - case 150 /* Decorator */: + case 152 /* Decorator */: return resolveDecorator(node, candidatesOutArray, isForSignatureHelp); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - // This code-path is called by language service - var exprTypes = checkExpression(node.tagName); - return forEachType(exprTypes, function (exprType) { - var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray, isForSignatureHelp); - if (sfcResult && sfcResult !== unknownSignature) { - return sfcResult; - } - var sigs = getInstantiatedJsxSignatures(node, exprType); - if (candidatesOutArray && ts.length(sigs)) { - candidatesOutArray.push.apply(candidatesOutArray, sigs); - } - return ts.length(sigs) ? sigs[0] : unknownSignature; - }) || unknownSignature; + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + return resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -49075,7 +49645,7 @@ var ts; return false; } function isJSConstructorType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); } @@ -49110,10 +49680,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 187 /* PropertyAccessExpression */) { + while (parent && parent.kind === 189 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 59 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -49139,15 +49709,15 @@ var ts; if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return voidType; } - if (node.kind === 190 /* NewExpression */) { + if (node.kind === 192 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 155 /* Constructor */ && - declaration.kind !== 159 /* ConstructSignature */ && - declaration.kind !== 164 /* ConstructorType */ && + declaration.kind !== 157 /* Constructor */ && + declaration.kind !== 161 /* ConstructSignature */ && + declaration.kind !== 166 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -49155,7 +49725,7 @@ var ts; // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. var funcSymbol = checkExpression(node.expression).symbol; - if (!funcSymbol && node.expression.kind === 71 /* Identifier */) { + if (!funcSymbol && node.expression.kind === 72 /* Identifier */) { funcSymbol = getResolvedSymbol(node.expression); } var type = funcSymbol && getJSClassType(funcSymbol); @@ -49175,7 +49745,7 @@ 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 & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } var jsAssignmentType; @@ -49221,7 +49791,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -49274,9 +49844,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 237 /* FunctionDeclaration */ + ? 239 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 235 /* VariableDeclaration */ + ? 237 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -49312,10 +49882,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 94 /* NewKeyword */) { + if (node.keywordToken === 95 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 91 /* ImportKeyword */) { + if (node.keywordToken === 92 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -49326,7 +49896,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 === 155 /* Constructor */) { + else if (container.kind === 157 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -49497,7 +50067,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71 /* Identifier */) { + if (element.name.kind === 72 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -49511,7 +50081,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* Identifier */) { // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType) { links.type = getTypeFromBindingPattern(decl.name); @@ -49561,7 +50131,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 216 /* Block */) { + if (func.body.kind !== 218 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -49671,7 +50241,7 @@ var ts; 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]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -49681,7 +50251,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -49689,7 +50259,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]) || 64 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -49703,14 +50273,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 197 /* TypeOfExpression */) { + if (node.expression.kind === 199 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // 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_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 32768 /* Never */); + return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -49726,7 +50296,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 232 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -49748,7 +50318,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, 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 & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -49769,11 +50339,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 154 /* MethodDeclaration */: - return func.parent.kind === 186 /* ObjectLiteralExpression */; + case 156 /* MethodDeclaration */: + return func.parent.kind === 188 /* ObjectLiteralExpression */; default: return false; } @@ -49792,16 +50362,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 4096 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 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 === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 155 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 218 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 32768 /* Never */) { + if (returnType && returnType.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -49830,7 +50400,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -49850,7 +50420,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 196 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -49895,7 +50465,7 @@ var ts; getAwaitedType(type) || errorType : type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -49911,7 +50481,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 216 /* Block */) { + if (node.body.kind === 218 /* Block */) { checkSourceElement(node.body); } else { @@ -49934,34 +50504,66 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { + if (!isTypeAssignableTo(type, numberOrBigIntType)) { error(operand, diagnostic); return false; } return true; } + function isReadonlyAssignmentDeclaration(d) { + if (!ts.isCallExpression(d)) { + return false; + } + if (!ts.isBindableObjectDefinePropertyCall(d)) { + return false; + } + var objectLitType = checkExpressionCached(d.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + var writableProp = getPropertyOfType(objectLitType, "writable"); + var writableType = writableProp && getTypeOfSymbol(writableProp); + if (!writableType || writableType === falseType || writableType === regularFalseType) { + return true; + } + // We include this definition whereupon we walk back and check the type at the declaration because + // The usual definition of `Object.defineProperty` will _not_ cause literal types to be preserved in the + // argument types, should the type be contextualized by the call itself. + if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) { + var initializer = writableProp.valueDeclaration.initializer; + var rawOriginalType = checkExpression(initializer); + if (rawOriginalType === falseType || rawOriginalType === regularFalseType) { + return true; + } + } + return false; + } + var setProp = getPropertyOfType(objectLitType, "set"); + return !setProp; + } function isReadonlySymbol(symbol) { // The following symbols are considered read-only: // Properties with a 'readonly' modifier // Variables declared with 'const' // Get accessors without matching set accessors // 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 */); + symbol.flags & 8 /* EnumMember */ || + ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && - expr.expression.kind === 99 /* ThisKeyword */) { + (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) && + expr.expression.kind === 100 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 155 /* Constructor */)) { + if (!(func && func.kind === 157 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -49974,13 +50576,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 249 /* NamespaceImport */; + return !!declaration && declaration.kind === 251 /* NamespaceImport */; } } } @@ -49989,7 +50591,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 72 /* Identifier */ && node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -49998,7 +50600,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -50035,37 +50637,52 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operand.kind === 8 /* NumericLiteral */) { - if (node.operator === 38 /* MinusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - } - else if (node.operator === 37 /* PlusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); - } + switch (node.operand.kind) { + case 8 /* NumericLiteral */: + switch (node.operator) { + case 39 /* MinusToken */: + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + case 38 /* PlusToken */: + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } + break; + case 9 /* BigIntLiteral */: + if (node.operator === 39 /* MinusToken */) { + return getFreshTypeOfLiteralType(getLiteralType({ + negative: true, + base10Value: ts.parsePseudoBigInt(node.operand.text) + })); + } } switch (node.operator) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - return numberType; - case 51 /* ExclamationToken */: + if (node.operator === 38 /* PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + } + return numberType; + } + return getUnaryResultType(operandType); + case 52 /* ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); - return facts === 1048576 /* Truthy */ ? falseType : - facts === 2097152 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); + return facts === 4194304 /* Truthy */ ? falseType : + facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + case 44 /* PlusPlusToken */: + case 45 /* 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } - return numberType; + return getUnaryResultType(operandType); } return errorType; } @@ -50074,11 +50691,20 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } + return getUnaryResultType(operandType); + } + function getUnaryResultType(operandType) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + ? numberOrBigIntType + : bigintType; + } + // If it's not a bigint type, implicit coercion will result in a number return numberType; } // Return true if type might be of the given kind. A union or intersection type might be of a given @@ -50087,7 +50713,7 @@ var ts; if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -50102,21 +50728,22 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { return false; } - return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 132 /* 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); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 262144 /* Union */ ? + return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } @@ -50136,7 +50763,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, 32764 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* 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 @@ -50155,10 +50782,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -50168,8 +50795,8 @@ var ts; if (strictNullChecks && properties.length === 0) { return checkNonNullType(sourceType, node); } - for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { - var p = properties_7[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var p = properties_6[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis); } return sourceType; @@ -50177,9 +50804,9 @@ var ts; /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) { if (rightIsThis === void 0) { rightIsThis = false; } - if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */ || property.kind === 276 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -50188,13 +50815,13 @@ var ts; var type = getTypeOfObjectLiteralDestructuringProperty(objectLiteralType, name, property, rightIsThis); if (type) { // non-shorthand property assignments should always have initializers - return checkDestructuringAssignment(property.kind === 274 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 276 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } else { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 275 /* SpreadAssignment */) { + else if (property.kind === 277 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -50246,8 +50873,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 208 /* OmittedExpression */) { - if (element.kind !== 206 /* SpreadElement */) { + if (element.kind !== 210 /* OmittedExpression */) { + if (element.kind !== 208 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType : everyType(sourceType, isTupleLikeType) ? getTupleElementType(sourceType, elementIndex) : @@ -50271,7 +50898,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 204 /* BinaryExpression */ && restExpression.operatorToken.kind === 59 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -50288,14 +50915,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 276 /* 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)) & 8192 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -50304,21 +50931,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 204 /* BinaryExpression */ && target.operatorToken.kind === 59 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 186 /* ObjectLiteralExpression */) { + if (target.kind === 188 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 185 /* ArrayLiteralExpression */) { + if (target.kind === 187 /* 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 === 275 /* SpreadAssignment */ ? + var error = target.parent.kind === 277 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -50337,58 +50964,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 191 /* TaggedTemplateExpression */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 193 /* TaggedTemplateExpression */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 140 /* UndefinedKeyword */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 197 /* TypeOfExpression */: - case 211 /* NonNullExpression */: - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 141 /* UndefinedKeyword */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 199 /* TypeOfExpression */: + case 213 /* NonNullExpression */: + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: return true; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 51 /* ExclamationToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 52 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 198 /* VoidExpression */: // Explicit opt-out - case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 200 /* VoidExpression */: // Explicit opt-out + case 194 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 212 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { @@ -50398,11 +51026,11 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 99 /* ThisKeyword */); + if (operator === 59 /* EqualsToken */ && (left.kind === 188 /* ObjectLiteralExpression */ || left.kind === 187 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 100 /* ThisKeyword */); } var leftType; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -50410,28 +51038,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 39 /* AsteriskToken */: - case 40 /* AsteriskAsteriskToken */: - case 61 /* AsteriskEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 42 /* PercentToken */: - case 64 /* PercentEqualsToken */: - case 38 /* MinusToken */: - case 60 /* MinusEqualsToken */: - case 45 /* LessThanLessThanToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: + case 40 /* AsteriskToken */: + case 41 /* AsteriskAsteriskToken */: + case 62 /* AsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 43 /* PercentToken */: + case 65 /* PercentEqualsToken */: + case 39 /* MinusToken */: + case 61 /* MinusEqualsToken */: + case 46 /* LessThanLessThanToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -50440,36 +51068,61 @@ 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 & 272 /* BooleanLike */) && - (rightType.flags & 272 /* BooleanLike */) && + if ((leftType.flags & 528 /* BooleanLike */) && + (rightType.flags & 528 /* 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; } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + 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 */)) || + // Or, if neither could be bigint, implicit coercion results in a number result + !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + resultType_1 = numberType; } + // At least one is assignable to bigint, so both should be only assignable to bigint + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + switch (operator) { + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + reportOperatorError(); + } + resultType_1 = bigintType; + } + else { + reportOperatorError(); + resultType_1 = errorType; + } + if (leftOk && rightOk) { + checkAssignmentOperator(resultType_1); + } + return resultType_1; } - return numberType; - case 37 /* PlusToken */: - case 59 /* PlusEqualsToken */: + case 38 /* PlusToken */: + case 60 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 132 /* StringLike */) && !isTypeAssignableToKind(rightType, 132 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* 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, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* 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, 132 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 132 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -50486,26 +51139,27 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 59 /* PlusEqualsToken */) { + if (operator === 60 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); - if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { + if (!(isTypeComparableTo(leftType, rightType) || isTypeComparableTo(rightType, leftType) || + (isTypeAssignableTo(leftType, numberOrBigIntType) && isTypeAssignableTo(rightType, numberOrBigIntType)))) { reportOperatorError(); } } return booleanType; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -50516,19 +51170,19 @@ var ts; reportOperatorError(); } return booleanType; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 53 /* AmpersandAmpersandToken */: - return getTypeFacts(leftType) & 1048576 /* Truthy */ ? + case 54 /* AmpersandAmpersandToken */: + return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 54 /* BarBarToken */: - return getTypeFacts(leftType) & 2097152 /* Falsy */ ? + case 55 /* BarBarToken */: + return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, right); if (isAssignmentDeclaration(declKind)) { @@ -50538,7 +51192,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 26 /* CommaToken */: + case 27 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -50564,12 +51218,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 72 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 12288 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -50579,15 +51233,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - return 54 /* BarBarToken */; - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - return 35 /* ExclamationEqualsEqualsToken */; - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: - return 53 /* AmpersandAmpersandToken */; + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + return 55 /* BarBarToken */; + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + return 36 /* ExclamationEqualsEqualsToken */; + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: + return 54 /* AmpersandAmpersandToken */; default: return undefined; } @@ -50634,11 +51288,11 @@ var ts; } function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { switch (operatorToken.kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); } return undefined; @@ -50716,14 +51370,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } }); return stringType; } function getContextNode(node) { - if (node.kind === 266 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 268 /* 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; @@ -50759,7 +51413,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; + return node.kind === 194 /* TypeAssertionExpression */ || node.kind === 212 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -50768,7 +51422,7 @@ var ts; ts.isDeclarationReadonly(declaration) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 24576 /* Nullable */) { + if (widened.flags & 98304 /* Nullable */) { reportImplicitAny(declaration, anyType); return anyType; } @@ -50781,26 +51435,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 786432 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* 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) || emptyObjectType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || + 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 */) || 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 & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || - contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */) && 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 false; } @@ -50816,7 +51472,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -50827,7 +51483,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -50858,14 +51514,14 @@ var ts; var 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 (expr.kind === 189 /* CallExpression */ && expr.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 191 /* CallExpression */ && expr.expression.kind !== 98 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - else if (expr.kind === 192 /* TypeAssertionExpression */ || expr.kind === 210 /* AsExpression */) { + else if (expr.kind === 194 /* TypeAssertionExpression */ || expr.kind === 212 /* AsExpression */) { return getTypeFromTypeNode(expr.type); } // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions @@ -50900,7 +51556,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode, forceTuple) { var type; - if (node.kind === 146 /* QualifiedName */) { + if (node.kind === 148 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -50912,10 +51568,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 167 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } @@ -50931,94 +51587,97 @@ var ts; } function checkExpressionWorker(node, checkMode, forceTuple) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return checkIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return checkThisExpression(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkSuperExpression(node); - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullWideningType; - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101 /* TrueKeyword */: + case 9 /* BigIntLiteral */: + checkGrammarBigIntLiteral(node); + return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); + case 102 /* TrueKeyword */: return trueType; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: return falseType; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return checkTemplateExpression(node); - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 189 /* CallExpression */: - if (node.expression.kind === 91 /* ImportKeyword */) { + case 191 /* CallExpression */: + if (node.expression.kind === 92 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 190 /* NewExpression */: + case 192 /* NewExpression */: return checkCallExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return checkClassExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return checkAssertion(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return checkNonNullAssertion(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return checkMetaProperty(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkDeleteExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return checkVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return checkAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return undefinedWideningType; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return checkYieldExpression(node); - case 213 /* SyntheticExpression */: + case 215 /* SyntheticExpression */: return node.type; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return checkJsxElement(node, checkMode); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 262 /* JsxFragment */: - return checkJsxFragment(node, checkMode); - case 266 /* JsxAttributes */: + case 264 /* JsxFragment */: + return checkJsxFragment(node); + case 268 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -51056,7 +51715,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 157 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -51067,10 +51726,10 @@ 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 === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { + if (func.kind === 157 /* Constructor */ || func.kind === 161 /* ConstructSignature */ || func.kind === 166 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -51125,13 +51784,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 195 /* ArrowFunction */: - case 158 /* CallSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 163 /* FunctionType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 197 /* ArrowFunction */: + case 160 /* CallSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 165 /* FunctionType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -51145,11 +51804,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 71 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 72 /* 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 === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { + else if (name.kind === 185 /* ArrayBindingPattern */ || name.kind === 184 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -51158,13 +51817,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* 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 === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || - node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || - node.kind === 159 /* ConstructSignature */) { + else if (node.kind === 165 /* FunctionType */ || node.kind === 239 /* FunctionDeclaration */ || node.kind === 166 /* ConstructorType */ || + node.kind === 160 /* CallSignature */ || node.kind === 157 /* Constructor */ || + node.kind === 161 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -51194,10 +51853,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -51227,7 +51886,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -51244,7 +51903,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 155 /* Constructor */) { + if (member.kind === 157 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -51259,16 +51918,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: addName(names, name, memberName, 1 /* Getter */); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: addName(names, name, memberName, 2 /* Setter */); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* Property */); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: addName(names, name, memberName, 4 /* Method */); break; } @@ -51331,15 +51990,15 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* PropertySignature */) { + if (member.kind === 153 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: memberName = name.text; break; - case 71 /* Identifier */: + case 72 /* Identifier */: memberName = ts.idText(name); break; default: @@ -51356,7 +52015,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* 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 @@ -51376,7 +52035,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -51384,7 +52043,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -51411,7 +52070,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 156 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -51436,7 +52095,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 152 /* PropertyDeclaration */ && + return n.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -51466,7 +52125,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -51491,7 +52150,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -51501,13 +52160,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -51525,7 +52184,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -51573,7 +52232,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 164 /* 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); } var type = getTypeFromTypeReference(node); @@ -51621,7 +52280,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 170 /* RestType */) { + if (e.kind === 172 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -51630,7 +52289,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 169 /* OptionalType */) { + else if (e.kind === 171 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -51645,14 +52304,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 2097152 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* 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 === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 190 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -51660,7 +52319,7 @@ 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. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -51692,7 +52351,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 175 /* 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); @@ -51709,9 +52368,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 239 /* InterfaceDeclaration */ && - n.parent.kind !== 238 /* ClassDeclaration */ && - n.parent.kind !== 207 /* ClassExpression */ && + if (n.parent.kind !== 241 /* InterfaceDeclaration */ && + n.parent.kind !== 240 /* ClassDeclaration */ && + n.parent.kind !== 209 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* 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 @@ -51802,7 +52461,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && + var reportError = (node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -51841,7 +52500,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 241 /* InterfaceDeclaration */ || node.parent.kind === 168 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -51852,7 +52511,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 239 /* FunctionDeclaration */ || node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */ || node.kind === 157 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -51904,8 +52563,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_7 = signatures; _a < signatures_7.length; _a++) { - var signature = signatures_7[_a]; + for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { + var signature = signatures_6[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -51981,22 +52640,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -52004,17 +52663,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: var result_4 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_4 |= getDeclarationSpaces(d); }); return result_4; - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 237 /* FunctionDeclaration */: - case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 239 /* FunctionDeclaration */: + case 253 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -52061,7 +52720,7 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } @@ -52092,7 +52751,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -52243,7 +52902,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 71 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 72 /* 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 { @@ -52282,24 +52941,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 149 /* Parameter */: + case 151 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -52320,7 +52979,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 71 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 72 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -52345,50 +53004,55 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 172 /* IntersectionType */: - case 171 /* UnionType */: - var commonEntityName = void 0; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { - typeNode = typeNode.type; // Skip parens if need be - } - if (typeNode.kind === 131 /* NeverKeyword */) { - continue; // Always elide `never` from the union/intersection if possible - } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* 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); - if (!individualEntityName) { - // Individual is something like string number - // So it would be serialized to either that type or object - // Safe to return here - return undefined; - } - if (commonEntityName) { - // Note this is in sync with the transformation that happens for type node. - // Keep this in sync with serializeUnionOrIntersectionType - // Verify if they refer to same entity and is identifier - // return undefined if they dont match because we would emit object - if (!ts.isIdentifier(commonEntityName) || - !ts.isIdentifier(individualEntityName) || - commonEntityName.escapedText !== individualEntityName.escapedText) { - return undefined; - } - } - else { - commonEntityName = individualEntityName; - } - } - return commonEntityName; - case 175 /* ParenthesizedType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return getEntityNameForDecoratorMetadataFromTypeList(node.types); + case 175 /* ConditionalType */: + return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + case 177 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; } } } + function getEntityNameForDecoratorMetadataFromTypeList(types) { + var commonEntityName; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { + typeNode = typeNode.type; // Skip parens if need be + } + if (typeNode.kind === 132 /* NeverKeyword */) { + continue; // Always elide `never` from the union/intersection if possible + } + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); + if (!individualEntityName) { + // Individual is something like string number + // So it would be serialized to either that type or object + // Safe to return here + return undefined; + } + if (commonEntityName) { + // Note this is in sync with the transformation that happens for type node. + // Keep this in sync with serializeUnionOrIntersectionType + // Verify if they refer to same entity and is identifier + // return undefined if they dont match because we would emit object + if (!ts.isIdentifier(commonEntityName) || + !ts.isIdentifier(individualEntityName) || + commonEntityName.escapedText !== individualEntityName.escapedText) { + return undefined; + } + } + else { + commonEntityName = individualEntityName; + } + } + return commonEntityName; + } function getParameterTypeNodeForDecoratorCheck(node) { var typeNode = ts.getEffectiveTypeAnnotationNode(node); return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode; @@ -52408,14 +53072,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -52424,23 +53088,23 @@ var ts; } } break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 154 /* MethodDeclaration */: + case 156 /* 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 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 149 /* Parameter */: + case 151 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -52493,16 +53157,22 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } } } } + function checkJSDocFunctionType(node) { + if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) { + reportImplicitAny(node, anyType); + } + checkSignatureDeclaration(node); + } function checkJSDocAugmentsTag(node) { var classLike = ts.getJSDocHost(node); if (!ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { @@ -52525,9 +53195,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -52540,7 +53210,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 === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -52569,7 +53239,7 @@ var ts; } } } - var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 155 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); @@ -52614,42 +53284,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 277 /* SourceFile */: - case 242 /* ModuleDeclaration */: - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 279 /* SourceFile */: + case 244 /* ModuleDeclaration */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 240 /* TypeAliasDeclaration */: - case 174 /* InferType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 242 /* TypeAliasDeclaration */: + case 176 /* InferType */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -52670,11 +53340,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 154 /* MethodDeclaration */: - case 152 /* PropertyDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 156 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + if (member.kind === 159 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -52683,7 +53353,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -52691,8 +53361,8 @@ var ts; } } break; - case 160 /* IndexSignature */: - case 215 /* SemicolonClassElement */: + case 162 /* IndexSignature */: + case 217 /* SemicolonClassElement */: // Can't be private break; default: @@ -52704,9 +53374,9 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (node.flags & 4194304 /* Ambient */ || node.kind !== 174 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) + if (node.flags & 4194304 /* Ambient */ || node.kind !== 176 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) return; - if (node.kind === 174 /* InferType */) { + if (node.kind === 176 /* InferType */) { 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))); @@ -52721,7 +53391,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 174 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 176 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -52807,7 +53477,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 251 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -52825,7 +53495,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 237 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 238 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -52846,7 +53516,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -52858,24 +53528,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; + return node.kind === 250 /* ImportClause */ || node.kind === 253 /* ImportSpecifier */ || node.kind === 251 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 250 /* ImportClause */ ? decl : decl.kind === 251 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 216 /* Block */) { + if (node.kind === 218 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -52905,12 +53575,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 152 /* PropertyDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 154 /* MethodDeclaration */ || - node.kind === 153 /* MethodSignature */ || - node.kind === 156 /* GetAccessor */ || - node.kind === 157 /* SetAccessor */) { + if (node.kind === 154 /* PropertyDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 156 /* MethodDeclaration */ || + node.kind === 155 /* MethodSignature */ || + node.kind === 158 /* GetAccessor */ || + node.kind === 159 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -52919,7 +53589,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 151 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -52929,7 +53599,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 71 /* Identifier */; + var isDeclaration_1 = node.kind !== 72 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -52944,7 +53614,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 71 /* Identifier */; + var isDeclaration_2 = node.kind !== 72 /* 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); } @@ -52970,7 +53640,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -52985,7 +53655,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -53020,7 +53690,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 237 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -53032,17 +53702,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 217 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 238 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 219 /* 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 === 216 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 243 /* ModuleBlock */ || - container.kind === 242 /* ModuleDeclaration */ || - container.kind === 277 /* SourceFile */); + (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 245 /* ModuleBlock */ || + container.kind === 244 /* ModuleDeclaration */ || + container.kind === 279 /* 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 @@ -53057,7 +53727,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 151 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -53068,11 +53738,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 187 /* PropertyAccessExpression */) { + if (n.kind === 189 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 71 /* Identifier */) { + else if (n.kind === 72 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.escapedText, 67220415 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -53087,8 +53757,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 184 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 151 /* Parameter */ || + symbol.valueDeclaration.kind === 186 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -53102,7 +53772,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 152 /* PropertyDeclaration */ && + (current.parent.kind === 154 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -53135,18 +53805,18 @@ 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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 184 /* BindingElement */) { - if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 186 /* BindingElement */) { + if (node.parent.kind === 184 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -53159,27 +53829,27 @@ var ts; var property = getPropertyOfType(parentType, nameText); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { - checkPropertyAccessibility(parent, parent.initializer.kind === 97 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, parent.initializer.kind === 98 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 185 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 151 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 226 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -53202,11 +53872,16 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 226 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } + if (symbol.declarations.length > 1) { + if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); + } + } } else { // Node is a secondary declaration, check that type is identical to primary declaration and check that @@ -53221,14 +53896,13 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { - error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { + if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -53237,14 +53911,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* PropertySignature */ + var message = nextDeclaration.kind === 154 /* PropertyDeclaration */ || nextDeclaration.kind === 153 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || - (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 151 /* Parameter */ && right.kind === 237 /* VariableDeclaration */) || + (left.kind === 237 /* VariableDeclaration */ && right.kind === 151 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -53283,7 +53957,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 218 /* EmptyStatement */) { + if (node.thenStatement.kind === 220 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -53302,7 +53976,7 @@ var ts; } function checkTruthinessExpression(node, checkMode) { var type = checkExpression(node, checkMode); - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -53310,12 +53984,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 238 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -53349,14 +54023,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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. @@ -53382,13 +54056,13 @@ var ts; function checkForInStatement(node) { // Grammar checking checkGrammarForInOrForOfStatement(node); - var rightType = checkNonNullExpression(node.expression); + var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); // TypeScript 1.0 spec (April 2014): 5.4 // In a 'for-in' statement of the form // 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 === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* 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); @@ -53402,7 +54076,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 === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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)) { @@ -53415,7 +54089,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, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* 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); @@ -53470,16 +54144,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 262144 /* Union */) { + if (arrayType.flags & 1048576 /* 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 & 68 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 68 /* StringLike */) { + else if (arrayType.flags & 132 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -53492,7 +54166,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 & 32768 /* Never */) { + if (arrayType.flags & 131072 /* Never */) { return stringType; } } @@ -53523,7 +54197,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 68 /* StringLike */) { + if (arrayElementType.flags & 132 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -53737,7 +54411,7 @@ var ts; var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -53753,7 +54427,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -53762,12 +54436,12 @@ var ts; // for generators. return; } - else if (func.kind === 157 /* SetAccessor */) { + else if (func.kind === 159 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 155 /* Constructor */) { + else if (func.kind === 157 /* 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); } @@ -53788,7 +54462,7 @@ var ts; } } } - else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 157 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -53817,7 +54491,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 === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 272 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -53829,7 +54503,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 271 /* 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. @@ -53858,7 +54532,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 233 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -53965,8 +54639,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 202 /* BinaryExpression */ || - name.kind === 147 /* ComputedPropertyName */ || + (propDeclaration.kind === 204 /* BinaryExpression */ || + name.kind === 149 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -53995,6 +54669,7 @@ var ts; case "any": case "unknown": case "number": + case "bigint": case "boolean": case "string": case "symbol": @@ -54174,10 +54849,10 @@ var ts; // 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 & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 8650752 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { + 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. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -54272,7 +54947,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; + return d.kind === 240 /* ClassDeclaration */ || d.kind === 241 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -54311,7 +54986,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 207 /* ClassExpression */) { + if (derivedClassDecl.kind === 209 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -54361,8 +55036,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { - var prop = properties_8[_a]; + for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { + var prop = properties_7[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -54393,7 +55068,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* 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)); } @@ -54403,7 +55078,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 152 /* PropertyDeclaration */ && + return node.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -54414,7 +55089,7 @@ var ts; reference.parent = constructor; reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 8192 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -54427,7 +55102,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -54532,60 +55207,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 37 /* PlusToken */: return value_2; - case 38 /* MinusToken */: return -value_2; - case 52 /* TildeToken */: return ~value_2; + case 38 /* PlusToken */: return value_2; + case 39 /* MinusToken */: return -value_2; + case 53 /* TildeToken */: return ~value_2; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 49 /* BarToken */: return left | right; - case 48 /* AmpersandToken */: return left & right; - case 46 /* GreaterThanGreaterThanToken */: return left >> right; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 45 /* LessThanLessThanToken */: return left << right; - case 50 /* CaretToken */: return left ^ right; - case 39 /* AsteriskToken */: return left * right; - case 41 /* SlashToken */: return left / right; - case 37 /* PlusToken */: return left + right; - case 38 /* MinusToken */: return left - right; - case 42 /* PercentToken */: return left % right; - case 40 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 50 /* BarToken */: return left | right; + case 49 /* AmpersandToken */: return left & right; + case 47 /* GreaterThanGreaterThanToken */: return left >> right; + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 46 /* LessThanLessThanToken */: return left << right; + case 51 /* CaretToken */: return left ^ right; + case 40 /* AsteriskToken */: return left * right; + case 42 /* SlashToken */: return left / right; + case 38 /* PlusToken */: return left + right; + case 39 /* MinusToken */: return left - right; + case 43 /* PercentToken */: return left % right; + case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 37 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { return left + right; } break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 71 /* Identifier */: + case 72 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 187 /* PropertyAccessExpression */) { + if (ex.kind === 189 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -54616,10 +55291,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 71 /* Identifier */ || - node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 9 /* StringLiteral */; + return node.kind === 72 /* Identifier */ || + node.kind === 189 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 190 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -54656,7 +55331,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 !== 241 /* EnumDeclaration */) { + if (declaration.kind !== 243 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -54679,8 +55354,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 238 /* ClassDeclaration */ || - (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 240 /* ClassDeclaration */ || + (declaration.kind === 239 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -54717,7 +55392,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 9 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -54743,7 +55418,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 240 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -54793,23 +55468,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -54820,12 +55495,12 @@ var ts; break; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 237 /* FunctionDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -54838,7 +55513,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -54846,17 +55521,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; } } @@ -54870,9 +55545,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 253 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -54905,14 +55580,14 @@ var ts; (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 255 /* ExportSpecifier */ ? + var message = node.kind === 257 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 255 /* ExportSpecifier */ + && node.kind === 257 /* ExportSpecifier */ && !(target.flags & 67220415 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -54939,7 +55614,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -54963,7 +55638,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 259 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67220415 /* Value */) { @@ -54999,10 +55674,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -55019,7 +55694,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -55048,8 +55723,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 === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -55062,7 +55737,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { markExportAsReferenced(node); if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); @@ -55137,7 +55812,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 239 /* FunctionDeclaration */ && declaration.kind !== 156 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -55155,158 +55830,158 @@ 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return checkTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return checkParameter(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return checkPropertyDeclaration(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return checkSignatureDeclaration(node); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return checkMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return checkConstructorDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return checkAccessorDeclaration(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return checkTypeReferenceNode(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return checkTypePredicate(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return checkTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return checkTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return checkArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return checkTupleType(node); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 175 /* ParenthesizedType */: - case 169 /* OptionalType */: - case 170 /* RestType */: + case 177 /* ParenthesizedType */: + case 171 /* OptionalType */: + case 172 /* RestType */: return checkSourceElement(node.type); - case 176 /* ThisType */: + case 178 /* ThisType */: return checkThisType(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return checkTypeOperator(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return checkConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return checkInferType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return checkImportType(node); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 287 /* JSDocFunctionType */: - checkSignatureDeclaration(node); + case 289 /* JSDocFunctionType */: + checkJSDocFunctionType(node); // falls through - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: - case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: + case 292 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 281 /* JSDocTypeExpression */: + case 283 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return checkMappedType(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return checkBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return checkVariableStatement(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return checkExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return checkIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return checkDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return checkWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return checkForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return checkForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkForOfStatement(node); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return checkReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return checkSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return checkThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return checkTryStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return checkBindingElement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return checkClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return checkImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return checkExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return checkExportAssignment(node); - case 218 /* EmptyStatement */: - case 234 /* DebuggerStatement */: + case 220 /* EmptyStatement */: + case 236 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -55397,23 +56072,23 @@ var ts; } links.deferredNodes.forEach(function (node) { switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 258 /* JsxElement */: + case 260 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -55450,6 +56125,7 @@ var ts; ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); ts.forEach(node.statements, checkSourceElement); + checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); if (ts.isExternalOrCommonJsModule(node)) { registerForUnusedIdentifiersCheck(node); @@ -55542,13 +56218,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) + break; + // falls through + case 244 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -55556,8 +56236,8 @@ var ts; // falls through // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* 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. @@ -55566,7 +56246,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -55608,17 +56288,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 71 /* Identifier */ && + return name.kind === 72 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 148 /* TypeParameter */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 150 /* TypeParameter */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -55626,16 +56306,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 162 /* TypeReference */; + return node.parent.kind === 164 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 187 /* PropertyAccessExpression */) { + while (node.parent.kind === 189 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 209 /* ExpressionWithTypeArguments */; + return node.parent.kind === 211 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -55663,13 +56343,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 148 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 248 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 254 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -55695,7 +56375,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 183 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -55705,7 +56385,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 187 /* PropertyAccessExpression */ && + entityName.parent.kind === 189 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -55713,7 +56393,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 254 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -55723,7 +56403,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 248 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -55741,7 +56421,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 211 /* ExpressionWithTypeArguments */) { meaning = 67897832 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -55757,10 +56437,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 297 /* JSDocParameterTag */) { + if (entityName.parent.kind === 299 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 301 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -55770,19 +56450,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 71 /* Identifier */) { + if (entityName.kind === 72 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 189 /* PropertyAccessExpression */ || entityName.kind === 148 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 187 /* PropertyAccessExpression */) { + if (entityName.kind === 189 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -55792,20 +56472,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 164 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 265 /* JsxAttribute */) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 161 /* TypePredicate */) { + if (entityName.parent.kind === 163 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -55821,12 +56498,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 184 /* BindingElement */ && - grandParent.kind === 182 /* ObjectBindingPattern */ && + else if (parent.kind === 186 /* BindingElement */ && + grandParent.kind === 184 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -55836,11 +56513,11 @@ var ts; } } switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -55852,29 +56529,32 @@ var ts; return checkExpression(node).symbol; } // falls through - case 176 /* ThisType */: + case 178 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkExpression(node).symbol; - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 157 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: + case 14 /* 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 === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 249 /* ImportDeclaration */ || node.parent.kind === 255 /* 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); } + if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) { + return getSymbolOfNode(parent); + } // falls through case 8 /* NumericLiteral */: // index access @@ -55884,19 +56564,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 79 /* DefaultKeyword */: - case 89 /* FunctionKeyword */: - case 36 /* EqualsGreaterThanToken */: - case 75 /* ClassKeyword */: + case 80 /* DefaultKeyword */: + case 90 /* FunctionKeyword */: + case 37 /* EqualsGreaterThanToken */: + case 76 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; + case 85 /* ExportKeyword */: + return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 276 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -55964,28 +56646,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 188 /* ObjectLiteralExpression */ || expr.kind === 187 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 225 /* ForOfStatement */) { + if (expr.parent.kind === 227 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 202 /* BinaryExpression */) { + if (expr.parent.kind === 204 /* 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 === 273 /* PropertyAssignment */) { + if (expr.parent.kind === 275 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 187 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -56021,14 +56703,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return getLiteralType(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: ts.Debug.fail("Unsupported property name."); return errorType; @@ -56083,7 +56765,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -56139,7 +56821,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* 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. @@ -56194,7 +56876,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 218 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -56235,18 +56917,18 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return node.expression - && node.expression.kind === 71 /* Identifier */ + && node.expression.kind === 72 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -56254,7 +56936,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -56281,7 +56963,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -56354,15 +57037,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 276 /* EnumMember */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 278 /* EnumMember */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 276 /* EnumMember */) { + if (node.kind === 278 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -56376,7 +57059,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. @@ -56413,22 +57096,25 @@ var ts; else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + return ts.TypeReferenceSerializationKind.BigIntLikeType; + } + else if (isTypeAssignableToKind(type, 132 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -56444,14 +57130,14 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* 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 */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 2048 /* UniqueESSymbol */ && + if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -56463,7 +57149,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56471,7 +57157,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56509,19 +57195,18 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } - function literalTypeToNode(type, enclosing) { - var enumResult = type.flags & 512 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing) + function literalTypeToNode(type, enclosing, tracker) { + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } - function createLiteralConstValue(node) { + function createLiteralConstValue(node, tracker) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return literalTypeToNode(type, node); + return literalTypeToNode(type, node, tracker); } function createResolver() { // this variable and functions that use it are deliberately moved here from the outer scope @@ -56594,12 +57279,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* SetAccessor */; + var otherKind = accessor.kind === 159 /* SetAccessor */ ? 158 /* GetAccessor */ : 159 /* 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 === 157 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 159 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 158 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -56615,7 +57300,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; + return node.parent && node.parent.kind === 211 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 273 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -56627,7 +57312,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 72 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 189 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -56678,7 +57363,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -56693,12 +57378,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 244 /* 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, 277 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -56876,14 +57561,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 154 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 156 /* 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 === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */) { + else if (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* 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); @@ -56900,23 +57585,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { + if (modifier.kind !== 133 /* ReadonlyKeyword */) { + if (node.kind === 153 /* PropertySignature */ || node.kind === 155 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 76 /* ConstKeyword */: - if (node.kind !== 241 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); + case 77 /* ConstKeyword */: + if (node.kind !== 243 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(77 /* ConstKeyword */)); } break; - case 114 /* PublicKeyword */: - case 113 /* ProtectedKeyword */: - case 112 /* PrivateKeyword */: + case 115 /* PublicKeyword */: + case 114 /* ProtectedKeyword */: + case 113 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -56930,11 +57615,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* 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 === 112 /* PrivateKeyword */) { + if (modifier.kind === 113 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -56943,7 +57628,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -56953,10 +57638,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -56965,18 +57650,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 132 /* ReadonlyKeyword */: + case 133 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { + else if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */ && node.kind !== 162 /* IndexSignature */ && node.kind !== 151 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -56989,52 +57674,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 79 /* DefaultKeyword */: - var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 80 /* DefaultKeyword */: + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 124 /* DeclareKeyword */: + case 125 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 245 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 117 /* AbstractKeyword */: + case 118 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 238 /* ClassDeclaration */) { - if (node.kind !== 154 /* MethodDeclaration */ && - node.kind !== 152 /* PropertyDeclaration */ && - node.kind !== 156 /* GetAccessor */ && - node.kind !== 157 /* SetAccessor */) { + if (node.kind !== 240 /* ClassDeclaration */) { + if (node.kind !== 156 /* MethodDeclaration */ && + node.kind !== 154 /* PropertyDeclaration */ && + node.kind !== 158 /* GetAccessor */ && + node.kind !== 159 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 240 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -57046,14 +57731,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -57061,7 +57746,7 @@ var ts; break; } } - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -57076,13 +57761,13 @@ var ts; } return false; } - else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 249 /* ImportDeclaration */ || node.kind === 248 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -57103,38 +57788,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 242 /* ModuleDeclaration */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 149 /* Parameter */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 244 /* ModuleDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 151 /* Parameter */: return false; default: - if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return false; } switch (node.kind) { - case 237 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 238 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 239 /* InterfaceDeclaration */: - case 217 /* VariableStatement */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AsyncKeyword */); + case 240 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 118 /* AbstractKeyword */); + case 241 /* InterfaceDeclaration */: + case 219 /* VariableStatement */: + case 242 /* TypeAliasDeclaration */: return true; - case 241 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); + case 243 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 77 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -57146,10 +57831,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -57267,12 +57952,12 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { + if (parameter.type.kind !== 138 /* StringKeyword */ && parameter.type.kind !== 135 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(getTypeFromTypeNode(node.type))); } - if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -57303,7 +57988,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 208 /* OmittedExpression */) { + if (arg.kind === 210 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -57333,7 +58018,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 === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -57346,7 +58031,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -57362,14 +58047,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -57380,20 +58065,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 147 /* ComputedPropertyName */) { + if (node.kind !== 149 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 204 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 237 /* FunctionDeclaration */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 154 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 239 /* FunctionDeclaration */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 156 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -57419,15 +58104,15 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */) { + if (prop.kind === 277 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 274 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 276 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -57436,7 +58121,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { + if (mod.kind !== 121 /* AsyncKeyword */ || prop.kind !== 156 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -57451,23 +58136,23 @@ 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 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); /* tslint:disable:no-switch-case-fall-through */ - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: @@ -57504,7 +58189,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 267 /* JsxSpreadAttribute */) { + if (attr.kind === 269 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -57514,7 +58199,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 270 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -57523,12 +58208,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 227 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 238 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -57543,20 +58228,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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); @@ -57583,11 +58268,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 158 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 157 /* SetAccessor */) { + else if (kind === 159 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -57611,23 +58296,23 @@ 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 === 156 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 141 /* UniqueKeyword */) { - if (node.type.kind !== 138 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(138 /* SymbolKeyword */)); + if (node.operator === 142 /* UniqueKeyword */) { + if (node.type.kind !== 139 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(139 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* 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)) { @@ -57637,13 +58322,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { 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 151 /* PropertySignature */: + case 153 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* 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); } @@ -57662,10 +58347,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 156 /* MethodDeclaration */) { + if (node.parent.kind === 188 /* 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 === 120 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 121 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -57691,14 +58376,14 @@ var ts; if (node.flags & 4194304 /* 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 === 154 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 156 /* 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 === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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 === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* 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); } } @@ -57709,11 +58394,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 231 /* LabeledStatement */: + case 233 /* 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 === 226 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 228 /* 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); @@ -57721,8 +58406,8 @@ var ts; return false; } break; - case 230 /* SwitchStatement */: - if (node.kind === 227 /* BreakStatement */ && !node.label) { + case 232 /* SwitchStatement */: + if (node.kind === 229 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -57737,13 +58422,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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 === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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); @@ -57766,34 +58451,43 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } + function isBigIntLiteralExpression(expr) { + return expr.kind === 9 /* BigIntLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.operand.kind === 9 /* BigIntLiteral */; + } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) - return !!(checkExpressionCached(expr).flags & 512 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); } function checkAmbientInitializer(node) { - if (node.initializer) { - var isInvalidInitializer = !(isStringOrNumberLiteralExpression(node.initializer) || isSimpleLiteralEnumReference(node.initializer) || node.initializer.kind === 101 /* TrueKeyword */ || node.initializer.kind === 86 /* FalseKeyword */); + var initializer = node.initializer; + if (initializer) { + var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || + isSimpleLiteralEnumReference(initializer) || + initializer.kind === 102 /* TrueKeyword */ || initializer.kind === 87 /* FalseKeyword */ || + isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { if (isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); + return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); } } else { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { + if (node.parent.parent.kind !== 226 /* ForInStatement */ && node.parent.parent.kind !== 227 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -57806,7 +58500,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 219 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -57823,7 +58517,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -57840,8 +58534,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 71 /* Identifier */) { - if (name.originalKeywordKind === 110 /* LetKeyword */) { + if (name.kind === 72 /* Identifier */) { + if (name.originalKeywordKind === 111 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -57868,15 +58562,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return false; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -57894,12 +58588,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 94 /* NewKeyword */: + case 95 /* 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 91 /* ImportKeyword */: + case 92 /* 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"); } @@ -57954,7 +58648,7 @@ var ts; return true; } } - else if (node.parent.kind === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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; } @@ -57962,7 +58656,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -57991,13 +58685,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 240 /* TypeAliasDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 253 /* ExportDeclaration */ || - node.kind === 252 /* ExportAssignment */ || - node.kind === 245 /* NamespaceExportDeclaration */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 242 /* TypeAliasDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 255 /* ExportDeclaration */ || + node.kind === 254 /* ExportAssignment */ || + node.kind === 247 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -58006,7 +58700,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 === 217 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 219 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -58033,7 +58727,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 === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -58055,20 +58749,32 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 182 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 278 /* 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 === 38 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } return false; } + function checkGrammarBigIntLiteral(node) { + var literalType = ts.isLiteralTypeNode(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); + if (!literalType) { + if (languageVersion < 6 /* ESNext */) { + if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ESNext)) { + return true; + } + } + } + return false; + } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -58113,8 +58819,8 @@ var ts; /** 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 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -58122,14 +58828,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 248 /* ImportClause */: // For default import - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: // For rename import `x as y` + case 250 /* ImportClause */: // For default import + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: // For rename import `x as y` return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 251 /* ImportSpecifier */; + return decl.parent.kind === 253 /* ImportSpecifier */; default: return false; } @@ -58149,7 +58855,7 @@ var ts; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function typeIsLiteralType(type) { - return !!(type.flags & 448 /* Literal */); + return !!(type.flags & 2944 /* Literal */); } })(ts || (ts = {})); var ts; @@ -58213,6 +58919,9 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt + return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); + } if (typeof value === "boolean") { return value ? createTrue() : createFalse(); } @@ -58232,14 +58941,20 @@ var ts; return node; } ts.createNumericLiteral = createNumericLiteral; + function createBigIntLiteral(value) { + var node = createSynthesizedNode(9 /* BigIntLiteral */); + node.text = value; + return node; + } + ts.createBigIntLiteral = createBigIntLiteral; function createStringLiteral(text) { - var node = createSynthesizedNode(9 /* StringLiteral */); + var node = createSynthesizedNode(10 /* StringLiteral */); node.text = text; return node; } ts.createStringLiteral = createStringLiteral; function createRegularExpressionLiteral(text) { - var node = createSynthesizedNode(12 /* RegularExpressionLiteral */); + var node = createSynthesizedNode(13 /* RegularExpressionLiteral */); node.text = text; return node; } @@ -58250,7 +58965,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(71 /* Identifier */); + var node = createSynthesizedNode(72 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -58331,23 +59046,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(97 /* SuperKeyword */); + return createSynthesizedNode(98 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(99 /* ThisKeyword */); + return createSynthesizedNode(100 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(95 /* NullKeyword */); + return createSynthesizedNode(96 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(101 /* TrueKeyword */); + return createSynthesizedNode(102 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(86 /* FalseKeyword */); + return createSynthesizedNode(87 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -58358,44 +59073,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(84 /* ExportKeyword */)); + result.push(createModifier(85 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(124 /* DeclareKeyword */)); + result.push(createModifier(125 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(79 /* DefaultKeyword */)); + result.push(createModifier(80 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(76 /* ConstKeyword */)); + result.push(createModifier(77 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(114 /* PublicKeyword */)); + result.push(createModifier(115 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(112 /* PrivateKeyword */)); + result.push(createModifier(113 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(113 /* ProtectedKeyword */)); + result.push(createModifier(114 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(117 /* AbstractKeyword */)); + result.push(createModifier(118 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(115 /* StaticKeyword */)); + result.push(createModifier(116 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(132 /* ReadonlyKeyword */)); + result.push(createModifier(133 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(120 /* AsyncKeyword */)); + result.push(createModifier(121 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(146 /* QualifiedName */); + var node = createSynthesizedNode(148 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -58414,7 +59129,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(147 /* ComputedPropertyName */); + var node = createSynthesizedNode(149 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -58427,7 +59142,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(148 /* TypeParameter */); + var node = createSynthesizedNode(150 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -58443,7 +59158,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(149 /* Parameter */); + var node = createSynthesizedNode(151 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -58467,7 +59182,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(150 /* Decorator */); + var node = createSynthesizedNode(152 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -58480,7 +59195,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertySignature */); + var node = createSynthesizedNode(153 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -58500,12 +59215,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(152 /* PropertyDeclaration */); + var node = createSynthesizedNode(154 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -58515,8 +59230,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -58524,7 +59239,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(155 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -58541,7 +59256,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(154 /* MethodDeclaration */); + var node = createSynthesizedNode(156 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -58569,7 +59284,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(155 /* Constructor */); + var node = createSynthesizedNode(157 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -58589,7 +59304,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(156 /* GetAccessor */); + var node = createSynthesizedNode(158 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58612,7 +59327,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(157 /* SetAccessor */); + var node = createSynthesizedNode(159 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58633,7 +59348,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(160 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -58641,7 +59356,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(161 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -58649,7 +59364,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(160 /* IndexSignature */); + var node = createSynthesizedNode(162 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -58689,7 +59404,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(161 /* TypePredicate */); + var node = createSynthesizedNode(163 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -58703,7 +59418,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(162 /* TypeReference */); + var node = createSynthesizedNode(164 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -58717,7 +59432,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -58725,7 +59440,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(166 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -58733,7 +59448,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(165 /* TypeQuery */); + var node = createSynthesizedNode(167 /* TypeQuery */); node.exprName = exprName; return node; } @@ -58745,7 +59460,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(166 /* TypeLiteral */); + var node = createSynthesizedNode(168 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -58757,7 +59472,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(167 /* ArrayType */); + var node = createSynthesizedNode(169 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -58769,7 +59484,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(168 /* TupleType */); + var node = createSynthesizedNode(170 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -58781,7 +59496,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(169 /* OptionalType */); + var node = createSynthesizedNode(171 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -58793,7 +59508,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(170 /* RestType */); + var node = createSynthesizedNode(172 /* RestType */); node.type = type; return node; } @@ -58805,7 +59520,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(173 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -58813,7 +59528,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(174 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -58832,7 +59547,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(173 /* ConditionalType */); + var node = createSynthesizedNode(175 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -58850,7 +59565,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(174 /* InferType */); + var node = createSynthesizedNode(176 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -58862,7 +59577,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(181 /* ImportType */); + var node = createSynthesizedNode(183 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -58880,7 +59595,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(175 /* ParenthesizedType */); + var node = createSynthesizedNode(177 /* ParenthesizedType */); node.type = type; return node; } @@ -58892,12 +59607,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(176 /* ThisType */); + return createSynthesizedNode(178 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(177 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; + var node = createSynthesizedNode(179 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 129 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -58907,7 +59622,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(178 /* IndexedAccessType */); + var node = createSynthesizedNode(180 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -58921,7 +59636,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(179 /* MappedType */); + var node = createSynthesizedNode(181 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -58939,7 +59654,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(180 /* LiteralType */); + var node = createSynthesizedNode(182 /* LiteralType */); node.literal = literal; return node; } @@ -58952,7 +59667,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(182 /* ObjectBindingPattern */); + var node = createSynthesizedNode(184 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58964,7 +59679,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(183 /* ArrayBindingPattern */); + var node = createSynthesizedNode(185 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58976,7 +59691,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(184 /* BindingElement */); + var node = createSynthesizedNode(186 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -58995,7 +59710,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(187 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -59009,7 +59724,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(188 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -59023,7 +59738,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(187 /* PropertyAccessExpression */); + var node = createSynthesizedNode(189 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -59040,7 +59755,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(188 /* ElementAccessExpression */); + var node = createSynthesizedNode(190 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -59054,7 +59769,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(189 /* CallExpression */); + var node = createSynthesizedNode(191 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -59070,7 +59785,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(190 /* NewExpression */); + var node = createSynthesizedNode(192 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -59086,7 +59801,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(193 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -59109,7 +59824,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(192 /* TypeAssertionExpression */); + var node = createSynthesizedNode(194 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -59123,7 +59838,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(193 /* ParenthesizedExpression */); + var node = createSynthesizedNode(195 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -59135,7 +59850,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(194 /* FunctionExpression */); + var node = createSynthesizedNode(196 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -59159,12 +59874,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(195 /* ArrowFunction */); + var node = createSynthesizedNode(197 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -59181,7 +59896,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(196 /* DeleteExpression */); + var node = createSynthesizedNode(198 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59193,7 +59908,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(197 /* TypeOfExpression */); + var node = createSynthesizedNode(199 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59205,7 +59920,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(198 /* VoidExpression */); + var node = createSynthesizedNode(200 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59217,7 +59932,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(199 /* AwaitExpression */); + var node = createSynthesizedNode(201 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59229,7 +59944,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(202 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -59242,7 +59957,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(203 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -59255,7 +59970,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(202 /* BinaryExpression */); + var node = createSynthesizedNode(204 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -59272,11 +59987,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(203 /* ConditionalExpression */); + var node = createSynthesizedNode(205 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(56 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -59292,7 +60007,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(204 /* TemplateExpression */); + var node = createSynthesizedNode(206 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -59306,33 +60021,33 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createTemplateHead(text) { - var node = createSynthesizedNode(14 /* TemplateHead */); + var node = createSynthesizedNode(15 /* TemplateHead */); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; function createTemplateMiddle(text) { - var node = createSynthesizedNode(15 /* TemplateMiddle */); + var node = createSynthesizedNode(16 /* TemplateMiddle */); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; function createTemplateTail(text) { - var node = createSynthesizedNode(16 /* TemplateTail */); + var node = createSynthesizedNode(17 /* TemplateTail */); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(13 /* NoSubstitutionTemplateLiteral */); + var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); node.text = text; return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(205 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(207 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -59344,7 +60059,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(206 /* SpreadElement */); + var node = createSynthesizedNode(208 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -59356,7 +60071,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(207 /* ClassExpression */); + var node = createSynthesizedNode(209 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59377,11 +60092,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(208 /* OmittedExpression */); + return createSynthesizedNode(210 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(211 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -59395,7 +60110,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(210 /* AsExpression */); + var node = createSynthesizedNode(212 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -59409,7 +60124,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(211 /* NonNullExpression */); + var node = createSynthesizedNode(213 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -59421,7 +60136,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(212 /* MetaProperty */); + var node = createSynthesizedNode(214 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -59435,7 +60150,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(214 /* TemplateSpan */); + var node = createSynthesizedNode(216 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -59449,12 +60164,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(215 /* SemicolonClassElement */); + return createSynthesizedNode(217 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(216 /* Block */); + var block = createSynthesizedNode(218 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -59468,7 +60183,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(217 /* VariableStatement */); + var node = createSynthesizedNode(219 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -59483,11 +60198,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(218 /* EmptyStatement */); + return createSynthesizedNode(220 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(219 /* ExpressionStatement */); + var node = createSynthesizedNode(221 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -59503,7 +60218,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(220 /* IfStatement */); + var node = createSynthesizedNode(222 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -59519,7 +60234,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(221 /* DoStatement */); + var node = createSynthesizedNode(223 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -59533,7 +60248,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(222 /* WhileStatement */); + var node = createSynthesizedNode(224 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -59547,7 +60262,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(223 /* ForStatement */); + var node = createSynthesizedNode(225 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -59565,7 +60280,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(224 /* ForInStatement */); + var node = createSynthesizedNode(226 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -59581,7 +60296,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(225 /* ForOfStatement */); + var node = createSynthesizedNode(227 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -59599,7 +60314,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(226 /* ContinueStatement */); + var node = createSynthesizedNode(228 /* ContinueStatement */); node.label = asName(label); return node; } @@ -59611,7 +60326,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(227 /* BreakStatement */); + var node = createSynthesizedNode(229 /* BreakStatement */); node.label = asName(label); return node; } @@ -59623,7 +60338,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(228 /* ReturnStatement */); + var node = createSynthesizedNode(230 /* ReturnStatement */); node.expression = expression; return node; } @@ -59635,7 +60350,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(229 /* WithStatement */); + var node = createSynthesizedNode(231 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -59649,7 +60364,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(230 /* SwitchStatement */); + var node = createSynthesizedNode(232 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -59663,7 +60378,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(231 /* LabeledStatement */); + var node = createSynthesizedNode(233 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -59677,7 +60392,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(232 /* ThrowStatement */); + var node = createSynthesizedNode(234 /* ThrowStatement */); node.expression = expression; return node; } @@ -59689,7 +60404,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(233 /* TryStatement */); + var node = createSynthesizedNode(235 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -59705,11 +60420,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(234 /* DebuggerStatement */); + return createSynthesizedNode(236 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(235 /* VariableDeclaration */); + var node = createSynthesizedNode(237 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -59726,7 +60441,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(236 /* VariableDeclarationList */); + var node = createSynthesizedNode(238 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -59739,7 +60454,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(237 /* FunctionDeclaration */); + var node = createSynthesizedNode(239 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -59765,7 +60480,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(238 /* ClassDeclaration */); + var node = createSynthesizedNode(240 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59787,7 +60502,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(239 /* InterfaceDeclaration */); + var node = createSynthesizedNode(241 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59809,7 +60524,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(242 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59829,7 +60544,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(241 /* EnumDeclaration */); + var node = createSynthesizedNode(243 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59848,7 +60563,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(242 /* ModuleDeclaration */); + var node = createSynthesizedNode(244 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -59867,7 +60582,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(243 /* ModuleBlock */); + var node = createSynthesizedNode(245 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -59879,7 +60594,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(244 /* CaseBlock */); + var node = createSynthesizedNode(246 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -59891,7 +60606,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(247 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -59903,7 +60618,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(248 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59921,7 +60636,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(247 /* ImportDeclaration */); + var node = createSynthesizedNode(249 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -59939,7 +60654,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(248 /* ImportClause */); + var node = createSynthesizedNode(250 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -59953,7 +60668,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(249 /* NamespaceImport */); + var node = createSynthesizedNode(251 /* NamespaceImport */); node.name = name; return node; } @@ -59965,7 +60680,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(250 /* NamedImports */); + var node = createSynthesizedNode(252 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -59977,7 +60692,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ImportSpecifier */); + var node = createSynthesizedNode(253 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -59991,11 +60706,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(252 /* ExportAssignment */); + var node = createSynthesizedNode(254 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(58 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(59 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -60008,7 +60723,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(253 /* ExportDeclaration */); + var node = createSynthesizedNode(255 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -60026,7 +60741,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(254 /* NamedExports */); + var node = createSynthesizedNode(256 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -60038,7 +60753,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(255 /* ExportSpecifier */); + var node = createSynthesizedNode(257 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -60053,7 +60768,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(257 /* ExternalModuleReference */); + var node = createSynthesizedNode(259 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -60064,9 +60779,57 @@ var ts; : node; } ts.updateExternalModuleReference = updateExternalModuleReference; + // JSDoc + /* @internal */ + function createJSDocTypeExpression(type) { + var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + node.type = type; + return node; + } + ts.createJSDocTypeExpression = createJSDocTypeExpression; + /* @internal */ + function createJSDocTypeTag(typeExpression, comment) { + var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocTypeTag = createJSDocTypeTag; + /* @internal */ + function createJSDocReturnTag(typeExpression, comment) { + var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocReturnTag = createJSDocReturnTag; + /* @internal */ + function createJSDocParamTag(name, isBracketed, typeExpression, comment) { + var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + tag.typeExpression = typeExpression; + tag.name = name; + tag.isBracketed = isBracketed; + tag.comment = comment; + return tag; + } + ts.createJSDocParamTag = createJSDocParamTag; + /* @internal */ + function createJSDocComment(comment, tags) { + var node = createSynthesizedNode(291 /* JSDocComment */); + node.comment = comment; + node.tags = tags; + return node; + } + ts.createJSDocComment = createJSDocComment; + /* @internal */ + function createJSDocTag(kind, tagName) { + var node = createSynthesizedNode(kind); + node.tagName = createIdentifier(tagName); + return node; + } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(258 /* JsxElement */); + var node = createSynthesizedNode(260 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -60082,7 +60845,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(261 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60098,7 +60861,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(260 /* JsxOpeningElement */); + var node = createSynthesizedNode(262 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60114,7 +60877,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(261 /* JsxClosingElement */); + var node = createSynthesizedNode(263 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -60126,7 +60889,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(262 /* JsxFragment */); + var node = createSynthesizedNode(264 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -60142,7 +60905,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(265 /* JsxAttribute */); + var node = createSynthesizedNode(267 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -60156,7 +60919,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(266 /* JsxAttributes */); + var node = createSynthesizedNode(268 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -60168,7 +60931,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(269 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -60180,7 +60943,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(268 /* JsxExpression */); + var node = createSynthesizedNode(270 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -60194,7 +60957,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(269 /* CaseClause */); + var node = createSynthesizedNode(271 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -60208,7 +60971,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(270 /* DefaultClause */); + var node = createSynthesizedNode(272 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -60220,7 +60983,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(271 /* HeritageClause */); + var node = createSynthesizedNode(273 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -60233,7 +60996,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(272 /* CatchClause */); + var node = createSynthesizedNode(274 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -60248,7 +61011,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(273 /* PropertyAssignment */); + var node = createSynthesizedNode(275 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -60263,7 +61026,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(276 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -60277,7 +61040,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(275 /* SpreadAssignment */); + var node = createSynthesizedNode(277 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -60290,7 +61053,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(276 /* EnumMember */); + var node = createSynthesizedNode(278 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -60311,7 +61074,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(277 /* SourceFile */); + var updated = createSynthesizedNode(279 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -60395,7 +61158,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(305 /* NotEmittedStatement */); + var node = createSynthesizedNode(307 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -60407,7 +61170,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(309 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60419,7 +61182,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(308 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60434,7 +61197,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(306 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -60450,17 +61213,17 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 307 /* CommaListExpression */) { + if (node.kind === 309 /* CommaListExpression */) { return node.elements; } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { return [node.left, node.right]; } } return node; } function createCommaList(elements) { - var node = createSynthesizedNode(307 /* CommaListExpression */); + var node = createSynthesizedNode(309 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -60473,14 +61236,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(278 /* Bundle */); + var node = ts.createNode(280 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(279 /* UnparsedSource */); + var node = ts.createNode(281 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -60488,7 +61251,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(280 /* InputFiles */); + var node = ts.createNode(282 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -60530,47 +61293,47 @@ var ts; } ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { - return createBinary(left, 26 /* CommaToken */, right); + return createBinary(left, 27 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 27 /* LessThanToken */, right); + return createBinary(left, 28 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 58 /* EqualsToken */, right); + return createBinary(left, 59 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 34 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 35 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 37 /* PlusToken */, right); + return createBinary(left, 38 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 38 /* MinusToken */, right); + return createBinary(left, 39 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 43 /* PlusPlusToken */); + return createPostfix(operand, 44 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 53 /* AmpersandAmpersandToken */, right); + return createBinary(left, 54 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 54 /* BarBarToken */, right); + return createBinary(left, 55 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(51 /* ExclamationToken */, operand); + return createPrefix(52 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -60631,7 +61394,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 === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -61142,7 +61905,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 233 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -61154,19 +61917,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return cacheIdentifiers; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: return false; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -61181,7 +61945,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 97 /* SuperKeyword */) { + else if (callee.kind === 98 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -61193,7 +61957,7 @@ var ts; } else { switch (callee.kind) { - case 187 /* PropertyAccessExpression */: { + case 189 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61206,7 +61970,7 @@ var ts; } break; } - case 188 /* ElementAccessExpression */: { + case 190 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61263,14 +62027,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -61278,7 +62042,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_9 = []; + var properties_8 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -61289,7 +62053,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_9.push(getter); + properties_8.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -61301,15 +62065,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_9.push(setter); + properties_8.push(setter); } - properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_9, multiLine) + ts.createObjectLiteral(properties_8, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -61596,7 +62360,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 === 193 /* ParenthesizedExpression */) { + if (skipped.kind === 195 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -61630,10 +62394,10 @@ 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(202 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(204 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 195 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 197 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -61645,7 +62409,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 205 /* YieldExpression */) { + && operand.kind === 207 /* YieldExpression */) { return false; } return true; @@ -61682,7 +62446,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 37 /* PlusToken */) { + if (binaryOperator === 38 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -61717,10 +62481,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 === 39 /* AsteriskToken */ - || binaryOperator === 49 /* BarToken */ - || binaryOperator === 48 /* AmpersandToken */ - || binaryOperator === 50 /* CaretToken */; + return binaryOperator === 40 /* AsteriskToken */ + || binaryOperator === 50 /* BarToken */ + || binaryOperator === 49 /* AmpersandToken */ + || binaryOperator === 51 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -61733,7 +62497,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -61748,7 +62512,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(205 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -61783,8 +62547,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: needsParens = true; } } @@ -61800,9 +62564,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.createParen(expression); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -61825,7 +62589,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 192 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -61863,7 +62627,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -61874,29 +62638,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { + if (kind === 196 /* FunctionExpression */ || kind === 197 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { + if (leftmostExpressionKind === 188 /* ObjectLiteralExpression */ || leftmostExpressionKind === 196 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 175 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -61904,9 +62668,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 174 /* InferType */: + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 176 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -61932,28 +62696,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: node = node.operand; continue; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: node = node.left; continue; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: node = node.condition; continue; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: node = node.tag; continue; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 210 /* AsExpression */: - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: - case 211 /* NonNullExpression */: - case 306 /* PartiallyEmittedExpression */: + case 212 /* AsExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 213 /* NonNullExpression */: + case 308 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -61961,15 +62725,15 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 188 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || - node.kind === 307 /* CommaListExpression */; + return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 309 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -61982,13 +62746,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 211 /* NonNullExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -62013,7 +62777,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 213 /* NonNullExpression */) { node = node.expression; } return node; @@ -62021,11 +62785,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 306 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 195 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -62043,7 +62807,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 193 /* ParenthesizedExpression */ + return node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -62108,10 +62872,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 249 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 255 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -62127,7 +62891,7 @@ var ts; */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 - if (moduleName.kind === 9 /* StringLiteral */) { + if (moduleName.kind === 10 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) || ts.getSynthesizedClone(moduleName); @@ -62230,7 +62994,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -62242,11 +63006,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -62278,12 +63042,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 151 /* Parameter */: + case 186 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 206 /* SpreadElement */: - case 275 /* SpreadAssignment */: + case 208 /* SpreadElement */: + case 277 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -62295,7 +63059,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 184 /* BindingElement */: + case 186 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -62307,7 +63071,7 @@ var ts; : propertyName; } break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -62319,7 +63083,7 @@ var ts; : propertyName; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -62334,7 +63098,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ + return kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */; } /** @@ -62342,13 +63106,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -62388,11 +63152,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -62553,276 +63317,276 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */) || kind === 178 /* ThisType */) { return node; } switch (kind) { // Names - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 150 /* Decorator */: + case 152 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 155 /* Constructor */: + case 157 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 168 /* TupleType */: + case 170 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 170 /* RestType */: + case 172 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 171 /* UnionType */: + case 173 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 174 /* InferType */: + case 176 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 179 /* MappedType */: + case 181 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 216 /* Block */: + case 218 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -62864,58 +63628,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { + if ((kind >= 163 /* TypePredicate */ && kind <= 182 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 215 /* SemicolonClassElement */: - case 218 /* EmptyStatement */: - case 208 /* OmittedExpression */: - case 234 /* DebuggerStatement */: - case 305 /* NotEmittedStatement */: + case 217 /* SemicolonClassElement */: + case 220 /* EmptyStatement */: + case 210 /* OmittedExpression */: + case 236 /* DebuggerStatement */: + case 307 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 149 /* Parameter */: + case 151 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 150 /* Decorator */: + case 152 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62924,12 +63688,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* Constructor */: + case 157 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62937,7 +63701,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62945,49 +63709,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 190 /* NewExpression */: + case 192 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -62995,123 +63760,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ParenthesizedExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 210 /* AsExpression */: + case 212 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 216 /* Block */: + case 218 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 222 /* WhileStatement */: - case 229 /* WithStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63120,7 +63885,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63128,139 +63893,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); + result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -63333,7 +64099,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 211 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -63383,7 +64149,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -63420,288 +64186,623 @@ var ts; /* @internal */ var ts; (function (ts) { - function createSourceFileLikeCache(host) { - var cached = ts.createMap(); + function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) { + var _a = generatorOptions.extendedDiagnostics + ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap") + : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit; + // Current source map file and its index in the sources list + var rawSources = []; + var sources = []; + var sourceToSourceIndexMap = ts.createMap(); + var sourcesContent; + var names = []; + var nameToNameIndexMap; + var mappings = ""; + // Last recorded and encoded mappings + var lastGeneratedLine = 0; + var lastGeneratedCharacter = 0; + var lastSourceIndex = 0; + var lastSourceLine = 0; + var lastSourceCharacter = 0; + var lastNameIndex = 0; + var hasLast = false; + var pendingGeneratedLine = 0; + var pendingGeneratedCharacter = 0; + var pendingSourceIndex = 0; + var pendingSourceLine = 0; + var pendingSourceCharacter = 0; + var pendingNameIndex = 0; + var hasPending = false; + var hasPendingSource = false; + var hasPendingName = false; return { - get: function (path) { - if (cached.has(path)) { - return cached.get(path); + getSources: function () { return rawSources; }, + addSource: addSource, + setSourceContent: setSourceContent, + addName: addName, + addMapping: addMapping, + appendSourceMap: appendSourceMap, + toJSON: toJSON, + toString: function () { return JSON.stringify(toJSON()); } + }; + function addSource(fileName) { + enter(); + var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + var sourceIndex = sourceToSourceIndexMap.get(source); + if (sourceIndex === undefined) { + sourceIndex = sources.length; + sources.push(source); + rawSources.push(fileName); + sourceToSourceIndexMap.set(source, sourceIndex); + } + exit(); + return sourceIndex; + } + function setSourceContent(sourceIndex, content) { + enter(); + if (content !== null) { + if (!sourcesContent) + sourcesContent = []; + while (sourcesContent.length < sourceIndex) { + // tslint:disable-next-line:no-null-keyword boolean-trivia + sourcesContent.push(null); } - if (!host.fileExists || !host.readFile || !host.fileExists(path)) - return; - // And failing that, check the disk - var text = host.readFile(path); // TODO: GH#18217 - var file = { - text: text, - lineMap: undefined, - getLineAndCharacterOfPosition: function (pos) { - return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + sourcesContent[sourceIndex] = content; + } + exit(); + } + function addName(name) { + enter(); + if (!nameToNameIndexMap) + nameToNameIndexMap = ts.createMap(); + var nameIndex = nameToNameIndexMap.get(name); + if (nameIndex === undefined) { + nameIndex = names.length; + names.push(name); + nameToNameIndexMap.set(name, nameIndex); + } + exit(); + return nameIndex; + } + function isNewGeneratedPosition(generatedLine, generatedCharacter) { + return !hasPending + || pendingGeneratedLine !== generatedLine + || pendingGeneratedCharacter !== generatedCharacter; + } + function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) { + return sourceIndex !== undefined + && sourceLine !== undefined + && sourceCharacter !== undefined + && pendingSourceIndex === sourceIndex + && (pendingSourceLine > sourceLine + || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter); + } + function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) { + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative"); + ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative"); + ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative"); + enter(); + // If this location wasn't recorded or the location in source is going backwards, record the mapping + if (isNewGeneratedPosition(generatedLine, generatedCharacter) || + isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) { + commitPendingMapping(); + pendingGeneratedLine = generatedLine; + pendingGeneratedCharacter = generatedCharacter; + hasPendingSource = false; + hasPendingName = false; + hasPending = true; + } + if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) { + pendingSourceIndex = sourceIndex; + pendingSourceLine = sourceLine; + pendingSourceCharacter = sourceCharacter; + hasPendingSource = true; + if (nameIndex !== undefined) { + pendingNameIndex = nameIndex; + hasPendingName = true; + } + } + exit(); + } + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + var _a; + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + enter(); + // First, decode the old component sourcemap + var sourceIndexToNewSourceIndexMap = []; + var nameIndexToNewNameIndexMap; + var mappingIterator = decodeMappings(map.mappings); + for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + // Then reencode all the updated mappings into the overall map + var newSourceIndex = void 0; + var newSourceLine = void 0; + var newSourceCharacter = void 0; + var newNameIndex = void 0; + if (raw.sourceIndex !== undefined) { + newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex]; + if (newSourceIndex === undefined) { + // Apply offsets to each position and fixup source entries + var rawPath = map.sources[raw.sourceIndex]; + var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath); + sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath); + if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") { + setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]); + } } - }; - cached.set(path, file); - return file; + newSourceLine = raw.sourceLine; + newSourceCharacter = raw.sourceCharacter; + if (map.names && raw.nameIndex !== undefined) { + if (!nameIndexToNewNameIndexMap) + nameIndexToNewNameIndexMap = []; + newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex]; + if (newNameIndex === undefined) { + nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]); + } + } + } + var newGeneratedLine = raw.generatedLine + generatedLine; + var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); + } + exit(); + } + function shouldCommitMapping() { + return !hasLast + || lastGeneratedLine !== pendingGeneratedLine + || lastGeneratedCharacter !== pendingGeneratedCharacter + || lastSourceIndex !== pendingSourceIndex + || lastSourceLine !== pendingSourceLine + || lastSourceCharacter !== pendingSourceCharacter + || lastNameIndex !== pendingNameIndex; + } + function commitPendingMapping() { + if (!hasPending || !shouldCommitMapping()) { + return; + } + enter(); + // Line/Comma delimiters + if (lastGeneratedLine < pendingGeneratedLine) { + // Emit line delimiters + do { + mappings += ";"; + lastGeneratedLine++; + lastGeneratedCharacter = 0; + } while (lastGeneratedLine < pendingGeneratedLine); + } + else { + ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); + // Emit comma to separate the entry + if (hasLast) { + mappings += ","; + } + } + // 1. Relative generated character + mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + lastGeneratedCharacter = pendingGeneratedCharacter; + if (hasPendingSource) { + // 2. Relative sourceIndex + mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + lastSourceIndex = pendingSourceIndex; + // 3. Relative source line + mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + lastSourceLine = pendingSourceLine; + // 4. Relative source character + mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + lastSourceCharacter = pendingSourceCharacter; + if (hasPendingName) { + // 5. Relative nameIndex + mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + lastNameIndex = pendingNameIndex; + } + } + hasLast = true; + exit(); + } + function toJSON() { + commitPendingMapping(); + return { + version: 3, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings, + sourcesContent: sourcesContent, + }; + } + } + ts.createSourceMapGenerator = createSourceMapGenerator; + // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + /** + * Tries to find the sourceMappingURL comment at the end of a file. + * @param text The source text of the file. + * @param lineStarts The line starts of the file. + */ + function tryGetSourceMappingURL(text, lineStarts) { + if (lineStarts === void 0) { lineStarts = ts.computeLineStarts(text); } + for (var index = lineStarts.length - 1; index >= 0; index--) { + var line = text.substring(lineStarts[index], lineStarts[index + 1]); + var comment = sourceMapCommentRegExp.exec(line); + if (comment) { + return comment[1]; + } + // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!line.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + function isStringOrNull(x) { + // tslint:disable-next-line:no-null-keyword + return typeof x === "string" || x === null; + } + function isRawSourceMap(x) { + // tslint:disable-next-line:no-null-keyword + return x !== null + && typeof x === "object" + && x.version === 3 + && typeof x.file === "string" + && typeof x.mappings === "string" + && ts.isArray(x.sources) && ts.every(x.sources, ts.isString) + && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string") + && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull)) + && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); + } + ts.isRawSourceMap = isRawSourceMap; + function tryParseRawSourceMap(text) { + try { + var parsed = JSON.parse(text); + if (isRawSourceMap(parsed)) { + return parsed; + } + } + catch (_a) { + // empty + } + return undefined; + } + ts.tryParseRawSourceMap = tryParseRawSourceMap; + function decodeMappings(mappings) { + var done = false; + var pos = 0; + var generatedLine = 0; + var generatedCharacter = 0; + var sourceIndex = 0; + var sourceLine = 0; + var sourceCharacter = 0; + var nameIndex = 0; + var error; + return { + get pos() { return pos; }, + get error() { return error; }, + get state() { return captureMapping(/*hasSource*/ true, /*hasName*/ true); }, + next: function () { + while (!done && pos < mappings.length) { + var ch = mappings.charCodeAt(pos); + if (ch === 59 /* semicolon */) { + // new line + generatedLine++; + generatedCharacter = 0; + pos++; + continue; + } + if (ch === 44 /* comma */) { + // Next entry is on same line - no action needed + pos++; + continue; + } + var hasSource = false; + var hasName = false; + generatedCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (generatedCharacter < 0) + return setErrorAndStopIterating("Invalid generatedCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasSource = true; + sourceIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceIndex < 0) + return setErrorAndStopIterating("Invalid sourceIndex found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex"); + sourceLine += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceLine < 0) + return setErrorAndStopIterating("Invalid sourceLine found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine"); + sourceCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceCharacter < 0) + return setErrorAndStopIterating("Invalid sourceCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasName = true; + nameIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (nameIndex < 0) + return setErrorAndStopIterating("Invalid nameIndex found"); + if (!isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex"); + } + } + return { value: captureMapping(hasSource, hasName), done: done }; + } + return stopIterating(); } }; + function captureMapping(hasSource, hasName) { + return { + generatedLine: generatedLine, + generatedCharacter: generatedCharacter, + sourceIndex: hasSource ? sourceIndex : undefined, + sourceLine: hasSource ? sourceLine : undefined, + sourceCharacter: hasSource ? sourceCharacter : undefined, + nameIndex: hasName ? nameIndex : undefined + }; + } + function stopIterating() { + done = true; + return { value: undefined, done: true }; + } + function setError(message) { + if (error === undefined) { + error = message; + } + } + function setErrorAndStopIterating(message) { + setError(message); + return stopIterating(); + } + function hasReportedError() { + return error !== undefined; + } + function isSourceMappingSegmentEnd() { + return (pos === mappings.length || + mappings.charCodeAt(pos) === 44 /* comma */ || + mappings.charCodeAt(pos) === 59 /* semicolon */); + } + function base64VLQFormatDecode() { + var moreDigits = true; + var shiftCount = 0; + var value = 0; + for (; moreDigits; pos++) { + if (pos >= mappings.length) + return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1; + // 6 digit number + var currentByte = base64FormatDecode(mappings.charCodeAt(pos)); + if (currentByte === -1) + return setError("Invalid character in VLQ"), -1; + // If msb is set, we still have more bits to continue + moreDigits = (currentByte & 32) !== 0; + // least significant 5 bits are the next msbs in the final value. + value = value | ((currentByte & 31) << shiftCount); + shiftCount += 5; + } + // Least significant bit if 1 represents negative and rest of the msb is actual absolute value + if ((value & 1) === 0) { + // + number + value = value >> 1; + } + else { + // - number + value = value >> 1; + value = -value; + } + return value; + } } - ts.createSourceFileLikeCache = createSourceFileLikeCache; -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - var sourcemaps; - (function (sourcemaps) { - sourcemaps.identitySourceMapper = { getOriginalPosition: ts.identity, getGeneratedPosition: ts.identity }; - function decode(host, mapPath, map, program, fallbackCache) { - if (fallbackCache === void 0) { fallbackCache = ts.createSourceFileLikeCache(host); } - var currentDirectory = ts.getDirectoryPath(mapPath); - var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory; - var decodedMappings; - var generatedOrderedMappings; - var sourceOrderedMappings; - return { - getOriginalPosition: getOriginalPosition, - getGeneratedPosition: getGeneratedPosition - }; - function getGeneratedPosition(loc) { - var maps = getSourceOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { sourcePath: loc.fileName, sourcePosition: loc.position }, ts.identity, compareProcessedPositionSourcePositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - if (!maps[targetIndex] || ts.comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot) !== 0) { - return loc; - } - return { fileName: ts.toPath(map.file, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].emittedPosition }; // Closest pos - } - function getOriginalPosition(loc) { - var maps = getGeneratedOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { emittedPosition: loc.position }, ts.identity, compareProcessedPositionEmittedPositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - return { fileName: ts.toPath(maps[targetIndex].sourcePath, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].sourcePosition }; // Closest pos - } - function getSourceFileLike(fileName, location) { - // Lookup file in program, if provided - var path = ts.toPath(fileName, location, host.getCanonicalFileName); - var file = program && program.getSourceFile(path); - // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file - if (!file || file.resolvedPath !== path) { - // Otherwise check the cache (which may hit disk) - return fallbackCache.get(path); - } - return file; - } - function getPositionOfLineAndCharacterUsingName(fileName, directory, line, character) { - var file = getSourceFileLike(fileName, directory); - if (!file) { - return -1; - } - return ts.getPositionOfLineAndCharacter(file, line, character); - } - function getDecodedMappings() { - return decodedMappings || (decodedMappings = calculateDecodedMappings(map, processPosition, host)); - } - function getSourceOrderedMappings() { - return sourceOrderedMappings || (sourceOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionSourcePositions)); - } - function getGeneratedOrderedMappings() { - return generatedOrderedMappings || (generatedOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionEmittedPositions)); - } - function compareProcessedPositionSourcePositions(a, b) { - return ts.comparePaths(a.sourcePath, b.sourcePath, sourceRoot) || - ts.compareValues(a.sourcePosition, b.sourcePosition); - } - function compareProcessedPositionEmittedPositions(a, b) { - return ts.compareValues(a.emittedPosition, b.emittedPosition); - } - function processPosition(position) { - var sourcePath = map.sources[position.sourceIndex]; - return { - emittedPosition: getPositionOfLineAndCharacterUsingName(map.file, currentDirectory, position.emittedLine, position.emittedColumn), - sourcePosition: getPositionOfLineAndCharacterUsingName(sourcePath, sourceRoot, position.sourceLine, position.sourceColumn), - sourcePath: sourcePath, - }; - } + ts.decodeMappings = decodeMappings; + function sameMapping(left, right) { + return left === right + || left.generatedLine === right.generatedLine + && left.generatedCharacter === right.generatedCharacter + && left.sourceIndex === right.sourceIndex + && left.sourceLine === right.sourceLine + && left.sourceCharacter === right.sourceCharacter + && left.nameIndex === right.nameIndex; + } + ts.sameMapping = sameMapping; + function isSourceMapping(mapping) { + return mapping.sourceIndex !== undefined + && mapping.sourceLine !== undefined + && mapping.sourceCharacter !== undefined; + } + 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 */ : + ts.Debug.fail(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 : + -1; + } + function base64VLQFormatEncode(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; } - sourcemaps.decode = decode; - /*@internal*/ - function decodeMappings(map) { - var state = { - encodedText: map.mappings, - currentNameIndex: undefined, - sourceMapNamesLength: map.names ? map.names.length : undefined, - currentEmittedColumn: 0, - currentEmittedLine: 0, - currentSourceColumn: 0, - currentSourceLine: 0, - currentSourceIndex: 0, - decodingIndex: 0 - }; - function captureSpan() { - return { - emittedColumn: state.currentEmittedColumn, - emittedLine: state.currentEmittedLine, - sourceColumn: state.currentSourceColumn, - sourceIndex: state.currentSourceIndex, - sourceLine: state.currentSourceLine, - nameIndex: state.currentNameIndex - }; + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + return encodedStr; + } + function isSourceMappedPosition(value) { + return value.sourceIndex !== undefined + && value.sourcePosition !== undefined; + } + function sameMappedPosition(left, right) { + return left.generatedPosition === right.generatedPosition + && left.sourceIndex === right.sourceIndex + && left.sourcePosition === right.sourcePosition; + } + function compareSourcePositions(left, right) { + return ts.compareValues(left.sourceIndex, right.sourceIndex); + } + function compareGeneratedPositions(left, right) { + return ts.compareValues(left.generatedPosition, right.generatedPosition); + } + function getSourcePositionOfMapping(value) { + return value.sourcePosition; + } + function getGeneratedPositionOfMapping(value) { + return value.generatedPosition; + } + function createDocumentPositionMapper(host, map, mapPath) { + var mapDirectory = ts.getDirectoryPath(mapPath); + var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory; + var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory); + var generatedCanonicalFilePath = host.getCanonicalFileName(generatedAbsoluteFilePath); + var generatedFile = host.getSourceFileLike(generatedCanonicalFilePath); + var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); }); + var sourceFileCanonicalPaths = sourceFileAbsolutePaths.map(function (source) { return host.getCanonicalFileName(source); }); + var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileCanonicalPaths.map(function (source, i) { return [source, i]; })); + var decodedMappings; + var generatedMappings; + var sourceMappings; + return { + getSourcePosition: getSourcePosition, + getGeneratedPosition: getGeneratedPosition + }; + function processMapping(mapping) { + var generatedPosition = generatedFile !== undefined + ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter) + : -1; + var source; + var sourcePosition; + if (isSourceMapping(mapping)) { + var sourceFilePath = sourceFileCanonicalPaths[mapping.sourceIndex]; + var sourceFile = host.getSourceFileLike(sourceFilePath); + source = map.sources[mapping.sourceIndex]; + sourcePosition = sourceFile !== undefined + ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter) + : -1; } return { - get decodingIndex() { return state.decodingIndex; }, - get error() { return state.error; }, - get lastSpan() { return captureSpan(); }, - next: function () { - if (hasCompletedDecoding(state) || state.error) - return { done: true, value: undefined }; - if (!decodeSinglePosition(state)) - return { done: true, value: undefined }; - return { done: false, value: captureSpan() }; - } + generatedPosition: generatedPosition, + source: source, + sourceIndex: mapping.sourceIndex, + sourcePosition: sourcePosition, + nameIndex: mapping.nameIndex }; } - sourcemaps.decodeMappings = decodeMappings; - function calculateDecodedMappings(map, processPosition, host) { - var decoder = decodeMappings(map); - var positions = ts.arrayFrom(decoder, processPosition); - if (decoder.error) { - if (host && host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); - } - return []; - } - return positions; - } - function hasCompletedDecoding(state) { - return state.decodingIndex === state.encodedText.length; - } - function decodeSinglePosition(state) { - while (state.decodingIndex < state.encodedText.length) { - var char = state.encodedText.charCodeAt(state.decodingIndex); - if (char === 59 /* semicolon */) { - // New line - state.currentEmittedLine++; - state.currentEmittedColumn = 0; - state.decodingIndex++; - continue; - } - if (char === 44 /* comma */) { - // Next entry is on same line - no action needed - state.decodingIndex++; - continue; - } - // Read the current position - // 1. Column offset from prev read jsColumn - state.currentEmittedColumn += base64VLQFormatDecode(); - // Incorrect emittedColumn dont support this map - if (createErrorIfCondition(state.currentEmittedColumn < 0, "Invalid emittedColumn found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted column")) { - return false; - } - // 2. Relative sourceIndex - state.currentSourceIndex += base64VLQFormatDecode(); - // Incorrect sourceIndex dont support this map - if (createErrorIfCondition(state.currentSourceIndex < 0, "Invalid sourceIndex found")) { - return false; - } - // Dont support reading mappings that dont have information about original source position - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after sourceIndex")) { - return false; - } - // 3. Relative sourceLine 0 based - state.currentSourceLine += base64VLQFormatDecode(); - // Incorrect sourceLine dont support this map - if (createErrorIfCondition(state.currentSourceLine < 0, "Invalid sourceLine found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted Line")) { - return false; - } - // 4. Relative sourceColumn 0 based - state.currentSourceColumn += base64VLQFormatDecode(); - // Incorrect sourceColumn dont support this map - if (createErrorIfCondition(state.currentSourceColumn < 0, "Invalid sourceLine found")) { - return false; - } - // 5. Check if there is name: - if (!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex)) { - if (state.currentNameIndex === undefined) { - state.currentNameIndex = 0; + function getDecodedMappings() { + if (decodedMappings === undefined) { + var decoder = decodeMappings(map.mappings); + var mappings = ts.arrayFrom(decoder, processMapping); + if (decoder.error !== undefined) { + if (host.log) { + host.log("Encountered error while decoding sourcemap: " + decoder.error); } - state.currentNameIndex += base64VLQFormatDecode(); - // Incorrect nameIndex dont support this map - // TODO: If we start using `name`s, issue errors when they aren't correct in the sourcemap - // if (createErrorIfCondition(state.currentNameIndex < 0 || state.currentNameIndex >= state.sourceMapNamesLength, "Invalid name index for the source map entry")) { - // return; - // } - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: There are more entries after " + (state.currentNameIndex === undefined ? "sourceColumn" : "nameIndex"))) { - return false; - } - // Entry should be complete - return true; - } - createErrorIfCondition(/*condition*/ true, "No encoded entry found"); - return false; - function createErrorIfCondition(condition, errormsg) { - if (state.error) { - // An error was already reported - return true; - } - if (condition) { - state.error = errormsg; - } - return condition; - } - function base64VLQFormatDecode() { - var moreDigits = true; - var shiftCount = 0; - var value = 0; - for (; moreDigits; state.decodingIndex++) { - if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return undefined; // TODO: GH#18217 - } - // 6 digit number - var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); - // If msb is set, we still have more bits to continue - moreDigits = (currentByte & 32) !== 0; - // least significant 5 bits are the next msbs in the final value. - value = value | ((currentByte & 31) << shiftCount); - shiftCount += 5; - } - // Least significant bit if 1 represents negative and rest of the msb is actual absolute value - if ((value & 1) === 0) { - // + number - value = value >> 1; + decodedMappings = ts.emptyArray; } else { - // - number - value = value >> 1; - value = -value; + decodedMappings = mappings; } - return value; } + return decodedMappings; } - function base64FormatDecode(char) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(char); + function getSourceMappings(sourceIndex) { + if (sourceMappings === undefined) { + var lists = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + if (!isSourceMappedPosition(mapping)) + continue; + var list = lists[mapping.sourceIndex]; + if (!list) + lists[mapping.sourceIndex] = list = []; + list.push(mapping); + } + sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); }); + } + return sourceMappings[sourceIndex]; } - function isSourceMappingSegmentEnd(encodedText, pos) { - return (pos === encodedText.length || - encodedText.charCodeAt(pos) === 44 /* comma */ || - encodedText.charCodeAt(pos) === 59 /* semicolon */); + function getGeneratedMappings() { + if (generatedMappings === undefined) { + var list = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + list.push(mapping); + } + generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition); + } + return generatedMappings; } - })(sourcemaps = ts.sourcemaps || (ts.sourcemaps = {})); + function getGeneratedPosition(loc) { + var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName)); + if (sourceIndex === undefined) + return loc; + var sourceMappings = getSourceMappings(sourceIndex); + if (!ts.some(sourceMappings)) + return loc; + var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = sourceMappings[targetIndex]; + if (mapping === undefined || mapping.sourceIndex !== sourceIndex) { + return loc; + } + return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition }; // Closest pos + } + function getSourcePosition(loc) { + var generatedMappings = getGeneratedMappings(); + if (!ts.some(generatedMappings)) + return loc; + var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = generatedMappings[targetIndex]; + if (mapping === undefined || !isSourceMappedPosition(mapping)) { + return loc; + } + return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition }; // Closest pos + } + } + ts.createDocumentPositionMapper = createDocumentPositionMapper; + ts.identitySourceMapConsumer = { + getSourcePosition: ts.identity, + getGeneratedPosition: ts.identity + }; })(ts || (ts = {})); /* @internal */ var ts; @@ -63724,7 +64825,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -63770,7 +64871,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -63778,13 +64879,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 246 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + case 248 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -63814,13 +64915,13 @@ var ts; } } break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -63828,7 +64929,7 @@ var ts; } } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -63848,7 +64949,7 @@ var ts; } } break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -64464,8 +65565,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -64495,14 +65596,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -64551,16 +65652,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 243 /* ModuleBlock */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 245 /* ModuleBlock */: + case 218 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -64572,7 +65673,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 === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 240 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -64620,10 +65721,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -64644,13 +65745,13 @@ var ts; return node; } switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -64670,11 +65771,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 253 /* ExportDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 248 /* ImportClause */ || - (node.kind === 246 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 257 /* ExternalModuleReference */)) { + if (node.kind === 255 /* ExportDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 250 /* ImportClause */ || + (node.kind === 248 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 259 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -64704,19 +65805,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 152 /* PropertyDeclaration */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -64726,7 +65827,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 84 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 85 /* ExportKeyword */) { return undefined; } return node; @@ -64743,67 +65844,67 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 133 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 166 /* TypeLiteral */: - case 161 /* TypePredicate */: - case 148 /* TypeParameter */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 122 /* BooleanKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 105 /* VoidKeyword */: - case 138 /* SymbolKeyword */: - case 164 /* ConstructorType */: - case 163 /* FunctionType */: - case 165 /* TypeQuery */: - case 162 /* TypeReference */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 175 /* ParenthesizedType */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 168 /* TypeLiteral */: + case 163 /* TypePredicate */: + case 150 /* TypeParameter */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 123 /* BooleanKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 132 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 139 /* SymbolKeyword */: + case 166 /* ConstructorType */: + case 165 /* FunctionType */: + case 167 /* TypeQuery */: + case 164 /* TypeReference */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 177 /* ParenthesizedType */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: // TypeScript type nodes are elided. - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: // TypeScript index signatures are elided. - case 150 /* Decorator */: + case 152 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 152 /* PropertyDeclaration */: + case 154 /* 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 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructor(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64814,7 +65915,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64825,35 +65926,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -64863,35 +65964,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -64928,7 +66029,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -64997,7 +66098,7 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -65199,7 +66300,7 @@ var ts; pendingExpressions = undefined; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85 /* ExtendsKeyword */; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 86 /* ExtendsKeyword */; })); var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); @@ -65375,7 +66476,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -65446,7 +66547,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 152 /* PropertyDeclaration */ + return member.kind === 154 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -65457,8 +66558,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -65474,8 +66575,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); ts.startOnNewLine(expression); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -65586,12 +66687,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -65744,7 +66845,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 152 /* PropertyDeclaration */ + ? member.kind === 154 /* 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`. ? ts.createVoidZero() @@ -65845,13 +66946,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -65867,10 +66968,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 152 /* PropertyDeclaration */; + return kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 154 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -65880,7 +66981,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -65891,12 +66992,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; } return false; @@ -65913,15 +67014,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: return serializeTypeNode(node.type); - case 157 /* SetAccessor */: - case 156 /* GetAccessor */: + case 159 /* SetAccessor */: + case 158 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 156 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -65958,7 +67059,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 156 /* GetAccessor */) { + if (container && node.kind === 158 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -66003,77 +67104,83 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: return ts.createVoidZero(); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createIdentifier("Function"); - case 167 /* ArrayType */: - case 168 /* TupleType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: return ts.createIdentifier("Array"); - case 161 /* TypePredicate */: - case 122 /* BooleanKeyword */: + case 163 /* TypePredicate */: + case 123 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return ts.createIdentifier("String"); - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 180 /* LiteralType */: + case 182 /* LiteralType */: switch (node.literal.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + return getGlobalBigIntNameWithFallback(); + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 138 /* SymbolKeyword */: + case 146 /* BigIntKeyword */: + return getGlobalBigIntNameWithFallback(); + case 139 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return serializeTypeReferenceNode(node); - case 172 /* IntersectionType */: - case 171 /* UnionType */: - return serializeUnionOrIntersectionType(node); - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 166 /* TypeLiteral */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 176 /* ThisType */: - case 181 /* ImportType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return serializeTypeList(node.types); + case 175 /* ConditionalType */: + return serializeTypeList([node.trueType, node.falseType]); + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 168 /* TypeLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 178 /* ThisType */: + case 183 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); } return ts.createIdentifier("Object"); } - function serializeUnionOrIntersectionType(node) { + function serializeTypeList(types) { // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 131 /* NeverKeyword */) { + if (typeNode.kind === 132 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); @@ -66109,6 +67216,10 @@ var ts; var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: + // From conditional type type reference that cannot be resolved is Similar to any or unknown + if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { + return ts.createIdentifier("Object"); + } var serialized = serializeEntityNameAsExpressionFallback(node.typeName); var temp = ts.createTempVariable(hoistVariableDeclaration); return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object")); @@ -66116,6 +67227,8 @@ var ts; return serializeEntityNameAsExpression(node.typeName); case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.createVoidZero(); + case ts.TypeReferenceSerializationKind.BigIntLikeType: + return getGlobalBigIntNameWithFallback(); case ts.TypeReferenceSerializationKind.BooleanType: return ts.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -66147,12 +67260,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 71 /* Identifier */) { + if (node.left.kind === 72 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -66168,7 +67281,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* 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.getMutableClone(node); @@ -66176,7 +67289,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -66197,6 +67310,15 @@ var ts; function getGlobalSymbolNameWithFallback() { return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object")); } + /** + * Gets an expression that points to the global "BigInt" constructor at runtime if it is + * available. + */ + function getGlobalBigIntNameWithFallback() { + return languageVersion < 6 /* ESNext */ + ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object")) + : ts.createIdentifier("BigInt"); + } /** * A simple inlinable expression is an expression which can be copied into multiple locations * without risk of repeating any sideeffects and whose value could not possibly change between @@ -66277,9 +67399,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 85 /* ExtendsKeyword */) { + if (node.token === 86 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(85 /* ExtendsKeyword */, types), node); + return ts.setTextRange(ts.createHeritageClause(86 /* ExtendsKeyword */, types), node); } return undefined; } @@ -66675,7 +67797,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -66756,12 +67878,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 241 /* EnumDeclaration */) { + if (node.kind === 243 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -66886,7 +68008,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 243 /* ModuleBlock */) { + if (body.kind === 245 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -66932,13 +68054,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 243 /* ModuleBlock */) { + if (body.kind !== 245 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -66979,7 +68101,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 249 /* NamespaceImport */) { + if (node.kind === 251 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -67192,7 +68314,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -67200,7 +68322,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -67210,17 +68332,17 @@ var ts; enabledSubstitutions |= 2 /* 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(71 /* Identifier */); - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); + context.enableSubstitution(72 /* Identifier */); + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(242 /* ModuleDeclaration */); + context.enableEmitNotification(244 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 244 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 243 /* EnumDeclaration */; } /** * Hook for node emit. @@ -67279,11 +68401,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -67321,9 +68443,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 !== 277 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); + if (container && container.kind !== 279 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -67463,26 +68585,26 @@ var ts; return node; } switch (node.kind) { - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -67493,27 +68615,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 216 /* Block */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 229 /* WithStatement */: - case 231 /* LabeledStatement */: + case 218 /* Block */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 231 /* WithStatement */: + case 233 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -67714,7 +68836,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 195 /* ArrowFunction */; + var isArrowFunction = node.kind === 197 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -67799,17 +68921,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -67857,23 +68979,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -67893,11 +69015,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -67964,7 +69086,7 @@ var ts; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -68032,7 +69154,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 120 /* AsyncKeyword */) { + if (node.kind === 121 /* AsyncKeyword */) { return undefined; } return node; @@ -68042,55 +69164,55 @@ var ts; return node; } switch (node.kind) { - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitVoidExpression(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructorDeclaration(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -68126,7 +69248,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 227 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -68138,7 +69260,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 275 /* SpreadAssignment */) { + if (e.kind === 277 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -68147,7 +69269,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 275 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -68165,7 +69287,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 188 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -68193,7 +69315,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 262144 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -68421,7 +69543,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); @@ -68490,17 +69612,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -68548,23 +69670,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -68584,11 +69706,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -68697,13 +69819,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -68711,15 +69833,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 10 /* JsxText */: + case 11 /* JsxText */: return visitJsxText(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -68787,14 +69909,14 @@ var ts; if (node === undefined) { return ts.createTrue(); } - else if (node.kind === 9 /* StringLiteral */) { + else if (node.kind === 10 /* 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 literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text); literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 268 /* JsxExpression */) { + else if (node.kind === 270 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -68888,7 +70010,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 258 /* JsxElement */) { + if (node.kind === 260 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -69194,7 +70316,7 @@ var ts; return node; } switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69202,9 +70324,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 62 /* AsteriskAsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69432,13 +70554,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 228 /* ReturnStatement */ + && node.kind === 230 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 218 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -69457,104 +70579,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: return undefined; // elide static keyword - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return visitClassExpression(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 71 /* Identifier */: + case 72 /* Identifier */: return visitIdentifier(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return visitTemplateLiteral(node); - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitSpreadElement(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return visitThisKeyword(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitMetaProperty(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -69641,14 +70763,14 @@ 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 === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 229 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -69659,7 +70781,7 @@ var ts; } } else { - if (node.kind === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -69678,10 +70800,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 26 /* CommaToken */, copyExpr); + expr = ts.createBinary(expr, 27 /* CommaToken */, copyExpr); } } - returnExpression = ts.createBinary(expr, 26 /* CommaToken */, returnExpression); + returnExpression = ts.createBinary(expr, 27 /* CommaToken */, returnExpression); } return ts.createReturn(returnExpression); } @@ -69815,7 +70937,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -69920,7 +71042,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -69959,11 +71081,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 228 /* ReturnStatement */) { + if (statement.kind === 230 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 220 /* IfStatement */) { + else if (statement.kind === 222 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -69971,7 +71093,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 216 /* Block */) { + else if (statement.kind === 218 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -70029,7 +71151,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -70039,8 +71161,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (8192 /* ContainsLexicalThis */ | 16384 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 202 /* BinaryExpression */ - || superCallExpression.left.kind !== 189 /* CallExpression */) { + if (superCallExpression.kind !== 204 /* BinaryExpression */ + || superCallExpression.left.kind !== 191 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -70185,7 +71307,7 @@ var ts; * synthesized call to `super` */ function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 71 /* Identifier */ && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 72 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** * Adds statements to the body of a function-like node if it contains a rest parameter. @@ -70237,7 +71359,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { + if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 197 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -70256,25 +71378,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return statements; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 94 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70302,20 +71424,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -70507,7 +71629,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 239 /* FunctionDeclaration */ || node.kind === 196 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -70552,7 +71674,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 195 /* ArrowFunction */); + ts.Debug.assert(node.kind === 197 /* 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 @@ -70590,7 +71712,7 @@ var ts; ts.setEmitFlags(block, 1 /* SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 18 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -70620,9 +71742,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -70641,9 +71763,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -70678,7 +71800,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 58 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 59 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -70852,14 +71974,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -71043,7 +72165,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 147 /* ComputedPropertyName */) { + if (property.name.kind === 149 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -71098,7 +72220,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -71164,11 +72286,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 223 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 224 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 225 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 221 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 222 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 225 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 226 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 227 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 223 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 224 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -71193,11 +72315,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 238 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -71348,7 +72470,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -71410,7 +72532,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(51 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -71448,7 +72570,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -71459,7 +72581,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 58 /* EqualsToken */, source); + return ts.createBinary(target, 59 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -71472,7 +72594,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -71486,7 +72608,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -71507,10 +72629,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -71596,20 +72718,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -71720,7 +72842,7 @@ var ts; var body = node.transformFlags & (16384 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -71897,10 +73019,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 131072 /* ContainsRestOrSpread */ || - node.expression.kind === 97 /* SuperKeyword */ || + node.expression.kind === 98 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -71933,7 +73055,7 @@ var ts; resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -71998,7 +73120,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 187 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -72115,7 +73237,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 === 13 /* NoSubstitutionTemplateLiteral */ || node.kind === 16 /* TemplateTail */; + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's @@ -72213,7 +73335,7 @@ var ts; : ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 94 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 95 /* NewKeyword */ && node.name.escapedText === "target") { if (hierarchyFacts & 8192 /* ComputedPropertyName */) { hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; } @@ -72250,7 +73372,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } /** @@ -72260,14 +73382,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(155 /* Constructor */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(195 /* ArrowFunction */); - context.enableEmitNotification(194 /* FunctionExpression */); - context.enableEmitNotification(237 /* FunctionDeclaration */); + context.enableSubstitution(100 /* ThisKeyword */); + context.enableEmitNotification(157 /* Constructor */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(197 /* ArrowFunction */); + context.enableEmitNotification(196 /* FunctionExpression */); + context.enableEmitNotification(239 /* FunctionDeclaration */); } } /** @@ -72308,10 +73430,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 237 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -72324,9 +73446,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -72393,19 +73515,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 221 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 191 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 98 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 208 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -72458,15 +73580,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(260 /* JsxOpeningElement */); - context.enableEmitNotification(261 /* JsxClosingElement */); - context.enableEmitNotification(259 /* JsxSelfClosingElement */); + context.enableEmitNotification(262 /* JsxOpeningElement */); + context.enableEmitNotification(263 /* JsxClosingElement */); + context.enableEmitNotification(261 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(273 /* PropertyAssignment */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(275 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -72485,9 +73607,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -72544,7 +73666,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -72819,13 +73941,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -72838,24 +73960,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return visitBreakStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return visitContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 4194304 /* ContainsYield */) { @@ -72876,21 +73998,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitConditionalExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -72903,9 +74025,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -73104,23 +74226,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 59 /* FirstCompoundAssignment */ - && kind <= 70 /* LastCompoundAssignment */; + return kind >= 60 /* FirstCompoundAssignment */ + && kind <= 71 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 59 /* PlusEqualsToken */: return 37 /* PlusToken */; - case 60 /* MinusEqualsToken */: return 38 /* MinusToken */; - case 61 /* AsteriskEqualsToken */: return 39 /* AsteriskToken */; - case 62 /* AsteriskAsteriskEqualsToken */: return 40 /* AsteriskAsteriskToken */; - case 63 /* SlashEqualsToken */: return 41 /* SlashToken */; - case 64 /* PercentEqualsToken */: return 42 /* PercentToken */; - case 65 /* LessThanLessThanEqualsToken */: return 45 /* LessThanLessThanToken */; - case 66 /* GreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanToken */; - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanGreaterThanToken */; - case 68 /* AmpersandEqualsToken */: return 48 /* AmpersandToken */; - case 69 /* BarEqualsToken */: return 49 /* BarToken */; - case 70 /* CaretEqualsToken */: return 50 /* CaretToken */; + case 60 /* PlusEqualsToken */: return 38 /* PlusToken */; + case 61 /* MinusEqualsToken */: return 39 /* MinusToken */; + case 62 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; + case 63 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; + case 64 /* SlashEqualsToken */: return 42 /* SlashToken */; + case 65 /* PercentEqualsToken */: return 43 /* PercentToken */; + case 66 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; + case 67 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; + case 69 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; + case 70 /* BarEqualsToken */: return 50 /* BarToken */; + case 71 /* CaretEqualsToken */: return 51 /* CaretToken */; } } /** @@ -73133,7 +74255,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -73145,7 +74267,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -73177,7 +74299,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -73232,7 +74354,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 === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -73263,7 +74385,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -73521,35 +74643,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: return transformAndEmitBlock(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return transformAndEmitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return transformAndEmitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return transformAndEmitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return transformAndEmitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -73979,7 +75101,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 272 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -73992,7 +75114,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -74304,7 +75426,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -75220,12 +76342,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(279 /* 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. @@ -75553,23 +76675,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -75596,24 +76718,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -76091,7 +77213,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -76146,10 +77268,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -76331,8 +77453,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -76348,7 +77470,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -76410,12 +77532,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -76436,7 +77558,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -76504,15 +77626,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 203 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 60 /* PlusEqualsToken */ : 61 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -76586,12 +77708,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(279 /* 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. @@ -76812,7 +77934,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 255 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -76837,7 +77959,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 253 /* ExportDeclaration */) { + if (externalImport.kind !== 255 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -76915,19 +78037,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -76977,15 +78099,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -77161,7 +78283,7 @@ 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 === 277 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -77225,7 +78347,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -77287,10 +78409,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -77470,43 +78592,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitDefaultClause(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitTryStatement(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -77689,7 +78811,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 202 /* BinaryExpression */) { + && node.kind === 204 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -77754,7 +78876,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 277 /* SourceFile */; + return container !== undefined && container.kind === 279 /* SourceFile */; } else { return false; @@ -77770,8 +78892,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -77787,7 +78909,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -77835,7 +78957,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -77869,12 +78991,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -77960,22 +79082,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ + var expression = node.kind === 203 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 201 /* PostfixUnaryExpression */) { - expression = node.operator === 43 /* PlusPlusToken */ + if (node.kind === 203 /* PostfixUnaryExpression */) { + expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -77996,7 +79118,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -78035,8 +79157,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(277 /* SourceFile */); - context.enableSubstitution(71 /* Identifier */); + context.enableEmitNotification(279 /* SourceFile */); + context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -78064,10 +79186,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -78174,7 +79296,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78203,7 +79325,7 @@ var ts; 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 === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78250,7 +79372,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78259,8 +79381,8 @@ var ts; } // 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 === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || - (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 154 /* PropertyDeclaration */ || node.kind === 153 /* PropertySignature */ || + (node.kind === 151 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -78269,7 +79391,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 240 /* ClassDeclaration */ || node.kind === 151 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78294,7 +79416,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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.hasModifier(node, 32 /* Static */)) { @@ -78333,26 +79455,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78360,7 +79482,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78374,7 +79496,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78399,30 +79521,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 159 /* ConstructSignature */: - case 164 /* ConstructorType */: + case 161 /* ConstructSignature */: + case 166 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78430,7 +79552,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78443,8 +79565,8 @@ 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 237 /* FunctionDeclaration */: - case 163 /* FunctionType */: + case 239 /* FunctionDeclaration */: + case 165 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78458,34 +79580,34 @@ 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 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* 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 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -78500,9 +79622,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + if (node.parent.parent.kind === 240 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 108 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 109 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -78667,10 +79789,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -78693,14 +79815,14 @@ 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_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(124 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(125 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -78814,11 +79936,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { return name; } else { - if (name.kind === 183 /* ArrayBindingPattern */) { + if (name.kind === 185 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -78826,7 +79948,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 208 /* OmittedExpression */) { + if (elem.kind === 210 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -78839,7 +79961,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(55 /* QuestionToken */)) : undefined, ensureType(p, 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 || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -78851,7 +79973,7 @@ var ts; } function ensureNoInitializer(node) { if (shouldPrintWithInitializer(node)) { - return resolver.createLiteralConstValue(ts.getParseTreeNode(node)); // TODO: Make safe + return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker); // TODO: Make safe } return undefined; } @@ -78864,19 +79986,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 149 /* Parameter */ && + var shouldUseResolverType = node.kind === 151 /* 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) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(120 /* AnyKeyword */); } - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -78884,12 +80006,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 149 /* Parameter */ - || node.kind === 152 /* PropertyDeclaration */ - || node.kind === 151 /* PropertySignature */) { + if (node.kind === 151 /* Parameter */ + || node.kind === 154 /* PropertyDeclaration */ + || node.kind === 153 /* 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)); @@ -78900,26 +80022,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(119 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(120 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return false; } return false; @@ -78973,7 +80095,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 244 /* ModuleDeclaration */ && parent.kind !== 183 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -78993,7 +80115,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 259 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -79020,7 +80142,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 251 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -79125,68 +80247,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 168 /* TypeLiteral */ || input.kind === 181 /* MappedType */) && input.parent.kind !== 242 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 209 /* ExpressionWithTypeArguments */: { + case 211 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 162 /* TypeReference */: { + case 164 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 155 /* Constructor */: { + case 157 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(157 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 154 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 156 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(155 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 156 /* GetAccessor */: { + case 158 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 157 /* SetAccessor */: { + case 159 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 153 /* MethodSignature */: { + case 155 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 158 /* CallSignature */: { + case 160 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 160 /* IndexSignature */: { + case 162 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(120 /* AnyKeyword */))); } - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -79194,13 +80316,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 148 /* TypeParameter */: { + case 150 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 173 /* ConditionalType */: { + case 175 /* 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); @@ -79212,13 +80334,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 163 /* FunctionType */: { + case 165 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 164 /* ConstructorType */: { + case 166 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 181 /* ImportType */: { + case 183 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -79247,7 +80369,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 156 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -79257,7 +80379,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 253 /* ExportDeclaration */: { + case 255 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -79266,13 +80388,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 252 /* ExportAssignment */: { + case 254 /* 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 === 71 /* Identifier */) { + if (input.expression.kind === 72 /* Identifier */) { return input; } else { @@ -79282,7 +80404,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -79296,10 +80418,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -79320,14 +80442,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 242 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 239 /* InterfaceDeclaration */: { + case 241 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 237 /* FunctionDeclaration */: { + case 239 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), @@ -79349,10 +80471,10 @@ var ts; return clean; } } - case 242 /* ModuleDeclaration */: { + case 244 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 243 /* ModuleBlock */) { + if (inner && inner.kind === 245 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -79373,7 +80495,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 238 /* ClassDeclaration */: { + case 240 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -79384,7 +80506,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 71 /* Identifier */) { + if (param.name.kind === 72 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -79414,7 +80536,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 96 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ @@ -79423,16 +80545,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 85 /* ExtendsKeyword */) { + if (clause.token === 86 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 96 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -79443,10 +80565,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 241 /* EnumDeclaration */: { + case 243 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -79465,7 +80587,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 242 /* ModuleDeclaration */) { + if (input.kind === 244 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -79486,7 +80608,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 208 /* OmittedExpression */) { + if (e.kind === 210 /* OmittedExpression */) { return; } if (e.name) { @@ -79549,7 +80671,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 277 /* SourceFile */; + var parentIsFile = node.parent.kind === 279 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -79591,13 +80713,13 @@ var ts; } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 85 /* ExtendsKeyword */ && t.expression.kind === 95 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 86 /* ExtendsKeyword */ && t.expression.kind === 96 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* InterfaceDeclaration */) { return true; } return false; @@ -79622,7 +80744,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 156 /* GetAccessor */ + return accessor.kind === 158 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -79631,52 +80753,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 217 /* VariableStatement */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 219 /* VariableStatement */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 235 /* VariableDeclaration */: - case 148 /* TypeParameter */: - case 209 /* ExpressionWithTypeArguments */: - case 162 /* TypeReference */: - case 173 /* ConditionalType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 181 /* ImportType */: + case 161 /* ConstructSignature */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 237 /* VariableDeclaration */: + case 150 /* TypeParameter */: + case 211 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 175 /* ConditionalType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 183 /* ImportType */: return true; } return false; @@ -79741,6 +80863,14 @@ var ts; return transformers; } ts.getTransformers = getTransformers; + function noEmitSubstitution(_hint, node) { + return node; + } + ts.noEmitSubstitution = noEmitSubstitution; + function noEmitNotification(hint, node, callback) { + callback(hint, node); + } + ts.noEmitNotification = noEmitNotification; /** * Transforms an array of SourceFiles by passing them through each transformer. * @@ -79752,7 +80882,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(310 /* Count */); + var enabledSyntaxKindFeatures = new Array(312 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -79760,8 +80890,8 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; - var onSubstituteNode = function (_, node) { return node; }; - var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var onSubstituteNode = noEmitSubstitution; + var onEmitNode = noEmitNotification; var state = 0 /* Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer @@ -80010,825 +81140,11 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans - var defaultLastEncodedSourceMapSpan = { - emittedLine: 0, - emittedColumn: 0, - sourceLine: 0, - sourceColumn: 0, - sourceIndex: 0 - }; - function createSourceMapWriter(host, writer, compilerOptions) { - if (compilerOptions === void 0) { compilerOptions = host.getCompilerOptions(); } - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var currentSource; - var currentSourceText; - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex; - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan; - var lastEncodedNameIndex; - // Source map data - var sourceMapData; - var sourceMapDataList; - var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); - return { - initialize: initialize, - reset: reset, - setSourceFile: setSourceFile, - emitPos: emitPos, - emitNodeWithSourceMap: emitNodeWithSourceMap, - emitTokenWithSourceMap: emitTokenWithSourceMap, - getText: getText, - getSourceMappingURL: getSourceMappingURL, - }; - /** - * Skips trivia such as comments and white-space that can optionally overriden by the source map source - */ - function skipSourceTrivia(pos) { - return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); - } - /** - * Initialize the SourceMapWriter for a new output file. - * - * @param filePath The path to the generated output file. - * @param sourceMapFilePath The path to the output source map file. - * @param sourceFileOrBundle The input source file or bundle for the program. - */ - function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { - return; - } - if (sourceMapData) { - reset(); - } - sourceMapDataList = outputSourceMapDataList; - currentSource = undefined; - currentSourceText = undefined; - // Current source map file and its index in the sources list - sourceMapSourceIndex = -1; - // Last recorded and encoded spans - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; - lastEncodedNameIndex = 0; - // Initialize source map data - sourceMapData = { - sourceMapFilePath: sourceMapFilePath, - jsSourceMappingURL: !compilerOptions.inlineSourceMap ? ts.getBaseFileName(ts.normalizeSlashes(sourceMapFilePath)) : undefined, - sourceMapFile: ts.getBaseFileName(ts.normalizeSlashes(filePath)), - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 277 /* SourceFile */) { // emitting single module file - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle.fileName, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(filePath)); - } - } - /** - * Reset the SourceMapWriter to an empty state. - */ - function reset() { - if (disabled) { - return; - } - // Record source map data for the test harness. - if (sourceMapDataList) { - sourceMapDataList.push(sourceMapData); - } - currentSource = undefined; - sourceMapDir = undefined; - sourceMapSourceIndex = undefined; - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = undefined; - lastEncodedNameIndex = undefined; - sourceMapData = undefined; - sourceMapDataList = undefined; - } - function captureSection() { - return { - version: 3, - file: sourceMapData.sourceMapFile, - sourceRoot: sourceMapData.sourceMapSourceRoot, - sources: sourceMapData.sourceMapSources, - names: sourceMapData.sourceMapNames, - mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent, - }; - } - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - ts.Debug.assert(lastRecordedSourceMapSpan.emittedColumn >= 0, "lastEncodedSourceMapSpan.emittedColumn was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceIndex >= 0, "lastEncodedSourceMapSpan.sourceIndex was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceLine >= 0, "lastEncodedSourceMapSpan.sourceLine was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceColumn >= 0, "lastEncodedSourceMapSpan.sourceColumn was negative"); - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 0; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - } - /** - * Emits a mapping. - * - * If the position is synthetic (undefined or a negative value), no mapping will be - * created. - * - * @param pos The position. - */ - function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeSourcemap"); - } - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSource, pos); - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - sourceIndex: sourceMapSourceIndex - }; - } - else { - // Take the new pos instead since there is no change in emittedLine and column since last location - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - if (extendedDiagnostics) { - ts.performance.mark("afterSourcemap"); - ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); - } - } - function isPossiblySourceMap(x) { - return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; - } - /** - * Emits a node with possible leading and trailing source maps. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to emit. - * @param emitCallback The callback used to emit the node. - */ - function emitNodeWithSourceMap(hint, node, emitCallback) { - var _a; - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(hint, node); - } - if (node) { - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var text = node.sourceMapText; - var parsed = void 0; - try { - parsed = JSON.parse(text); - } - catch (_b) { - // empty - } - if (!parsed || !isPossiblySourceMap(parsed)) { - return emitCallback(hint, node); - } - var offsetLine = writer.getLine(); - var firstLineColumnOffset = writer.getColumn(); - // First, decode the old component sourcemap - var originalMap = parsed; - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache = ts.createMap(); - var absolutePathCache = ts.createMap(); - var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); - for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { - var pathCacheKey = "" + raw.sourceIndex; - // Apply offsets to each position and fixup source entries - if (!resolvedPathCache.has(pathCacheKey)) { - var rawPath = originalMap.sources[raw.sourceIndex]; - var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - resolvedPathCache.set(pathCacheKey, resolvedPath_1); - absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); - } - var resolvedPath = resolvedPathCache.get(pathCacheKey); - var absolutePath = absolutePathCache.get(pathCacheKey); - // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? - var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); - // Then reencode all the updated spans into the overall map - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); - } - // And actually emit the text these sourcemaps are for - return emitCallback(hint, node); - } - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.sourceMapRange; - var _d = range || node, pos = _d.pos, end = _d.end; - var source = range && range.source; - var oldSource = currentSource; - if (source === oldSource) - source = undefined; - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitPos(skipSourceTrivia(pos)); - } - if (source) - setSourceFile(oldSource); - if (emitFlags & 64 /* NoNestedSourceMaps */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitPos(end); - } - if (source) - setSourceFile(oldSource); - } - } - /** - * Emits a token of a node with possible leading and trailing source maps. - * - * @param node The node containing the token. - * @param token The token to emit. - * @param tokenStartPos The start pos of the token. - * @param emitCallback The callback used to emit the token. - */ - function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(token, writer, tokenPos); - } - var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; - tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - tokenPos = emitCallback(token, writer, tokenPos); - if (range) - tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - return tokenPos; - } - function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); - } - /** - * Set the current source file. - * - * @param sourceFile The source file. - */ - function setSourceFile(sourceFile) { - if (disabled) { - return; - } - currentSource = sourceFile; - currentSourceText = currentSource.text; - if (isJsonSourceMapSource(sourceFile)) { - return; - } - setupSourceEntry(sourceFile.fileName, sourceFile.text); - } - function setupSourceEntry(fileName, content, source) { - if (!source) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); - if (sourceMapSourceIndex === -1) { - sourceMapSourceIndex = sourceMapData.sourceMapSources.length; - sourceMapData.sourceMapSources.push(source); - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(fileName); - if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent.push(content); - } - } - } - /** - * Gets the text for the source map. - */ - function getText() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - encodeLastRecordedSourceMapSpan(); - return JSON.stringify(captureSection()); - } - /** - * Gets the SourceMappingURL for the source map. - */ - function getSourceMappingURL() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.base64encode(ts.sys, getText()); - return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; - } - else { - return sourceMapData.jsSourceMappingURL; - } - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - function base64FormatEncode(inValue) { - if (inValue < 64) { - return base64Chars.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - function createCommentWriter(printerOptions, emitPos) { - var extendedDiagnostics = printerOptions.extendedDiagnostics; - var newLine = ts.getNewLineCharacter(printerOptions); - var writer; - var containerPos = -1; - var containerEnd = -1; - var declarationListContainerEnd = -1; - var currentSourceFile; - var currentText; - var currentLineMap; - var detachedCommentsInfo; - var hasWrittenComment = false; - var disabled = !!printerOptions.removeComments; - return { - reset: reset, - setWriter: setWriter, - setSourceFile: setSourceFile, - emitNodeWithComments: emitNodeWithComments, - emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, - emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, - }; - function emitNodeWithComments(hint, node, emitCallback) { - if (disabled) { - emitCallback(hint, node); - return; - } - if (node) { - hasWrittenComment = false; - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; - if ((pos < 0 && end < 0) || (pos === end)) { - // Both pos and end are synthesized, so just emit the node without comments. - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - } - else { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithComment"); - } - var isEmittedNode = node.kind !== 305 /* NotEmittedStatement */; - // 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 === 10 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 10 /* JsxText */; - // 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); - } - // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { - // Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments. - containerPos = pos; - } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* 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 === 236 /* VariableDeclarationList */) { - declarationListContainerEnd = end; - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithComment"); - } - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithComment"); - } - // Restore previous container state. - containerPos = savedContainerPos; - containerEnd = savedContainerEnd; - 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 && isEmittedNode) { - emitTrailingComments(end); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithComment"); - } - } - } - } - function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { - var leadingComments = emitNode && emitNode.leadingComments; - if (ts.some(leadingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithSynthesizedComments"); - } - ts.forEach(leadingComments, emitLeadingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); - } - } - emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); - var trailingComments = emitNode && emitNode.trailingComments; - if (ts.some(trailingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithSynthesizedComments"); - } - ts.forEach(trailingComments, emitTrailingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); - } - } - } - function emitLeadingSynthesizedComment(comment) { - if (comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function emitTrailingSynthesizedComment(comment) { - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - } - function writeSynthesizedComment(comment) { - var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; - ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); - } - function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; - } - function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - } - function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitBodyWithDetachedComments"); - } - var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = disabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; - if (!skipLeadingComments) { - emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); - } - if (emitFlags & 2048 /* NoNestedComments */ && !disabled) { - disabled = true; - emitCallback(node); - disabled = false; - } - else { - emitCallback(node); - } - if (extendedDiagnostics) { - ts.performance.mark("beginEmitBodyWithDetachedComments"); - } - if (!skipTrailingComments) { - emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); - if (hasWrittenComment && !writer.isAtStartOfLine()) { - writer.writeLine(); - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitBodyWithDetachedComments"); - } - } - function emitLeadingComments(pos, isEmittedNode) { - hasWrittenComment = false; - if (isEmittedNode) { - forEachLeadingCommentToEmit(pos, emitLeadingComment); - } - else if (pos === 0) { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted - forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); - } - } - function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); - } - } - function shouldWriteComment(text, pos) { - if (printerOptions.onlyPrintJsDocStyle) { - return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); - } - return true; - } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (!hasWrittenComment) { - ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); - hasWrittenComment = true; - } - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else if (kind === 3 /* MultiLineCommentTrivia */) { - writer.write(" "); - } - } - function emitLeadingCommentsOfPosition(pos) { - if (disabled || pos === -1) { - return; - } - emitLeadingComments(pos, /*isEmittedNode*/ true); - } - function emitTrailingComments(pos) { - forEachTrailingCommentToEmit(pos, emitTrailingComment); - } - function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - } - function emitTrailingCommentsOfPosition(pos, prefixSpace) { - if (disabled) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); - } - forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); - } - } - function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function forEachLeadingCommentToEmit(pos, cb) { - // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments - if (containerPos === -1 || pos !== containerPos) { - if (hasDetachedComments(pos)) { - forEachLeadingCommentWithoutDetachedComments(cb); - } - else { - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - } - } - function forEachTrailingCommentToEmit(end, cb) { - // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments - if (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd)) { - ts.forEachTrailingCommentRange(currentText, end, cb); - } - } - function reset() { - currentSourceFile = undefined; - currentText = undefined; - currentLineMap = undefined; - detachedCommentsInfo = undefined; - } - function setWriter(output) { - writer = output; - } - function setSourceFile(sourceFile) { - currentSourceFile = sourceFile; - currentText = currentSourceFile.text; - currentLineMap = ts.getLineStarts(currentSourceFile); - detachedCommentsInfo = undefined; - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; - } - function forEachLeadingCommentWithoutDetachedComments(cb) { - // get the leading comments from detachedPos - var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentText, currentLineMap, writer, writeComment, range, newLine, disabled); - if (currentDetachedCommentInfo) { - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - */ - function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); - } - } - ts.createCommentWriter = createCommentWriter; -})(ts || (ts = {})); var ts; (function (ts) { var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); + var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. @@ -80866,7 +81182,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 278 /* Bundle */) { + if (sourceFile.kind === 280 /* Bundle */) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); @@ -80928,22 +81244,16 @@ var ts; var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); - var newLine = host.getNewLine(); + var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); - var sourceMap = ts.createSourceMapWriter(host, writer); - var declarationSourceMap = ts.createSourceMapWriter(host, writer, { - sourceMap: compilerOptions.declarationMap, - sourceRoot: compilerOptions.sourceRoot, - mapRoot: compilerOptions.mapRoot, - extendedDiagnostics: compilerOptions.extendedDiagnostics, - }); + var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; var bundleInfo = createDefaultBundleInfo(); var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file - ts.performance.mark("beforePrint"); + enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); - ts.performance.measure("printTime", "beforePrint"); + exit(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -80986,22 +81296,27 @@ var ts; } // Transform the source files var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], transformers, /*allowDtsFiles*/ false); + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: compilerOptions.noEmitHelpers, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + inlineSources: compilerOptions.inlineSources, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }; // Create a printer to print the nodes - var printer = createPrinter(__assign({}, compilerOptions, { noEmitHelpers: compilerOptions.noEmitHelpers }), { + var printer = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, // transform hooks onEmitNode: transform.emitNodeWithNotification, substituteNode: transform.substituteNode, - // sourcemap hooks - onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: sourceMap.emitPos, - // emitter hooks - onSetSourceFile: setSourceFile, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, sourceMap); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); } @@ -81025,14 +81340,20 @@ var ts; emitterDiagnostics.add(diagnostic); } } - var declarationPrinter = createPrinter(__assign({}, compilerOptions, { onlyPrintJsDocStyle: true, noEmitHelpers: true }), { + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: true, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + onlyPrintJsDocStyle: true, + }; + var declarationPrinter = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, - // sourcemap hooks - onEmitSourceMapOfNode: declarationSourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: declarationSourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: declarationSourceMap.emitPos, - onSetSourceFile: setSourceFileForDeclarationSourceMaps, // transform hooks onEmitNode: declarationTransform.emitNodeWithNotification, substituteNode: declarationTransform.substituteNode, @@ -81041,8 +81362,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, declarationSourceMap); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 277 /* SourceFile */) { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + sourceMap: compilerOptions.declarationMap, + sourceRoot: compilerOptions.sourceRoot, + mapRoot: compilerOptions.mapRoot, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }); + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -81051,7 +81377,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -81062,25 +81388,41 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; - mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); + var sourceMapGenerator; + if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { + sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); + } if (bundle) { - printer.writeBundle(bundle, writer, bundleInfo); + printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); } else { - printer.writeFile(sourceFile, writer); + printer.writeFile(sourceFile, writer, sourceMapGenerator); } - writer.writeLine(); - var sourceMappingURL = mapRecorder.getSourceMappingURL(); - if (sourceMappingURL) { - writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + if (sourceMapGenerator) { + if (sourceMapDataList) { + sourceMapDataList.push({ + inputSourceFileNames: sourceMapGenerator.getSources(), + sourceMap: sourceMapGenerator.toJSON() + }); + } + var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile); + if (sourceMappingURL) { + if (!writer.isAtStartOfLine()) + writer.rawWrite(newLine); + writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + } + // Write the source map + if (sourceMapFilePath) { + var sourceMap = sourceMapGenerator.toString(); + ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); + } } - // Write the source map - if (sourceMapFilePath) { - ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); + else { + writer.writeLine(); } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); @@ -81090,32 +81432,84 @@ var ts; ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); } // Reset state - mapRecorder.reset(); writer.clear(); bundleInfo = createDefaultBundleInfo(); } - function setSourceFile(node) { - sourceMap.setSourceFile(node); + function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { + return (mapOptions.sourceMap || mapOptions.inlineSourceMap) + && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } - function setSourceFileForDeclarationSourceMaps(node) { - declarationSourceMap.setSourceFile(node); + function getSourceRoot(mapOptions) { + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); + return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot; + } + function getSourceMapDirectory(mapOptions, filePath, sourceFile) { + if (mapOptions.sourceRoot) + return host.getCommonSourceDirectory(); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + } + return sourceMapDir; + } + return ts.getDirectoryPath(ts.normalizePath(filePath)); + } + function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) { + if (mapOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var sourceMapText = sourceMapGenerator.toString(); + var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); + return "data:application/json;base64," + base64SourceMapText; + } + var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath))); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapFile), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + return ts.combinePaths(sourceMapDir, sourceMapFile); + } + } + return sourceMapFile; } } ts.emitFiles = emitFiles; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; - PipelinePhase[PipelinePhase["Comments"] = 1] = "Comments"; - PipelinePhase[PipelinePhase["SourceMaps"] = 2] = "SourceMaps"; - PipelinePhase[PipelinePhase["Emit"] = 3] = "Emit"; + PipelinePhase[PipelinePhase["Substitution"] = 1] = "Substitution"; + PipelinePhase[PipelinePhase["Comments"] = 2] = "Comments"; + PipelinePhase[PipelinePhase["SourceMaps"] = 3] = "SourceMaps"; + PipelinePhase[PipelinePhase["Emit"] = 4] = "Emit"; })(PipelinePhase || (PipelinePhase = {})); function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); - var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var moduleKind = ts.getEmitModuleKind(printerOptions); + var bundledHelpers = ts.createMap(); var currentSourceFile; var nodeIdToGeneratedName; // Map of generated names for specific nodes. var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. @@ -81125,19 +81519,23 @@ var ts; var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes. var reservedNames; // TempFlags to reserve in nested name generation scopes. var writer; - var ownWriter; + var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; - var commitPendingSemicolon = ts.noop; - var writeSemicolon = writeSemicolonInternal; - var pendingSemicolon = false; - if (printerOptions.omitTrailingSemicolon) { - commitPendingSemicolon = commitPendingSemicolonInternal; - writeSemicolon = deferWriteSemicolon; - } - var syntheticParent = { pos: -1, end: -1 }; - var moduleKind = ts.getEmitModuleKind(printerOptions); - var bundledHelpers = ts.createMap(); var isOwnFileEmit; + // Source Maps + var sourceMapsDisabled = true; + var sourceMapGenerator; + var sourceMapSource; + var sourceMapSourceIndex = -1; + // Comments + var containerPos = -1; + var containerEnd = -1; + var declarationListContainerEnd = -1; + var currentLineMap; + var detachedCommentsInfo; + var hasWrittenComment = false; + var commentsDisabled = !!printerOptions.removeComments; + var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { // public API @@ -81164,9 +81562,9 @@ var ts; break; } switch (node.kind) { - case 277 /* SourceFile */: return printFile(node); - case 278 /* Bundle */: return printBundle(node); - case 279 /* UnparsedSource */: return printUnparsedSource(node); + case 279 /* SourceFile */: return printFile(node); + case 280 /* Bundle */: return printBundle(node); + case 281 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -81176,11 +81574,11 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, beginPrint()); + writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { - writeFile(sourceFile, beginPrint()); + writeFile(sourceFile, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printUnparsedSource(unparsed) { @@ -81189,14 +81587,14 @@ var ts; } function writeNode(hint, node, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(hint, node, sourceFile); reset(); writer = previousWriter; } function writeList(format, nodes, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); if (sourceFile) { setSourceFile(sourceFile); } @@ -81204,18 +81602,18 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, output, bundleInfo) { + function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { isOwnFileEmit = false; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(bundle); emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { var prepend = _b[_a]; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); writeLine(); + print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); } if (bundleInfo) { bundleInfo.originalOffset = writer.getTextPos(); @@ -81229,15 +81627,15 @@ var ts; } function writeUnparsedSource(unparsed, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } - function writeFile(sourceFile, output) { + function writeFile(sourceFile, output, sourceMapGenerator) { isOwnFileEmit = true; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); print(0 /* SourceFile */, sourceFile, sourceFile); @@ -81256,19 +81654,24 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, hint); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; - comments.setSourceFile(sourceFile); - if (onSetSourceFile) { - onSetSourceFile(sourceFile); + currentLineMap = undefined; + detachedCommentsInfo = undefined; + if (sourceFile) { + setSourceMapSource(sourceFile); } } - function setWriter(output) { - writer = output; // TODO: GH#18217 - comments.setWriter(output); + function setWriter(_writer, _sourceMapGenerator) { + if (_writer && printerOptions.omitTrailingSemicolon) { + _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + } + writer = _writer; // TODO: GH#18217 + sourceMapGenerator = _sourceMapGenerator; + sourceMapsDisabled = !writer || !sourceMapGenerator; } function reset() { nodeIdToGeneratedName = []; @@ -81277,68 +81680,66 @@ var ts; tempFlagsStack = []; tempFlags = 0 /* Auto */; reservedNamesStack = []; - comments.reset(); - setWriter(/*output*/ undefined); + currentSourceFile = undefined; + currentLineMap = undefined; + detachedCommentsInfo = undefined; + setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); + } + function getCurrentLineMap() { + return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } function emit(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 4 /* Unspecified */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); } function emitIdentifierName(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 2 /* IdentifierName */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(2 /* IdentifierName */, node); } function emitExpression(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(1 /* Expression */, node); } - function getPipelinePhase(phase, hint) { + function getPipelinePhase(phase, node) { switch (phase) { case 0 /* Notification */: - if (onEmitNode) { + if (onEmitNode !== ts.noEmitNotification) { return pipelineEmitWithNotification; } // falls through - case 1 /* Comments */: - if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + case 1 /* Substitution */: + if (substituteNode !== ts.noEmitSubstitution) { + return pipelineEmitWithSubstitution; + } + // falls through + case 2 /* Comments */: + if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { return pipelineEmitWithComments; } - return pipelineEmitWithoutComments; - case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { + // falls through + case 3 /* SourceMaps */: + if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through - case 3 /* Emit */: + case 4 /* Emit */: return pipelineEmitWithHint; default: - return ts.Debug.assertNever(phase, "Unexpected value for PipelinePhase: " + phase); + return ts.Debug.assertNever(phase); } } - function getNextPipelinePhase(currentPhase, hint) { - return getPipelinePhase(currentPhase + 1, hint); + function getNextPipelinePhase(currentPhase, node) { + return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); - } - function pipelineEmitWithComments(hint, node) { - ts.Debug.assertDefined(emitNodeWithComments); - ts.Debug.assert(hint !== 0 /* SourceFile */); - emitNodeWithComments(hint, trySubstituteNode(hint, node), getNextPipelinePhase(1 /* Comments */, hint)); - } - function pipelineEmitWithoutComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Comments */, hint); - pipelinePhase(hint, trySubstituteNode(hint, node)); - } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */); - ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); + var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); + onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -81347,254 +81748,285 @@ var ts; return emitIdentifier(ts.cast(node, ts.isIdentifier)); if (hint === 3 /* MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + if (hint === 5 /* EmbeddedStatement */) { + ts.Debug.assertNode(node, ts.isEmptyStatement); + return emitEmptyStatement(/*isEmbeddedStatement*/ true); + } if (hint === 4 /* Unspecified */) { if (ts.isKeyword(node.kind)) return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return emitLiteral(node); - case 279 /* UnparsedSource */: + case 281 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return emitQualifiedName(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return emitTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return emitParameter(node); - case 150 /* Decorator */: + case 152 /* Decorator */: return emitDecorator(node); // Type members - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return emitPropertySignature(node); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return emitMethodSignature(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return emitConstructor(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return emitAccessorDeclaration(node); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return emitCallSignature(node); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return emitConstructSignature(node); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return emitIndexSignature(node); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return emitTypePredicate(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return emitTypeReference(node); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return emitFunctionType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return emitConstructorType(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return emitTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return emitTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return emitArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return emitTupleType(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return emitOptionalType(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return emitUnionType(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return emitIntersectionType(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return emitConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return emitInferType(node); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return emitParenthesizedType(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return emitThisType(); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return emitTypeOperator(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return emitMappedType(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return emitLiteralType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return emitImportTypeNode(node); - case 282 /* JSDocAllType */: - write("*"); + case 284 /* JSDocAllType */: + writePunctuation("*"); return; - case 283 /* JSDocUnknownType */: - write("?"); + case 285 /* JSDocUnknownType */: + writePunctuation("?"); return; - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 170 /* RestType */: - case 288 /* JSDocVariadicType */: + case 172 /* RestType */: + case 290 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return emitBindingElement(node); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return emitTemplateSpan(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 216 /* Block */: + case 218 /* Block */: return emitBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return emitVariableStatement(node); - case 218 /* EmptyStatement */: - return emitEmptyStatement(); - case 219 /* ExpressionStatement */: + case 220 /* EmptyStatement */: + return emitEmptyStatement(/*isEmbeddedStatement*/ false); + case 221 /* ExpressionStatement */: return emitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return emitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return emitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return emitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return emitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return emitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return emitForOfStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return emitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return emitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return emitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return emitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return emitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return emitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return emitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return emitTryStatement(node); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return emitClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return emitModuleBlock(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return emitCaseBlock(node); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return emitImportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return emitImportClause(node); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return emitNamespaceImport(node); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return emitNamedImports(node); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return emitImportSpecifier(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return emitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return emitExportDeclaration(node); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return emitNamedExports(node); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return emitExportSpecifier(node); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 10 /* JsxText */: + case 11 /* JsxText */: return emitJsxText(node); - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 261 /* JsxClosingElement */: - case 264 /* JsxClosingFragment */: + case 263 /* JsxClosingElement */: + case 266 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return emitJsxAttribute(node); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return emitJsxAttributes(node); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return emitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return emitDefaultClause(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return emitHeritageClause(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return emitEnumMember(node); - // JSDoc nodes (ignored) + // JSDoc nodes (only used in codefixes currently) + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + return emitJSDocPropertyLikeTag(node); + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 301 /* JSDocThisTag */: + case 298 /* JSDocEnumTag */: + return emitJSDocSimpleTypedTag(node); + case 295 /* JSDocAugmentsTag */: + return emitJSDocAugmentsTag(node); + case 303 /* JSDocTemplateTag */: + return emitJSDocTemplateTag(node); + case 304 /* JSDocTypedefTag */: + return emitJSDocTypedefTag(node); + case 297 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + case 293 /* JSDocSignature */: + return emitJSDocSignature(node); + case 292 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 296 /* JSDocClassTag */: + case 294 /* JSDocTag */: + return emitJSDocSimpleTag(node); + case 291 /* JSDocComment */: + return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; - node = trySubstituteNode(1 /* Expression */, node); + if (substituteNode !== ts.noEmitSubstitution) { + node = substituteNode(hint, node); + } } else if (ts.isToken(node)) { return writeTokenNode(node, writePunctuation); @@ -81604,89 +82036,90 @@ var ts; switch (node.kind) { // Literals case 8 /* NumericLiteral */: - return emitNumericLiteral(node); - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + return emitNumericOrBigIntLiteral(node); + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Reserved words - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 101 /* TrueKeyword */: - case 99 /* ThisKeyword */: - case 91 /* ImportKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 102 /* TrueKeyword */: + case 100 /* ThisKeyword */: + case 92 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return emitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return emitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return emitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return emitArrowFunction(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return emitDeleteExpression(node); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return emitVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return emitAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return emitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return emitConditionalExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return emitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return emitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return emitSpreadExpression(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return emitClassExpression(node); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: return emitAsExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return emitNonNullExpression(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return emitJsxElement(node); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return emitCommaList(node); } } @@ -81698,12 +82131,13 @@ var ts; writeSpace(); emit(node.constraint); } - function trySubstituteNode(hint, node) { - return node && substituteNode && substituteNode(hint, node) || node; + function pipelineEmitWithSubstitution(hint, node) { + var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); + pipelinePhase(hint, substituteNode(hint, node)); } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 278 /* Bundle */ ? node : undefined; + var bundle = node.kind === 280 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -81752,7 +82186,8 @@ var ts; // Literals/Pseudo-literals // // SyntaxKind.NumericLiteral - function emitNumericLiteral(node) { + // SyntaxKind.BigIntLiteral + function emitNumericOrBigIntLiteral(node) { emitLiteral(node); } // SyntaxKind.StringLiteral @@ -81764,7 +82199,7 @@ var ts; function emitLiteral(node) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -81782,7 +82217,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 26896 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -81793,7 +82228,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -81829,7 +82264,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -81851,7 +82286,7 @@ var ts; emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitPropertyDeclaration(node) { emitDecorators(node, node.decorators); @@ -81861,7 +82296,7 @@ var ts; emit(node.exclamationToken); emitTypeAnnotation(node.type); emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node); - writeSemicolon(); + writeTrailingSemicolon(); } function emitMethodSignature(node) { pushNameGenerationScope(node); @@ -81872,7 +82307,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitMethodDeclaration(node) { @@ -81891,7 +82326,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 158 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -81903,7 +82338,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitConstructSignature(node) { @@ -81915,7 +82350,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitIndexSignature(node) { @@ -81923,10 +82358,10 @@ var ts; emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitSemicolonClassElement() { - writeSemicolon(); + writeTrailingSemicolon(); } // // Types @@ -81953,22 +82388,22 @@ var ts; popNameGenerationScope(node); } function emitJSDocFunctionType(node) { - write("function"); + writeKeyword("function"); emitParameters(node, node.parameters); - write(":"); + writePunctuation(":"); emit(node.type); } function emitJSDocNullableType(node) { - write("?"); + writePunctuation("?"); emit(node.type); } function emitJSDocNonNullableType(node) { - write("!"); + writePunctuation("!"); emit(node.type); } function emitJSDocOptionalType(node) { emit(node.type); - write("="); + writePunctuation("="); } function emitConstructorType(node) { pushNameGenerationScope(node); @@ -81989,8 +82424,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineTypeLiteralMembers */ : 16449 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 262144 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -81999,23 +82434,23 @@ var ts; writePunctuation("]"); } function emitRestOrJSDocVariadicType(node) { - write("..."); + writePunctuation("..."); emit(node.type); } function emitTupleType(node) { writePunctuation("["); - emitList(node, node.elementTypes, 272 /* TupleTypeElements */); + emitList(node, node.elementTypes, 528 /* TupleTypeElements */); writePunctuation("]"); } function emitOptionalType(node) { emit(node.type); - write("?"); + writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 260 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */); } function emitIntersectionType(node) { - emitList(node, node.types, 264 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */); } function emitConditionalType(node) { emit(node.checkType); @@ -82068,25 +82503,25 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 3 /* MappedTypeParameter */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 55 /* QuestionToken */) { + if (node.questionToken.kind !== 56 /* QuestionToken */) { writePunctuation("?"); } } writePunctuation(":"); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); if (emitFlags & 1 /* SingleLine */) { writeSpace(); } @@ -82119,12 +82554,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 262448 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -82142,8 +82577,8 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -82151,9 +82586,9 @@ var ts; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + 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); if (indentedFlag) { decreaseIndent(); } @@ -82164,20 +82599,20 @@ var ts; if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = ts.createToken(23 /* DotToken */); + var dotToken = ts.createToken(24 /* DotToken */); dotToken.pos = dotRangeStart; dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } emitExpression(node.expression); - increaseIndentIf(indentBeforeDot); + increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(23 /* DotToken */, node.expression.end, writePunctuation, node); - increaseIndentIf(indentAfterDot); + emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } @@ -82189,7 +82624,7 @@ var ts; // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); return !expression.numericLiteralFlags - && !ts.stringContains(text, ts.tokenToString(23 /* DotToken */)); + && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -82202,21 +82637,21 @@ var ts; } function emitElementAccessExpression(node) { emitExpression(node.expression); - emitTokenWithComment(21 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(22 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(94 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(95 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { emitExpression(node.tag); @@ -82231,9 +82666,9 @@ var ts; emitExpression(node.expression); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(19 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -82252,22 +82687,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(80 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(103 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(105 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(121 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(122 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -82292,24 +82727,24 @@ 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 === 200 /* PrefixUnaryExpression */ - && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) - || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); + return operand.kind === 202 /* PrefixUnaryExpression */ + && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) + || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator, writeOperator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 26 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); - increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 93 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - increaseIndentIf(indentAfterOperator, " "); + increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); } @@ -82319,23 +82754,23 @@ var ts; var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken); var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); - increaseIndentIf(indentBeforeQuestion, " "); + increaseIndentIf(indentBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); - increaseIndentIf(indentAfterQuestion, " "); + increaseIndentIf(indentAfterQuestion, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); - increaseIndentIf(indentBeforeColon, " "); + increaseIndentIf(indentBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); - increaseIndentIf(indentAfterColon, " "); + increaseIndentIf(indentAfterColon, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 131072 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(116 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(117 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -82383,38 +82818,45 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineBlockStatements */ : 65 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(18 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); emit(node.declarationList); - writeSemicolon(); + writeTrailingSemicolon(); } - function emitEmptyStatement() { - writeSemicolon(); + function emitEmptyStatement(isEmbeddedStatement) { + // While most trailing semicolons are possibly insignificant, an embedded "empty" + // statement is significant and cannot be elided by a trailing-semicolon-omitting writer. + if (isEmbeddedStatement) { + writePunctuation(";"); + } + else { + writeTrailingSemicolon(); + } } function emitExpressionStatement(node) { emitExpression(node.expression); // 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)) { - writeSemicolon(); + writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(91 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 220 /* IfStatement */) { + emitTokenWithComment(83 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 222 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -82424,14 +82866,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(106 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(81 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -82447,45 +82889,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.condition ? node.condition.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(20 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(92 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(93 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(147 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 236 /* VariableDeclarationList */) { + if (node.kind === 238 /* VariableDeclarationList */) { emit(node); } else { @@ -82494,14 +82936,14 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(77 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(78 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(72 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(73 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) { var node = ts.getParseTreeNode(contextNode); @@ -82527,40 +82969,40 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(96 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(97 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(107 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(108 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(98 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(56 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(100 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(101 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(102 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -82569,14 +83011,14 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(87 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(88 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(78 /* DebuggerKeyword */, node.pos, writeKeyword); - writeSemicolon(); + writeToken(79 /* DebuggerKeyword */, node.pos, writeKeyword); + writeTrailingSemicolon(); } // // Declarations @@ -82589,7 +83031,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 272 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -82637,7 +83079,7 @@ var ts; } else { emitSignatureHead(node); - writeSemicolon(); + writeTrailingSemicolon(); } } function emitSignatureHead(node) { @@ -82689,7 +83131,7 @@ var ts; emitBlockFunctionBody(body); } decreaseIndent(); - writeToken(18 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -82701,7 +83143,7 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); increaseIndent(); } else { @@ -82728,7 +83170,7 @@ var ts; emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* ClassMembers */); + emitList(node, node.members, 129 /* ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -82741,10 +83183,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 256 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* InterfaceMembers */); + emitList(node, node.members, 129 /* InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -82758,7 +83200,7 @@ var ts; writePunctuation("="); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitEnumDeclaration(node) { emitModifiers(node, node.modifiers); @@ -82767,7 +83209,7 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 81 /* EnumMembers */); + emitList(node, node.members, 145 /* EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { @@ -82779,8 +83221,8 @@ var ts; emit(node.name); var body = node.body; if (!body) - return writeSemicolon(); - while (body.kind === 242 /* ModuleDeclaration */) { + return writeTrailingSemicolon(); + while (body.kind === 244 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -82795,23 +83237,23 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 65 /* CaseBlockClauses */); - emitTokenWithComment(18 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* CaseBlockClauses */); + emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(59 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); - writeSemicolon(); + writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -82820,29 +83262,29 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); - writeSemicolon(); + writeTrailingSemicolon(); } function emitImportClause(node) { emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(26 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(39 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -82853,45 +83295,45 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(58 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(59 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(79 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(80 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(39 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(118 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(119 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(130 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(131 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamedExports(node) { emitNamedImportsOrExports(node); @@ -82901,14 +83343,14 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -82927,7 +83369,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -82939,7 +83381,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -82954,7 +83396,6 @@ var ts; writePunctuation(">"); } function emitJsxText(node) { - commitPendingSemicolon(); writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); } function emitJsxClosingElementOrFragment(node) { @@ -82965,7 +83406,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 131328 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -82985,7 +83426,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -82996,13 +83437,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(73 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(74 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(79 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(80 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -83012,14 +83453,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 81985 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 64 /* Indented */); + format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -83027,15 +83468,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 272 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(74 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(75 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(20 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -83084,6 +83525,142 @@ var ts; emitInitializer(node.initializer, node.name.end, node); } // + // JSDoc + // + function emitJSDoc(node) { + write("/**"); + if (node.comment) { + var lines = node.comment.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } + } + if (node.tags) { + if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + writeSpace(); + emit(node.tags[0]); + } + else { + emitList(node, node.tags, 33 /* JSDocComment */); + } + } + writeSpace(); + write("*/"); + } + function emitJSDocSimpleTypedTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.typeExpression); + emitJSDocComment(tag.comment); + } + function emitJSDocAugmentsTag(tag) { + emitJSDocTagName(tag.tagName); + writeSpace(); + writePunctuation("{"); + emit(tag.class); + writePunctuation("}"); + emitJSDocComment(tag.comment); + } + function emitJSDocTemplateTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.constraint); + writeSpace(); + emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitJSDocComment(tag.comment); + } + function emitJSDocTypedefTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.typeExpression) { + if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + emitJSDocTypeExpression(tag.typeExpression); + } + else { + writeSpace(); + writePunctuation("{"); + write("Object"); + if (tag.typeExpression.isArrayType) { + writePunctuation("["); + writePunctuation("]"); + } + writePunctuation("}"); + } + } + if (tag.fullName) { + writeSpace(); + emit(tag.fullName); + } + emitJSDocComment(tag.comment); + if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + emitJSDocTypeLiteral(tag.typeExpression); + } + } + function emitJSDocCallbackTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.name) { + writeSpace(); + emit(tag.name); + } + emitJSDocComment(tag.comment); + emitJSDocSignature(tag.typeExpression); + } + function emitJSDocSimpleTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocComment(tag.comment); + } + function emitJSDocTypeLiteral(lit) { + emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + } + function emitJSDocSignature(sig) { + if (sig.typeParameters) { + emitList(sig, ts.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + } + if (sig.parameters) { + emitList(sig, ts.createNodeArray(sig.parameters), 33 /* JSDocComment */); + } + if (sig.type) { + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + emit(sig.type); + } + } + function emitJSDocPropertyLikeTag(param) { + emitJSDocTagName(param.tagName); + emitJSDocTypeExpression(param.typeExpression); + writeSpace(); + if (param.isBracketed) { + writePunctuation("["); + } + emit(param.name); + if (param.isBracketed) { + writePunctuation("]"); + } + emitJSDocComment(param.comment); + } + function emitJSDocTagName(tagName) { + writePunctuation("@"); + emit(tagName); + } + function emitJSDocComment(comment) { + if (comment) { + writeSpace(); + write(comment); + } + } + function emitJSDocTypeExpression(typeExpression) { + if (typeExpression) { + writeSpace(); + writePunctuation("{"); + emit(typeExpression.type); + writePunctuation("}"); + } + } + // // Top-level nodes // function emitSourceFile(node) { @@ -83111,38 +83688,38 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - write("/// "); + writeComment("/// "); } else { - write("/// "); + writeComment("/// "); } writeLine(); } } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; - write("/// "); + writeComment("/// "); writeLine(); } - for (var _d = 0, types_16 = types; _d < types_16.length; _d++) { - var directive = types_16[_d]; - write("/// "); + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; + writeComment("/// "); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; - write("/// "); + writeComment("/// "); writeLine(); } } @@ -83161,7 +83738,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 272 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -83201,13 +83778,14 @@ var ts; setSourceFile(sourceFile); emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); } + setSourceFile(undefined); } } function emitShebangIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { - write(shebang); + writeComment(shebang); writeLine(); return true; } @@ -83235,7 +83813,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 131328 /* Modifiers */); + emitList(node, modifiers, 262656 /* Modifiers */); writeSpace(); } } @@ -83249,7 +83827,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(59 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -83286,24 +83864,30 @@ var ts; else { writeLine(); increaseIndent(); - emit(node); + if (ts.isEmptyStatement(node)) { + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); + pipelinePhase(5 /* EmbeddedStatement */, node); + } + else { + emit(node); + } decreaseIndent(); } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 24577 /* Decorators */); + emitList(parentNode, decorators, 49153 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 26896 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */); } 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, 26896 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 1296 /* Parameters */); + emitList(parentNode, parameters, 2576 /* Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -83324,14 +83908,14 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 1296 /* Parameters */ & ~1024 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 4432 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } function emitList(parentNode, children, format, start, count) { emitNodeList(emit, parentNode, children, format, start, count); @@ -83340,7 +83924,7 @@ var ts; emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { - switch (format & 28 /* DelimitersMask */) { + switch (format & 60 /* DelimitersMask */) { case 0 /* None */: break; case 16 /* CommaDelimited */: @@ -83350,6 +83934,11 @@ var ts; writeSpace(); writePunctuation("|"); break; + case 32 /* AsteriskDelimited */: + writeSpace(); + writePunctuation("*"); + writeSpace(); + break; case 8 /* AmpersandDelimited */: writeSpace(); writePunctuation("&"); @@ -83360,11 +83949,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 & 8192 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 16384 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -83373,7 +83962,7 @@ var ts; } return; } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { // TODO: GH#18217 @@ -83388,23 +83977,23 @@ var ts; if (format & 1 /* MultiLine */) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */ && !(format & 262144 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { writeSpace(); } } else { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { increaseIndent(); } // Emit each child. @@ -83413,14 +84002,19 @@ 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 (previousSibling) { + if (format & 32 /* AsteriskDelimited */) { + // always write JSDoc in the format "\n *" + writeLine(); + writeDelimiter(format); + } + else if (previousSibling) { // i.e // function commentedParameters( // /* Parameter a */ // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -83428,14 +84022,14 @@ var ts; if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 64 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 256 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { writeSpace(); } } @@ -83457,7 +84051,7 @@ var ts; previousSibling = child; } // Write a trailing comma, if requested. - var hasTrailingComma = (format & 32 /* AllowTrailingComma */) && children.hasTrailingComma; + var hasTrailingComma = (format & 64 /* AllowTrailingComma */) && children.hasTrailingComma; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { writePunctuation(","); } @@ -83467,25 +84061,25 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { + if (previousSibling && format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { emitLeadingCommentsOfPosition(previousSibling.end); } // Decrease the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { decreaseIndent(); } // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { if (isEmpty && !isUndefined) { // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists @@ -83493,73 +84087,55 @@ var ts; writePunctuation(getClosingBracket(format)); } } - function commitPendingSemicolonInternal() { - if (pendingSemicolon) { - writeSemicolonInternal(); - pendingSemicolon = false; - } - } + // Writers function writeLiteral(s) { - commitPendingSemicolon(); writer.writeLiteral(s); } function writeStringLiteral(s) { - commitPendingSemicolon(); writer.writeStringLiteral(s); } function writeBase(s) { - commitPendingSemicolon(); writer.write(s); } function writeSymbol(s, sym) { - commitPendingSemicolon(); writer.writeSymbol(s, sym); } function writePunctuation(s) { - commitPendingSemicolon(); writer.writePunctuation(s); } - function deferWriteSemicolon() { - pendingSemicolon = true; - } - function writeSemicolonInternal() { - writer.writePunctuation(";"); + function writeTrailingSemicolon() { + writer.writeTrailingSemicolon(";"); } function writeKeyword(s) { - commitPendingSemicolon(); writer.writeKeyword(s); } function writeOperator(s) { - commitPendingSemicolon(); writer.writeOperator(s); } function writeParameter(s) { - commitPendingSemicolon(); writer.writeParameter(s); } + function writeComment(s) { + writer.writeComment(s); + } function writeSpace() { - commitPendingSemicolon(); writer.writeSpace(" "); } function writeProperty(s) { - commitPendingSemicolon(); writer.writeProperty(s); } function writeLine() { - commitPendingSemicolon(); writer.writeLine(); } function increaseIndent() { - commitPendingSemicolon(); writer.increaseIndent(); } function decreaseIndent() { - commitPendingSemicolon(); writer.decreaseIndent(); } function writeToken(token, pos, writer, contextNode) { - return onEmitSourceMapOfToken - ? onEmitSourceMapOfToken(contextNode, token, writer, pos, writeTokenText) + return !sourceMapsDisabled + ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText) : writeTokenText(token, writer, pos); } function writeTokenNode(node, writer) { @@ -83587,23 +84163,23 @@ var ts; function writeLines(text) { var lines = text.split(/\r\n?|\n/g); var indentation = ts.guessIndentation(lines); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var lineText = lines_2[_a]; + for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) { + var lineText = lines_3[_a]; var line = indentation ? lineText.slice(indentation) : lineText; if (line.length) { writeLine(); write(line); - writeLine(); + writer.rawWrite(newLine); } } } - function increaseIndentIf(value, valueToWriteWhenNotIndenting) { + function increaseIndentIf(value, writeSpaceIfNotIndenting) { if (value) { increaseIndent(); writeLine(); } - else if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); + else if (writeSpaceIfNotIndenting) { + writeSpace(); } } // Helper function to decrease the indent if we previously indented. Allows multiple @@ -83623,7 +84199,7 @@ var ts; return true; } if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var firstChild = children[0]; @@ -83662,10 +84238,10 @@ var ts; } function shouldWriteClosingLineTerminator(parentNode, children, format) { if (format & 1 /* MultiLine */) { - return (format & 65536 /* NoTrailingNewLine */) === 0; + return (format & 131072 /* NoTrailingNewLine */) === 0; } else if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var lastChild = ts.lastOrUndefined(children); @@ -83687,11 +84263,11 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { parent = skipSynthesizedParentheses(parent); @@ -83711,7 +84287,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -83723,7 +84299,7 @@ var ts; else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { return ts.idText(node); } - else if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { @@ -83732,7 +84308,7 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape) { - if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode)) { return neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? @@ -83776,81 +84352,81 @@ var ts; if (!node) return; switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: ts.forEach(node.statements, generateNames); break; - case 231 /* LabeledStatement */: - case 229 /* WithStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 233 /* LabeledStatement */: + case 231 /* WithStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: generateNames(node.statement); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: generateNames(node.declarationList); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: generateNames(node.importClause); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -83859,12 +84435,12 @@ var ts; if (!node) return; switch (node.kind) { - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -84044,23 +84620,23 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 254 /* ExportAssignment */: return generateNameForExportDefault(); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return generateNameForClassExpression(); - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -84101,21 +84677,396 @@ var ts; // otherwise, return the original node for the source; return node; } + // Comments + function pipelineEmitWithComments(hint, node) { + enterComment(); + hasWrittenComment = false; + var emitFlags = ts.getEmitFlags(node); + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + // 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 */; + // Save current container state on the stack. + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + 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); + } + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* 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)) { + // 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 === 238 /* VariableDeclarationList */) { + declarationListContainerEnd = end; + } + } + } + ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); + exitComment(); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, node); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + pipelinePhase(hint, node); + commentsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + enterComment(); + ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); + if ((pos > 0 || end > 0) && pos !== end) { + // Restore previous container state. + containerPos = savedContainerPos; + containerEnd = savedContainerEnd; + 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 && isEmittedNode) { + emitTrailingComments(end); + } + } + exitComment(); + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 /* MultiLineCommentTrivia */ + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { + 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; + if (!skipLeadingComments) { + emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); + } + exitComment(); + if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + commentsDisabled = true; + emitCallback(node); + commentsDisabled = false; + } + else { + emitCallback(node); + } + enterComment(); + if (!skipTrailingComments) { + emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); + if (hasWrittenComment && !writer.isAtStartOfLine()) { + writer.writeLine(); + } + } + exitComment(); + } + function emitLeadingComments(pos, isEmittedNode) { + hasWrittenComment = false; + if (isEmittedNode) { + forEachLeadingCommentToEmit(pos, emitLeadingComment); + } + else if (pos === 0) { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted + forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); + } + } + function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (isTripleSlashComment(commentPos, commentEnd)) { + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + } + } + function shouldWriteComment(text, pos) { + if (printerOptions.onlyPrintJsDocStyle) { + return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); + } + return true; + } + function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + if (!hasWrittenComment) { + ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); + hasWrittenComment = true; + } + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + else if (kind === 3 /* MultiLineCommentTrivia */) { + writer.writeSpace(" "); + } + } + function emitLeadingCommentsOfPosition(pos) { + if (commentsDisabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } + function emitTrailingComments(pos) { + forEachTrailingCommentToEmit(pos, emitTrailingComment); + } + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + } + function emitTrailingCommentsOfPosition(pos, prefixSpace) { + if (commentsDisabled) { + return; + } + enterComment(); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); + exitComment(); + } + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + // 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 (hasTrailingNewLine) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function forEachLeadingCommentToEmit(pos, cb) { + // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) { + if (hasDetachedComments(pos)) { + forEachLeadingCommentWithoutDetachedComments(cb); + } + else { + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + } + } + function forEachTrailingCommentToEmit(end, cb) { + // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) { + ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; + } + function forEachLeadingCommentWithoutDetachedComments(cb) { + // get the leading comments from detachedPos + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + function emitDetachedCommentsAndUpdateCommentsInfo(range) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + emitPos(commentPos); + ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + */ + function isTripleSlashComment(commentPos, commentEnd) { + return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + } + // Source Maps + function pipelineEmitWithSourceMap(hint, node) { + var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); + if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { + var parsed = ts.tryParseRawSourceMap(node.sourceMapText); + if (parsed) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + } + pipelinePhase(hint, node); + } + else { + var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; + var emitFlags = ts.getEmitFlags(node); + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + && pos >= 0) { + emitSourcePos(source, skipSourceTrivia(source, pos)); + } + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = true; + pipelinePhase(hint, node); + sourceMapsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + && end >= 0) { + emitSourcePos(source, end); + } + } + } + /** + * Skips trivia such as comments and white-space that can optionally overriden by the source map source + */ + function skipSourceTrivia(source, pos) { + return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(sourceMapSource.text, pos); + } + /** + * Emits a mapping. + * + * If the position is synthetic (undefined or a negative value), no mapping will be + * created. + * + * @param pos The position. + */ + function emitPos(pos) { + if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) { + return; + } + var _a = ts.getLineAndCharacterOfPosition(currentSourceFile, pos), sourceLine = _a.line, sourceCharacter = _a.character; + sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, + /*nameIndex*/ undefined); + } + function emitSourcePos(source, pos) { + if (source !== sourceMapSource) { + var savedSourceMapSource = sourceMapSource; + setSourceMapSource(source); + emitPos(pos); + setSourceMapSource(savedSourceMapSource); + } + else { + emitPos(pos); + } + } + /** + * Emits a token of a node with possible leading and trailing source maps. + * + * @param node The node containing the token. + * @param token The token to emit. + * @param tokenStartPos The start pos of the token. + * @param emitCallback The callback used to emit the token. + */ + function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { + if (sourceMapsDisabled || node && ts.isInJsonFile(node)) { + return emitCallback(token, writer, tokenPos); + } + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags || 0 /* 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) { + emitSourcePos(source, tokenPos); + } + tokenPos = emitCallback(token, writer, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + emitSourcePos(source, tokenPos); + } + return tokenPos; + } + function setSourceMapSource(source) { + if (sourceMapsDisabled) { + return; + } + sourceMapSource = source; + if (isJsonSourceMapSource(source)) { + return; + } + sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName); + if (printerOptions.inlineSources) { + sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text); + } + } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* Braces */] = ["{", "}"]; + brackets[2048 /* Parenthesis */] = ["(", ")"]; + brackets[4096 /* AngleBrackets */] = ["<", ">"]; + brackets[8192 /* SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; + return brackets[format & 15360 /* BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; + return brackets[format & 15360 /* BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -84810,7 +85761,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function loadWithLocalCache(names, containingFile, loader) { + function loadWithLocalCache(names, containingFile, redirectedReference, loader) { if (names.length === 0) { return []; } @@ -84823,7 +85774,7 @@ var ts; result = cache.get(name); } else { - cache.set(name, result = loader(name, containingFile)); + cache.set(name, result = loader(name, containingFile, redirectedReference)); } resolutions.push(result); } @@ -84842,6 +85793,7 @@ var ts; if (program.getRootFileNames().length !== rootFileNames.length) { return false; } + var seenResolvedRefs; // If project references dont match if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { return false; @@ -84867,7 +85819,7 @@ var ts; return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || - hasInvalidatedResolution(sourceFile.resolvedPath); + hasInvalidatedResolution(sourceFile.path); } function sourceFileVersionUptoDate(sourceFile) { return sourceFile.version === getSourceVersion(sourceFile.resolvedPath); @@ -84876,10 +85828,24 @@ var ts; if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { return false; } - var oldResolvedRef = program.getResolvedProjectReferences()[index]; + return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + } + function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { + if (ts.contains(seenResolvedRefs, oldResolvedRef)) { + // Assume true + return true; + } // If sourceFile for the oldResolvedRef existed, check the version for uptodate - return sourceFileVersionUptoDate(oldResolvedRef.sourceFile); + if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + return false; + } + // Add to seen before checking the referenced paths of this config file + (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); + // If child project references are upto date, this project reference is uptodate + return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) { + return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]); + }); } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. @@ -84926,7 +85892,7 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; - var modifiedFilePaths; + var ambientModuleNameToUnmodifiedFileName = ts.createMap(); var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -84958,12 +85924,11 @@ var ts; // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createMap(); var _compilerOptionsObjectLiteralSyntax; - var _referencesArrayLiteralSyntax; var moduleResolutionCache; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -84975,16 +85940,16 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 - resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; + var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 + resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, 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). @@ -85000,7 +85965,7 @@ var ts; // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; // A parallel array to projectReferences storing the results of reading in the referenced tsconfig files - var resolvedProjectReferences = projectReferences ? [] : undefined; + var resolvedProjectReferences; var projectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -85008,23 +85973,25 @@ var ts; processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { - for (var _i = 0, projectReferences_1 = projectReferences; _i < projectReferences_1.length; _i++) { - var ref = projectReferences_1[_i]; - var parsedRef = parseProjectReferenceConfigFile(ref); - resolvedProjectReferences.push(parsedRef); - if (parsedRef) { - var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - var dtsOutfile = ts.changeExtension(out, ".d.ts"); - processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (!resolvedProjectReferences) { + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + } + if (rootNames.length) { + for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { + var parsedRef = resolvedProjectReferences_1[_i]; + if (parsedRef) { + var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; + if (out) { + var dtsOutfile = ts.changeExtension(out, ".d.ts"); + processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } - addProjectReferenceRedirects(parsedRef.commandLine); } } } ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false); }); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); @@ -85038,7 +86005,7 @@ var ts; // - The '--noLib' flag is used. // - A 'no-default-lib' reference comment is encountered in // processing the root files. - if (!skipDefaultLib) { + if (rootNames.length && !skipDefaultLib) { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file var defaultLibraryFileName = getDefaultLibraryFileName(); @@ -85063,10 +86030,18 @@ var ts; var oldSourceFiles = oldProgram.getSourceFiles(); for (var _a = 0, oldSourceFiles_1 = oldSourceFiles; _a < oldSourceFiles_1.length; _a++) { var oldSourceFile = oldSourceFiles_1[_a]; - if (!getSourceFile(oldSourceFile.path) || shouldCreateNewSourceFile) { - host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions()); + var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); + if (shouldCreateNewSourceFile || !newFile || + // old file wasnt redirect but new file is + (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { + host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; @@ -85107,7 +86082,10 @@ var ts; getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, getProjectReferences: getProjectReferences, getResolvedProjectReferences: getResolvedProjectReferences, - getProjectReferenceRedirect: getProjectReferenceRedirect + getProjectReferenceRedirect: getProjectReferenceRedirect, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, + forEachResolvedProjectReference: forEachResolvedProjectReference }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -85170,13 +86148,13 @@ var ts; } return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) { if (structuralIsReused === 0 /* 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, containingFile); + return resolveModuleNamesWorker(moduleNames, containingFile, /*reusedNames*/ undefined, getResolvedProjectReferenceToRedirect(file.originalFileName)); } - var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile); + var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); if (oldSourceFile !== file && file.resolvedModules) { // `file` was created for the new program. // @@ -85239,7 +86217,7 @@ var ts; } } else { - resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName); } if (resolvesToAmbientModuleInNonModifiedFile) { (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; @@ -85250,7 +86228,7 @@ var ts; } } var resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames) + ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName)) : ts.emptyArray; // Combine results of resolutions and predicted results if (!result) { @@ -85276,12 +86254,9 @@ var ts; return result; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. - function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - if (!oldProgramState.program) { - return false; - } - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 - var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) { + var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName); + var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same // place as we expected to find an actual module file. @@ -85290,16 +86265,34 @@ var ts; return false; } // at least one of declarations should come from non-modified source file - var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); }); - if (!firstUnmodifiedFile) { + var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName); + if (!unmodifiedFile) { return false; } if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile); } return true; } } + function canReuseProjectReferences() { + return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) { + var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var newResolvedRef = parseProjectReferenceConfigFile(newRef); + if (oldResolvedRef) { + // Resolved project reference has gone missing or changed + return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + } + else { + // A previously-unresolved reference may be resolved now + return newResolvedRef !== undefined; + } + }, function (oldProjectReferences, parent) { + // If array of references is changed, we cant resue old program + var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences; + return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo); + }); + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return 0 /* Not */; @@ -85320,40 +86313,14 @@ var ts; return oldProgram.structureIsReused = 0 /* Not */; } // Check if any referenced project tsconfig files are different - // If array of references is changed, we cant resue old program - var oldProjectReferences = oldProgram.getProjectReferences(); - if (!ts.arrayIsEqualTo(oldProjectReferences, projectReferences, ts.projectReferenceIsEqualTo)) { + if (!canReuseProjectReferences()) { return oldProgram.structureIsReused = 0 /* Not */; } - // Check the json files for the project references - var oldRefs = oldProgram.getResolvedProjectReferences(); if (projectReferences) { - // Resolved project referenced should be array if projectReferences provided are array - ts.Debug.assert(!!oldRefs); - for (var i = 0; i < projectReferences.length; i++) { - var oldRef = oldRefs[i]; - var newRef = parseProjectReferenceConfigFile(projectReferences[i]); - if (oldRef) { - if (!newRef || newRef.sourceFile !== oldRef.sourceFile) { - // Resolved project reference has gone missing or changed - return oldProgram.structureIsReused = 0 /* Not */; - } - } - else { - // A previously-unresolved reference may be resolved now - if (newRef !== undefined) { - return oldProgram.structureIsReused = 0 /* Not */; - } - } - } - } - else { - // Resolved project referenced should be undefined if projectReferences is undefined - ts.Debug.assert(!oldRefs); + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2 /* Completely */; // If the missing file paths are now present, it can change the progam structure, @@ -85404,7 +86371,6 @@ var ts; newSourceFile.originalFileName = oldSourceFile.originalFileName; newSourceFile.resolvedPath = oldSourceFile.resolvedPath; newSourceFile.fileName = oldSourceFile.fileName; - filePaths.push(newSourceFile.path); 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, @@ -85465,15 +86431,23 @@ var ts; if (oldProgram.structureIsReused !== 2 /* Completely */) { return oldProgram.structureIsReused; } - modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); + for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) { + var oldFile = oldSourceFiles_3[_a]; + if (!ts.contains(modifiedFiles, oldFile)) { + for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) { + var moduleName = _c[_b]; + ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); + } + } + } // try to verify results of module resolution - for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { - var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; + for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { + var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = getModuleNames(newSourceFile); - var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { @@ -85487,7 +86461,7 @@ var ts; if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); if (resolutionsChanged) { @@ -85507,28 +86481,22 @@ var ts; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping - for (var i = 0; i < newSourceFiles.length; i++) { - filesByName.set(filePaths[i], newSourceFiles[i]); + for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { + var newSourceFile = newSourceFiles_1[_f]; + var filePath = newSourceFile.path; + addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); // Set the file as found during node modules search if it was found that way in old progra, - if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) { - sourceFilesFoundSearchingNodeModules.set(filePaths[i], true); + if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePath))) { + sourceFilesFoundSearchingNodeModules.set(filePath, true); } } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) { - var modifiedFile = modifiedSourceFiles_2[_c]; + for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) { + var modifiedFile = modifiedSourceFiles_2[_g]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - resolvedProjectReferences = oldProgram.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - resolvedProjectReferences.forEach(function (ref) { - if (ref) { - addProjectReferenceRedirects(ref.commandLine); - } - }); - } sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; return oldProgram.structureIsReused = 2 /* Completely */; @@ -85791,22 +86759,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 149 /* Parameter */: - case 152 /* PropertyDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 235 /* VariableDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 237 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -85814,41 +86782,41 @@ var ts; } } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 108 /* ImplementsKeyword */) { + if (heritageClause.token === 109 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -85861,51 +86829,51 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 240 /* ClassDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 219 /* VariableStatement */); } break; - case 152 /* PropertyDeclaration */: + case 154 /* 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 !== 115 /* StaticKeyword */) { + if (modifier.kind !== 116 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -85922,24 +86890,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 124 /* DeclareKeyword */: - case 117 /* AbstractKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 125 /* DeclareKeyword */: + case 118 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 115 /* StaticKeyword */: - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 116 /* StaticKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: } } } @@ -85987,10 +86955,22 @@ var ts; return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } function getOptionsDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), options.configFile ? programDiagnostics.getDiagnostics(options.configFile.fileName) : []))); + return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile()))); + } + function getOptionsDiagnosticsOfConfigFile() { + if (!options.configFile) { + return ts.emptyArray; + } + var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); + } + }); + return diagnostics; } function getGlobalDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); + return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray; } function getConfigFileParsingDiagnostics() { return configFileParsingDiagnostics || ts.emptyArray; @@ -86002,9 +86982,9 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 71 /* Identifier */ - ? b.kind === 71 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 9 /* StringLiteral */ && a.text === b.text; + return a.kind === 72 /* Identifier */ + ? b.kind === 72 /* Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -86032,12 +87012,9 @@ var ts; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(node); - } } if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(file.endOfFileToken); + collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; file.moduleAugmentations = moduleAugmentations || ts.emptyArray; @@ -86085,24 +87062,37 @@ var ts; } } } - function collectDynamicImportOrRequireCalls(node) { - if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { - imports = ts.append(imports, node.arguments[0]); - } - // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. - else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { - imports = ts.append(imports, node.arguments[0]); - } - else if (ts.isLiteralImportTypeNode(node)) { - imports = ts.append(imports, node.argument.literal); - } - collectDynamicImportOrRequireCallsForEachChild(node); - if (ts.hasJSDocNodes(node)) { - ts.forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild); + function collectDynamicImportOrRequireCalls(file) { + var r = /import|require/g; + while (r.exec(file.text) !== null) { + var node = getNodeAtPosition(file, r.lastIndex); + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { + imports = ts.append(imports, node.arguments[0]); + } + // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. + else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { + imports = ts.append(imports, node.arguments[0]); + } + else if (ts.isLiteralImportTypeNode(node)) { + imports = ts.append(imports, node.argument.literal); + } } } - function collectDynamicImportOrRequireCallsForEachChild(node) { - ts.forEachChild(node, collectDynamicImportOrRequireCalls); + /** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */ + 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 */)))) { + return child; + } + }; + while (true) { + var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild); + if (!child) { + return current; + } + current = child; + } } } function getLibFileFromReference(ref) { @@ -86264,7 +87254,7 @@ var ts; // Instead of creating a duplicate, just redirect to the existing one. var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 redirectTargetsMap.add(fileFromPackageId.path, fileName); - filesByName.set(path, dupFile); + addFileToFilesByName(dupFile, path, redirectedPath); sourceFileToPackageName.set(path, packageId.name); processingOtherFiles.push(dupFile); return dupFile; @@ -86275,10 +87265,7 @@ var ts; sourceFileToPackageName.set(path, packageId.name); } } - filesByName.set(path, file); - if (redirectedPath) { - filesByName.set(redirectedPath, file); - } + addFileToFilesByName(file, path, redirectedPath); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; @@ -86312,24 +87299,82 @@ var ts; } return file; } + function addFileToFilesByName(file, path, redirectedPath) { + filesByName.set(path, file); + if (redirectedPath) { + filesByName.set(redirectedPath, file); + } + } function getProjectReferenceRedirect(fileName) { // Ignore dts or any of the non ts files - if (!projectReferenceRedirects || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to // look in the output folder of the referenced project rather than the input - return ts.forEach(projectReferenceRedirects, function (referencedProject) { + var referencedProject = getResolvedProjectReferenceToRedirect(fileName); + if (!referencedProject) { + return undefined; + } + var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out; + return out ? + ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine); + } + /** + * Get the referenced project if the file is input file from that reference project + */ + function getResolvedProjectReferenceToRedirect(fileName) { + return forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) { // not input file from the referenced project, ignore - if (!ts.contains(referencedProject.fileNames, fileName, isSameFile)) { + if (!referencedProject || + toPath(options.configFilePath) === referenceProjectPath || + !ts.contains(referencedProject.commandLine.fileNames, fileName, isSameFile)) { return undefined; } - var out = referencedProject.options.outFile || referencedProject.options.out; - return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : - ts.getOutputDeclarationFileName(fileName, referencedProject); + return referencedProject; }); } + function forEachResolvedProjectReference(cb) { + return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var resolvedRefPath = toPath(resolveProjectReferencePath(ref)); + return cb(resolvedRef, resolvedRefPath); + }); + } + function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { + var seenResolvedRefs; + return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); + function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) { + // Visit project references first + if (cbRef) { + var result = cbRef(projectReferences, parent); + if (result) { + return result; + } + } + return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { + if (ts.contains(seenResolvedRefs, resolvedRef)) { + // ignore recursives + return undefined; + } + var result = cbResolvedRef(resolvedRef, index, parent); + if (result) { + return result; + } + if (!resolvedRef) + return undefined; + (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef); + return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef); + }); + } + } + function getResolvedProjectReferenceByPath(projectReferencePath) { + if (!projectReferenceRedirects) { + return undefined; + } + return projectReferenceRedirects.get(projectReferencePath) || undefined; + } function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); @@ -86342,7 +87387,7 @@ var ts; if (!typeDirectives) { return; } - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName)); for (var i = 0; i < typeDirectives.length; i++) { var ref = file.typeReferenceDirectives[i]; var resolvedTypeReferenceDirective = resolutions[i]; @@ -86360,6 +87405,8 @@ var ts; } var saveResolution = true; if (resolvedTypeReferenceDirective) { + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 @@ -86384,6 +87431,8 @@ var ts; processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth--; } else { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 @@ -86428,8 +87477,7 @@ var ts; if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); - var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file); ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; @@ -86497,20 +87545,34 @@ var ts; return allFilesBelongToPath; } function parseProjectReferenceConfigFile(ref) { + if (!projectReferenceRedirects) { + projectReferenceRedirects = ts.createMap(); + } // The actual filename (i.e. add "/tsconfig.json" if necessary) var refPath = resolveProjectReferencePath(ref); + var sourceFilePath = toPath(refPath); + var fromCache = projectReferenceRedirects.get(sourceFilePath); + if (fromCache !== undefined) { + return fromCache || undefined; + } // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); return undefined; } - sourceFile.path = toPath(refPath); + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; var commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); - return { commandLine: commandLine, sourceFile: sourceFile }; - } - function addProjectReferenceRedirects(referencedProject) { - (projectReferenceRedirects || (projectReferenceRedirects = [])).push(referencedProject); + var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile }; + projectReferenceRedirects.set(sourceFilePath, resolvedRef); + if (commandLine.projectReferences) { + resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile); + } + return resolvedRef; } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { @@ -86546,30 +87608,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } } - if (projectReferences) { - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i] && resolvedProjectReferences[i].commandLine.options; - if (resolvedRefOpts === undefined) { - createDiagnosticForReference(i, ts.Diagnostics.File_0_does_not_exist, ref.path); - continue; - } - if (!resolvedRefOpts.composite) { - createDiagnosticForReference(i, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); - } - if (ref.prepend) { - var out = resolvedRefOpts.outFile || resolvedRefOpts.out; - if (out) { - if (!host.fileExists(out)) { - createDiagnosticForReference(i, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); - } - } - else { - createDiagnosticForReference(i, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); - } - } - } - } + verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); @@ -86648,12 +87687,12 @@ var ts; } var languageVersion = options.target || 0 /* ES3 */; var outFile = options.outFile || options.out; - var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + 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 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } - var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); @@ -86691,7 +87730,7 @@ var ts; // Precalculate and cache the common source directory var dir = getCommonSourceDirectory(); // If we failed to find a good common directory, but outDir is specified and at least one of our files is on a windows drive/URL/other resource, add a failure - if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { + if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) { createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } @@ -86761,6 +87800,35 @@ var ts; } } } + function verifyProjectReferences() { + forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var parentFile = parent && parent.sourceFile; + if (!resolvedRef) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path); + return; + } + var options = resolvedRef.commandLine.options; + if (!options.composite) { + // ok to not have composite if the current program is container only + var inputs = parent ? parent.commandLine.fileNames : rootNames; + if (inputs.length) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); + } + } + if (ref.prepend) { + var out = options.outFile || options.out; + if (out) { + if (!host.fileExists(out)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); + } + } + else { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); + } + } + }); + } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { var needCompilerDiagnostic = true; var pathsSyntax = getOptionPathsSyntax(); @@ -86811,10 +87879,10 @@ var ts; function createOptionValueDiagnostic(option1, message, arg0) { createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0); } - function createDiagnosticForReference(index, message, arg0, arg1) { - var referencesSyntax = getProjectReferencesSyntax(); + function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) { + var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; }); if (referencesSyntax && referencesSyntax.elements.length > index) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); } else { programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1)); @@ -86828,22 +87896,6 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2)); } } - function getProjectReferencesSyntax() { - if (_referencesArrayLiteralSyntax === undefined) { - _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword - if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 - for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { - var prop = _a[_i]; - if (ts.isArrayLiteralExpression(prop.initializer)) { - _referencesArrayLiteralSyntax = prop.initializer; - break; - } - } - } - } - return _referencesArrayLiteralSyntax; - } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword @@ -86918,7 +87970,8 @@ var ts; readFile: function (f) { return host.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: function () { return undefined; } + onUnRecoverableConfigFileDiagnostic: function () { return undefined; }, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost; @@ -86968,7 +88021,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 === 9 /* StringLiteral */) { + if (aug.kind === 10 /* StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -87193,6 +88246,11 @@ var ts; var latestSignature; if (sourceFile.isDeclarationFile) { latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.path) : undefined; + exportedModulesMapCache.set(sourceFile.path, references || false); + } } else { var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); @@ -87258,7 +88316,7 @@ var ts; return getAllFileNames(state, programOfThisState); } // If this is non module emit, or its a global file, it depends on all the source files - if (!state.referencedMap || (!ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile))) { + if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) { return getAllFileNames(state, programOfThisState); } // Get the references, traversing deep from the referenceMap @@ -87317,6 +88375,20 @@ var ts; } return true; } + /** + * Return true if file contains anything that augments to global scope we need to build them as if + * they are global files as well as module + */ + function containsGlobalScopeAugmentation(sourceFile) { + return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); }); + } + /** + * Return true if the file will invalidate all files because it affectes global scope + */ + function isFileAffectingGlobalScope(sourceFile) { + return containsGlobalScopeAugmentation(sourceFile) || + !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + } /** * Gets all files of the program excluding the default library file */ @@ -87357,7 +88429,7 @@ var ts; * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { - if (!ts.isExternalModule(sourceFileWithUpdatedShape) && !containsOnlyAmbientModules(sourceFileWithUpdatedShape)) { + if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } var compilerOptions = programOfThisState.getCompilerOptions(); @@ -87407,8 +88479,9 @@ var ts; } state.changedFilesSet = ts.createMap(); var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); + var oldCompilerOptions = useOldState ? oldState.program.getCompilerOptions() : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && - !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldState.program.getCompilerOptions()); + !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions); if (useOldState) { // Verify the sanity of old state if (!oldState.currentChangedFilePath) { @@ -87423,6 +88496,8 @@ var ts; // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; + var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck; + var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -87440,6 +88515,13 @@ var ts; state.changedFilesSet.set(sourceFilePath, true); } else if (canCopySemanticDiagnostics) { + var sourceFile = state.program.getSourceFileByPath(sourceFilePath); + if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { + return; + } + if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { + return; + } // Unchanged file copy diagnostics var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath); if (diagnostics) { @@ -87523,18 +88605,31 @@ var ts; // If there are no more diagnostics from old cache, done return; } + // Clean lib file diagnostics if its all files excluding default files to emit + if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles && !state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var options_2 = state.program.getCompilerOptions(); + if (ts.forEach(state.program.getSourceFiles(), function (f) { + return state.program.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2) && + removeSemanticDiagnosticsOf(state, f.path); + })) { + return; + } + } // If there was change in signature for the changed file, // then delete the semantic diagnostics for files that are affected by using exports of this module if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { return; } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); + var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { return exportedModules && exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); })) { return; } @@ -87542,16 +88637,44 @@ var ts; ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** * removes the semantic diagnostics of files referencing referencedPath and * returns true if there are no more semantic diagnostics from old state */ - function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath) { + function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile) { return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) { - return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOf(state, filePath); + return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile); + }); + } + /** + * Removes semantic diagnostics of file and anything that exports this file + */ + function removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile) { + if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) { + return false; + } + if (removeSemanticDiagnosticsOf(state, filePath)) { + // If there are no more diagnostics from old cache, done + return true; + } + 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 + if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { + return exportedModules && + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); + })) { + return true; + } + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + return !!ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { + return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** @@ -87560,7 +88683,7 @@ var ts; */ function removeSemanticDiagnosticsOf(state, path) { if (!state.semanticDiagnosticsFromOldState) { - return false; + return true; } state.semanticDiagnosticsFromOldState.delete(path); state.semanticDiagnosticsPerFile.delete(path); @@ -87833,6 +88956,10 @@ var ts; /*@internal*/ var ts; (function (ts) { + function isPathInNodeModulesStartingWithDot(path) { + return ts.stringContains(path, "/node_modules/."); + } + ts.isPathInNodeModulesStartingWithDot = isPathInNodeModulesStartingWithDot; ts.maxNumberOfFilesToIterateForInvalidation = 256; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; @@ -87846,11 +88973,11 @@ var ts; // The key in the map is source file's path. // The values are Map of resolutions with key being name lookedup. var resolvedModuleNames = ts.createMap(); - var perDirectoryResolvedModuleNames = ts.createMap(); - var nonRelaticeModuleNameCache = ts.createMap(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelaticeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); + var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); + var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); var resolvedTypeReferenceDirectives = ts.createMap(); - var perDirectoryResolvedTypeReferenceDirectives = ts.createMap(); + var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -87874,6 +89001,7 @@ var ts; resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives: resolveTypeReferenceDirectives, + removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects, removeResolutionsOfFile: removeResolutionsOfFile, invalidateResolutionOfFile: invalidateResolutionOfFile, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, @@ -87935,7 +89063,7 @@ var ts; } function clearPerDirectoryResolutions() { perDirectoryResolvedModuleNames.clear(); - nonRelaticeModuleNameCache.clear(); + nonRelativeModuleNameCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); @@ -87951,8 +89079,8 @@ var ts; } }); } - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache); + function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference); // 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; @@ -87970,10 +89098,11 @@ var ts; // Default return the result from the first pass return primaryResult; } - function resolveNamesWithLocalCache(names, containingFile, cache, perDirectoryCache, loader, getResolutionWithResolvedFileName, reusedNames, logChanges) { + function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) { var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); + var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); var perDirectoryResolution = perDirectoryCache.get(dirPath); if (!perDirectoryResolution) { perDirectoryResolution = ts.createMap(); @@ -87982,22 +89111,28 @@ var ts; var resolvedModules = []; var compilerOptions = resolutionHost.getCompilationSettings(); var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path); + // All the resolutions in this file are invalidated if this file wasnt resolved using same redirect + var program = resolutionHost.getCurrentProgram(); + var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile); + var unmatchedRedirects = oldRedirect ? + !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : + !!redirectedReference; var seenNamesInFile = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { var name = names_2[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && - allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated || + allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate - (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && !getResolutionWithResolvedFileName(resolution))) { + (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; } else { - resolution = loader(name, containingFile, compilerOptions, resolutionHost); + resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -88013,7 +89148,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -88041,12 +89176,14 @@ var ts; return oldResult.resolvedFileName === newResult.resolvedFileName; } } - function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile) { - return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) { + return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + /*shouldRetryResolution*/ function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, /*reusedNames*/ undefined, /*logChanges*/ false); } - function resolveModuleNames(moduleNames, containingFile, reusedNames) { - return resolveNamesWithLocalCache(moduleNames, containingFile, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, reusedNames, logChangesWhenResolvingModule); + function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { + return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, + /*shouldRetryResolution*/ function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule); } function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); @@ -88089,12 +89226,6 @@ var ts; } return true; } - function filterFSRootDirectoriesToWatch(watchPath, dirPath) { - if (!canWatchDirectory(dirPath)) { - watchPath.ignore = true; - } - return watchPath; - } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path @@ -88114,13 +89245,13 @@ var ts; } function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) { // If directory path contains node module, get the most parent node_modules directory for watching - while (ts.stringContains(dirPath, ts.nodeModulesPathPart)) { + while (ts.pathContainsNodeModules(dirPath)) { dir = ts.getDirectoryPath(dir); dirPath = ts.getDirectoryPath(dirPath); } // If the directory is node_modules use it to watch, always watch it recursively if (isNodeModulesDirectory(dirPath)) { - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); + return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -88138,7 +89269,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive }, dirPath); + return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -88167,8 +89298,9 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, nonRecursive = _a.nonRecursive, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive; // If the failed lookup location path is not one of the supported extensions, // store it in the custom path if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { @@ -88221,8 +89353,9 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dirPath = toWatch.dirPath; var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { if (refCount === 1) { @@ -88270,6 +89403,22 @@ var ts; cache.delete(filePath); } } + function removeResolutionsFromProjectReferenceRedirects(filePath) { + if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) { + return; + } + var program = resolutionHost.getCurrentProgram(); + if (!program) { + return; + } + // If this file is input file for the referenced project, get it + var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath); + if (!resolvedProjectReference) { + return; + } + // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution + resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); + } function removeResolutionsOfFile(filePath) { removeResolutionsOfFileFromCache(resolvedModuleNames, filePath); removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath); @@ -88331,6 +89480,9 @@ var ts; isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); }; } else { + // If something to do with folder/file starting with "." in node_modules folder, skip it + if (isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return false; // Some file or directory in the watching directory is created // Return early if it does not have any of the watching extension or not the custom failed lookup path var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); @@ -88371,8 +89523,8 @@ var ts; if (isInDirectoryPath(rootPath, typeRootPath)) { return rootPath; } - var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; + var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath); + return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -88860,7 +90012,6 @@ var ts; } return false; } - /** @internal */ ts.screenStartingMessageCodes = [ ts.Diagnostics.Starting_compilation_in_watch_mode.code, ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code, @@ -88901,6 +90052,23 @@ var ts; return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; + function getErrorCountForSummary(diagnostics) { + return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + ts.getErrorCountForSummary = getErrorCountForSummary; + function getWatchErrorSummaryDiagnosticMessage(errorCount) { + return errorCount === 1 ? + ts.Diagnostics.Found_1_error_Watching_for_file_changes : + ts.Diagnostics.Found_0_errors_Watching_for_file_changes; + } + ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage; + function getErrorSummaryText(errorCount, newLine) { + if (errorCount === 0) + return ""; + var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount); + return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine; + } + ts.getErrorSummaryText = getErrorSummaryText; /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ @@ -88939,7 +90107,7 @@ var ts; } } if (reportSummary) { - reportSummary(diagnostics.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length); + reportSummary(getErrorCountForSummary(diagnostics)); } if (emitSkipped && diagnostics.length > 0) { // If the emitter didn't emit anything, then pass that value along. @@ -89018,15 +90186,7 @@ var ts; function emitFilesAndReportErrorUsingBuilder(builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - var reportSummary = function (errorCount) { - if (errorCount === 1) { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_1_error_Watching_for_file_changes, errorCount), newLine, compilerOptions); - } - else { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_0_errors_Watching_for_file_changes, errorCount, errorCount), newLine, compilerOptions); - } - }; - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, reportSummary); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); } } /** @@ -89102,7 +90262,8 @@ var ts; fileExists: function (path) { return host.fileExists(path); }, readFile: readFile, getCurrentDirectory: getCurrentDirectory, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; // From tsc we want to get already parsed result and hence check for rootFileNames var newLine = updateNewLine(); @@ -89170,11 +90331,11 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }) : - (function (moduleNames, containingFile, reusedNames) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); }); + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }) : - (function (typeDirectiveNames, containingFile) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }); + (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; synchronizeProgram(); // Update the wild card directory watch @@ -89348,8 +90509,8 @@ var ts; var hostSourceFile = sourceFilesCache.get(path); return !hostSourceFile || isFileMissingOnHost(hostSourceFile) ? undefined : hostSourceFile.version.toString(); } - function onReleaseOldSourceFile(oldSourceFile, _oldOptions) { - var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.path); + function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { + var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); // If this is the source file thats in the cache and new program doesnt need it, // remove the cached entry. // Note we arent deleting entry if file became missing in new program or @@ -89363,8 +90524,10 @@ var ts; if (hostSourceFileInfo.fileWatcher) { hostSourceFileInfo.fileWatcher.close(); } - sourceFilesCache.delete(oldSourceFile.path); - resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + sourceFilesCache.delete(oldSourceFile.resolvedPath); + if (!hasSourceFileByPath) { + resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + } } } } @@ -89444,6 +90607,7 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.get(path)) { resolutionCache.invalidateResolutionOfFile(path); } + resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -89484,6 +90648,8 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } nextSourceFileVersion(fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) { @@ -89686,7 +90852,7 @@ var ts; }; } ts.createBuilderStatusReporter = createBuilderStatusReporter; - function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus) { + function createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) { if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker({}, /*setParentNodes*/ undefined, system); host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; @@ -89696,10 +90862,15 @@ var ts; host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; } + function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { + if (system === void 0) { system = ts.sys; } + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); + host.reportErrorSummary = reportErrorSummary; + return host; + } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { - if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); host.onWatchStatusChange = watchHost.onWatchStatusChange; host.watchFile = watchHost.watchFile; @@ -89716,12 +90887,6 @@ var ts; }); return result; } - /** - * A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but - * can dynamically add/remove other projects based on changes on the rootNames' references - * TODO: use SolutionBuilderWithWatchHost => watchedSolution - * use SolutionBuilderHost => Solution - */ function createSolutionBuilder(host, rootNames, defaultOptions) { var hostWithWatch = host; var currentDirectory = host.getCurrentDirectory(); @@ -90080,9 +91245,7 @@ var ts; globalDependencyGraph = undefined; } projectStatus.removeKey(resolved); - if (options.watch) { - diagnostics.removeKey(resolved); - } + diagnostics.removeKey(resolved); addProjToQueue(resolved, reloadLevel); } /** @@ -90144,7 +91307,7 @@ var ts; } } function reportErrorSummary() { - if (options.watch) { + if (options.watch || host.reportErrorSummary) { // Report errors from the other projects getGlobalDependencyGraph().buildQueue.forEach(function (project) { if (!projectErrorsReported.hasKey(project)) { @@ -90152,8 +91315,13 @@ var ts; } }); var totalErrors_1 = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += singleProjectErrors.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length; }); - reportWatchStatus(totalErrors_1 === 1 ? ts.Diagnostics.Found_1_error_Watching_for_file_changes : ts.Diagnostics.Found_0_errors_Watching_for_file_changes, totalErrors_1); + diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += ts.getErrorCountForSummary(singleProjectErrors); }); + if (options.watch) { + reportWatchStatus(ts.getWatchErrorSummaryDiagnosticMessage(totalErrors_1), totalErrors_1); + } + else { + host.reportErrorSummary(totalErrors_1); + } } } function buildSingleInvalidatedProject(resolved, reloadLevel) { @@ -90317,9 +91485,7 @@ var ts; type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime }; - if (options.watch) { - diagnostics.removeKey(proj); - } + diagnostics.removeKey(proj); projectStatus.setValue(proj, status); return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { @@ -90445,10 +91611,8 @@ var ts; } function reportAndStoreErrors(proj, errors) { reportErrors(errors); - if (options.watch) { - projectErrorsReported.setValue(proj, true); - diagnostics.setValue(proj, errors); - } + projectErrorsReported.setValue(proj, true); + diagnostics.setValue(proj, errors); } function reportErrors(errors) { errors.forEach(function (err) { return host.reportDiagnostic(err); }); @@ -90570,10 +91734,12 @@ var ts; if (builtin !== undefined) return builtin; var entries = getEntriesOfObject(value); - return { kind: 3 /* Object */, name: name, members: ts.flatMap(entries, function (_a) { - var key = _a.key, value = _a.value; - return getValueInfo(key, value, recurser); - }) }; + var hasNontrivialPrototype = Object.getPrototypeOf(value) !== Object.prototype; + var members = ts.flatMap(entries, function (_a) { + var key = _a.key, value = _a.value; + return getValueInfo(key, value, recurser); + }); + return { kind: 3 /* Object */, name: name, hasNontrivialPrototype: hasNontrivialPrototype, members: members }; } return { kind: 0 /* Const */, name: name, typeName: isNullOrUndefined(value) ? "any" : typeof value }; }, function (isCircularReference, keyStack) { return anyValue(name, " " + (isCircularReference ? "Circular reference" : "Too-deep object hierarchy") + " from " + keyStack.join(".")); }); @@ -90702,7 +91868,6 @@ var ts; : undefined; } server.findArgument = findArgument; - /*@internal*/ function nowString() { // E.g. "12:34:56.789" var d = new Date(); @@ -90716,13 +91881,11 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - /* @internal */ function isTypingUpToDate(cachedTyping, availableTypingVersions) { var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; - /* @internal */ JsTyping.nodeCoreModuleList = [ "assert", "async_hooks", @@ -90761,7 +91924,6 @@ var ts; "vm", "zlib" ]; - /* @internal */ JsTyping.nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); @@ -91057,30 +92219,32 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + function getDefaultFormatCodeSettings(newLineCharacter) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: newLineCharacter || "\n", + convertTabsToSpaces: true, + indentStyle: IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; /* @internal */ - ts.testFormatSettings = { - baseIndentSize: 0, - indentSize: 4, - tabSize: 4, - newLineCharacter: "\n", - convertTabsToSpaces: true, - indentStyle: IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterConstructor: false, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - insertSpaceAfterTypeAssertion: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - insertSpaceBeforeTypeAnnotation: false - }; + ts.testFormatSettings = getDefaultFormatCodeSettings("\n"); var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; @@ -91142,8 +92306,9 @@ var ts; TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + TokenClass[TokenClass["BigIntLiteral"] = 7] = "BigIntLiteral"; + TokenClass[TokenClass["StringLiteral"] = 8] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 9] = "RegExpLiteral"; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { @@ -91226,6 +92391,12 @@ var ts; ScriptElementKindModifier["staticModifier"] = "static"; ScriptElementKindModifier["abstractModifier"] = "abstract"; ScriptElementKindModifier["optionalModifier"] = "optional"; + ScriptElementKindModifier["dtsModifier"] = ".d.ts"; + ScriptElementKindModifier["tsModifier"] = ".ts"; + ScriptElementKindModifier["tsxModifier"] = ".tsx"; + ScriptElementKindModifier["jsModifier"] = ".js"; + ScriptElementKindModifier["jsxModifier"] = ".jsx"; + ScriptElementKindModifier["jsonModifier"] = ".json"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames; (function (ClassificationTypeNames) { @@ -91233,6 +92404,7 @@ var ts; ClassificationTypeNames["identifier"] = "identifier"; ClassificationTypeNames["keyword"] = "keyword"; ClassificationTypeNames["numericLiteral"] = "number"; + ClassificationTypeNames["bigintLiteral"] = "bigint"; ClassificationTypeNames["operator"] = "operator"; ClassificationTypeNames["stringLiteral"] = "string"; ClassificationTypeNames["whiteSpace"] = "whitespace"; @@ -91279,6 +92451,7 @@ var ts; ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + ClassificationType[ClassificationType["bigintLiteral"] = 25] = "bigintLiteral"; })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); // These utilities are common to multiple language service features. @@ -91296,37 +92469,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 272 /* CatchClause */: - case 265 /* JsxAttribute */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 274 /* CatchClause */: + case 267 /* JsxAttribute */: return 1 /* Value */; - case 148 /* TypeParameter */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 166 /* TypeLiteral */: + case 150 /* TypeParameter */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 168 /* TypeLiteral */: return 2 /* Type */; - case 302 /* JSDocTypedefTag */: + case 304 /* 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 276 /* EnumMember */: - case 238 /* ClassDeclaration */: + case 278 /* EnumMember */: + case 240 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -91336,26 +92509,26 @@ var ts; else { return 4 /* Namespace */; } - case 241 /* EnumDeclaration */: - case 250 /* NamedImports */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 243 /* EnumDeclaration */: + case 252 /* NamedImports */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 252 /* ExportAssignment */ || node.parent.kind === 257 /* ExternalModuleReference */) { + else if (node.parent.kind === 254 /* ExportAssignment */ || node.parent.kind === 259 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -91387,11 +92560,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 148 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 248 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -91403,27 +92576,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 146 /* QualifiedName */) { - while (root.parent && root.parent.kind === 146 /* QualifiedName */) { + if (root.parent.kind === 148 /* QualifiedName */) { + while (root.parent && root.parent.kind === 148 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 162 /* TypeReference */ && !isLastClause; + return root.parent.kind === 164 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 187 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { + if (root.parent.kind === 189 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 189 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 211 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 273 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 240 /* ClassDeclaration */ && root.parent.parent.token === 109 /* ImplementsKeyword */) || + (decl.kind === 241 /* InterfaceDeclaration */ && root.parent.parent.token === 86 /* ExtendsKeyword */); } return false; } @@ -91432,17 +92605,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return true; } switch (node.parent.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return true; - case 181 /* ImportType */: + case 183 /* ImportType */: return !node.parent.isTypeOf; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -91469,7 +92642,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 233 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -91485,11 +92658,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 71 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 71 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 72 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -91497,40 +92670,40 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 244 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 71 /* Identifier */ && + return node.kind === 72 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 273 /* PropertyAssignment */: - case 276 /* EnumMember */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 242 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 275 /* PropertyAssignment */: + case 278 /* EnumMember */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 244 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return true; - case 180 /* LiteralType */: - return node.parent.parent.kind === 178 /* IndexedAccessType */; + case 182 /* LiteralType */: + return node.parent.parent.kind === 180 /* IndexedAccessType */; default: return false; } @@ -91554,17 +92727,17 @@ var ts; return undefined; } switch (node.kind) { - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return node; } } @@ -91572,51 +92745,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return "class" /* classElement */; - case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 240 /* TypeAliasDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 241 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 242 /* TypeAliasDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 241 /* EnumDeclaration */: return "enum" /* enumElement */; - case 235 /* VariableDeclaration */: + case 243 /* EnumDeclaration */: return "enum" /* enumElement */; + case 237 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return "function" /* functionElement */; - case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 158 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 159 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return "property" /* memberVariableElement */; - case 160 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 159 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 158 /* CallSignature */: return "call" /* callSignatureElement */; - case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 276 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: - case 249 /* NamespaceImport */: + case 162 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 161 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 160 /* CallSignature */: return "call" /* callSignatureElement */; + case 157 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 150 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 278 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 151 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: + case 251 /* NamespaceImport */: return "alias" /* alias */; - case 202 /* BinaryExpression */: + case 204 /* 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 */: @@ -91637,7 +92813,7 @@ var ts; return "" /* unknown */; } } - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -91653,12 +92829,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 149 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 151 /* Parameter */; default: return false; } @@ -91723,42 +92899,42 @@ var ts; return false; } switch (n.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 182 /* ObjectBindingPattern */: - case 166 /* TypeLiteral */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 244 /* CaseBlock */: - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 272 /* CatchClause */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 168 /* TypeLiteral */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 246 /* CaseBlock */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); + case 274 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 190 /* NewExpression */: + case 192 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 189 /* CallExpression */: - case 193 /* ParenthesizedExpression */: - case 175 /* ParenthesizedType */: - return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 191 /* CallExpression */: + case 195 /* ParenthesizedExpression */: + case 177 /* ParenthesizedType */: + return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 197 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -91767,66 +92943,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 242 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); + case 244 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 220 /* IfStatement */: + case 222 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 185 /* ArrayLiteralExpression */: - case 183 /* ArrayBindingPattern */: - case 188 /* ElementAccessExpression */: - case 147 /* ComputedPropertyName */: - case 168 /* TupleType */: - return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); - case 160 /* IndexSignature */: + hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); + case 187 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 190 /* ElementAccessExpression */: + case 149 /* ComputedPropertyName */: + case 170 /* TupleType */: + return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); + case 162 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 107 /* WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 197 /* TypeOfExpression */: - case 196 /* DeleteExpression */: - case 198 /* VoidExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: + case 199 /* TypeOfExpression */: + case 198 /* DeleteExpression */: + case 200 /* VoidExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -91843,7 +93019,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 25 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -92005,7 +93181,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 277 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 279 /* SourceFile */ || n.kind === 1 /* 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. @@ -92067,25 +93243,25 @@ var ts; if (!token) { return false; } - if (token.kind === 10 /* JsxText */) { + if (token.kind === 11 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 270 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { + if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 263 /* JsxClosingElement */) { return true; } return false; @@ -92099,6 +93275,20 @@ var ts; return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; + function isInJSXText(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + if (ts.isJsxText(token)) { + return true; + } + if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + return true; + } + return false; + } + ts.isInJSXText = isInJSXText; function findPrecedingMatchingToken(token, matchingTokenKind, sourceFile) { var tokenKind = token.kind; var remainingMatchingTokens = 0; @@ -92145,7 +93335,7 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); if (!token || !ts.isIdentifier(token)) @@ -92155,53 +93345,54 @@ var ts; } remainingLessThanTokens--; break; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: remainingLessThanTokens++; break; - case 18 /* CloseBraceToken */: + case 19 /* 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, 17 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 20 /* CloseParenToken */: + case 21 /* 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, 19 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 22 /* CloseBracketToken */: + case 23 /* 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, 21 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 26 /* CommaToken */: + case 27 /* CommaToken */: nTypeArguments++; break; - case 36 /* EqualsGreaterThanToken */: - case 71 /* Identifier */: - case 9 /* StringLiteral */: + case 37 /* EqualsGreaterThanToken */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 103 /* TypeOfKeyword */: - case 85 /* ExtendsKeyword */: - case 128 /* KeyOfKeyword */: - case 23 /* DotToken */: - case 49 /* BarToken */: - case 55 /* QuestionToken */: - case 56 /* ColonToken */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 104 /* TypeOfKeyword */: + case 86 /* ExtendsKeyword */: + case 129 /* KeyOfKeyword */: + case 24 /* DotToken */: + case 50 /* BarToken */: + case 56 /* QuestionToken */: + case 57 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -92256,10 +93447,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { + if (node.kind === 164 /* TypeReference */ || node.kind === 191 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 240 /* ClassDeclaration */ || node.kind === 241 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -92270,8 +93461,8 @@ var ts; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 /* StringLiteral */ - || kind === 12 /* RegularExpressionLiteral */ + if (kind === 10 /* StringLiteral */ + || kind === 13 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -92279,7 +93470,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 71 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -92289,9 +93480,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: return true; } return false; @@ -92304,18 +93495,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 185 /* ArrayLiteralExpression */ || - node.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 187 /* ArrayLiteralExpression */ || + node.kind === 188 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 202 /* BinaryExpression */ && + if (node.parent.kind === 204 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 58 /* EqualsToken */) { + node.parent.operatorToken.kind === 59 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 225 /* ForOfStatement */ && + if (node.parent.kind === 227 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -92323,7 +93514,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 275 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -92367,21 +93558,21 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 119 /* AnyKeyword */, - 122 /* BooleanKeyword */, - 86 /* FalseKeyword */, - 128 /* KeyOfKeyword */, - 131 /* NeverKeyword */, - 95 /* NullKeyword */, - 134 /* NumberKeyword */, - 135 /* ObjectKeyword */, - 137 /* StringKeyword */, - 138 /* SymbolKeyword */, - 101 /* TrueKeyword */, - 105 /* VoidKeyword */, - 140 /* UndefinedKeyword */, - 141 /* UniqueKeyword */, - 142 /* UnknownKeyword */, + 120 /* AnyKeyword */, + 123 /* BooleanKeyword */, + 87 /* FalseKeyword */, + 129 /* KeyOfKeyword */, + 132 /* NeverKeyword */, + 96 /* NullKeyword */, + 135 /* NumberKeyword */, + 136 /* ObjectKeyword */, + 138 /* StringKeyword */, + 139 /* SymbolKeyword */, + 102 /* TrueKeyword */, + 106 /* VoidKeyword */, + 141 /* UndefinedKeyword */, + 142 /* UniqueKeyword */, + 143 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -92417,7 +93608,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 147 /* ComputedPropertyName */ + return name.kind === 149 /* 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.getTextOfIdentifierOrLiteral(name); @@ -92493,7 +93684,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 71 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 72 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -92506,13 +93697,7 @@ var ts; ts.isObjectBindingElementWithoutPropertyName = isObjectBindingElementWithoutPropertyName; function getPropertySymbolFromBindingElement(checker, bindingElement) { var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); - var propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); - if (propSymbol && propSymbol.flags & 98304 /* Accessor */) { - // See GH#16922 - ts.Debug.assert(!!(propSymbol.flags & 33554432 /* Transient */)); - return propSymbol.target; - } - return propSymbol; + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; /** @@ -92565,7 +93750,6 @@ var ts; return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); } ts.findModifier = findModifier; - /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); if (lastImportDeclaration) { @@ -92589,7 +93773,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 151 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -92615,6 +93799,7 @@ var ts; writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeTrailingSemicolon: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, @@ -92623,7 +93808,7 @@ var ts; writeSymbol: writeSymbol, writeLine: writeLine, write: unknownWrite, - writeTextOfNode: unknownWrite, + writeComment: unknownWrite, getText: function () { return ""; }, getTextPos: function () { return 0; }, getColumn: function () { return 0; }, @@ -92774,7 +93959,6 @@ var ts; return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } ts.lineBreakPart = lineBreakPart; - /* @internal */ function mapToDisplayParts(writeDisplayParts) { try { writeDisplayParts(displayPartWriter); @@ -92809,7 +93993,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && + (location.parent.kind === 253 /* ImportSpecifier */ || location.parent.kind === 257 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -92856,6 +94040,13 @@ var ts; return position; } ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getPrecedingNonSpaceCharacterPosition(text, position) { + while (position > -1 && ts.isWhiteSpaceSingleLine(text.charCodeAt(position))) { + position -= 1; + } + return position + 1; + } + ts.getPrecedingNonSpaceCharacterPosition = getPrecedingNonSpaceCharacterPosition; /** * Creates a deep, memberwise clone of a node with no source map location. * @@ -92922,7 +94113,6 @@ var ts; /** * Sets EmitFlags to suppress leading and trailing trivia on the node. */ - /* @internal */ function suppressLeadingAndTrailingTrivia(node) { suppressLeadingTrivia(node); suppressTrailingTrivia(node); @@ -92931,7 +94121,6 @@ var ts; /** * Sets EmitFlags to suppress leading trivia on the node. */ - /* @internal */ function suppressLeadingTrivia(node) { addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); } @@ -92939,7 +94128,6 @@ var ts; /** * Sets EmitFlags to suppress trailing trivia on the node. */ - /* @internal */ function suppressTrailingTrivia(node) { addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); } @@ -92953,7 +94141,6 @@ var ts; function getFirstChild(node) { return node.forEachChild(function (child) { return child; }); } - /* @internal */ function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { @@ -92967,7 +94154,6 @@ var ts; * to be on the reference, rather than the declaration, because it's closer to where the * user was before extracting it. */ - /* @internal */ function getRenameLocation(edits, renameFilename, name, preferLastLocation) { var delta = 0; var lastPos = -1; @@ -93021,6 +94207,72 @@ var ts; idx = change.indexOf('"' + name); return idx === -1 ? -1 : idx + 1; } + function getContextualTypeFromParent(node, checker) { + var parent = node.parent; + switch (parent.kind) { + case 192 /* NewExpression */: + return checker.getContextualType(parent); + case 204 /* 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 271 /* CaseClause */: + return parent.expression === node ? getSwitchedType(parent, checker) : undefined; + default: + return checker.getContextualType(node); + } + } + ts.getContextualTypeFromParent = getContextualTypeFromParent; + function quote(text, preferences) { + if (/^\d+$/.test(text)) { + return text; + } + var quoted = JSON.stringify(text); + switch (preferences.quotePreference) { + case undefined: + case "double": + return quoted; + case "single": + return "'" + stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; + default: + return ts.Debug.assertNever(preferences.quotePreference); + } + } + ts.quote = quote; + function isEqualityOperatorKind(kind) { + switch (kind) { + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + return true; + default: + return false; + } + } + ts.isEqualityOperatorKind = isEqualityOperatorKind; + function isStringLiteralOrTemplate(node) { + switch (node.kind) { + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + return true; + default: + return false; + } + } + ts.isStringLiteralOrTemplate = isStringLiteralOrTemplate; + function hasIndexSignature(type) { + return !!type.getStringIndexType() || !!type.getNumberIndexType(); + } + ts.hasIndexSignature = hasIndexSignature; + function getSwitchedType(caseClause, checker) { + return checker.getTypeAtLocation(caseClause.parent.parent.expression); + } + ts.getSwitchedType = getSwitchedType; })(ts || (ts = {})); var ts; (function (ts) { @@ -93059,7 +94311,7 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(14 /* TemplateHead */); + templateStack.push(15 /* TemplateHead */); } scanner.setText(text); var endOfLineState = 0 /* None */; @@ -93101,65 +94353,65 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 12 /* RegularExpressionLiteral */) { - token = 12 /* RegularExpressionLiteral */; + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + token = 13 /* RegularExpressionLiteral */; } break; - case 27 /* LessThanToken */: - if (lastNonTriviaToken === 71 /* Identifier */) { + case 28 /* LessThanToken */: + if (lastNonTriviaToken === 72 /* 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 29 /* GreaterThanToken */: + case 30 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 119 /* AnyKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: + case 120 /* AnyKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: templateStack.push(token); break; - case 17 /* OpenBraceToken */: + case 18 /* 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 18 /* CloseBraceToken */: + case 19 /* 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 === 14 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 16 /* TemplateTail */) { + if (token === 17 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 15 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 17 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -93168,15 +94420,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 23 /* DotToken */) { - token = 71 /* Identifier */; + if (lastNonTriviaToken === 24 /* DotToken */) { + token = 72 /* 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 = 71 /* Identifier */; + token = 72 /* Identifier */; } } } @@ -93190,22 +94442,23 @@ 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([ - 71 /* Identifier */, - 9 /* StringLiteral */, + 72 /* Identifier */, + 10 /* StringLiteral */, 8 /* NumericLiteral */, - 12 /* RegularExpressionLiteral */, - 99 /* ThisKeyword */, - 43 /* PlusPlusToken */, - 44 /* MinusMinusToken */, - 20 /* CloseParenToken */, - 22 /* CloseBracketToken */, - 18 /* CloseBraceToken */, - 101 /* TrueKeyword */, - 86 /* FalseKeyword */, + 9 /* BigIntLiteral */, + 13 /* RegularExpressionLiteral */, + 100 /* ThisKeyword */, + 44 /* PlusPlusToken */, + 45 /* MinusMinusToken */, + 21 /* CloseParenToken */, + 23 /* CloseBracketToken */, + 19 /* CloseBraceToken */, + 102 /* TrueKeyword */, + 87 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; @@ -93229,15 +94482,15 @@ var ts; return undefined; } switch (token) { - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return 5 /* InTemplateMiddleOrTail */; - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 14 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { @@ -93286,6 +94539,7 @@ var ts; 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; @@ -93312,10 +94566,10 @@ var ts; return true; } switch (keyword2) { - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 123 /* ConstructorKeyword */: - case 115 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 124 /* ConstructorKeyword */: + case 116 /* 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. @@ -93348,43 +94602,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 48 /* AmpersandToken */: - case 50 /* CaretToken */: - case 49 /* BarToken */: - case 53 /* AmpersandAmpersandToken */: - case 54 /* BarBarToken */: - case 69 /* BarEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 49 /* AmpersandToken */: + case 51 /* CaretToken */: + case 50 /* BarToken */: + case 54 /* AmpersandAmpersandToken */: + case 55 /* BarBarToken */: + case 70 /* BarEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return true; default: return false; @@ -93392,12 +94646,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: return true; default: return false; @@ -93410,15 +94664,17 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 17 /* FirstPunctuation */ && token <= 70 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 71 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + return 25 /* bigintLiteral */; + case 10 /* StringLiteral */: return 6 /* stringLiteral */; - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -93427,7 +94683,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 71 /* Identifier */: + case 72 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -93452,10 +94708,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -93530,6 +94786,7 @@ var ts; 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 */; @@ -93663,22 +94920,22 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10 /* punctuation */); // "@" + pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -93749,10 +95006,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -93765,22 +95022,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -93797,7 +95054,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 27 /* LessThanToken */ || tokenKind === 29 /* GreaterThanToken */) { + if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* 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)) { @@ -93807,19 +95064,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 58 /* EqualsToken */) { + if (tokenKind === 59 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 235 /* VariableDeclaration */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 149 /* Parameter */ || - parent.kind === 265 /* JsxAttribute */) { + if (parent.kind === 237 /* VariableDeclaration */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 151 /* Parameter */ || + parent.kind === 267 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 202 /* BinaryExpression */ || - parent.kind === 200 /* PrefixUnaryExpression */ || - parent.kind === 201 /* PostfixUnaryExpression */ || - parent.kind === 203 /* ConditionalExpression */) { + if (parent.kind === 204 /* BinaryExpression */ || + parent.kind === 202 /* PrefixUnaryExpression */ || + parent.kind === 203 /* PostfixUnaryExpression */ || + parent.kind === 205 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -93828,11 +95085,14 @@ var ts; else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 9 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 9 /* BigIntLiteral */) { + return 25 /* bigintLiteral */; } - else if (tokenKind === 12 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* StringLiteral */) { + // TODO: GH#18217 + return token.parent.kind === 267 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + } + else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -93840,38 +95100,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 10 /* JsxText */) { + else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 71 /* Identifier */) { + else if (tokenKind === 72 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 149 /* Parameter */: + case 151 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -93905,37 +95165,245 @@ var ts; (function (ts) { var Completions; (function (Completions) { - var PathCompletions; - (function (PathCompletions) { - function nameAndKind(name, kind) { - return { name: name, kind: kind }; + var StringCompletions; + (function (StringCompletions) { + function getStringLiteralCompletions(sourceFile, position, contextToken, checker, options, host, log, preferences) { + if (ts.isInReferenceComment(sourceFile, position)) { + var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); + return entries && convertPathCompletions(entries); + } + if (ts.isInString(sourceFile, position, contextToken)) { + return !contextToken || !ts.isStringLiteralLike(contextToken) + ? undefined + : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host), sourceFile, checker, log, preferences); + } + } + StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; + function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { + if (completion === undefined) { + return undefined; + } + switch (completion.kind) { + case 0 /* Paths */: + return convertPathCompletions(completion.paths); + case 1 /* Properties */: { + var entries = []; + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; + } + case 2 /* Types */: { + var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; + } + default: + return ts.Debug.assertNever(completion); + } + } + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + if (!contextToken || !ts.isStringLiteralLike(contextToken)) + return undefined; + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); + } + StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; + function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { + switch (completion.kind) { + case 0 /* 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 */: { + 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; + default: + return ts.Debug.assertNever(completion); + } + } + function convertPathCompletions(pathCompletions) { + var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. + var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. + var entries = pathCompletions.map(function (_a) { + var name = _a.name, kind = _a.kind, span = _a.span, extension = _a.extension; + return ({ name: name, kind: kind, kindModifiers: kindModifiersFromExtension(extension), sortText: "0", replacementSpan: span }); + }); + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + } + 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 undefined: return "" /* none */; + default: + return ts.Debug.assertNever(extension); + } + } + var StringLiteralCompletionKind; + (function (StringLiteralCompletionKind) { + StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; + StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; + })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + var parent = node.parent; + switch (parent.kind) { + case 182 /* LiteralType */: + switch (parent.parent.kind) { + case 164 /* TypeReference */: + return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; + case 180 /* IndexedAccessType */: + // Get all apparent property names + // i.e. interface Foo { + // foo: string; + // bar: string; + // } + // let x: Foo["/*completion position*/"] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); + case 183 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; + case 173 /* UnionType */: { + if (!ts.isTypeReferenceNode(parent.parent.parent)) + return undefined; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + } + default: + return undefined; + } + case 275 /* PropertyAssignment */: + if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { + // Get quoted name of properties of the object literal expression + // i.e. interface ConfigFiles { + // 'jspm:dev': string + // } + // let files: ConfigFiles = { + // '/*completion position*/' + // } + // + // function foo(c: ConfigFiles) {} + // foo({ + // '/*completion position*/' + // }); + return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); + } + return fromContextualType(); + case 190 /* ElementAccessExpression */: { + var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; + if (node === argumentExpression) { + // Get all names of properties on the expression + // i.e. interface A { + // 'prop1': string + // } + // let a: A; + // a['/*completion position*/'] + return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); + } + return undefined; + } + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); + } + // falls through (is `require("")` or `import("")`) + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 259 /* 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) }; + 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 }; + } + } + function getAlreadyUsedTypesInStringLiteralUnion(union, current) { + return ts.mapDefined(union.types, function (type) { + return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; + }); + } + function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { + var isNewIdentifier = false; + var uniques = ts.createMap(); + var candidates = []; + checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); + var types = ts.flatMap(candidates, function (candidate) { + if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + return; + var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + return getStringLiteralTypes(type, uniques); + }); + return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + } + function stringLiteralCompletionsFromProperties(type) { + return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: ts.hasIndexSignature(type) }; + } + function getStringLiteralTypes(type, uniques) { + if (uniques === void 0) { uniques = ts.createMap(); } + if (!type) + 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; + } + function nameAndKind(name, kind, extension) { + return { name: name, kind: kind, extension: extension }; + } + function directoryResult(name) { + return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); return names.map(function (_a) { - var name = _a.name, kind = _a.kind; - return ({ name: name, kind: kind, span: span }); + var name = _a.name, kind = _a.kind, extension = _a.extension; + return ({ name: name, kind: kind, extension: extension, span: span }); }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } - PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); - if (compilerOptions.rootDirs) { - return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, compilerOptions, host, scriptPath); - } - else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, host, scriptPath); - } + return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + } + function getExtensionOptions(compilerOptions, includeExtensions) { + if (includeExtensions === void 0) { includeExtensions = false; } + return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; + } + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { + var extensionOptions = getExtensionOptions(compilerOptions); + if (compilerOptions.rootDirs) { + return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); } } function getSupportedExtensionsForModuleResolution(compilerOptions) { @@ -93958,21 +95426,22 @@ var ts; // Now find a path for each potential directory that is to be merged with the one containing the script return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, compilerOptions, host, exclude) { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); var result = []; for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, host, exclude, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude, result); } return result; } /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, host, exclude, result) { + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { + var extensions = _a.extensions, includeExtensions = _a.includeExtensions; if (result === void 0) { result = []; } if (fragment === undefined) { fragment = ""; @@ -93993,55 +95462,53 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles.has(foundFileName)) { - foundFiles.set(foundFileName, true); - } + if (!tryDirectoryExists(host, baseDirectory)) + return result; + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); // maps file to its extension + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; } - ts.forEachKey(foundFiles, function (foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */)); - }); + var foundFileName = includeExtensions || ts.fileExtensionIs(filePath, ".json" /* Json */) ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { - var directory = directories_1[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - if (directoryName !== "@types") { - result.push(nameAndKind(directoryName, "directory" /* directory */)); - } + foundFiles.forEach(function (ext, foundFile) { + result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { + var directory = directories_1[_b]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + if (directoryName !== "@types") { + result.push(directoryResult(directoryName)); } } - // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); - if (packageJsonPath) { - var packageJson = ts.readJson(packageJsonPath, host); - var typesVersions = packageJson.typesVersions; - if (typeof typesVersions === "object") { - var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); - var versionPaths = versionResult && versionResult.paths; - var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); - if (versionPaths) { - addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); - } + } + // check for a version redirect + var packageJsonPath = findPackageJson(baseDirectory, host); + if (packageJsonPath) { + var packageJson = ts.readJson(packageJsonPath, host); + var typesVersions = packageJson.typesVersions; + if (typeof typesVersions === "object") { + var versionResult = ts.getPackageJsonTypesVersionsPaths(typesVersions); + var versionPaths = versionResult && versionResult.paths; + var rest = absolutePath.slice(ts.ensureTrailingDirectorySeparator(baseDirectory).length); + if (versionPaths) { + addCompletionEntriesFromPaths(result, rest, baseDirectory, extensions, versionPaths, host); } } } @@ -94053,15 +95520,15 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_10 = function (name, kind) { + var _loop_10 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { - result.push(nameAndKind(name, kind)); + result.push(nameAndKind(name, kind, extension)); } }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { - var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_10(name, kind); + var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; + _loop_10(name, kind, extension); } } } @@ -94076,21 +95543,21 @@ var ts; function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; var result = []; - var fileExtensions = getSupportedExtensionsForModuleResolution(compilerOptions); + var extensionOptions = getExtensionOptions(compilerOptions); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); - getCompletionEntriesForDirectoryFragment(fragment, absolute, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, fileExtensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); } } - var fragmentDirectory = containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + 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 */)); + result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, result); + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) { // 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.) @@ -94099,7 +95566,7 @@ var ts; var _loop_11 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); + result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); } }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { @@ -94111,13 +95578,16 @@ var ts; ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); if (tryDirectoryExists(host, nodeModules)) { - getCompletionEntriesForDirectoryFragment(fragment, nodeModules, fileExtensions, /*includeExtensions*/ false, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); } } return result; } + function getFragmentDirectory(fragment) { + return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; + } function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. @@ -94129,7 +95599,7 @@ var ts; return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; + return ts.startsWith(name, fragment) ? [directoryResult(name)] : ts.emptyArray; } } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { @@ -94157,15 +95627,20 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]).map(function (name) { return ({ name: name, kind: "script" /* scriptElement */ }); }); - var directories = tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }).map(function (name) { return ({ name: name, kind: "directory" /* directory */ }); }); - // Trim away prefix and suffix - return ts.mapDefined(ts.concatenate(matches, directories), function (_a) { - var name = _a.name, kind = _a.kind; - var normalizedMatch = ts.normalizePath(name); - var inner = withoutStartAndEnd(normalizedMatch, completePrefix, normalizedSuffix); - return inner !== undefined ? { name: removeLeadingDirectorySeparator(ts.removeFileExtension(inner)), kind: kind } : undefined; + var matches = ts.mapDefined(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); }); + var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var name = trimPrefixAndSuffix(dir); + return name === undefined ? undefined : directoryResult(name); + }); + return matches.concat(directories); + function trimPrefixAndSuffix(path) { + var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); + return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); + } } function withoutStartAndEnd(s, start, end) { return ts.startsWith(s, start) && ts.endsWith(s, end) ? s.slice(start.length, s.length - end.length) : undefined; @@ -94200,62 +95675,48 @@ 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, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, host, sourceFile.path) - : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath) - : undefined; - return names && addReplacementSpans(toComplete, range.pos + prefix.length, names); + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, /*includeExtensions*/ true), host, sourceFile.path) + : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) + : ts.Debug.fail(); + return addReplacementSpans(toComplete, range.pos + prefix.length, names); } - PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; - function getCompletionEntriesFromTypings(host, options, scriptPath, result) { + function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var typesName = _a[_i]; - var moduleName = ts.unmangleScopedPackageName(typesName); - pushResult(moduleName); - } + var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; + getCompletionEntriesFromDirectories(root); } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch ( /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */_b) { /* Wrap in try catch because getEffectiveTypeRoots touches the filesystem */ } - if (typeRoots) { - for (var _c = 0, typeRoots_2 = typeRoots; _c < typeRoots_2.length; _c++) { - var root = typeRoots_2[_c]; - getCompletionEntriesFromDirectories(root); - } - } - // Also get all @types typings installed in visible node_modules directories - for (var _d = 0, _e = findPackageJsons(scriptPath, host); _d < _e.length; _d++) { - var packageJson = _e[_d]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(typesDir); - } + // Also get all @types typings installed in visible node_modules directories + for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + var packageJson = _b[_a]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - ts.Debug.assert(!!host.getDirectories); - if (tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_2 = directories; _i < directories_2.length; _i++) { - var typeDirectory = directories_2[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - var directoryName = ts.getBaseFileName(typeDirectory); - var moduleName = ts.unmangleScopedPackageName(directoryName); - pushResult(moduleName); + if (!tryDirectoryExists(host, directory)) + return; + for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + var typeDirectoryName = _a[_i]; + var packageName = ts.unmangleScopedPackageName(typeDirectoryName); + if (options.types && !ts.contains(options.types, packageName)) + continue; + if (fragmentDirectory === undefined) { + if (!seen.has(packageName)) { + result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + seen.set(packageName, true); + } + } + else { + var baseDirectory = ts.combinePaths(directory, typeDirectoryName); + var remainingFragment = ts.tryRemoveDirectoryPrefix(fragmentDirectory, packageName, ts.hostGetCanonicalFileName(host)); + if (remainingFragment !== undefined) { + getCompletionEntriesForDirectoryFragment(remainingFragment, baseDirectory, extensionOptions, host, /*exclude*/ undefined, result); } } - } - } - function pushResult(moduleName) { - if (!seen.has(moduleName)) { - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); - seen.set(moduleName, true); } } } @@ -94345,27 +95806,27 @@ var ts; return tryIOAndConsumeErrors(host, host.fileExists, path); } function tryDirectoryExists(host, path) { - try { - return ts.directoryProbablyExists(path, host); - } - catch ( /*ignore*/_a) { /*ignore*/ } - return false; + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + function tryAndIgnoreErrors(cb) { try { - return toApply && toApply.apply(host, args); + return cb(); + } + catch (_a) { + return undefined; } - catch ( /*ignore*/_a) { /*ignore*/ } - return undefined; } function containsSlash(fragment) { return ts.stringContains(fragment, ts.directorySeparator); } - })(PathCompletions = Completions.PathCompletions || (Completions.PathCompletions = {})); + })(StringCompletions = Completions.StringCompletions || (Completions.StringCompletions = {})); })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -94405,20 +95866,15 @@ var ts; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); - if (ts.isInReferenceComment(sourceFile, position)) { - var entries = Completions.PathCompletions.getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); - return entries && convertPathCompletions(entries); - } var contextToken = ts.findPrecedingToken(position, sourceFile); if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) return undefined; - if (ts.isInString(sourceFile, position, contextToken)) { - return !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host), sourceFile, typeChecker, log, preferences); + var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); + if (stringCompletions) { + return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 72 /* BreakKeyword */ || contextToken.kind === 77 /* ContinueKeyword */ || contextToken.kind === 71 /* Identifier */)) { + && (contextToken.kind === 73 /* BreakKeyword */ || contextToken.kind === 78 /* ContinueKeyword */ || contextToken.kind === 72 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); @@ -94441,35 +95897,6 @@ var ts; } } Completions.getCompletionsAtPosition = getCompletionsAtPosition; - function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { - if (completion === undefined) { - return undefined; - } - switch (completion.kind) { - case 0 /* Paths */: - return convertPathCompletions(completion.paths); - case 1 /* Properties */: { - var entries = []; - getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 6 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; - } - case 2 /* Types */: { - var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; - } - default: - return ts.Debug.assertNever(completion); - } - } - function convertPathCompletions(pathCompletions) { - var isGlobalCompletion = false; // We don't want the editor to offer any other completions, such as snippets, inside a comment. - var isNewIdentifierLocation = true; // The user may type in a path that doesn't yet exist, creating a "new identifier" with respect to the collection of identifiers the server is aware of. - var entries = pathCompletions.map(function (_a) { - var name = _a.name, kind = _a.kind, span = _a.span; - return ({ name: name, kind: kind, kindModifiers: "" /* none */, sortText: "0", replacementSpan: span }); - }); - return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: false, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - } function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } @@ -94483,7 +95910,7 @@ var ts; // The completion list at "1" will contain "div>" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 29 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -94548,7 +95975,9 @@ var ts; } }); } - var completionNameForLiteral = JSON.stringify; + var completionNameForLiteral = function (literal) { + return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal); + }; function createCompletionEntryForLiteral(literal) { return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: "0" }; } @@ -94561,13 +95990,13 @@ var ts; var insertText; var replacementSpan; if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + quote(name, preferences) + "]" : "this." + name; + insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 23 /* DotToken */, sourceFile); + insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -94602,21 +96031,6 @@ var ts; replacementSpan: replacementSpan, }; } - function quote(text, preferences) { - if (/^\d+$/.test(text)) { - return text; - } - var quoted = JSON.stringify(text); - switch (preferences.quotePreference) { - case undefined: - case "double": - return quoted; - case "single": - return "'" + ts.stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"') + "'"; - default: - return ts.Debug.assertNever(preferences.quotePreference); - } - } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; @@ -94654,6 +96068,7 @@ var ts; log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); return uniques; } + Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { var entries = getLabelStatementCompletions(node); if (entries.length) { @@ -94684,131 +96099,6 @@ var ts; } return entries; } - var StringLiteralCompletionKind; - (function (StringLiteralCompletionKind) { - StringLiteralCompletionKind[StringLiteralCompletionKind["Paths"] = 0] = "Paths"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; - StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; - })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { - var parent = node.parent; - switch (parent.kind) { - case 180 /* LiteralType */: - switch (parent.parent.kind) { - case 162 /* TypeReference */: - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 178 /* IndexedAccessType */: - // Get all apparent property names - // i.e. interface Foo { - // foo: string; - // bar: string; - // } - // let x: Foo["/*completion position*/"] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 181 /* ImportType */: - return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 171 /* UnionType */: { - if (!ts.isTypeReferenceNode(parent.parent.parent)) - return undefined; - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent.parent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; - } - default: - return undefined; - } - case 273 /* PropertyAssignment */: - if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { - // Get quoted name of properties of the object literal expression - // i.e. interface ConfigFiles { - // 'jspm:dev': string - // } - // let files: ConfigFiles = { - // '/*completion position*/' - // } - // - // function foo(c: ConfigFiles) {} - // foo({ - // '/*completion position*/' - // }); - return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); - } - return fromContextualType(); - case 188 /* ElementAccessExpression */: { - var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; - if (node === argumentExpression) { - // Get all names of properties on the expression - // i.e. interface A { - // 'prop1': string - // } - // let a: A; - // a['/*completion position*/'] - return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); - } - return undefined; - } - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(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(); - } - // falls through (is `require("")` or `import("")`) - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 257 /* 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: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - 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(getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; - } - } - function getAlreadyUsedTypesInStringLiteralUnion(union, current) { - return ts.mapDefined(union.types, function (type) { - return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined; - }); - } - function getStringLiteralCompletionsFromSignature(argumentInfo, checker) { - var isNewIdentifier = false; - var uniques = ts.createMap(); - var candidates = []; - checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); - var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) - return; - var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); - return getStringLiteralTypes(type, uniques); - }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; - } - function stringLiteralCompletionsFromProperties(type) { - return type && { kind: 1 /* Properties */, symbols: type.getApparentProperties(), hasIndexSignature: hasIndexSignature(type) }; - } - function getStringLiteralTypes(type, uniques) { - if (uniques === void 0) { uniques = ts.createMap(); } - if (!type) - return ts.emptyArray; - type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 512 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; - } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); @@ -94847,10 +96137,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - var stringLiteralCompletions = !contextToken || !ts.isStringLiteralLike(contextToken) - ? undefined - : getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host); - return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); // TODO: GH#18217 + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); @@ -94894,25 +96181,11 @@ var ts; }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } - function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { - switch (completion.kind) { - case 0 /* Paths */: { - var match = ts.find(completion.paths, function (p) { return p.name === name; }); - return match && createCompletionDetails(name, "" /* none */, match.kind, [ts.textPart(name)]); - } - case 1 /* Properties */: { - var match = ts.find(completion.symbols, function (s) { return s.name === name; }); - return match && createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); - } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; - default: - return ts.Debug.assertNever(completion); - } - } + Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } + Completions.createCompletionDetails = createCompletionDetails; function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { @@ -94943,7 +96216,7 @@ var ts; CompletionKind[CompletionKind["MemberLike"] = 3] = "MemberLike"; CompletionKind[CompletionKind["String"] = 4] = "String"; CompletionKind[CompletionKind["None"] = 5] = "None"; - })(CompletionKind || (CompletionKind = {})); + })(CompletionKind = Completions.CompletionKind || (Completions.CompletionKind = {})); function getRecommendedCompletion(previousToken, contextualType, checker) { // For a union, return the first one with a recommended completion. return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { @@ -94957,56 +96230,36 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 71 /* Identifier */: - return getContextualTypeFromParent(previousToken, checker); - case 58 /* EqualsToken */: + case 72 /* Identifier */: + return ts.getContextualTypeFromParent(previousToken, checker); + case 59 /* EqualsToken */: switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return checker.getContextualType(parent); - case 73 /* CaseKeyword */: - return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); - case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + case 74 /* CaseKeyword */: + return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); + case 18 /* OpenBraceToken */: + return ts.isJsxExpression(parent) && parent.parent.kind !== 260 /* JsxElement */ ? 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 === 26 /* CommaToken */ ? 1 : 0)) - : isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind) + ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* 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) : checker.getContextualType(previousToken); } } - function getContextualTypeFromParent(node, checker) { - var parent = node.parent; - switch (parent.kind) { - case 190 /* NewExpression */: - return checker.getContextualType(parent); - case 202 /* 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 269 /* CaseClause */: - return parent.expression === node ? getSwitchedType(parent, checker) : undefined; - default: - return checker.getContextualType(node); - } - } - function getSwitchedType(caseClause, checker) { - return checker.getTypeAtLocation(caseClause.parent.parent.expression); - } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); if (chain) @@ -95014,7 +96267,7 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 279 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); @@ -95065,11 +96318,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 303 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 305 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -95095,9 +96348,9 @@ var ts; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { - var start_4 = ts.timestamp(); + var start_3 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 - log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); + log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_3)); } // Find the node where completion is requested on. // Also determine whether we are trying to complete with members of that node @@ -95116,21 +96369,21 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 23 /* DotToken */) { + if (contextToken.kind === 24 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: node = parent.left; break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: node = parent.name; break; - case 181 /* ImportType */: - case 212 /* MetaProperty */: + case 183 /* ImportType */: + case 214 /* MetaProperty */: node = parent; break; default: @@ -95143,56 +96396,56 @@ var ts; // // 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 === 187 /* PropertyAccessExpression */) { + if (parent && parent.kind === 189 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { + case 30 /* GreaterThanToken */: + if (currentToken.parent.kind === 260 /* JsxElement */ || currentToken.parent.kind === 262 /* JsxOpeningElement */) { location = currentToken; } break; - case 41 /* SlashToken */: - if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { + case 42 /* SlashToken */: + if (currentToken.parent.kind === 261 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 261 /* JsxClosingElement */: - if (contextToken.kind === 41 /* SlashToken */) { + case 263 /* JsxClosingElement */: + if (contextToken.kind === 42 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: - case 260 /* JsxOpeningElement */: - if (contextToken.kind === 27 /* LessThanToken */) { + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: + case 262 /* JsxOpeningElement */: + if (contextToken.kind === 28 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: switch (previousToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: isJsxInitializer = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: // For `
` 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, 58 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 59 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -95240,11 +96493,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: - case 298 /* JSDocReturnTag */: - case 300 /* JSDocTypeTag */: - case 302 /* JSDocTypedefTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 304 /* JSDocTypedefTag */: return true; default: return false; @@ -95284,15 +96537,15 @@ 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.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 279 /* SourceFile */ && d.kind !== 244 /* ModuleDeclaration */ && d.kind !== 243 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 94 /* NewKeyword */ || node.keywordToken === 91 /* ImportKeyword */)) { - var completion = (node.keywordToken === 94 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 95 /* NewKeyword */ || node.keywordToken === 92 /* ImportKeyword */)) { + var completion = (node.keywordToken === 95 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -95313,7 +96566,7 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 183 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -95367,10 +96620,10 @@ var ts; function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element - var attrsType = jsxContainer && typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); + var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) return 0 /* Continue */; - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); + symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -95416,7 +96669,7 @@ var ts; var symbolMeanings = 67897832 /* Type */ | 67220415 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 279 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { @@ -95452,10 +96705,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 277 /* SourceFile */: - case 204 /* TemplateExpression */: - case 268 /* JsxExpression */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 206 /* TemplateExpression */: + case 270 /* JsxExpression */: + case 218 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -95491,41 +96744,35 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 103 /* TypeOfKeyword */ && - (contextToken.parent.kind === 165 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 104 /* TypeOfKeyword */ && + (contextToken.parent.kind === 167 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 56 /* ColonToken */: - return parentKind === 152 /* PropertyDeclaration */ || - parentKind === 151 /* PropertySignature */ || - parentKind === 149 /* Parameter */ || - parentKind === 235 /* VariableDeclaration */ || + case 57 /* ColonToken */: + return parentKind === 154 /* PropertyDeclaration */ || + parentKind === 153 /* PropertySignature */ || + parentKind === 151 /* Parameter */ || + parentKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 58 /* EqualsToken */: - return parentKind === 240 /* TypeAliasDeclaration */; - case 118 /* AsKeyword */: - return parentKind === 210 /* AsExpression */; + case 59 /* EqualsToken */: + return parentKind === 242 /* TypeAliasDeclaration */; + case 119 /* AsKeyword */: + return parentKind === 212 /* AsExpression */; } } return false; } - function symbolCanBeReferencedAtTypeLocation(symbol) { - symbol = symbol.exportSymbol || symbol; - // This is an alias, follow what it aliases - symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & 67897832 /* Type */) { - return true; - } - if (symbol.flags & 1536 /* Module */) { - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - // If the exported symbols contains type, - // symbol can be referenced at locations where type is allowed - return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); - } - return false; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { + if (seenModules === void 0) { seenModules = ts.createMap(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); + return !!(sym.flags & 67897832 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); @@ -95553,13 +96800,16 @@ var ts; // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. // This is just to avoid adding duplicate completion entries. // - // If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. - // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { + || ts.some(symbol.declarations, function (d) { + // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); + })) { continue; } - var isDefaultExport = symbol.name === "default" /* Default */; + var isDefaultExport = symbol.escapedName === "default" /* Default */; if (isDefaultExport) { symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; } @@ -95613,15 +96863,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 10 /* JsxText */) { + if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { + if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 262 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; + if (contextToken.parent.kind === 263 /* JsxClosingElement */ || contextToken.parent.kind === 261 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 260 /* JsxElement */; } } return false; @@ -95631,41 +96881,41 @@ var ts; var containingNodeKind = previousToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { - case 26 /* CommaToken */: - return containingNodeKind === 189 /* CallExpression */ // func( a, | - || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 190 /* NewExpression */ // new C(a, | - || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| - case 19 /* OpenParenToken */: - return containingNodeKind === 189 /* CallExpression */ // func( | - || containingNodeKind === 155 /* Constructor */ // constructor( | - || containingNodeKind === 190 /* NewExpression */ // new C(a| - || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 21 /* OpenBracketToken */: - return containingNodeKind === 185 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 129 /* ModuleKeyword */: // module | - case 130 /* NamespaceKeyword */: // namespace | + case 27 /* CommaToken */: + return containingNodeKind === 191 /* CallExpression */ // func( a, | + || containingNodeKind === 157 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 192 /* NewExpression */ // new C(a, | + || containingNodeKind === 187 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 204 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 165 /* FunctionType */; // var x: (s: string, list| + case 20 /* OpenParenToken */: + return containingNodeKind === 191 /* CallExpression */ // func( | + || containingNodeKind === 157 /* Constructor */ // constructor( | + || containingNodeKind === 192 /* NewExpression */ // new C(a| + || containingNodeKind === 195 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 177 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* OpenBracketToken */: + return containingNodeKind === 187 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 162 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 149 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 130 /* ModuleKeyword */: // module | + case 131 /* NamespaceKeyword */: // namespace | return true; - case 23 /* DotToken */: - return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| - case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | - case 58 /* EqualsToken */: - return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 202 /* BinaryExpression */; // x = a| - case 14 /* TemplateHead */: - return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| - case 15 /* TemplateMiddle */: - return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */; // class A{ public | + case 24 /* DotToken */: + return containingNodeKind === 244 /* ModuleDeclaration */; // module A.| + case 18 /* OpenBraceToken */: + return containingNodeKind === 240 /* ClassDeclaration */; // class A{ | + case 59 /* EqualsToken */: + return containingNodeKind === 237 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 204 /* BinaryExpression */; // x = a| + case 15 /* TemplateHead */: + return containingNodeKind === 206 /* TemplateExpression */; // `aa ${| + case 16 /* TemplateMiddle */: + return containingNodeKind === 216 /* TemplateSpan */; // `aa ${10} dd ${| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -95692,16 +96942,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 188 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; - isNewIdentifierLocation = hasIndexSignature(typeForObject); + isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 184 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -95712,12 +96962,12 @@ 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 === 225 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 227 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 151 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 154 /* MethodDeclaration */ || rootDeclaration.parent.kind === 157 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 156 /* MethodDeclaration */ || rootDeclaration.parent.kind === 159 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -95753,13 +97003,13 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { // `import { |` or `import { a as 0, | }` - var namedImportsOrExports = contextToken && (contextToken.kind === 17 /* OpenBraceToken */ || contextToken.kind === 26 /* CommaToken */) + var namedImportsOrExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 252 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -95782,7 +97032,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 39 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* 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)) @@ -95790,7 +97040,7 @@ var ts; var classElement = contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 71 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 72 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -95819,15 +97069,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 17 /* OpenBraceToken */: // const x = { | - case 26 /* CommaToken */: // const x = { a: 0, | + case 18 /* OpenBraceToken */: // const x = { | + case 27 /* CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 71 /* Identifier */: + case 72 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -95846,8 +97096,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 19 /* OpenParenToken */: - case 26 /* CommaToken */: + case 20 /* OpenParenToken */: + case 27 /* CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -95877,17 +97127,17 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 28 /* LessThanSlashToken */: - case 41 /* SlashToken */: - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 266 /* JsxAttributes */: - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { + case 29 /* LessThanSlashToken */: + case 42 /* SlashToken */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 268 /* JsxAttributes */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 261 /* JsxSelfClosingElement */ || parent.kind === 262 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 265 /* JsxAttribute */) { + else if (parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95898,8 +97148,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 9 /* StringLiteral */: - if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { + case 10 /* StringLiteral */: + if (parent && ((parent.kind === 267 /* JsxAttribute */) || (parent.kind === 269 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95907,10 +97157,10 @@ var ts; return parent.parent.parent; } break; - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: if (parent && - parent.kind === 268 /* JsxExpression */ && - parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { + parent.kind === 270 /* JsxExpression */ && + parent.parent && parent.parent.kind === 267 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95918,7 +97168,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 269 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -95937,65 +97187,65 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 26 /* CommaToken */: - return containingNodeKind === 235 /* VariableDeclaration */ || - containingNodeKind === 236 /* VariableDeclarationList */ || - containingNodeKind === 217 /* VariableStatement */ || - containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | + case 27 /* CommaToken */: + return containingNodeKind === 237 /* VariableDeclaration */ || + containingNodeKind === 238 /* VariableDeclarationList */ || + containingNodeKind === 219 /* VariableStatement */ || + containingNodeKind === 243 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 23 /* DotToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| - case 56 /* ColonToken */: - return containingNodeKind === 184 /* BindingElement */; // var {x :html| - case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| - case 19 /* OpenParenToken */: - return containingNodeKind === 272 /* CatchClause */ || + case 24 /* DotToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [.| + case 57 /* ColonToken */: + return containingNodeKind === 186 /* BindingElement */; // var {x :html| + case 22 /* OpenBracketToken */: + return containingNodeKind === 185 /* ArrayBindingPattern */; // var [x| + case 20 /* OpenParenToken */: + return containingNodeKind === 274 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 17 /* OpenBraceToken */: - return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | - case 27 /* LessThanToken */: - return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | - containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | + case 18 /* OpenBraceToken */: + return containingNodeKind === 243 /* EnumDeclaration */; // enum a { | + case 28 /* LessThanToken */: + return containingNodeKind === 240 /* ClassDeclaration */ || // class A< | + containingNodeKind === 209 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 241 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 242 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 115 /* StaticKeyword */: - return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 24 /* DotDotDotToken */: - return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 118 /* AsKeyword */: - return containingNodeKind === 251 /* ImportSpecifier */ || - containingNodeKind === 255 /* ExportSpecifier */ || - containingNodeKind === 249 /* NamespaceImport */; - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + return containingNodeKind === 154 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* DotDotDotToken */: + return containingNodeKind === 151 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 185 /* ArrayBindingPattern */); // var [...z| + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + return containingNodeKind === 151 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 119 /* AsKeyword */: + return containingNodeKind === 253 /* ImportSpecifier */ || + containingNodeKind === 257 /* ExportSpecifier */ || + containingNodeKind === 251 /* NamespaceImport */; + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 109 /* InterfaceKeyword */: - case 89 /* FunctionKeyword */: - case 104 /* VarKeyword */: - case 91 /* ImportKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 116 /* YieldKeyword */: - case 139 /* TypeKeyword */: // type htm| + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 110 /* InterfaceKeyword */: + case 90 /* FunctionKeyword */: + case 105 /* VarKeyword */: + case 92 /* ImportKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 117 /* YieldKeyword */: + case 140 /* TypeKeyword */: // type htm| return true; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -96016,22 +97266,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 117 /* AbstractKeyword */: - case 75 /* ClassKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 83 /* EnumKeyword */: - case 89 /* FunctionKeyword */: - case 109 /* InterfaceKeyword */: - case 110 /* LetKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 115 /* StaticKeyword */: - case 104 /* VarKeyword */: - case 116 /* YieldKeyword */: + case 118 /* AbstractKeyword */: + case 76 /* ClassKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 84 /* EnumKeyword */: + case 90 /* FunctionKeyword */: + case 110 /* InterfaceKeyword */: + case 111 /* LetKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 116 /* StaticKeyword */: + case 105 /* VarKeyword */: + case 117 /* YieldKeyword */: return true; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -96041,7 +97291,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 155 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 157 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -96064,12 +97314,12 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 273 /* PropertyAssignment */ && - m.kind !== 274 /* ShorthandPropertyAssignment */ && - m.kind !== 184 /* BindingElement */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 275 /* PropertyAssignment */ && + m.kind !== 276 /* ShorthandPropertyAssignment */ && + m.kind !== 186 /* BindingElement */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -96079,7 +97329,7 @@ var ts; var existingName = void 0; if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 71 /* Identifier */) { + if (m.propertyName.kind === 72 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -96104,10 +97354,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 !== 152 /* PropertyDeclaration */ && - m.kind !== 154 /* MethodDeclaration */ && - m.kind !== 156 /* GetAccessor */ && - m.kind !== 157 /* SetAccessor */) { + if (m.kind !== 154 /* PropertyDeclaration */ && + m.kind !== 156 /* MethodDeclaration */ && + m.kind !== 158 /* GetAccessor */ && + m.kind !== 159 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -96147,7 +97397,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 265 /* JsxAttribute */) { + if (attr.kind === 267 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -96191,7 +97441,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72 /* FirstKeyword */; i <= 145 /* LastKeyword */; i++) { + for (var i = 73 /* FirstKeyword */; i <= 147 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -96208,8 +97458,8 @@ var ts; case 0 /* None */: return false; case 1 /* All */: - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 124 /* DeclareKeyword */ || kind === 129 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 140 /* UndefinedKeyword */; + return kind === 121 /* AsyncKeyword */ || 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === 125 /* DeclareKeyword */ || kind === 130 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 141 /* UndefinedKeyword */; case 2 /* ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); case 3 /* InterfaceElementKeywords */: @@ -96226,37 +97476,26 @@ var ts; })); } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 132 /* ReadonlyKeyword */; + return kind === 133 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 117 /* AbstractKeyword */: - case 123 /* ConstructorKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - case 120 /* AsyncKeyword */: + case 118 /* AbstractKeyword */: + case 124 /* ConstructorKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + case 121 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 120 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; } - function isEqualityOperatorKind(kind) { - switch (kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - return true; - default: - return false; - } - } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { var jsdoc = ts.findAncestor(node, ts.isJSDoc); @@ -96266,7 +97505,7 @@ var ts; return contextualType.isUnion() ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - return !(memberType.flags & 32764 /* Primitive */ || + return !(memberType.flags & 131068 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); @@ -96289,31 +97528,31 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 304 /* SyntaxList */: + case 306 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { return cls; } } if (!contextToken) return undefined; switch (contextToken.kind) { - case 25 /* SemicolonToken */: // class c {getValue(): number; | } - case 18 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SemicolonToken */: // class c {getValue(): number; | } + case 19 /* CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 17 /* OpenBraceToken */: // class c { | - case 26 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* OpenBraceToken */: // class c { | + case 27 /* CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) return undefined; var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 39 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -96321,9 +97560,6 @@ var ts; function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); } - function hasIndexSignature(type) { - return !!type.getStringIndexType() || !!type.getNumberIndexType(); - } function isValidTrigger(sourceFile, triggerCharacter, contextToken, position) { switch (triggerCharacter) { case ".": @@ -96333,14 +97569,14 @@ var ts; case "'": case "`": // Only automatically bring up completions if this is an opening quote. - return !!contextToken && isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; + return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 41 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -96349,17 +97585,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function isStringLiteralOrTemplate(node) { - switch (node.kind) { - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - return true; - default: - return false; - } - } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -96412,40 +97637,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 90 /* IfKeyword */: - case 82 /* ElseKeyword */: + case 91 /* IfKeyword */: + case 83 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 96 /* ReturnKeyword */: + case 97 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 102 /* TryKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: - var tryStatement = node.kind === 74 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 103 /* TryKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: + var tryStatement = node.kind === 75 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 73 /* CaseKeyword */: - case 79 /* DefaultKeyword */: + case 74 /* CaseKeyword */: + case 80 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 72 /* BreakKeyword */: - case 77 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 78 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 88 /* ForKeyword */: - case 106 /* WhileKeyword */: - case 81 /* DoKeyword */: + case 89 /* ForKeyword */: + case 107 /* WhileKeyword */: + case 82 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 123 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [123 /* ConstructorKeyword */]); - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [125 /* GetKeyword */, 136 /* SetKeyword */]); - case 121 /* AwaitKeyword */: + case 124 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [124 /* ConstructorKeyword */]); + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [126 /* GetKeyword */, 137 /* SetKeyword */]); + case 122 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 116 /* YieldKeyword */: + case 117 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -96488,7 +97713,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 279 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -96520,16 +97745,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 230 /* SwitchStatement */: - if (statement.kind === 226 /* ContinueStatement */) { + case 232 /* SwitchStatement */: + if (statement.kind === 228 /* ContinueStatement */) { return false; } // falls through - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -96545,11 +97770,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 216 /* Block */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 218 /* Block */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -96557,12 +97782,12 @@ var ts; else { return container.statements; } - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: 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. @@ -96593,12 +97818,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 89 /* ForKeyword */, 107 /* WhileKeyword */, 82 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 221 /* DoStatement */) { + if (loopNode.kind === 223 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 107 /* WhileKeyword */)) { break; } } @@ -96606,7 +97831,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */, 77 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */, 78 /* ContinueKeyword */); } }); return keywords; @@ -96615,13 +97840,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -96629,13 +97854,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 98 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 99 /* 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(), 73 /* CaseKeyword */, 79 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 74 /* CaseKeyword */, 80 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 73 /* BreakKeyword */); } }); }); @@ -96643,13 +97868,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 102 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 103 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 75 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 87 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 88 /* FinallyKeyword */); } return keywords; } @@ -96660,13 +97885,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* 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, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -96678,11 +97903,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 96 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 97 /* 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, 100 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 101 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -96694,13 +97919,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 120 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 121 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 122 /* AwaitKeyword */); } }); }); @@ -96715,7 +97940,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 116 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 117 /* YieldKeyword */); } }); }); @@ -96734,7 +97959,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 === 82 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 83 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -96769,10 +97994,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], 90 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 91 /* 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], 82 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 83 /* ElseKeyword */)) { break; } } @@ -96805,13 +98030,6 @@ var ts; // for those settings. var buckets = ts.createMap(); var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets.get(key); - if (!bucket && createIfMissing) { - buckets.set(key, bucket = ts.createMap()); - } - return bucket; // TODO: GH#18217 - } function reportStats() { var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { var entries = buckets.get(name); @@ -96847,7 +98065,7 @@ var ts; return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); + var bucket = ts.getOrUpdate(buckets, key, ts.createMap); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; if (!entry && externalCache) { @@ -96901,8 +98119,7 @@ var ts; return releaseDocumentWithKey(path, key); } function releaseDocumentWithKey(path, key) { - var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ false); - ts.Debug.assert(bucket !== undefined); + var bucket = ts.Debug.assertDefined(buckets.get(key)); var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); @@ -96996,12 +98213,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 237 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { directImports.push(name); break; } @@ -97010,22 +98227,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 71 /* Identifier */: // for 'const x = require("y"); + case 72 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 251 /* 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 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -97035,7 +98252,7 @@ var ts; directImports.push(direct); } break; - case 181 /* ImportType */: + case 183 /* ImportType */: directImports.push(direct); break; default: @@ -97052,7 +98269,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 279 /* SourceFile */ || sourceFileLike.kind === 244 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -97107,17 +98324,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 246 /* ImportEqualsDeclaration */) { + if (decl.kind === 248 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 71 /* Identifier */) { + if (decl.kind === 72 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 181 /* ImportType */) { + if (decl.kind === 183 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -97129,20 +98346,20 @@ var ts; return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 253 /* ExportDeclaration */) { + if (decl.kind === 255 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -97192,7 +98409,7 @@ var ts; } } else { - var localSymbol = element.kind === 255 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 257 /* 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); @@ -97221,7 +98438,7 @@ var ts; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var referencingFile = sourceFiles_3[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 277 /* SourceFile */) { + if (searchSourceFile.kind === 279 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -97269,7 +98486,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 === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 279 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -97284,15 +98501,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 253 /* ExportDeclaration */: - case 247 /* ImportDeclaration */: { + case 255 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -97316,7 +98533,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 187 /* PropertyAccessExpression */) { + if (parent.kind === 189 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -97438,10 +98655,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 235 /* VariableDeclaration */) { + if (parent.kind === 237 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 274 /* CatchClause */ ? undefined : p.parent.parent.kind === 219 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -97450,15 +98667,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -97491,21 +98708,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 277 /* SourceFile */) { + if (parent.kind === 279 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 245 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 244 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 259 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -97557,18 +98774,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* 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 === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var result_7 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_7.push(nodeEntry(node)); }); return result_7; } - else if (node.kind === 97 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 98 /* 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); @@ -97630,7 +98847,7 @@ var ts; } function getDefinitionKindAndDisplayParts(symbol, checker, node) { var meaning = FindAllReferences.Core.getIntersectingMeaningFromDeclarations(node, symbol); - var enclosingDeclaration = ts.firstOrUndefined(symbol.declarations) || node; + var enclosingDeclaration = symbol.declarations && ts.firstOrUndefined(symbol.declarations) || node; var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, enclosingDeclaration.getSourceFile(), enclosingDeclaration, enclosingDeclaration, meaning), displayParts = _a.displayParts, symbolKind = _a.symbolKind; return { displayParts: displayParts, kind: symbolKind }; } @@ -97648,7 +98865,7 @@ var ts; textSpan: textSpan, fileName: fileName, isWriteAccess: isWriteAccessForReference(node), - isDefinition: node.kind === 79 /* DefaultKeyword */ + isDefinition: node.kind === 80 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined, @@ -97703,16 +98920,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 207 /* ClassExpression */) { + else if (node.kind === 209 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] + displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] }; } else { @@ -97738,7 +98955,7 @@ var ts; function getTextSpan(node, sourceFile) { var start = node.getStart(sourceFile); var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { start += 1; end -= 1; } @@ -97747,7 +98964,7 @@ var ts; /** 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 === 79 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 80 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -97758,46 +98975,46 @@ var ts; if (!!(decl.flags & 4194304 /* Ambient */)) return true; switch (decl.kind) { - case 202 /* BinaryExpression */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 79 /* DefaultKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 255 /* ExportSpecifier */: - case 248 /* ImportClause */: // default import - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 239 /* InterfaceDeclaration */: - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 265 /* JsxAttribute */: - case 242 /* ModuleDeclaration */: - case 245 /* NamespaceExportDeclaration */: - case 249 /* NamespaceImport */: - case 149 /* Parameter */: - case 274 /* ShorthandPropertyAssignment */: - case 240 /* TypeAliasDeclaration */: - case 148 /* TypeParameter */: + case 204 /* BinaryExpression */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 80 /* DefaultKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 257 /* ExportSpecifier */: + case 250 /* ImportClause */: // default import + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 241 /* InterfaceDeclaration */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 267 /* JsxAttribute */: + case 244 /* ModuleDeclaration */: + case 247 /* NamespaceExportDeclaration */: + case 251 /* NamespaceImport */: + case 151 /* Parameter */: + case 276 /* ShorthandPropertyAssignment */: + case 242 /* TypeAliasDeclaration */: + case 150 /* TypeParameter */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return !!decl.body; - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 153 /* MethodSignature */: - case 151 /* PropertySignature */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 155 /* MethodSignature */: + case 153 /* PropertySignature */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -97834,6 +99051,9 @@ var ts; // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. return !options.implementations && ts.isStringLiteral(node) ? getReferencesForStringLiteral(node, sourceFiles, cancellationToken) : undefined; } + if (symbol.escapedName === "export=" /* ExportEquals */) { + return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); + } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); var referencedNode = node; @@ -97878,10 +99098,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 277 /* SourceFile */: + case 279 /* 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -97891,6 +99111,22 @@ var ts; ts.Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } + var exported = symbol.exports.get("export=" /* ExportEquals */); + if (exported) { + for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { + var decl = _c[_b]; + var sourceFile = decl.getSourceFile(); + 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.assertDefined(ts.findChildOfKind(decl, 85 /* ExportKeyword */, sourceFile)) + : ts.getNameOfDeclaration(decl) || decl; + references.push(FindAllReferences.nodeEntry(node)); + } + } + } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** getReferencedSymbols for special node kinds. */ @@ -97912,7 +99148,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -97924,7 +99160,7 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - if (node && node.kind === 79 /* DefaultKeyword */) { + if (node && node.kind === 80 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -97949,9 +99185,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: return 1 /* Constructor */; - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -98183,7 +99419,7 @@ 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 === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 196 /* FunctionExpression */ || valueDeclaration.kind === 209 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -98193,7 +99429,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 240 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -98222,7 +99458,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 279 /* 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; @@ -98243,7 +99479,9 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = checker.getSymbolAtLocation(definition); + var symbol = ts.isParameterPropertyDeclaration(definition.parent) + ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) + : checker.getSymbolAtLocation(definition); if (!symbol) return undefined; for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { @@ -98328,16 +99566,16 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.text.length === searchSymbolName.length; - case 9 /* StringLiteral */: { + case 10 /* StringLiteral */: { var str = node; - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(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 */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 79 /* DefaultKeyword */: + case 80 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -98401,7 +99639,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 71 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 72 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -98456,7 +99694,7 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!(referenceLocation === propertyName && state.options.isForRename)) { - var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; + var exportKind = referenceLocation.originalKeywordKind === 80 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); if (!exportInfo) return ts.Debug.fail(); @@ -98536,7 +99774,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 80 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -98562,7 +99800,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -98579,16 +99817,16 @@ var ts; function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { for (var _i = 0, _a = classSymbol.members.get("__constructor" /* Constructor */).declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 155 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 124 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 157 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 154 /* MethodDeclaration */) { + if (decl && decl.kind === 156 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 100 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -98605,10 +99843,10 @@ var ts; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 155 /* Constructor */); + ts.Debug.assert(decl.kind === 157 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 98 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -98622,10 +99860,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 71 /* Identifier */) { + if (refNode.kind !== 72 /* Identifier */) { return; } - if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 276 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -98645,7 +99883,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 216 /* Block */) { + if (body.kind === 218 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -98673,13 +99911,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 185 /* ArrayLiteralExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 187 /* ArrayLiteralExpression */: return true; default: return false; @@ -98732,13 +99970,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -98747,7 +99985,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 97 /* SuperKeyword */) { + if (node.kind !== 98 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -98763,34 +100001,34 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 279 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -98798,19 +100036,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 277 /* SourceFile */: - return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); + case 279 /* SourceFile */: + return container.kind === 279 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -99007,7 +100245,7 @@ var ts; var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); } @@ -99016,7 +100254,7 @@ var ts; function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var originalPath = sourceMapper && sourceMapper.tryGetOriginalLocation({ fileName: path, position: 0 }); + var originalPath = sourceMapper && sourceMapper.tryGetSourcePosition({ fileName: path, pos: 0 }); var updatedPath = getUpdatedPath(originalPath ? originalPath.fileName : path); return originalPath ? updatedPath === undefined ? undefined : makeCorrespondingRelativeChange(originalPath.fileName, updatedPath, path, getCanonicalFileName) @@ -99035,7 +100273,7 @@ var ts; var rel = ts.getRelativePathFromFile(a0, b0, getCanonicalFileName); return combinePathsSafe(ts.getDirectoryPath(a1), rel); } - function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + function updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) return; @@ -99053,7 +100291,8 @@ var ts; var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); // If there isn't some include for this, add a new one. - if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + if (ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && + !ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); } } @@ -99246,7 +100485,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 97 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 98 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -99254,7 +100493,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 276 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -99407,18 +100646,18 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 71 /* Identifier */) { + if (node.kind !== 72 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 248 /* ImportClause */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: return true; - case 251 /* ImportSpecifier */: - return declaration.parent.kind === 250 /* NamedImports */; + case 253 /* ImportSpecifier */: + return declaration.parent.kind === 252 /* NamedImports */; default: return false; } @@ -99428,7 +100667,7 @@ var ts; 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 */ && (ts.isNewExpressionTarget(node) || node.kind === 123 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 124 /* ConstructorKeyword */)) { var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -99502,9 +100741,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return true; default: return false; @@ -99622,11 +100861,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: return [declaration]; - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -99647,16 +100886,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return withNode(tag.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -99833,7 +101072,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 === 71 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 72 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -99843,23 +101082,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 155 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 151 /* PropertySignature */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 153 /* PropertySignature */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 242 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -99867,14 +101106,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 277 /* SourceFile */: + case 279 /* SourceFile */: return "quit"; - case 242 /* ModuleDeclaration */: + case 244 /* 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 === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 202 /* BinaryExpression */: { + return commentOwner.parent.kind === 244 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 204 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -99893,14 +101132,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 195 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return rightHandSide.parameters; - case 207 /* ClassExpression */: { + case 209 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -99962,9 +101201,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 248 /* ImportClause */: - case 251 /* ImportSpecifier */: - case 246 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 253 /* ImportSpecifier */: + case 248 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -99974,7 +101213,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 147 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 149 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -99991,7 +101230,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 === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 149 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -100160,7 +101399,7 @@ var ts; return; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* 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); @@ -100172,21 +101411,21 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 155 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -100198,7 +101437,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -100209,8 +101448,8 @@ var ts; } } break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -100231,12 +101470,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -100246,9 +101485,9 @@ var ts; } endNode(); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -100256,18 +101495,18 @@ var ts; } endNode(); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 255 /* ExportSpecifier */: - case 246 /* ImportEqualsDeclaration */: - case 160 /* IndexSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 240 /* TypeAliasDeclaration */: + case 257 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 162 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 242 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -100279,6 +101518,9 @@ var ts; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -100346,12 +101588,12 @@ var ts; return false; } switch (a.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -100367,7 +101609,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 244 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -100397,7 +101639,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -100405,16 +101647,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 242 /* ModuleDeclaration */) { + if (node.kind === 244 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -100424,16 +101666,16 @@ var ts; } } switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -100441,13 +101683,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return "new()"; - case 158 /* CallSignature */: + case 160 /* CallSignature */: return "()"; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "[]"; default: return ""; @@ -100471,25 +101713,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 277 /* SourceFile */: - case 240 /* TypeAliasDeclaration */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 279 /* SourceFile */: + case 242 /* TypeAliasDeclaration */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return true; - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 235 /* VariableDeclaration */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 237 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 195 /* ArrowFunction */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -100499,10 +101741,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 243 /* ModuleBlock */: - case 277 /* SourceFile */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: + case 245 /* ModuleBlock */: + case 279 /* SourceFile */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -100511,7 +101753,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; + return childKind !== 237 /* VariableDeclaration */ && childKind !== 186 /* BindingElement */; }); } } @@ -100568,7 +101810,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -100582,13 +101824,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 147 /* ComputedPropertyName */; + return !member.name || member.name.kind === 149 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 279 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 237 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -100603,7 +101845,7 @@ var ts; return ts.declarationNameToString(parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -100641,9 +101883,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 195 /* ArrowFunction */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: return true; default: return false; @@ -100770,7 +102012,7 @@ var ts; ? specifier.text : undefined; } - /* @internal */ // Internal for testing + // Internal for testing /** * @param importGroup a list of ImportDeclarations, all with the same module name. */ @@ -100869,7 +102111,7 @@ var ts; } } OrganizeImports.coalesceImports = coalesceImports; - /* @internal */ // Internal for testing + // Internal for testing /** * @param exportGroup a list of ExportDeclarations, all with the same module name. */ @@ -100972,7 +102214,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 91 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 92 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -101079,31 +102321,31 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 197 /* ArrowFunction */); } // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 221 /* DoStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 272 /* CatchClause */: + case 223 /* DoStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 274 /* CatchClause */: return spanForNode(n.parent); - case 233 /* TryStatement */: + case 235 /* 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) { - return spanForNode(ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 88 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -101111,21 +102353,21 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanForNode(n.parent); - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 244 /* CaseBlock */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 246 /* CaseBlock */: return spanForNode(n); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 185 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); - case 258 /* JsxElement */: + case 187 /* ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); + case 260 /* JsxElement */: return spanForJSXElement(n); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -101141,7 +102383,7 @@ var ts; return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -101150,9 +102392,9 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 17 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* OpenBraceToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); - var close = open === 17 /* OpenBraceToken */ ? 18 /* CloseBraceToken */ : 22 /* CloseBracketToken */; + var close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; var closeToken = ts.findChildOfKind(n, close, sourceFile); if (!openToken || !closeToken) { return undefined; @@ -101511,11 +102753,11 @@ var ts; characterSpans: breakIntoCharacterSpans(text) }; } - /* @internal */ function breakIntoCharacterSpans(identifier) { + function breakIntoCharacterSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - /* @internal */ function breakIntoWordSpans(identifier) { + function breakIntoWordSpans(identifier) { return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; @@ -101655,10 +102897,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 17 /* OpenBraceToken */) { + if (currentToken === 18 /* OpenBraceToken */) { braceNesting++; } - else if (currentToken === 18 /* CloseBraceToken */) { + else if (currentToken === 19 /* CloseBraceToken */) { braceNesting--; } return currentToken; @@ -101688,12 +102930,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 124 /* DeclareKeyword */) { + if (token === 125 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 129 /* ModuleKeyword */) { + if (token === 130 /* ModuleKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); } } @@ -101705,42 +102947,42 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 23 /* DotToken */) { + if (lastToken === 24 /* DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 91 /* ImportKeyword */) { + if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 9 /* StringLiteral */) { + else if (token === 10 /* StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 58 /* EqualsToken */) { + else if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 26 /* CommaToken */) { + else if (token === 27 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -101749,18 +102991,18 @@ var ts; return true; } } - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -101768,15 +103010,15 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 118 /* AsKeyword */) { + if (token === 119 /* AsKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -101792,21 +103034,21 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 84 /* ExportKeyword */) { + if (token === 85 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 17 /* OpenBraceToken */) { + if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -101814,21 +103056,21 @@ var ts; } } } - else if (token === 39 /* AsteriskToken */) { + else if (token === 40 /* AsteriskToken */) { token = nextToken(); - if (token === 143 /* FromKeyword */) { + if (token === 144 /* FromKeyword */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 91 /* ImportKeyword */) { + else if (token === 92 /* ImportKeyword */) { token = nextToken(); - if (token === 71 /* Identifier */ || ts.isKeyword(token)) { + if (token === 72 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 58 /* EqualsToken */) { + if (token === 59 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -101841,11 +103083,11 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 133 /* RequireKeyword */) { + if (token === 134 /* RequireKeyword */) { token = nextToken(); - if (token === 19 /* OpenParenToken */) { + if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // require("mod"); recordModuleName(); } @@ -101856,16 +103098,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 71 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 72 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 19 /* OpenParenToken */) { + if (token !== 20 /* OpenParenToken */) { return true; } token = nextToken(); - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 26 /* CommaToken */) { + if (token === 27 /* CommaToken */) { token = nextToken(); } else { @@ -101874,15 +103116,15 @@ var ts; } } // should be start of dependency list - if (token !== 21 /* OpenBracketToken */) { + if (token !== 22 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names - if (token === 9 /* StringLiteral */) { + if (token === 10 /* StringLiteral */) { recordModuleName(); } token = nextToken(); @@ -101990,14 +103232,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 === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 80 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return getRenameInfoForModule(node, sourceFile, symbol); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 147 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 149 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -102044,7 +103286,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 9 /* StringLiteral */) { + if (node.kind === 10 /* StringLiteral */) { // Exclude the quotes start += 1; width -= 2; @@ -102053,9 +103295,9 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -102148,13 +103390,13 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 26 /* CommaToken */: { + case 27 /* CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -102200,7 +103442,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 27 /* LessThanToken */ || node.kind === 19 /* OpenParenToken */) { + if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* 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 }; @@ -102253,10 +103495,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 193 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 206 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -102319,24 +103561,24 @@ var ts; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) { - if (startingToken.kind !== 19 /* OpenParenToken */ && startingToken.kind !== 26 /* CommaToken */) + if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 195 /* ParenthesizedExpression */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 19 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* 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) }; } @@ -102368,7 +103610,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 26 /* CommaToken */) { + if (child.kind !== 27 /* CommaToken */) { argumentIndex++; } } @@ -102387,8 +103629,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 !== 26 /* CommaToken */; }); - if (listChildren.length > 0 && ts.last(listChildren).kind === 26 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); + if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -102457,7 +103699,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 === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -102522,10 +103764,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(); - var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(27 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(29 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = typeSymbolDisplay.concat([ts.punctuationPart(28 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(26 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var _a = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile), isVariadic = _a.isVariadic, parameters = _a.parameters, prefix = _a.prefix, suffix = _a.suffix; var prefixDisplayParts = callTargetDisplayParts.concat(prefix); @@ -102554,9 +103796,9 @@ var ts; var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(27 /* LessThanToken */)], suffix: [ts.punctuationPart(29 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = candidateSignature.hasRestParameter; @@ -102564,11 +103806,11 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration); })); - printer.writeList(26896 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); } }); var parameters = candidateSignature.parameters.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(19 /* OpenParenToken */)]), suffix: [ts.punctuationPart(20 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -102590,53 +103832,46 @@ var ts; /* @internal */ var ts; (function (ts) { - // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; - var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; - function getSourceMapper(getCanonicalFileName, currentDirectory, log, host, getProgram) { + function getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, getProgram) { + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var sourcemappedFileCache; - return { tryGetOriginalLocation: tryGetOriginalLocation, tryGetGeneratedLocation: tryGetGeneratedLocation, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + return { tryGetSourcePosition: tryGetSourcePosition, tryGetGeneratedPosition: tryGetGeneratedPosition, toLineColumnOffset: toLineColumnOffset, clearCache: clearCache }; + function toPath(fileName) { + return ts.toPath(fileName, currentDirectory, getCanonicalFileName); + } function scanForSourcemapURL(fileName) { - var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var mappedFile = sourcemappedFileCache.get(toPath(fileName)); if (!mappedFile) { return; } - var starts = ts.getLineStarts(mappedFile); - for (var index = starts.length - 1; index >= 0; index--) { - var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); - var comment = sourceMapCommentRegExp.exec(lineText); - if (comment) { - return comment[1]; - } - // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file - else if (!lineText.match(whitespaceOrMapCommentRegExp)) { - break; - } - } + return ts.tryGetSourceMappingURL(mappedFile.text, ts.getLineStarts(mappedFile)); } function convertDocumentToSourceMapper(file, contents, mapFileName) { - var maps; - try { - maps = JSON.parse(contents); - } - catch (_a) { - // swallow error - } - if (!maps || !maps.sources || !maps.file || !maps.mappings) { + var map = ts.tryParseRawSourceMap(contents); + if (!map || !map.sources || !map.file || !map.mappings) { // obviously invalid map - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - return file.sourceMapper = ts.sourcemaps.decode({ - readFile: function (s) { return host.readFile(s); }, - fileExists: function (s) { return host.fileExists(s); }, + var program = getProgram(); + return file.sourceMapper = ts.createDocumentPositionMapper({ + getSourceFileLike: function (s) { + // Lookup file in program, if provided + var file = program && program.getSourceFileByPath(s); + // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file + if (file === undefined || file.resolvedPath !== s) { + // Otherwise check the cache (which may hit disk) + return sourcemappedFileCache.get(s); + } + return file; + }, getCanonicalFileName: getCanonicalFileName, log: log, - }, mapFileName, maps, getProgram(), sourcemappedFileCache); + }, map, mapFileName); } function getSourceMapper(fileName, file) { if (!host.readFile || !host.fileExists) { - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } if (file.sourceMapper) { return file.sourceMapper; @@ -102665,20 +103900,24 @@ var ts; return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217 } } - return file.sourceMapper = ts.sourcemaps.identitySourceMapper; + return file.sourceMapper = ts.identitySourceMapConsumer; } - function tryGetOriginalLocation(info) { + function tryGetSourcePosition(info) { if (!ts.isDeclarationFileName(info.fileName)) return undefined; var file = getFile(info.fileName); if (!file) return undefined; - var newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info); - return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc; + var newLoc = getSourceMapper(info.fileName, file).getSourcePosition(info); + return newLoc === info ? undefined : tryGetSourcePosition(newLoc) || newLoc; } - function tryGetGeneratedLocation(info) { + function tryGetGeneratedPosition(info) { var program = getProgram(); - var declarationPath = ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); + var options = program.getCompilerOptions(); + var outPath = options.outFile || options.out; + var declarationPath = outPath ? + ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; var declarationFile = getFile(declarationPath); @@ -102688,18 +103927,45 @@ var ts; return newLoc === info ? undefined : newLoc; } function getFile(fileName) { - return getProgram().getSourceFile(fileName) || sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + var path = toPath(fileName); + var file = getProgram().getSourceFileByPath(path); + if (file && file.resolvedPath === path) { + return file; + } + return sourcemappedFileCache.get(path); } function toLineColumnOffset(fileName, position) { - var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217 + var file = getFile(fileName); // TODO: GH#18217 return file.getLineAndCharacterOfPosition(position); } function clearCache() { - sourcemappedFileCache = ts.createSourceFileLikeCache(host); + sourcemappedFileCache = createSourceFileLikeCache(host); } } ts.getSourceMapper = getSourceMapper; + function createSourceFileLikeCache(host) { + var cached = ts.createMap(); + return { + get: function (path) { + if (cached.has(path)) { + return cached.get(path); + } + if (!host.fileExists || !host.readFile || !host.fileExists(path)) + return; + // And failing that, check the disk + var text = host.readFile(path); // TODO: GH#18217 + var file = { + text: text, + lineMap: undefined, + getLineAndCharacterOfPosition: function (pos) { + return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + } + }; + cached.set(path, file); + return file; + } + }; + } })(ts || (ts = {})); /* @internal */ var ts; @@ -102735,7 +104001,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_2 = decl.symbol; @@ -102745,7 +104011,7 @@ var ts; } } // falls through if no diagnostic was created - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -102778,11 +104044,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -102799,58 +104065,42 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 251 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; default: return undefined; } } function addConvertToAsyncFunctionDiagnostics(node, checker, diags) { - if (ts.isAsyncFunction(node) || !node.body) { - return; + if (!ts.isAsyncFunction(node) && + node.body && + ts.isBlock(node.body) && + hasReturnStatementWithPromiseHandler(node.body) && + returnsPromise(node, checker)) { + diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); } + } + function returnsPromise(node, checker) { var functionType = checker.getTypeAtLocation(node); var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; - if (!returnType || !checker.getPromisedTypeOfPromise(returnType)) { - return; - } - // collect all the return statements - // check that a property access expression exists in there and that it is a handler - var returnStatements = getReturnStatementsWithPromiseHandlers(node); - if (returnStatements.length > 0) { - diags.push(ts.createDiagnosticForNode(!node.name && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name : node, ts.Diagnostics.This_may_be_converted_to_an_async_function)); - } + return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - /** @internal */ - function getReturnStatementsWithPromiseHandlers(node) { - var returnStatements = []; - if (ts.isFunctionLike(node)) { - ts.forEachChild(node, visit); - } - else { - visit(node); - } - function visit(child) { - if (ts.isFunctionLike(child)) { - return; - } - if (ts.isReturnStatement(child) && child.expression && isFixablePromiseHandler(child.expression)) { - returnStatements.push(child); - } - ts.forEachChild(child, visit); - } - return returnStatements; + function hasReturnStatementWithPromiseHandler(body) { + return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); } - ts.getReturnStatementsWithPromiseHandlers = getReturnStatementsWithPromiseHandlers; + function isReturnStatementWithFixablePromiseHandler(node) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + } + ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts function isFixablePromiseHandler(node) { // ensure outermost call exists and is a promise handler @@ -102867,17 +104117,18 @@ var ts; } return true; } + ts.isFixablePromiseHandler = isFixablePromiseHandler; function isPromiseHandler(node) { return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") || ts.hasPropertyAccessExpressionWithName(node, "catch")); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 95 /* NullKeyword */: - case 71 /* Identifier */: // identifier includes undefined - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: // identifier includes undefined + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -102897,7 +104148,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 209 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -102934,7 +104185,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 100 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -102985,11 +104236,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 260 /* JsxOpeningElement */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 265 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + return location.kind === 72 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 267 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -103016,13 +104267,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 100 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 99 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(99 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 100 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(100 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -103032,7 +104283,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 187 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 189 /* 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)) { @@ -103053,7 +104304,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 190 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 192 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 98 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -103071,7 +104322,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -103088,14 +104339,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* 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 */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -103108,29 +104359,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 155 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 124 /* ConstructorKeyword */ && location.parent.kind === 157 /* 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 = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 124 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 155 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 157 /* 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 === 155 /* Constructor */) { + if (functionDeclaration_1.kind === 157 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 160 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -103140,7 +104391,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 209 /* 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 @@ -103148,7 +104399,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(75 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(76 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -103156,45 +104407,45 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(109 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(110 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(77 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(83 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(84 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 244 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 72 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 131 /* NamespaceKeyword */ : 130 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -103205,7 +104456,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 148 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 150 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -103213,21 +104464,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 159 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(94 /* NewKeyword */)); + if (declaration.kind === 161 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(95 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 158 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 160 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 240 /* TypeAliasDeclaration */) { + else if (declaration.kind === 242 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(139 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(140 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -103239,11 +104490,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 276 /* EnumMember */) { + if (declaration.kind === 278 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -103269,41 +104520,41 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 245 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 247 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(131 /* NamespaceKeyword */)); break; - case 252 /* ExportAssignment */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 254 /* ExportAssignment */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 59 /* EqualsToken */ : 80 /* DefaultKeyword */)); break; - case 255 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); + case 257 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(85 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(91 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(92 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 246 /* ImportEqualsDeclaration */) { + if (declaration.kind === 248 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(133 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(134 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(58 /* EqualsToken */)); + displayParts.push(ts.operatorPart(59 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -103317,7 +104568,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(99 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(100 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -103328,7 +104579,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(56 /* ColonToken */)); + displayParts.push(ts.punctuationPart(57 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -103366,10 +104617,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 279 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 204 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -103412,7 +104663,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(92 /* InKeyword */)); + displayParts.push(ts.keywordPart(93 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -103422,7 +104673,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(55 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -103445,9 +104696,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); return; } } @@ -103456,12 +104707,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(37 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(38 /* 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(20 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); } var docComment = signature.getDocumentationComment(typeChecker); documentation = docComment.length === 0 ? undefined : docComment; @@ -103470,7 +104721,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration); - getPrinter().writeList(26896 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -103482,16 +104733,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 194 /* FunctionExpression */) { + if (declaration.kind === 196 /* FunctionExpression */) { return true; } - if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* FunctionDeclaration */) { + if (declaration.kind !== 237 /* VariableDeclaration */ && declaration.kind !== 239 /* 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 === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { + if (parent.kind === 279 /* SourceFile */ || parent.kind === 245 /* ModuleBlock */) { return false; } } @@ -103706,8 +104957,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 17 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 18 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -103789,11 +105040,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 31 /* GreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -103801,28 +105052,28 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 265 /* JsxAttribute */: - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 267 /* JsxAttribute */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* 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 === 71 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 72 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 12 /* RegularExpressionLiteral */; + return container.kind === 13 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 15 /* TemplateMiddle */ || - container.kind === 16 /* TemplateTail */; + return container.kind === 16 /* TemplateMiddle */ || + container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; + return t === 42 /* SlashToken */ || t === 64 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -103892,7 +105143,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -103908,7 +105159,7 @@ var ts; } break; case 3 /* RescanTemplateToken */: - if (token === 18 /* CloseBraceToken */) { + if (token === 19 /* CloseBraceToken */) { lastScanAction = 3 /* RescanTemplateToken */; return scanner.reScanTemplateToken(); } @@ -103981,7 +105232,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 145 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 147 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -103993,255 +105244,255 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 145 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); - var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 145 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; - var unaryPrefixOperators = [43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]; + var keywords = tokenRangeFromRange(73 /* FirstKeyword */, 147 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 71 /* LastBinaryOperator */); + var binaryKeywordOperators = [93 /* InKeyword */, 94 /* InstanceOfKeyword */, 147 /* OfKeyword */, 119 /* AsKeyword */, 128 /* IsKeyword */]; + var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, - 17 /* OpenBraceToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 72 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostincrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; - var unaryPredecrementExpressions = [71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]; - var unaryPostdecrementExpressions = [71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]; + var unaryPreincrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostincrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; + var unaryPredecrementExpressions = [72 /* Identifier */, 20 /* OpenParenToken */, 100 /* ThisKeyword */, 95 /* NewKeyword */]; + var unaryPostdecrementExpressions = [72 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 95 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [71 /* Identifier */].concat(ts.typeKeywords); + var typeNames = [72 /* Identifier */].concat(ts.typeKeywords); // 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([71 /* Identifier */, 3 /* MultiLineCommentTrivia */, 75 /* ClassKeyword */, 84 /* ExportKeyword */, 91 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([72 /* Identifier */, 3 /* MultiLineCommentTrivia */, 76 /* ClassKeyword */, 85 /* ExportKeyword */, 92 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([20 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 81 /* DoKeyword */, 102 /* TryKeyword */, 87 /* FinallyKeyword */, 82 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 82 /* DoKeyword */, 103 /* TryKeyword */, 88 /* FinallyKeyword */, 83 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 56 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 56 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 55 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), + rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), + rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 55 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 23 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 23 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 91 /* ImportKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenImportParenInImportType", 92 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), // 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], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 43 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 44 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 43 /* PlusPlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 37 /* PlusToken */, 37 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 37 /* PlusToken */, 43 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 44 /* MinusMinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 38 /* MinusToken */, 38 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 38 /* MinusToken */, 44 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 18 /* CloseBraceToken */, [26 /* CommaToken */, 25 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 18 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 18 /* CloseBraceToken */, anyTokenExcept(20 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 18 /* CloseBraceToken */, 82 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 18 /* CloseBraceToken */, 106 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 83 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 107 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), // 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", 20 /* CloseParenToken */, 21 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 89 /* FunctionKeyword */, 39 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 39 /* AsteriskToken */, [71 /* Identifier */, 19 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 89 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 90 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), + rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, [72 /* Identifier */, 20 /* OpenParenToken */], [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), + rule("SpaceAfterFunctionInFuncDecl", 90 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 17 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), // 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", [125 /* GetKeyword */, 136 /* SetKeyword */], 71 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 116 /* YieldKeyword */, 39 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [116 /* YieldKeyword */, 39 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 96 /* ReturnKeyword */, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [104 /* VarKeyword */, 100 /* ThrowKeyword */, 94 /* NewKeyword */, 80 /* DeleteKeyword */, 96 /* ReturnKeyword */, 103 /* TypeOfKeyword */, 121 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [110 /* LetKeyword */, 76 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [126 /* GetKeyword */, 137 /* SetKeyword */], 72 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBetweenYieldKeywordAndStar", 117 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [117 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), + rule("NoSpaceBetweenReturnAndSemicolon", 97 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterCertainKeywords", [105 /* VarKeyword */, 101 /* ThrowKeyword */, 95 /* NewKeyword */, 81 /* DeleteKeyword */, 97 /* ReturnKeyword */, 104 /* TypeOfKeyword */, 122 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterLetConstInVariableDeclaration", [111 /* LetKeyword */, 77 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), // 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], 2 /* Space */), rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 105 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceAfterVoidOperator", 106 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 120 /* AsyncKeyword */, 19 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 120 /* AsyncKeyword */, 89 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 121 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 121 /* AsyncKeyword */, 90 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [71 /* Identifier */, 20 /* CloseParenToken */], [13 /* NoSubstitutionTemplateLiteral */, 14 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [72 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 71 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 41 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 41 /* SlashToken */, 29 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 58 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 58 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 72 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 59 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterEqualInJsxAttribute", 59 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [129 /* ModuleKeyword */, 133 /* RequireKeyword */], 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [130 /* ModuleKeyword */, 134 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 117 /* AbstractKeyword */, - 75 /* ClassKeyword */, - 124 /* DeclareKeyword */, - 79 /* DefaultKeyword */, - 83 /* EnumKeyword */, - 84 /* ExportKeyword */, - 85 /* ExtendsKeyword */, - 125 /* GetKeyword */, - 108 /* ImplementsKeyword */, - 91 /* ImportKeyword */, - 109 /* InterfaceKeyword */, - 129 /* ModuleKeyword */, - 130 /* NamespaceKeyword */, - 112 /* PrivateKeyword */, - 114 /* PublicKeyword */, - 113 /* ProtectedKeyword */, - 132 /* ReadonlyKeyword */, - 136 /* SetKeyword */, - 115 /* StaticKeyword */, - 139 /* TypeKeyword */, - 143 /* FromKeyword */, - 128 /* KeyOfKeyword */, - 126 /* InferKeyword */, + 118 /* AbstractKeyword */, + 76 /* ClassKeyword */, + 125 /* DeclareKeyword */, + 80 /* DefaultKeyword */, + 84 /* EnumKeyword */, + 85 /* ExportKeyword */, + 86 /* ExtendsKeyword */, + 126 /* GetKeyword */, + 109 /* ImplementsKeyword */, + 92 /* ImportKeyword */, + 110 /* InterfaceKeyword */, + 130 /* ModuleKeyword */, + 131 /* NamespaceKeyword */, + 113 /* PrivateKeyword */, + 115 /* PublicKeyword */, + 114 /* ProtectedKeyword */, + 133 /* ReadonlyKeyword */, + 137 /* SetKeyword */, + 116 /* StaticKeyword */, + 140 /* TypeKeyword */, + 144 /* FromKeyword */, + 129 /* KeyOfKeyword */, + 127 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 143 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [86 /* ExtendsKeyword */, 109 /* ImplementsKeyword */, 144 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 9 /* StringLiteral */, 17 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 36 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 36 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 24 /* DotDotDotToken */, 71 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 55 /* QuestionToken */, [20 /* CloseParenToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 72 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 20 /* CloseParenToken */, 27 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 27 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 29 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 29 /* GreaterThanToken */, [19 /* OpenParenToken */, 21 /* OpenBracketToken */, 29 /* GreaterThanToken */, 26 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), // decorators - rule("SpaceBeforeAt", [20 /* CloseParenToken */, 71 /* Identifier */], 57 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 57 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 72 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 117 /* AbstractKeyword */, - 71 /* Identifier */, - 84 /* ExportKeyword */, - 79 /* DefaultKeyword */, - 75 /* ClassKeyword */, - 115 /* StaticKeyword */, - 114 /* PublicKeyword */, - 112 /* PrivateKeyword */, - 113 /* ProtectedKeyword */, - 125 /* GetKeyword */, - 136 /* SetKeyword */, - 21 /* OpenBracketToken */, - 39 /* AsteriskToken */, + 118 /* AbstractKeyword */, + 72 /* Identifier */, + 85 /* ExportKeyword */, + 80 /* DefaultKeyword */, + 76 /* ClassKeyword */, + 116 /* StaticKeyword */, + 115 /* PublicKeyword */, + 113 /* PrivateKeyword */, + 114 /* ProtectedKeyword */, + 126 /* GetKeyword */, + 137 /* SetKeyword */, + 22 /* OpenBracketToken */, + 40 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 51 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 94 /* NewKeyword */, 19 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 95 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), ]; // 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", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 123 /* ConstructorKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 26 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterConstructor", 124 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", 89 /* FunctionKeyword */, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceAfterAnonymousFunctionKeyword", 90 /* FunctionKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 19 /* OpenParenToken */, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 19 /* OpenParenToken */, 20 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 19 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 20 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 21 /* OpenBracketToken */, 22 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 21 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 22 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 17 /* OpenBraceToken */, 18 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 17 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 18 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [14 /* TemplateHead */, 15 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [15 /* TemplateMiddle */, 16 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 17 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 18 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 25 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), // Insert space before and after binary operators rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 19 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* 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, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 29 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 56 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), + rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), + rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), ]; // 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, 25 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 26 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(120 /* AsyncKeyword */, 73 /* CaseKeyword */), 21 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 22 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 25 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(121 /* AsyncKeyword */, 74 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 88 /* ForKeyword */, 121 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 89 /* ForKeyword */, 122 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), // 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", [20 /* CloseParenToken */, 81 /* DoKeyword */, 82 /* ElseKeyword */, 73 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 82 /* DoKeyword */, 83 /* ElseKeyword */, 74 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [102 /* TryKeyword */, 87 /* FinallyKeyword */], 17 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [103 /* TryKeyword */, 88 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), ]; return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); } @@ -104285,45 +105536,45 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 223 /* ForStatement */; + return context.contextNode.kind === 225 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 173 /* ConditionalType */: - case 210 /* AsExpression */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 161 /* TypePredicate */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 175 /* ConditionalType */: + case 212 /* AsExpression */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 163 /* TypePredicate */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 184 /* BindingElement */: + case 186 /* BindingElement */: // equals in type X = ... - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: // equal in p = 0; - case 149 /* Parameter */: - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; + case 151 /* Parameter */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + return context.currentTokenSpan.kind === 59 /* EqualsToken */ || context.nextTokenSpan.kind === 59 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 148 /* TypeParameter */: - return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; + case 150 /* TypeParameter */: + return context.currentTokenSpan.kind === 93 /* InKeyword */ || context.nextTokenSpan.kind === 93 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 225 /* ForOfStatement */: - return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; + case 227 /* ForOfStatement */: + return context.currentTokenSpan.kind === 147 /* OfKeyword */ || context.nextTokenSpan.kind === 147 /* OfKeyword */; } return false; } @@ -104335,22 +105586,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 152 /* PropertyDeclaration */ || - contextKind === 151 /* PropertySignature */ || - contextKind === 149 /* Parameter */ || - contextKind === 235 /* VariableDeclaration */ || + return contextKind === 154 /* PropertyDeclaration */ || + contextKind === 153 /* PropertySignature */ || + contextKind === 151 /* Parameter */ || + contextKind === 237 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 203 /* ConditionalExpression */ || - context.contextNode.kind === 173 /* ConditionalType */; + return context.contextNode.kind === 205 /* ConditionalExpression */ || + context.contextNode.kind === 175 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 182 /* ObjectBindingPattern */ || - context.contextNode.kind === 179 /* MappedType */ || + return context.contextNode.kind === 184 /* ObjectBindingPattern */ || + context.contextNode.kind === 181 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -104376,31 +105627,31 @@ var ts; return true; } switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 186 /* ObjectLiteralExpression */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 188 /* ObjectLiteralExpression */: + case 245 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 158 /* CallSignature */: - case 194 /* FunctionExpression */: - case 155 /* Constructor */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 196 /* FunctionExpression */: + case 157 /* Constructor */: + case 197 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 241 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -104409,40 +105660,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; + return context.contextNode.kind === 239 /* FunctionDeclaration */ || context.contextNode.kind === 196 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 166 /* TypeLiteral */: - case 242 /* ModuleDeclaration */: - case 253 /* ExportDeclaration */: - case 254 /* NamedExports */: - case 247 /* ImportDeclaration */: - case 250 /* NamedImports */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 168 /* TypeLiteral */: + case 244 /* ModuleDeclaration */: + case 255 /* ExportDeclaration */: + case 256 /* NamedExports */: + case 249 /* ImportDeclaration */: + case 252 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 272 /* CatchClause */: - case 243 /* ModuleBlock */: - case 230 /* SwitchStatement */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 274 /* CatchClause */: + case 245 /* ModuleBlock */: + case 232 /* SwitchStatement */: return true; - case 216 /* Block */: { + case 218 /* 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 !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 197 /* ArrowFunction */ && blockParent.kind !== 196 /* FunctionExpression */) { return true; } } @@ -104451,64 +105702,64 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 229 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 231 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 272 /* CatchClause */: + case 274 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 186 /* ObjectLiteralExpression */; + return context.contextNode.kind === 188 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 189 /* CallExpression */; + return context.contextNode.kind === 191 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 190 /* NewExpression */; + return context.contextNode.kind === 192 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 26 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 195 /* ArrowFunction */; + return context.contextNode.kind === 197 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 181 /* ImportType */; + return context.contextNode.kind === 183 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; + return context.contextNode.kind !== 260 /* JsxElement */ && context.contextNode.kind !== 264 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; + return context.contextNode.kind === 270 /* JsxExpression */ || context.contextNode.kind === 269 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 265 /* JsxAttribute */; + return context.nextTokenParent.kind === 267 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 265 /* JsxAttribute */; + return context.contextNode.kind === 267 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 259 /* JsxSelfClosingElement */; + return context.contextNode.kind === 261 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -104523,45 +105774,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 238 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 242 /* ModuleDeclaration */; + return context.contextNode.kind === 244 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 168 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 159 /* ConstructSignature */; + return context.contextNode.kind === 161 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { + if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 162 /* TypeReference */: - case 192 /* TypeAssertionExpression */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 194 /* TypeAssertionExpression */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -104572,16 +105823,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 192 /* TypeAssertionExpression */; + return context.contextNode.kind === 194 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; + return context.currentTokenSpan.kind === 106 /* VoidKeyword */ && context.currentTokenParent.kind === 200 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 207 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 211 /* NonNullExpression */; + return context.contextNode.kind === 213 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -104632,12 +105883,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 145 /* LastKeyword */ && column <= 145 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 147 /* LastKeyword */ && column <= 147 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 145 /* LastToken */ + 1; + var mapRowLength = 147 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -104726,12 +105977,12 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 25 /* SemicolonToken */, sourceFile); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 17 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -104757,7 +106008,7 @@ var ts; } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 18 /* CloseBraceToken */, sourceFile); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; @@ -104815,17 +106066,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 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 277 /* SourceFile */: - case 216 /* Block */: - case 243 /* ModuleBlock */: + return !!body && body.kind === 245 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 279 /* SourceFile */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -104938,7 +106189,6 @@ var ts; } return 0; } - /* @internal */ function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: 0, end: sourceFileLike.text.length }; 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 @@ -104968,7 +106218,7 @@ var ts; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine; + var indentationOnLastIndentedLine = -1 /* Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -104982,7 +106232,7 @@ var ts; if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); // TODO: GH#18217 + indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); trimTrailingWhitespacesForRemainingRange(); } } @@ -105027,7 +106277,7 @@ var ts; }; } else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 19 /* OpenParenToken */ && startLine === lastIndentedLine) { + if (node.kind === 20 /* 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) }; @@ -105048,19 +106298,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; - case 156 /* GetAccessor */: return 125 /* GetKeyword */; - case 157 /* SetAccessor */: return 136 /* SetKeyword */; - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: return 76 /* ClassKeyword */; + case 241 /* InterfaceDeclaration */: return 110 /* InterfaceKeyword */; + case 239 /* FunctionDeclaration */: return 90 /* FunctionKeyword */; + case 243 /* EnumDeclaration */: return 243 /* EnumDeclaration */; + case 158 /* GetAccessor */: return 126 /* GetKeyword */; + case 159 /* SetAccessor */: return 137 /* SetKeyword */; + case 156 /* MethodDeclaration */: if (node.asteriskToken) { - return 39 /* AsteriskToken */; + return 40 /* AsteriskToken */; } // falls through - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -105075,15 +106325,25 @@ var ts; // .. { // // comment // } - case 18 /* CloseBraceToken */: - case 22 /* CloseBracketToken */: - case 20 /* CloseParenToken */: + case 19 /* CloseBraceToken */: + case 23 /* CloseBracketToken */: + case 21 /* CloseParenToken */: return indentation + getDelta(container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; }, - getIndentationForToken: function (line, kind, container) { - return shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : 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. + // foo.then + // < + // number, + // string, + // >(); + // vs + // var a = xValue + // > yValue; + getIndentationForToken: function (line, kind, container, suppressDelta) { + return !suppressDelta && shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : indentation; }, getIndentation: function () { return indentation; }, getDelta: getDelta, @@ -105097,26 +106357,25 @@ 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 17 /* OpenBraceToken */: - case 18 /* CloseBraceToken */: - case 19 /* OpenParenToken */: - case 20 /* CloseParenToken */: - case 82 /* ElseKeyword */: - case 106 /* WhileKeyword */: - case 57 /* AtToken */: + case 18 /* OpenBraceToken */: + case 19 /* CloseBraceToken */: + case 21 /* CloseParenToken */: + case 83 /* ElseKeyword */: + case 107 /* WhileKeyword */: + case 58 /* AtToken */: return false; - case 41 /* SlashToken */: - case 29 /* GreaterThanToken */: + case 42 /* SlashToken */: + case 30 /* GreaterThanToken */: switch (container.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: return false; } break; - case 21 /* OpenBracketToken */: - case 22 /* CloseBracketToken */: - if (container.kind !== 179 /* MappedType */) { + case 22 /* OpenBracketToken */: + case 23 /* CloseBracketToken */: + if (container.kind !== 181 /* MappedType */) { return false; } break; @@ -105201,22 +106460,22 @@ var ts; return inheritedIndentation; } // JSX text shouldn't affect indenting - if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { + if (ts.isToken(child) && child.kind !== 11 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 150 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 152 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { var range = { pos: child.getStart(), end: child.getEnd() }; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 187 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -105237,9 +106496,20 @@ var ts; else if (tokenInfo.token.kind === listStartToken) { // consume list start token startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; - var indentation_2 = computeIndentation(tokenInfo.token, startLine, -1 /* Unknown */, parent, parentDynamicIndentation, parentStartLine); - listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation_2.indentation, indentation_2.delta); - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); + var indentationOnListStartToken = void 0; + if (indentationOnLastIndentedLine !== -1 /* 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; + // }: {}; + indentationOnListStartToken = indentationOnLastIndentedLine; + } + else { + var startLinePosition = ts.getLineStartPositionForPosition(tokenInfo.token.pos, sourceFile); + indentationOnListStartToken = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, tokenInfo.token.pos, sourceFile, options); + } + listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentationOnListStartToken, options.indentSize); // TODO: GH#18217 } else { // consume any tokens that precede the list as child elements of 'node' using its indentation scope @@ -105255,7 +106525,7 @@ var ts; var listEndToken = getCloseTokenForOpenToken(listStartToken); if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 26 /* CommaToken */ && ts.isCallLikeExpression(parent)) { + if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { formattingScanner.advance(); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; } @@ -105265,11 +106535,11 @@ var ts; // without this check close paren will be interpreted as list end token for function expression which is wrong if (tokenInfo && tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent, /*isListEndToken*/ true); } } } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container) { + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container, isListEndToken) { ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); var indentToken = false; @@ -105301,32 +106571,12 @@ var ts; } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) : + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : -1 /* Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); - switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: - if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); - } - indentNextTokenOrTrivia = false; - break; - case 2 /* SingleLineCommentTrivia */: - if (indentNextTokenOrTrivia && triviaInRange) { - insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); - } - indentNextTokenOrTrivia = false; - break; - case 4 /* NewLineTrivia */: - indentNextTokenOrTrivia = true; - break; - } - } + 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) { @@ -105339,16 +106589,39 @@ var ts; childContextNode = parent; } } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + function indentTriviaItems(trivia, commentIndentation, indentNextTokenOrTrivia, indentSingleLine) { for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { var triviaItem = trivia_1[_i]; + var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); + switch (triviaItem.kind) { + case 3 /* MultiLineCommentTrivia */: + if (triviaInRange) { + indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + } + indentNextTokenOrTrivia = false; + break; + case 2 /* SingleLineCommentTrivia */: + if (indentNextTokenOrTrivia && triviaInRange) { + indentSingleLine(triviaItem); + } + indentNextTokenOrTrivia = false; + break; + case 4 /* NewLineTrivia */: + indentNextTokenOrTrivia = true; + break; + } + } + return indentNextTokenOrTrivia; + } + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0, trivia_2 = trivia; _i < trivia_2.length; _i++) { + var triviaItem = trivia_2[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); } } } - // TODO: GH#18217 use an enum instead of `boolean | undefined` function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAction = 0 /* None */; @@ -105520,7 +106793,10 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - var startPosition = previousRange ? previousRange.end : originalRange.pos; + if (!previousRange) { + return; + } + var startPosition = previousRange.end; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -105620,41 +106896,46 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 195 /* ArrowFunction */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 197 /* ArrowFunction */: if (node.typeParameters === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.parameters === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } else if (node.arguments === list) { - return 19 /* OpenParenToken */; + return 20 /* OpenParenToken */; } break; - case 162 /* TypeReference */: + case 164 /* TypeReference */: if (node.typeArguments === list) { - return 27 /* LessThanToken */; + return 28 /* LessThanToken */; } + break; + case 168 /* TypeLiteral */: + return 18 /* OpenBraceToken */; } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 19 /* OpenParenToken */: - return 20 /* CloseParenToken */; - case 27 /* LessThanToken */: - return 29 /* GreaterThanToken */; + case 20 /* OpenParenToken */: + return 21 /* CloseParenToken */; + case 28 /* LessThanToken */: + return 30 /* GreaterThanToken */; + case 18 /* OpenBraceToken */: + return 19 /* CloseBraceToken */; } return 0 /* Unknown */; } @@ -105759,13 +107040,18 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 204 /* 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 */) { 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 + } return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options); } SmartIndenter.getIndentation = getIndentation; @@ -105776,12 +107062,12 @@ var ts; if (previousLine <= commentStartLine) { return findFirstNonWhitespaceColumn(ts.getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); } - var startPostionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); - var _a = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; + var startPositionOfLine = ts.getStartPositionOfLine(previousLine, sourceFile); + var _a = findFirstNonWhitespaceCharacterAndColumn(startPositionOfLine, position, sourceFile, options), column = _a.column, character = _a.character; if (column === 0) { return column; } - var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { @@ -105814,14 +107100,13 @@ var ts; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + // do not consider parent-child line sharing yet: + // 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 */) { return actualIndentation; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.indentSize; // TODO: GH#18217 - } previous = current; current = current.parent; } @@ -105848,23 +107133,17 @@ var ts; var start = current.getStart(sourceFile); useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; } - if (useActualIndentation) { - // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + indentationDelta; - } - } var containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); var parentAndChildShareLine = containingListOrParentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { - // try to fetch actual indentation for current node from source text - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + // check if current node is a list item - if yes, take indentation from it + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + // try to fetch actual indentation for current node from source text + actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { return actualIndentation + indentationDelta; } @@ -105915,7 +107194,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 279 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -105932,11 +107211,11 @@ var ts; if (!nextToken) { return 0 /* Unknown */; } - if (nextToken.kind === 17 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* OpenBraceToken */) { // open braces are always indented at the parent level return 1 /* OpenBrace */; } - else if (nextToken.kind === 18 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* 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 { @@ -105963,8 +107242,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); + if (parent.kind === 222 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 83 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -105972,103 +107251,87 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getListIfStartEndIsInListRange(list, start, end) { - return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; - } function getContainingList(node, sourceFile) { - if (node.parent) { - var end = node.end; - switch (node.parent.kind) { - case 162 /* TypeReference */: - return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 186 /* ObjectLiteralExpression */: - return node.parent.properties; - case 185 /* ArrayLiteralExpression */: - return node.parent.elements; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 155 /* Constructor */: - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || - getListIfStartEndIsInListRange(node.parent.parameters, start, end); - } - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: { - var typeParameters = node.parent.typeParameters; - return getListIfStartEndIsInListRange(typeParameters, node.getStart(sourceFile), end); - } - case 190 /* NewExpression */: - case 189 /* CallExpression */: { - var start = node.getStart(sourceFile); - return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || - getListIfStartEndIsInListRange(node.parent.arguments, start, end); - } - case 236 /* VariableDeclarationList */: - return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 250 /* NamedImports */: - case 254 /* NamedExports */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - } - } - return undefined; + return node.parent && getListByRange(node.getStart(sourceFile), node.getEnd(), node.parent, sourceFile); } SmartIndenter.getContainingList = getContainingList; - function getActualIndentationForListItem(node, sourceFile, options) { + function getListByPosition(pos, node, sourceFile) { + return node && getListByRange(pos, pos, node, sourceFile); + } + function getListByRange(start, end, node, sourceFile) { + switch (node.kind) { + case 164 /* TypeReference */: + return getList(node.typeArguments); + case 188 /* ObjectLiteralExpression */: + return getList(node.properties); + case 187 /* ArrayLiteralExpression */: + return getList(node.elements); + case 168 /* TypeLiteral */: + return getList(node.members); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 157 /* Constructor */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: + return getList(node.typeParameters) || getList(node.parameters); + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + return getList(node.typeParameters); + case 192 /* NewExpression */: + case 191 /* CallExpression */: + return getList(node.typeArguments) || getList(node.arguments); + case 238 /* VariableDeclarationList */: + return getList(node.declarations); + case 252 /* NamedImports */: + case 256 /* NamedExports */: + return getList(node.elements); + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + return getList(node.elements); + } + function getList(list) { + return list && ts.rangeContainsStartEnd(getVisualListRange(node, list, sourceFile), start, end) ? list : undefined; + } + } + function getVisualListRange(node, list, sourceFile) { + var children = node.getChildren(sourceFile); + for (var i = 1; i < children.length - 1; i++) { + if (children[i].pos === list.pos && children[i].end === list.end) { + return { pos: children[i - 1].end, end: children[i + 1].getStart(sourceFile) }; + } + } + return list; + } + function getActualIndentationForListStartLine(list, sourceFile, options) { + if (!list) { + return -1 /* Unknown */; + } + return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); + } + function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { + if (node.parent && node.parent.kind === 238 /* VariableDeclarationList */) { + // VariableDeclarationList has no wrapping tokens + return -1 /* Unknown */; + } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { - return deriveActualIndentationFromList(containingList, index, sourceFile, options); - } - } - return -1 /* Unknown */; - } - function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - // actual indentation should not be used when: - // - node is close parenthesis - this is the end of the expression - if (node.kind === 20 /* CloseParenToken */) { - return -1 /* Unknown */; - } - if (node.parent && ts.isCallOrNewExpression(node.parent) && node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1 /* Unknown */; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1 /* Unknown */; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); - } - return -1 /* Unknown */; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - node = node.expression; - break; - default: - return node; + var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); + if (result !== -1 /* Unknown */) { + return result; } } + return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } + return -1 /* Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -106077,7 +107340,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 === 26 /* CommaToken */) { + if (list[i].kind === 27 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -106126,83 +107389,83 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 219 /* ExpressionStatement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 185 /* ArrayLiteralExpression */: - case 216 /* Block */: - case 243 /* ModuleBlock */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 179 /* MappedType */: - case 168 /* TupleType */: - case 244 /* CaseBlock */: - case 270 /* DefaultClause */: - case 269 /* CaseClause */: - case 193 /* ParenthesizedExpression */: - case 187 /* PropertyAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 217 /* VariableStatement */: - case 252 /* ExportAssignment */: - case 228 /* ReturnStatement */: - case 203 /* ConditionalExpression */: - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: - case 259 /* JsxSelfClosingElement */: - case 268 /* JsxExpression */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 149 /* Parameter */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 175 /* ParenthesizedType */: - case 191 /* TaggedTemplateExpression */: - case 199 /* AwaitExpression */: - case 254 /* NamedExports */: - case 250 /* NamedImports */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 152 /* PropertyDeclaration */: + case 221 /* ExpressionStatement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 187 /* ArrayLiteralExpression */: + case 218 /* Block */: + case 245 /* ModuleBlock */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 181 /* MappedType */: + case 170 /* TupleType */: + case 246 /* CaseBlock */: + case 272 /* DefaultClause */: + case 271 /* CaseClause */: + case 195 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 219 /* VariableStatement */: + case 254 /* ExportAssignment */: + case 230 /* ReturnStatement */: + case 205 /* ConditionalExpression */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: + case 261 /* JsxSelfClosingElement */: + case 270 /* JsxExpression */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 151 /* Parameter */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 177 /* ParenthesizedType */: + case 193 /* TaggedTemplateExpression */: + case 201 /* AwaitExpression */: + case 256 /* NamedExports */: + case 252 /* NamedImports */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 154 /* PropertyDeclaration */: return true; - case 235 /* VariableDeclaration */: - case 273 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 237 /* VariableDeclaration */: + case 275 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 188 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } return true; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 220 /* IfStatement */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return childKind !== 216 /* Block */; - case 253 /* ExportDeclaration */: - return childKind !== 254 /* NamedExports */; - case 247 /* ImportDeclaration */: - return childKind !== 248 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); - case 258 /* JsxElement */: - return childKind !== 261 /* JsxClosingElement */; - case 262 /* JsxFragment */: - return childKind !== 264 /* JsxClosingFragment */; - case 172 /* IntersectionType */: - case 171 /* UnionType */: - if (childKind === 166 /* TypeLiteral */) { + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 222 /* IfStatement */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return childKind !== 218 /* Block */; + case 255 /* ExportDeclaration */: + return childKind !== 256 /* NamedExports */; + case 249 /* ImportDeclaration */: + return childKind !== 250 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 252 /* NamedImports */); + case 260 /* JsxElement */: + return childKind !== 263 /* JsxClosingElement */; + case 264 /* JsxFragment */: + return childKind !== 266 /* JsxClosingFragment */; + case 174 /* IntersectionType */: + case 173 /* UnionType */: + if (childKind === 168 /* TypeLiteral */) { return false; } // falls through @@ -106213,11 +107476,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: - return parent.kind !== 216 /* Block */; + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: + return parent.kind !== 218 /* Block */; default: return false; } @@ -106345,7 +107608,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 === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 188 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -106417,13 +107680,16 @@ var ts; if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, options), newNodes, options); }; + ChangeTracker.prototype.replaceNodeWithText = function (sourceFile, oldNode, text) { + this.replaceRangeWithText(sourceFile, getAdjustedRange(sourceFile, oldNode, oldNode, textChanges_3.useNonAdjustedPositions), text); + }; ChangeTracker.prototype.replaceNodeRangeWithNodes = function (sourceFile, startNode, endNode, newNodes, options) { if (options === void 0) { options = textChanges_3.useNonAdjustedPositions; } return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 26 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -106473,10 +107739,20 @@ var ts; var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); }; - ChangeTracker.prototype.insertCommentThenNewline = function (sourceFile, character, position, commentText) { - var token = ts.getTouchingToken(sourceFile, position); - var text = "/**" + commentText + "*/" + this.newLineCharacter + ts.repeatString(" ", character); - this.insertText(sourceFile, token.getStart(sourceFile), text); + ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { + var fnStart = node.getStart(sourceFile); + if (node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsdoc = _a[_i]; + this.deleteRange(sourceFile, { + pos: ts.getLineStartPositionForPosition(jsdoc.getStart(sourceFile), sourceFile), + end: getAdjustedEndPosition(sourceFile, jsdoc, /*options*/ {}) + }); + } + } + 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 }); }; ChangeTracker.prototype.replaceRangeWithText = function (sourceFile, range, text) { this.changes.push({ kind: ChangeKind.Text, sourceFile: sourceFile, range: range, text: text }); @@ -106484,28 +107760,11 @@ var ts; ChangeTracker.prototype.insertText = function (sourceFile, pos, text) { this.replaceRangeWithText(sourceFile, ts.createRange(pos), text); }; - ChangeTracker.prototype.tryInsertJSDocParameters = function (sourceFile, parameters) { - if (parameters.length === 0) { - return; - } - var parent = parameters[0].declaration.parent; - var indent = ts.getLineAndCharacterOfPosition(sourceFile, parent.getStart()).character; - var commentText = "\n"; - for (var _i = 0, parameters_3 = parameters; _i < parameters_3.length; _i++) { - var _a = parameters_3[_i], declaration = _a.declaration, typeNode = _a.typeNode, isOptional = _a.isOptional; - if (ts.isIdentifier(declaration.name)) { - var printed = changesToText.getNonformattedText(typeNode, sourceFile, this.newLineCharacter).text; - commentText += this.printJSDocParameter(indent, printed, declaration.name, isOptional); - } - } - commentText += ts.repeatString(" ", indent + 1); - this.insertCommentThenNewline(sourceFile, indent, parent.getStart(), commentText); - }; /** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */ ChangeTracker.prototype.tryInsertTypeAnnotation = function (sourceFile, node, type) { var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 20 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return; // Function missing parentheses, give up @@ -106514,32 +107773,13 @@ var ts; } } else { - endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 237 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; - ChangeTracker.prototype.tryInsertJSDocType = function (sourceFile, node, type) { - var printed = changesToText.getNonformattedText(type, sourceFile, this.newLineCharacter).text; - var commentText; - if (ts.isGetAccessorDeclaration(node)) { - commentText = " @return {" + printed + "} "; - } - else { - commentText = " @type {" + printed + "} "; - node = node.parent; - } - this.insertCommentThenNewline(sourceFile, ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile)).character, node.getStart(sourceFile), commentText); - }; - ChangeTracker.prototype.printJSDocParameter = function (indent, printed, name, isOptionalParameter) { - var printName = ts.unescapeLeadingUnderscores(name.escapedText); - if (isOptionalParameter) { - printName = "[" + printName + "]"; - } - return ts.repeatString(" ", indent) + (" * @param {" + printed + "} " + printName + "\n"); - }; 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, 19 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, doubleNewlines) { @@ -106633,7 +107873,7 @@ var ts; // 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.createToken(25 /* SemicolonToken */)); + this.replaceRange(sourceFile, ts.createRange(after.end), ts.createToken(26 /* SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -106645,18 +107885,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 235 /* VariableDeclaration */: - case 9 /* StringLiteral */: - case 71 /* Identifier */: + case 237 /* VariableDeclaration */: + case 10 /* StringLiteral */: + case 72 /* Identifier */: return { prefix: ", " }; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: return { prefix: " " }; - case 149 /* Parameter */: + case 151 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -106665,28 +107905,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 195 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); + if (node.kind === 197 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(90 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 216 /* Block */) { + if (node.body.kind !== 218 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(97 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 196 /* FunctionExpression */ ? 90 /* FunctionKeyword */ : 76 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -106774,12 +108014,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 = 26 /* CommaToken */; + separator = 27 /* 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 : 26 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* 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; @@ -106819,7 +108059,7 @@ var ts; }; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var deletedNodesInLists = new ts.NodeSet(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. var _loop_17 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { @@ -106873,7 +108113,7 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - return [ts.findChildOfKind(cls, 17 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 18 /* CloseBraceToken */, sourceFile).end]; + return [ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile).end, ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile).end]; } function getMembersOrProperties(cls) { return ts.isObjectLiteralExpression(cls) ? cls.properties : cls.members; @@ -106916,7 +108156,7 @@ var ts; var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 6 /* ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); - return applyChanges(nonFormattedText, changes); + return applyChanges(nonFormattedText, changes) + newLineCharacter; } changesToText.newFileChangesWorker = newFileChangesWorker; function computeNewText(change, sourceFile, newLineCharacter, formatContext, validate) { @@ -107041,6 +108281,9 @@ var ts; this.writer.write(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeComment = function (s) { + this.writer.writeComment(s); + }; Writer.prototype.writeKeyword = function (s) { this.writer.writeKeyword(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -107053,6 +108296,10 @@ var ts; this.writer.writePunctuation(s); this.setLastNonTriviaPosition(s, /*force*/ false); }; + Writer.prototype.writeTrailingSemicolon = function (s) { + this.writer.writeTrailingSemicolon(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; Writer.prototype.writeParameter = function (s) { this.writer.writeParameter(s); this.setLastNonTriviaPosition(s, /*force*/ false); @@ -107073,9 +108320,6 @@ var ts; this.writer.writeSymbol(s, sym); this.setLastNonTriviaPosition(s, /*force*/ false); }; - Writer.prototype.writeTextOfNode = function (text, node) { - this.writer.writeTextOfNode(text, node); - }; Writer.prototype.writeLine = function () { this.writer.writeLine(); }; @@ -107117,10 +108361,25 @@ var ts; }; return Writer; }()); - function getInsertionPositionAtSourceFileTop(_a) { - var text = _a.text; - var shebang = ts.getShebang(text); + function getInsertionPositionAtSourceFileTop(sourceFile) { + var lastPrologue; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + if (ts.isPrologueDirective(node)) { + lastPrologue = node; + } + else { + break; + } + } var position = 0; + var text = sourceFile.text; + if (lastPrologue) { + position = lastPrologue.end; + advancePastLineBreak(); + return position; + } + var shebang = ts.getShebang(text); if (shebang !== undefined) { position = shebang.length; advancePastLineBreak(); @@ -107136,8 +108395,8 @@ var ts; ranges = ranges.slice(1); } // As well as any triple slash references - for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) { - var range = ranges_1[_i]; + for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { + var range = ranges_1[_b]; if (range.kind === 2 /* SingleLineCommentTrivia */ && ts.isRecognizedTripleSlashComment(text, range.pos, range.end)) { position = range.end; advancePastLineBreak(); @@ -107159,45 +108418,40 @@ var ts; } } function isValidLocationToAddComment(sourceFile, position) { - return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position); + return !ts.isInComment(sourceFile, position) && !ts.isInString(sourceFile, position) && !ts.isInTemplateString(sourceFile, position) && !ts.isInJSXText(sourceFile, position); } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 149 /* 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 149 /* Parameter */: { + case 151 /* Parameter */: { var oldFunction = node.parent; - if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { + if (ts.isArrowFunction(oldFunction) && + oldFunction.parameters.length === 1 && + !ts.findChildOfKind(oldFunction, 20 /* 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`). - var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, // TODO: GH#18217 - oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); - // Drop leading and trailing trivia of the new function because we're only going - // to replace the span (vs the full span) of the old function - the old leading - // and trailing trivia will remain. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); + changes.replaceNodeWithText(sourceFile, node, "()"); } else { deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; } - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 185 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -107205,13 +108459,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -107220,7 +108474,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -107231,7 +108485,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } else { - deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + deleteNode(changes, sourceFile, node, node.kind === 26 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); } } } @@ -107245,7 +108499,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 === 26 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* 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 }); @@ -107267,15 +108521,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 249 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 272 /* CatchClause */) { + if (parent.kind === 274 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -107284,14 +108538,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -107436,6 +108690,32 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addConvertToUnknownForNonOverlappingTypes"; + var errorCodes = [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.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, + }); + function makeChange(changeTracker, sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var replacement = ts.isAsExpression(assertion) + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(143 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(143 /* UnknownKeyword */), assertion.expression); + changeTracker.replaceNode(sourceFile, assertion.expression, replacement); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107503,9 +108783,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 19 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(19 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -107515,7 +108795,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(20 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.createToken(21 /* CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -107530,26 +108810,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 235 /* VariableDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 237 /* VariableDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 154 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -107571,9 +108851,9 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 288 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 290 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -107611,8 +108891,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 134 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 135 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -107622,6 +108902,754 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "inferFromUsage"; + var errorCodes = [ + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, + ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, + //// Suggestions + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code, + ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var token = ts.getTokenAtPosition(sourceFile, start); + var declaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var markSeen = ts.nodeSeenTracker(); + return codefix.codeFixAll(context, errorCodes, function (changes, err) { + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + }); + }, + }); + function getDiagnostic(errorCode, token) { + switch (errorCode) { + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Infer_parameter_types_from_usage; + default: + return ts.Diagnostics.Infer_type_of_0_from_usage; + } + } + /** Map suggestion code to error code */ + function mapSuggestionDiagnostic(errorCode) { + switch (errorCode) { + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code; + case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code; + case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code; + } + return errorCode; + } + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 72 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 100 /* ThisKeyword */) { + return undefined; + } + var parent = token.parent; + errorCode = mapSuggestionDiagnostic(errorCode); + switch (errorCode) { + // Variable and Property declarations + case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: + if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + return parent; + } + if (ts.isPropertyAccessExpression(parent)) { + var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); + var typeNode = getTypeNodeIfAccessible(type, parent, program, host); + if (typeNode) { + // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags + var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ ""); + addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); + } + return parent; + } + return undefined; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { + var symbol = program.getTypeChecker().getSymbolAtLocation(token); + if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + return symbol.valueDeclaration; + } + return undefined; + } + } + var containingFunction = ts.getContainingFunction(token); + if (containingFunction === undefined) { + return undefined; + } + switch (errorCode) { + // Parameter declarations + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + // falls through + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + if (markSeen(containingFunction)) { + var param = ts.cast(parent, ts.isParameter); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + return param; + } + return undefined; + // Get Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: + case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: + if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + return containingFunction; + } + return undefined; + // Set Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + return containingFunction; + } + return undefined; + default: + return ts.Debug.fail(String(errorCode)); + } + } + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + if (ts.isIdentifier(declaration.name)) { + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + } + } + function isApplicableFunctionForInference(declaration) { + switch (declaration.kind) { + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + return true; + case 196 /* FunctionExpression */: + var parent = declaration.parent; + return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; + } + return false; + } + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + return; + } + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || + containingFunction.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + if (ts.isInJSFile(containingFunction)) { + annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); + } + else { + 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) { + annotate(changes, sourceFile, declaration, type, program, host); + } + } + } + } + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); + if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { + var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); + if (type === program.getTypeChecker().getAnyType()) { + type = inferTypeForVariableFromUsage(param.name, program, cancellationToken); + } + if (ts.isInJSFile(setAccessorDeclaration)) { + annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); + } + else { + annotate(changes, sourceFile, param, type, program, host); + } + } + } + function annotate(changes, sourceFile, declaration, type, program, host) { + var typeNode = getTypeNodeIfAccessible(type, declaration, program, host); + if (typeNode) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 153 /* PropertySignature */) { + var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; + if (!parent) { + return; + } + var typeExpression = ts.createJSDocTypeExpression(typeNode); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); + addJSDocTags(changes, sourceFile, parent, [typeTag]); + } + else { + changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); + } + } + } + function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { + var signature = parameterInferences.length && parameterInferences[0].declaration.parent; + if (!signature) { + return; + } + var paramTags = ts.mapDefined(parameterInferences, function (inference) { + var param = inference.declaration; + // only infer parameters that have (1) no type and (2) an accessible inferred type + if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name)) + return; + var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); + var name = ts.getSynthesizedClone(param.name); + ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), ""); + }); + addJSDocTags(changes, sourceFile, signature, paramTags); + } + function addJSDocTags(changes, sourceFile, parent, newTags) { + var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); + var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { + var merged = tryMergeJsdocTags(tag, newTag); + if (merged) + oldTags[i] = merged; + return !!merged; + }); }); + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); + changes.insertJsdocCommentBefore(sourceFile, parent, tag); + } + function tryMergeJsdocTags(oldTag, newTag) { + if (oldTag.kind !== newTag.kind) { + return undefined; + } + switch (oldTag.kind) { + case 299 /* JSDocParameterTag */: { + var oldParam = oldTag; + var newParam = newTag; + return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText + ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) + : undefined; + } + case 300 /* JSDocReturnTag */: + return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); + } + } + function getTypeNodeIfAccessible(type, enclosingScope, program, host) { + var checker = program.getTypeChecker(); + var typeIsAccessible = true; + var notAccessible = function () { typeIsAccessible = false; }; + var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { + trackSymbol: function (symbol, declaration, meaning) { + // TODO: GH#18217 + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + }, + reportInaccessibleThisError: notAccessible, + reportPrivateInBaseOfClassExpression: notAccessible, + reportInaccessibleUniqueSymbolError: notAccessible, + moduleResolverHost: { + readFile: host.readFile, + fileExists: host.fileExists, + directoryExists: host.directoryExists, + getSourceFiles: program.getSourceFiles, + getCurrentDirectory: program.getCurrentDirectory, + getCommonSourceDirectory: program.getCommonSourceDirectory, + } + }); + return typeIsAccessible ? res : undefined; + } + 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; + }); + } + function inferTypeForVariableFromUsage(token, program, cancellationToken) { + var references = getReferences(token, program, cancellationToken); + var checker = program.getTypeChecker(); + var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); + return InferFromReference.unifyFromContext(types, checker); + } + function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { + var searchToken; + switch (containingFunction.kind) { + case 157 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); + break; + case 196 /* FunctionExpression */: + var parent = containingFunction.parent; + searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? + parent.name : + containingFunction.name; + break; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + searchToken = containingFunction.name; + break; + } + if (searchToken) { + return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program, cancellationToken); + } + } + var InferFromReference; + (function (InferFromReference) { + function inferTypesFromReferences(references, checker, cancellationToken) { + var usageContext = {}; + for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { + var reference = references_1[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + return inferFromContext(usageContext, checker); + } + InferFromReference.inferTypesFromReferences = inferTypesFromReferences; + function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { + var checker = program.getTypeChecker(); + if (references.length === 0) { + return undefined; + } + if (!declaration.parameters) { + return undefined; + } + var usageContext = {}; + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + var isConstructor = declaration.kind === 157 /* Constructor */; + var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; + return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { + var types = []; + var isRest = ts.isRestParameter(parameter); + var isOptional = false; + for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { + var callContext = callContexts_1[_i]; + if (callContext.argumentTypes.length <= parameterIndex) { + isOptional = ts.isInJSFile(declaration); + types.push(checker.getUndefinedType()); + } + else if (isRest) { + for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + } + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + if (ts.isIdentifier(parameter.name)) { + types.push.apply(types, inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken)); + } + var type = unifyFromContext(types, checker); + return { + type: isRest ? checker.createArrayType(type) : type, + isOptional: isOptional && !isRest, + declaration: parameter + }; + }); + } + InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; + function inferTypeFromContext(node, checker, usageContext) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + switch (node.parent.kind) { + case 203 /* PostfixUnaryExpression */: + usageContext.isNumber = true; + break; + case 202 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + break; + case 204 /* BinaryExpression */: + inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + break; + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + break; + case 191 /* CallExpression */: + case 192 /* NewExpression */: + if (node.parent.expression === node) { + inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + } + else { + inferTypeFromContextualType(node, checker, usageContext); + } + break; + case 189 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + break; + case 190 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + break; + case 237 /* 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. + addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + } + break; + } + } + // falls through + default: + return inferTypeFromContextualType(node, checker, usageContext); + } + } + function inferTypeFromContextualType(node, checker, usageContext) { + if (ts.isExpressionNode(node)) { + addCandidateType(usageContext, checker.getContextualType(node)); + } + } + function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + switch (node.operator) { + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + usageContext.isNumber = true; + break; + case 38 /* PlusToken */: + usageContext.isNumber = true; + usageContext.isString = true; + break; + // case SyntaxKind.ExclamationToken: + // no inferences here; + } + } + function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + switch (parent.operatorToken.kind) { + // ExponentiationOperator + case 41 /* AsteriskAsteriskToken */: + // MultiplicativeOperator + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: + // ShiftOperator + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // BitwiseOperator + case 49 /* AmpersandToken */: + case 50 /* BarToken */: + case 51 /* CaretToken */: + // CompoundAssignmentOperator + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 70 /* BarEqualsToken */: + case 71 /* CaretEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + // AdditiveOperator + case 39 /* MinusToken */: + // RelationalOperator + case 28 /* LessThanToken */: + case 31 /* LessThanEqualsToken */: + case 30 /* GreaterThanToken */: + case 32 /* GreaterThanEqualsToken */: + var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (operandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, operandType); + } + else { + usageContext.isNumber = true; + } + break; + case 60 /* PlusEqualsToken */: + case 38 /* PlusToken */: + var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (otherOperandType.flags & 1056 /* EnumLike */) { + addCandidateType(usageContext, otherOperandType); + } + else if (otherOperandType.flags & 296 /* NumberLike */) { + usageContext.isNumber = true; + } + else if (otherOperandType.flags & 132 /* StringLike */) { + usageContext.isString = true; + } + else { + usageContext.isNumber = true; + usageContext.isString = true; + } + break; + // AssignmentOperators + case 59 /* EqualsToken */: + case 33 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + break; + case 93 /* InKeyword */: + if (node === parent.left) { + usageContext.isString = true; + } + break; + // LogicalOperator + case 55 /* BarBarToken */: + if (node === parent.left && + (node.parent.parent.kind === 237 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + // var x = x || {}; + // TODO: use getFalsyflagsOfType + addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + } + break; + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: + case 94 /* InstanceOfKeyword */: + // nothing to infer here + break; + } + } + function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { + addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + } + function inferTypeFromCallExpressionContext(parent, checker, usageContext) { + var callContext = { + argumentTypes: [], + returnType: {} + }; + if (parent.arguments) { + for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + } + } + inferTypeFromContext(parent, checker, callContext.returnType); + if (parent.kind === 191 /* CallExpression */) { + (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + } + else { + (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + } + } + function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + var name = ts.escapeLeadingUnderscores(parent.name.text); + if (!usageContext.properties) { + usageContext.properties = ts.createUnderscoreEscapedMap(); + } + var propertyUsageContext = usageContext.properties.get(name) || {}; + inferTypeFromContext(parent, checker, propertyUsageContext); + usageContext.properties.set(name, propertyUsageContext); + } + function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + if (node === parent.argumentExpression) { + usageContext.isNumber = true; + usageContext.isString = true; + return; + } + else { + var indexType = checker.getTypeAtLocation(parent.argumentExpression); + var indexUsageContext = {}; + inferTypeFromContext(parent, checker, indexUsageContext); + if (indexType.flags & 296 /* NumberLike */) { + usageContext.numberIndexContext = indexUsageContext; + } + else { + usageContext.stringIndexContext = indexUsageContext; + } + } + } + function unifyFromContext(inferences, checker, fallback) { + if (fallback === void 0) { fallback = checker.getAnyType(); } + if (!inferences.length) + return fallback; + var hasNonVacuousType = inferences.some(function (i) { return !(i.flags & (1 /* Any */ | 16384 /* Void */)); }); + var hasNonVacuousNonAnonymousType = inferences.some(function (i) { return !(i.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); + var anons = inferences.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); + var good = []; + if (!hasNonVacuousNonAnonymousType && anons.length) { + good.push(unifyAnonymousTypes(anons, checker)); + } + good.push.apply(good, inferences.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */) && !(hasNonVacuousType && i.flags & (1 /* Any */ | 16384 /* Void */)); })); + return checker.getWidenedType(checker.getUnionType(good)); + } + InferFromReference.unifyFromContext = unifyFromContext; + function unifyAnonymousTypes(anons, checker) { + if (anons.length === 1) { + return anons[0]; + } + var calls = []; + var constructs = []; + var stringIndices = []; + var numberIndices = []; + var stringIndexReadonly = false; + var numberIndexReadonly = false; + var props = ts.createMultiMap(); + for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) { + var anon = anons_1[_i]; + for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { + var p = _b[_a]; + props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + } + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); + if (anon.stringIndexInfo) { + stringIndices.push(anon.stringIndexInfo.type); + stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly; + } + if (anon.numberIndexInfo) { + numberIndices.push(anon.numberIndexInfo.type); + numberIndexReadonly = numberIndexReadonly || anon.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); + s.type = checker.getUnionType(types); + return [name, s]; + }); + return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); + } + function inferFromContext(usageContext, checker) { + var types = []; + if (usageContext.isNumber) { + types.push(checker.getNumberType()); + } + if (usageContext.isString) { + types.push(checker.getStringType()); + } + types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { + var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 + var types_19 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); + types_19.push(checker.createPromiseType(types_19.length ? checker.getUnionType(types_19, 2 /* Subtype */) : checker.getAnyType())); + } + else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { + types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); + } + if (usageContext.numberIndexContext) { + return [checker.createArrayType(recur(usageContext.numberIndexContext))]; + } + else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { + var members_6 = ts.createUnderscoreEscapedMap(); + var callSignatures = []; + var constructSignatures = []; + var stringIndexInfo = void 0; + if (usageContext.properties) { + usageContext.properties.forEach(function (context, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = recur(context); + members_6.set(name, symbol); + }); + } + if (usageContext.callContexts) { + for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { + var callContext = _a[_i]; + callSignatures.push(getSignatureFromCallContext(callContext, checker)); + } + } + if (usageContext.constructContexts) { + for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { + var constructContext = _c[_b]; + constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); + } + } + if (usageContext.stringIndexContext) { + stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); + } + types.push(checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + } + return types; + function recur(innerContext) { + return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + } + function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + var types = []; + if (callContexts) { + for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { + var callContext = callContexts_2[_i]; + if (callContext.argumentTypes.length > parameterIndex) { + if (isRestParameter) { + types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); + } + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } + } + } + } + if (types.length) { + var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); + return isRestParameter ? checker.createArrayType(type) : type; + } + return undefined; + } + function getSignatureFromCallContext(callContext, checker) { + var parameters = []; + for (var i = 0; i < callContext.argumentTypes.length; i++) { + var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + parameters.push(symbol); + } + var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + // TODO: GH#18217 + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + } + function addCandidateType(context, type) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + (context.candidateTypes || (context.candidateTypes = [])).push(type); + } + } + function hasCallContext(usageContext) { + return !!usageContext && !!usageContext.callContexts; + } + })(InferFromReference || (InferFromReference = {})); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -107646,12 +109674,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -107683,7 +109711,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(115 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(116 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -107706,7 +109734,7 @@ var ts; 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 === 219 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 221 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -107714,27 +109742,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 195 /* ArrowFunction */: { + case 197 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 216 /* Block */) { + if (arrowFunctionBody.kind === 218 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 120 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 121 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyComments(assignmentBinaryExpression, method, sourceFile); @@ -107755,17 +109783,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 196 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 71 /* Identifier */) { + if (node.name.kind !== 72 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107776,7 +109804,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 84 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 85 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -107828,13 +109856,13 @@ var ts; var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context, setOfExpressionsToReturn, originalTypeMap, allVarNames); var constIdentifiers = getConstIdentifiers(synthNamesMap); - var returnStatements = ts.getReturnStatementsWithPromiseHandlers(functionToConvertRenamed); + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, allVarNames: allVarNames, setOfExpressionsToReturn: setOfExpressionsToReturn, constIdentifiers: constIdentifiers, originalTypeMap: originalTypeMap, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 120 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 121 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); @@ -107854,6 +109882,14 @@ var ts; _loop_19(statement); } } + function getReturnStatementsWithPromiseHandlers(body) { + var res = []; + ts.forEachReturnStatement(body, function (ret) { + if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + res.push(ret); + }); + return res; + } // Returns the identifiers that are never reassigned in the refactor function getConstIdentifiers(synthNamesMap) { var constIdentifiers = []; @@ -108115,10 +110151,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 71 /* Identifier */: // identifier includes undefined + case 72 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -108140,8 +110176,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -108152,7 +110188,7 @@ var ts; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; } - if (ts.getReturnStatementsWithPromiseHandlers(statement).length) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -108163,7 +110199,7 @@ var ts; removeReturns(refactoredStmts, prevArgName === undefined ? undefined : prevArgName.identifier, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.getReturnStatementsWithPromiseHandlers(ts.createReturn(funcBody)); + var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.createReturn(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -108306,10 +110342,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -108355,29 +110391,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 58 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 59 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 219 /* ExpressionStatement */: { + case 221 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 189 /* CallExpression */: { + case 191 /* 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 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 59 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -108417,8 +110453,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: { + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -108426,7 +110462,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: @@ -108469,16 +110505,16 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 274 /* ShorthandPropertyAssignment */: - case 275 /* SpreadAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 277 /* SpreadAssignment */: return undefined; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 154 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); + case 156 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(85 /* ExportKeyword */)], prop); default: ts.Debug.assertNever(prop); } @@ -108527,23 +110563,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.createToken(84 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(85 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* 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, 23 /* DotToken */, sourceFile), [ts.createToken(84 /* ExportKeyword */), ts.createToken(76 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(85 /* ExportKeyword */), ts.createToken(77 /* 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) { - var modifiers = [ts.createToken(84 /* ExportKeyword */)]; + var modifiers = [ts.createToken(85 /* ExportKeyword */)]; switch (exported.kind) { - case 194 /* FunctionExpression */: { + case 196 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -108551,10 +110587,10 @@ var ts; } } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -108572,7 +110608,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: { + case 184 /* 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 @@ -108583,7 +110619,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 183 /* ArrayBindingPattern */: { + case 185 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -108594,7 +110630,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 71 /* Identifier */: + case 72 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name); @@ -108666,11 +110702,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node; - case 184 /* BindingElement */: + case 186 /* BindingElement */: return parent.propertyName !== node; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -109009,21 +111045,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 247 /* ImportDeclaration */) + if (declaration.kind !== 249 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 252 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 247 /* ImportDeclaration */) { + if (declaration.kind === 249 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 251 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -109034,7 +111070,7 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) + return (i.kind === 249 /* ImportDeclaration */ || i.kind === 248 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } @@ -109049,7 +111085,7 @@ var ts; }); }); // Sort to keep the shortest paths first - return choicesForEachExportingModule.sort(function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -109057,9 +111093,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 247 /* ImportDeclaration */ + var expression = declaration.kind === 249 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 259 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -109387,12 +111423,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 71 /* Identifier */); + ts.Debug.assert(node.kind === 72 /* Identifier */); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -109447,6 +111483,9 @@ var ts; var errorCodes = [ ts.Diagnostics.Property_0_does_not_exist_on_type_1.code, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code, + ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2.code, + ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more.code ]; var fixId = "addMissingMember"; codefix.registerCodeFix({ @@ -109580,7 +111619,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 207 /* ClassExpression */) { + if (classDeclaration.kind === 209 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -109606,13 +111645,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 202 /* BinaryExpression */) { + if (token.parent.parent.kind === 204 /* 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); } - return typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); + else { + var contextualType = checker.getContextualType(token.parent); + typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; + } + return typeNode || ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -109621,7 +111664,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -109645,7 +111688,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(137 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(138 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -109665,7 +111708,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, !ts.isInterfaceDeclaration(typeDecl)); - var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 156 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -109681,7 +111724,7 @@ var ts; */ var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 68 /* StringLike */); + return !!(type && type.flags & 132 /* StringLike */); }); var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); @@ -109930,7 +111973,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 99 /* ThisKeyword */) + if (token.kind !== 100 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -109969,7 +112012,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 124 /* ConstructorKeyword */); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -110007,17 +112050,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 86 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(109 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 85 /* ExtendsKeyword */ && - heritageClauses[1].token === 108 /* ImplementsKeyword */) { + heritageClauses[0].token === 86 /* ExtendsKeyword */ && + heritageClauses[1].token === 109 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(26 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* 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; @@ -110101,7 +112144,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 === 27 /* LessThanToken */) { + if (token.kind === 28 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -110121,7 +112164,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* 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)); @@ -110153,7 +112196,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 126 /* InferKeyword */) + if (token.kind === 127 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -110162,7 +112205,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 27 /* LessThanToken */) { + else if (token.kind === 28 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -110172,7 +112215,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -110183,7 +112226,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(142 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(143 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -110193,13 +112236,13 @@ var ts; } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 92 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { - if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) + if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 149 /* Parameter */) { + if (decl.kind === 151 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -110210,7 +112253,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -110219,7 +112262,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 === 126 /* InferKeyword */) { + if (token.kind === 127 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -110228,14 +112271,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 149 /* Parameter */: - case 148 /* TypeParameter */: + case 151 /* Parameter */: + case 150 /* TypeParameter */: return true; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: return true; } } @@ -110249,9 +112292,9 @@ var ts; } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 187 /* PropertyAccessExpression */) + if (ts.isPropertyAccessExpression(ref.parent) && ref.parent.name === ref) ref = ref.parent; - if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + if (ts.isBinaryExpression(ref.parent) && ts.isExpressionStatement(ref.parent.parent) && ref.parent.left === ref) { changes.delete(sourceFile, ref.parent.parent); } }); @@ -110267,33 +112310,41 @@ var ts; } function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { if (mayDeleteParameter(p, checker, isFixAll)) { - changes.delete(sourceFile, p); - deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + if (p.modifiers && p.modifiers.length > 0 + && (!ts.isIdentifier(p.name) || ts.FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) { + p.modifiers.forEach(function (modifier) { + changes.deleteModifier(sourceFile, modifier); + }); + } + else { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); + } } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: return true; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: { + case 196 /* FunctionExpression */: + case 197 /* 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. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 72 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -110333,7 +112384,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 220 /* IfStatement */: + case 222 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -110344,8 +112395,8 @@ var ts; return; } // falls through - case 222 /* WhileStatement */: - case 223 /* ForStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -110394,7 +112445,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, 56 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -110418,10 +112469,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 === 284 /* JSDocNullableType */) { + if (typeNode.kind === 286 /* 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, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -110438,7 +112489,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 286 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -110455,22 +112506,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 210 /* AsExpression */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 237 /* FunctionDeclaration */: - case 156 /* GetAccessor */: - case 160 /* IndexSignature */: - case 179 /* MappedType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 192 /* TypeAssertionExpression */: - case 235 /* VariableDeclaration */: + case 212 /* AsExpression */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 239 /* FunctionDeclaration */: + case 158 /* GetAccessor */: + case 162 /* IndexSignature */: + case 181 /* MappedType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 194 /* TypeAssertionExpression */: + case 237 /* VariableDeclaration */: return true; default: return false; @@ -110524,15 +112575,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 90 /* FunctionKeyword */, sourceFile); break; - case 195 /* ArrowFunction */: - insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); + case 197 /* ArrowFunction */: + insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: return; @@ -110546,11 +112597,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 71 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 72 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 120 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 121 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -110640,17 +112691,17 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); switch (declaration.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 151 /* PropertySignature */: - case 152 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 153 /* PropertySignature */: + case 154 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 153 /* MethodSignature */: - case 154 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 156 /* 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 @@ -110668,8 +112719,8 @@ var ts; outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { - var signature = signatures_8[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var signature = signatures_7[_i]; // Need to ensure nodes are fresh each time so they can have different positions. outputMethod(signature, ts.getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), ts.getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } @@ -110690,14 +112741,14 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 156 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(55 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -110713,11 +112764,11 @@ var ts; ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); - var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(119 /* AnyKeyword */); + var returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, call) || ts.createKeywordTypeNode(120 /* AnyKeyword */); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(39 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(116 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -110734,8 +112785,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(120 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -110749,8 +112800,8 @@ var ts; var maxArgsSignature = signatures[0]; var minArgumentCount = signatures[0].minArgumentCount; var someSigHasRestParameter = false; - for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) { - var sig = signatures_9[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); if (sig.hasRestParameter) { someSigHasRestParameter = true; @@ -110763,11 +112814,11 @@ 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.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(120 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyArrayType, + /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -110778,7 +112829,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -110787,10 +112838,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(114 /* PublicKeyword */); + return ts.createToken(115 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(113 /* ProtectedKeyword */); + return ts.createToken(114 /* ProtectedKeyword */); } return undefined; } @@ -110798,608 +112849,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - var codefix; - (function (codefix) { - var fixId = "inferFromUsage"; - var errorCodes = [ - // Variable declarations - ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, - // Variable uses - ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, - // Parameter declarations - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, - // Get Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, - ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, - // Set Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, - // Property declarations - ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, - ]; - codefix.registerCodeFix({ - errorCodes: errorCodes, - getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; - var token = ts.getTokenAtPosition(sourceFile, start); - var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); - var name = declaration && ts.getNameOfDeclaration(declaration); - return !name || changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; - }, - fixIds: [fixId], - getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; - var markSeen = ts.nodeSeenTracker(); - return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); - }); - }, - }); - function getDiagnostic(errorCode, token) { - switch (errorCode) { - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - return ts.Diagnostics.Infer_parameter_types_from_usage; - default: - return ts.Diagnostics.Infer_type_of_0_from_usage; - } - } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 71 /* Identifier */ && token.kind !== 24 /* DotDotDotToken */ && token.kind !== 99 /* ThisKeyword */) { - return undefined; - } - var parent = token.parent; - switch (errorCode) { - // Variable and Property declarations - case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: - case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: - if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); - return parent; - } - if (ts.isPropertyAccessExpression(parent)) { - var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); - var typeNode = type && getTypeNodeIfAccessible(type, parent, program, host); - if (typeNode) { - changes.tryInsertJSDocType(sourceFile, parent, typeNode); - } - return parent; - } - return undefined; - case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { - var symbol = program.getTypeChecker().getSymbolAtLocation(token); - if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); - return symbol.valueDeclaration; - } - return undefined; - } - } - var containingFunction = ts.getContainingFunction(token); - if (containingFunction === undefined) { - return undefined; - } - switch (errorCode) { - // Parameter declarations - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - // falls through - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - if (markSeen(containingFunction)) { - var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, param, containingFunction, sourceFile, program, host, cancellationToken); - return param; - } - return undefined; - // Get Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: - case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: - if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); - return containingFunction; - } - return undefined; - // Set Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - return undefined; - default: - return ts.Debug.fail(String(errorCode)); - } - } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { - if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); - } - } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - return true; - case 194 /* FunctionExpression */: - return !!declaration.name; - } - return false; - } - function annotateParameters(changes, parameterDeclaration, containingFunction, sourceFile, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { - return; - } - var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : undefined - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); - if (ts.isInJSFile(containingFunction)) { - annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); - } - else { - 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) { - annotate(changes, sourceFile, declaration, type, program, host); - } - } - } - } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { - var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); - if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { - var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken) || - inferTypeForVariableFromUsage(param.name, program, cancellationToken); - if (ts.isInJSFile(setAccessorDeclaration)) { - annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); - } - else { - annotate(changes, sourceFile, param, type, program, host); - } - } - } - function annotate(changes, sourceFile, declaration, type, program, host) { - var typeNode = type && getTypeNodeIfAccessible(type, declaration, program, host); - if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 151 /* PropertySignature */) { - changes.tryInsertJSDocType(sourceFile, declaration, typeNode); - } - else { - changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); - } - } - } - function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { - var result = ts.mapDefined(parameterInferences, function (inference) { - var param = inference.declaration; - var typeNode = inference.type && getTypeNodeIfAccessible(inference.type, param, program, host); - return typeNode && !param.initializer && !ts.getJSDocType(param) ? __assign({}, inference, { typeNode: typeNode }) : undefined; - }); - changes.tryInsertJSDocParameters(sourceFile, result); - } - function getTypeNodeIfAccessible(type, enclosingScope, program, host) { - var checker = program.getTypeChecker(); - var typeIsAccessible = true; - var notAccessible = function () { typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { - trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; - }, - reportInaccessibleThisError: notAccessible, - reportPrivateInBaseOfClassExpression: notAccessible, - reportInaccessibleUniqueSymbolError: notAccessible, - moduleResolverHost: { - readFile: host.readFile, - fileExists: host.fileExists, - directoryExists: host.directoryExists, - getSourceFiles: program.getSourceFiles, - getCurrentDirectory: program.getCurrentDirectory, - getCommonSourceDirectory: program.getCommonSourceDirectory, - } - }); - return typeIsAccessible ? res : undefined; - } - 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; - }); - } - function inferTypeForVariableFromUsage(token, program, cancellationToken) { - return InferFromReference.inferTypeFromReferences(getReferences(token, program, cancellationToken), program.getTypeChecker(), cancellationToken); - } - function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { - switch (containingFunction.kind) { - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - var isConstructor = containingFunction.kind === 155 /* Constructor */; - var searchToken = isConstructor ? - ts.findChildOfKind(containingFunction, 123 /* ConstructorKeyword */, sourceFile) : - containingFunction.name; - if (searchToken) { - return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program.getTypeChecker(), cancellationToken); - } - } - } - var InferFromReference; - (function (InferFromReference) { - function inferTypeFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_1 = references; _i < references_1.length; _i++) { - var reference = references_1[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - return getTypeFromUsageContext(usageContext, checker); - } - InferFromReference.inferTypeFromReferences = inferTypeFromReferences; - function inferTypeForParametersFromReferences(references, declaration, checker, cancellationToken) { - if (references.length === 0) { - return undefined; - } - if (!declaration.parameters) { - return undefined; - } - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - var isConstructor = declaration.kind === 155 /* Constructor */; - var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; - return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { - var types = []; - var isRest = ts.isRestParameter(parameter); - var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { - isOptional = ts.isInJSFile(declaration); - continue; - } - if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - } - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - if (!types.length) { - return { declaration: parameter }; - } - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return { - type: isRest ? checker.createArrayType(type) : type, - isOptional: isOptional && !isRest, - declaration: parameter - }; - }); - } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeFromContext(node, checker, usageContext) { - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - switch (node.parent.kind) { - case 201 /* PostfixUnaryExpression */: - usageContext.isNumber = true; - break; - case 200 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); - break; - case 202 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); - break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); - break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); - } - else { - inferTypeFromContextualType(node, checker, usageContext); - } - break; - case 187 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); - break; - case 188 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); - break; - case 235 /* 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. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); - } - break; - } - } - // falls through - default: - return inferTypeFromContextualType(node, checker, usageContext); - } - } - function inferTypeFromContextualType(node, checker, usageContext) { - if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); - } - } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { - switch (node.operator) { - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - usageContext.isNumber = true; - break; - case 37 /* PlusToken */: - usageContext.isNumberOrString = true; - break; - // case SyntaxKind.ExclamationToken: - // no inferences here; - } - } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { - switch (parent.operatorToken.kind) { - // ExponentiationOperator - case 40 /* AsteriskAsteriskToken */: - // MultiplicativeOperator - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: - // ShiftOperator - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - // BitwiseOperator - case 48 /* AmpersandToken */: - case 49 /* BarToken */: - case 50 /* CaretToken */: - // CompoundAssignmentOperator - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 69 /* BarEqualsToken */: - case 70 /* CaretEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - // AdditiveOperator - case 38 /* MinusToken */: - // RelationalOperator - case 27 /* LessThanToken */: - case 30 /* LessThanEqualsToken */: - case 29 /* GreaterThanToken */: - case 31 /* GreaterThanEqualsToken */: - var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, operandType); - } - else { - usageContext.isNumber = true; - } - break; - case 59 /* PlusEqualsToken */: - case 37 /* PlusToken */: - var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 544 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); - } - else if (otherOperandType.flags & 168 /* NumberLike */) { - usageContext.isNumber = true; - } - else if (otherOperandType.flags & 68 /* StringLike */) { - usageContext.isString = true; - } - else { - usageContext.isNumberOrString = true; - } - break; - // AssignmentOperators - case 58 /* EqualsToken */: - case 32 /* EqualsEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); - break; - case 92 /* InKeyword */: - if (node === parent.left) { - usageContext.isString = true; - } - break; - // LogicalOperator - case 54 /* BarBarToken */: - if (node === parent.left && - (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { - // var x = x || {}; - // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); - } - break; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: - case 93 /* InstanceOfKeyword */: - // nothing to infer here - break; - } - } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); - } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { - argumentTypes: [], - returnType: {} - }; - if (parent.arguments) { - for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); - } - } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 189 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); - } - else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); - } - } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { - var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); - } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); - } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { - if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; - return; - } - else { - var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 168 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; - } - else { - usageContext.stringIndexContext = indexUsageContext; - } - } - } - function getTypeFromUsageContext(usageContext, checker) { - if (usageContext.isNumberOrString && !usageContext.isNumber && !usageContext.isString) { - return checker.getUnionType([checker.getNumberType(), checker.getStringType()]); - } - else if (usageContext.isNumber) { - return checker.getNumberType(); - } - else if (usageContext.isString) { - return checker.getStringType(); - } - else if (usageContext.candidateTypes) { - return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(function (t) { return checker.getBaseTypeOfLiteralType(t); }), 2 /* Subtype */)); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - return checker.createPromiseType(types.length ? checker.getUnionType(types, 2 /* Subtype */) : checker.getAnyType()); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - return checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker)); - } - else if (usageContext.numberIndexContext) { - return checker.createArrayType(recur(usageContext.numberIndexContext)); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_6 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_6.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 - } - else { - return undefined; - } - function recur(innerContext) { - return getTypeFromUsageContext(innerContext, checker) || checker.getAnyType(); - } - } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { - var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - } - } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; - } - return undefined; - } - function getSignatureFromCallContext(callContext, checker) { - var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); - parameters.push(symbol); - } - var returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType(); - // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - } - function addCandidateType(context, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 32768 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); - } - } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); - })(codefix = ts.codefix || (ts.codefix = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var codefix; (function (codefix) { @@ -111432,7 +112881,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 191 /* CallExpression */ : 192 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; @@ -111543,7 +112992,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(51 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -111551,7 +113000,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(141 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -111572,7 +113021,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 512 /* BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.createFalse() : ts.createTrue(); } else if (type.isLiteral()) { @@ -111597,15 +113046,23 @@ var ts; } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); -/* @internal */ var ts; (function (ts) { function generateTypesForModule(name, moduleValue, formatSettings) { - return valueInfoToDeclarationFileText(ts.inspectValue(name, moduleValue), formatSettings); + return generateTypesForModuleOrGlobal(name, moduleValue, formatSettings, 0 /* ExportEquals */); } ts.generateTypesForModule = generateTypesForModule; - function valueInfoToDeclarationFileText(valueInfo, formatSettings) { - return ts.textChanges.getNewFileText(toStatements(valueInfo, 0 /* ExportEquals */), 3 /* TS */, "\n", ts.formatting.getFormatContext(formatSettings)); + function generateTypesForGlobal(name, globalValue, formatSettings) { + return generateTypesForModuleOrGlobal(name, globalValue, formatSettings, 3 /* Global */); + } + ts.generateTypesForGlobal = generateTypesForGlobal; + function generateTypesForModuleOrGlobal(name, globalValue, formatSettings, outputKind) { + return valueInfoToDeclarationFileText(ts.inspectValue(name, globalValue), formatSettings, outputKind); + } + /* @internal */ + function valueInfoToDeclarationFileText(valueInfo, formatSettings, outputKind) { + if (outputKind === void 0) { outputKind = 0 /* ExportEquals */; } + return ts.textChanges.getNewFileText(toStatements(valueInfo, outputKind), 3 /* TS */, formatSettings.newLineCharacter || "\n", ts.formatting.getFormatContext(formatSettings)); } ts.valueInfoToDeclarationFileText = valueInfoToDeclarationFileText; var OutputKind; @@ -111613,6 +113070,7 @@ var ts; OutputKind[OutputKind["ExportEquals"] = 0] = "ExportEquals"; OutputKind[OutputKind["NamedExport"] = 1] = "NamedExport"; OutputKind[OutputKind["NamespaceMember"] = 2] = "NamespaceMember"; + OutputKind[OutputKind["Global"] = 3] = "Global"; })(OutputKind || (OutputKind = {})); function toNamespaceMemberStatements(info) { return toStatements(info, 2 /* NamespaceMember */); @@ -111622,9 +113080,9 @@ var ts; var name = isDefault ? "_default" : info.name; if (!isValidIdentifier(name) || isDefault && kind !== 1 /* NamedExport */) return ts.emptyArray; - var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(84 /* ExportKeyword */), ts.createModifier(79 /* DefaultKeyword */)] - : kind === 0 /* ExportEquals */ ? [ts.createModifier(124 /* DeclareKeyword */)] - : kind === 1 /* NamedExport */ ? [ts.createModifier(84 /* ExportKeyword */)] + var modifiers = isDefault && info.kind === 2 /* FunctionOrClass */ ? [ts.createModifier(85 /* ExportKeyword */), ts.createModifier(80 /* DefaultKeyword */)] + : kind === 3 /* Global */ || kind === 0 /* ExportEquals */ ? [ts.createModifier(125 /* DeclareKeyword */)] + : kind === 1 /* NamedExport */ ? [ts.createModifier(85 /* ExportKeyword */)] : undefined; var exportEquals = function () { return kind === 0 /* ExportEquals */ ? [exportEqualsOrDefault(info.name, /*isExportEquals*/ true)] : ts.emptyArray; }; var exportDefault = function () { return isDefault ? [exportEqualsOrDefault("_default", /*isExportEquals*/ false)] : ts.emptyArray; }; @@ -111632,13 +113090,15 @@ var ts; case 2 /* FunctionOrClass */: return exportEquals().concat(functionOrClassToStatements(modifiers, name, info)); case 3 /* Object */: - var members = info.members; - if (kind === 0 /* ExportEquals */) { - return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); - } - if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { - // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. - return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + var members = info.members, hasNontrivialPrototype = info.hasNontrivialPrototype; + if (!hasNontrivialPrototype) { + if (kind === 0 /* ExportEquals */) { + return ts.flatMap(members, function (v) { return toStatements(v, 1 /* NamedExport */); }); + } + if (members.some(function (m) { return m.kind === 2 /* FunctionOrClass */; })) { + // If some member is a function, use a namespace so it gets a FunctionDeclaration or ClassDeclaration. + return exportDefault().concat([createNamespace(modifiers, name, ts.flatMap(members, toNamespaceMemberStatements))]); + } } // falls through case 0 /* Const */: @@ -111658,8 +113118,20 @@ var ts; var source = _a.source, prototypeMembers = _a.prototypeMembers, namespaceMembers = _a.namespaceMembers; var fnAst = parseClassOrFunctionBody(source); var _b = fnAst === undefined ? { parameters: ts.emptyArray, returnType: anyType() } : getParametersAndReturnType(fnAst), parameters = _b.parameters, returnType = _b.returnType; - var instanceProperties = typeof fnAst === "object" ? getConstructorFunctionInstanceProperties(fnAst) : ts.emptyArray; - var classStaticMembers = instanceProperties.length !== 0 || prototypeMembers.length !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */ ? [] : undefined; + var protoOrInstanceMembers = ts.createMap(); + if (typeof fnAst === "object") + getConstructorFunctionInstanceProperties(fnAst, protoOrInstanceMembers); + for (var _i = 0, prototypeMembers_1 = prototypeMembers; _i < prototypeMembers_1.length; _i++) { + var p = prototypeMembers_1[_i]; + // ignore non-functions on the prototype + if (p.kind === 2 /* FunctionOrClass */) { + var m = tryGetMethod(p); + if (m) { + protoOrInstanceMembers.set(p.name, m); + } + } + } + var classStaticMembers = protoOrInstanceMembers.size !== 0 || fnAst === undefined || typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */ ? [] : undefined; var namespaceStatements = ts.flatMap(namespaceMembers, function (info) { if (!isValidIdentifier(info.name)) return undefined; @@ -111672,16 +113144,19 @@ var ts; // falls through case 1 /* Array */: case 0 /* Const */: - classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(115 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); + classStaticMembers.push(addComment(ts.createProperty(/*decorators*/ undefined, [ts.createModifier(116 /* StaticKeyword */)], info.name, /*questionOrExclamationToken*/ undefined, toType(info), /*initializer*/ undefined), info.kind === 0 /* Const */ ? info.comment : undefined)); return undefined; case 2 /* FunctionOrClass */: if (!info.namespaceMembers.length) { // Else, can't merge a static method with a namespace. Must make it a function on the namespace. - var sig = tryGetMethod(info, [ts.createModifier(115 /* StaticKeyword */)]); + var sig = tryGetMethod(info, [ts.createModifier(116 /* StaticKeyword */)]); if (sig) { classStaticMembers.push(sig); return undefined; } } + break; + default: + ts.Debug.assertNever(info); } } return toStatements(info, 2 /* NamespaceMember */); @@ -111690,7 +113165,7 @@ var ts; ? ts.createClassDeclaration( /*decorators*/ undefined, modifiers, name, /*typeParameters*/ undefined, - /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), instanceProperties, ts.mapDefined(prototypeMembers, function (info) { return info.kind === 2 /* FunctionOrClass */ ? tryGetMethod(info) : undefined; }))) + /*heritageClauses*/ undefined, classStaticMembers.concat((parameters.length ? [ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, parameters, /*body*/ undefined)] : ts.emptyArray), ts.arrayFrom(protoOrInstanceMembers.values()))) : ts.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, name, /*typeParameters*/ undefined, parameters, returnType, /*body*/ undefined); return [decl].concat((namespaceStatements.length === 0 ? ts.emptyArray : [createNamespace(modifiers && modifiers.map(function (m) { return ts.getSynthesizedDeepClone(m); }), name, namespaceStatements)])); } @@ -111699,7 +113174,7 @@ var ts; if (!isValidIdentifier(name)) return undefined; var fnAst = parseClassOrFunctionBody(source); - if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 155 /* Constructor */)) + if (fnAst === undefined || (typeof fnAst !== "number" && fnAst.kind === 157 /* Constructor */)) return undefined; var sig = getParametersAndReturnType(fnAst); return sig && ts.createMethod( @@ -111718,23 +113193,25 @@ var ts; case 2 /* FunctionOrClass */: return ts.createTypeReferenceNode("Function", /*typeArguments*/ undefined); // Normally we create a FunctionDeclaration, but this can happen for a function in an array. case 3 /* Object */: - return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, m.name, /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); + return ts.createTypeLiteralNode(info.members.map(function (m) { return ts.createPropertySignature(/*modifiers*/ undefined, toPropertyName(m.name), /*questionToken*/ undefined, toType(m), /*initializer*/ undefined); })); default: return ts.Debug.assertNever(info); } } + function toPropertyName(name) { + return ts.isIdentifierText(name, 6 /* ESNext */) ? ts.createIdentifier(name) : ts.createStringLiteral(name); + } // Parses assignments to "this.x" in the constructor into class property declarations - function getConstructorFunctionInstanceProperties(fnAst) { - var members = []; + function getConstructorFunctionInstanceProperties(fnAst, members) { forEachOwnNodeOfFunction(fnAst, function (node) { if (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true) && - ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 99 /* ThisKeyword */) { - var name = node.left.name.text; - if (!ts.isJsPrivate(name)) - members.push(ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined)); + ts.isPropertyAccessExpression(node.left) && node.left.expression.kind === 100 /* ThisKeyword */) { + var name_6 = node.left.name.text; + if (!ts.isJsPrivate(name_6)) { + ts.getOrUpdate(members, name_6, function () { return ts.createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name_6, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined); }); + } } }); - return members; } function getParametersAndReturnType(fnAst) { if (typeof fnAst === "number") { @@ -111743,16 +113220,16 @@ var ts; var usedArguments = false, hasReturn = false; forEachOwnNodeOfFunction(fnAst, function (node) { usedArguments = usedArguments || ts.isIdentifier(node) && node.text === "arguments"; - hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 198 /* VoidExpression */; + hasReturn = hasReturn || ts.isReturnStatement(node) && !!node.expression && node.expression.kind !== 200 /* VoidExpression */; }); var parameters = fnAst.parameters.map(function (p) { return makeParameter("" + p.name.getText(), inferParameterType(fnAst, p)); }).concat((usedArguments ? [makeRestParameter()] : ts.emptyArray)); - return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(105 /* VoidKeyword */) }; + return { parameters: parameters, returnType: hasReturn ? anyType() : ts.createKeywordTypeNode(106 /* VoidKeyword */) }; } function makeParameter(name, type) { return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name, /*questionToken*/ undefined, type); } function makeRestParameter() { - return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); + return ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), "args", /*questionToken*/ undefined, ts.createArrayTypeNode(anyType())); } /** Returns 'undefined' for class with no declared constructor */ function parseClassOrFunctionBody(source) { @@ -111791,7 +113268,7 @@ var ts; return node; } function anyType() { - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } function createNamespace(modifiers, name, statements) { return ts.createModuleDeclaration(/*decorators*/ undefined, modifiers, ts.createIdentifier(name), ts.createModuleBlock(statements), 16 /* Namespace */); @@ -111893,8 +113370,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 181 /* ImportType */); + ts.Debug.assert(token.kind === 92 /* ImportKeyword */); + ts.Debug.assert(token.parent.kind === 183 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -111946,7 +113423,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(133 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -111966,7 +113443,7 @@ var ts; getAvailableActions: function (context) { var info = getInfo(context); if (!info) - return undefined; + return ts.emptyArray; var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; @@ -111993,16 +113470,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: { + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -112025,17 +113502,17 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 80 /* DefaultKeyword */))); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 85 /* ExportKeyword */)); switch (exportNode.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(80 /* DefaultKeyword */)); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. @@ -112043,9 +113520,9 @@ var ts; break; } // falls through - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); @@ -112072,18 +113549,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { + case 253 /* ImportSpecifier */: + case 257 /* 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 248 /* ImportClause */: { + case 250 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref); var spec = makeImportSpecifier(exportName, ref.text); @@ -112092,7 +113569,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 249 /* NamespaceImport */) { + else if (namedBindings.kind === 251 /* 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 */; @@ -112113,36 +113590,33 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: { - var spec = parent; - if (spec.kind === 251 /* ImportSpecifier */) { - // `import { foo } from "./a";` --> `import foo from "./a";` - // `import { foo as bar } from "./a";` --> `import bar from "./a";` - var defaultImport = ts.createIdentifier(spec.name.text); - if (spec.parent.elements.length === 1) { - changes.replaceNode(importingSourceFile, spec.parent, defaultImport); - } - else { - changes.delete(importingSourceFile, spec); - changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); - } + case 253 /* ImportSpecifier */: { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(parent.name.text); + if (parent.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, parent.parent, defaultImport); } else { - // `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";` - // (Because `export foo from "./a";` isn't valid syntax.) - changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + changes.delete(importingSourceFile, parent); + changes.insertNodeBefore(importingSourceFile, parent.parent, defaultImport); } break; } + case 257 /* 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";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, parent, makeExportSpecifier("default", parent.name.text)); + break; + } default: - ts.Debug.failBadSyntaxKind(parent); + ts.Debug.assertNever(parent); } } function makeImportSpecifier(propertyName, name) { @@ -112165,9 +113639,9 @@ var ts; getAvailableActions: function (context) { var i = getImportToConvert(context); if (!i) - return undefined; - var description = i.kind === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 249 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return ts.emptyArray; + var description = i.kind === 251 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 251 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { @@ -112189,7 +113663,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 249 /* NamespaceImport */) { + if (toConvert.kind === 251 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -112297,12 +113771,12 @@ var ts; var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context)); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { - return undefined; + return ts.emptyArray; } var extractions = getPossibleExtractions(targetRange, context); if (extractions === undefined) { // No extractions possible - return undefined; + return ts.emptyArray; } var functionActions = []; var usedFunctionNames = ts.createMap(); @@ -112358,7 +113832,7 @@ var ts; actions: constantActions }); } - return infos.length ? infos : undefined; + return infos.length ? infos : ts.emptyArray; } extractSymbol.getAvailableActions = getAvailableActions; /* Exported for tests */ @@ -112532,20 +114006,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 152 /* PropertyDeclaration */) { + if (current.kind === 154 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 149 /* Parameter */) { + else if (current.kind === 151 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 155 /* Constructor */) { + if (ctorOrMethod.kind === 157 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 154 /* MethodDeclaration */) { + else if (current.kind === 156 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -112588,7 +114062,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 235 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 237 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* 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`! @@ -112600,13 +114074,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 97 /* SuperKeyword */: + case 98 /* 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 === 189 /* CallExpression */) { + if (node.parent.kind === 191 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -112621,8 +114095,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -112634,20 +114108,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 220 /* IfStatement */: + case 222 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 216 /* Block */: - if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { + case 218 /* Block */: + if (node.parent && node.parent.kind === 235 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -112659,11 +114133,11 @@ var ts; break; } switch (node.kind) { - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -112671,8 +114145,8 @@ var ts; seenLabels.pop(); break; } - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: { var label = node.label; if (label) { @@ -112682,20 +114156,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 229 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -112749,7 +114223,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 === 149 /* Parameter */) { + if (current.kind === 151 /* 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; } @@ -112760,7 +114234,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 277 /* SourceFile */) { + if (current.kind === 279 /* SourceFile */) { return scopes; } } @@ -112850,32 +114324,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "constructor"; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return "arrow function"; - case 154 /* MethodDeclaration */: - return "method '" + scope.name.getText(); - case 156 /* GetAccessor */: + case 156 /* MethodDeclaration */: + return "method '" + scope.name.getText() + "'"; + case 158 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 238 /* ClassDeclaration */ + return scope.kind === 240 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 243 /* ModuleBlock */ + return scope.kind === 245 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -112941,20 +114415,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(112 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(113 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(120 /* AsyncKeyword */)); + modifiers.push(ts.createToken(121 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(121 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* 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; @@ -112971,7 +114445,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -113095,9 +114569,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 140 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 141 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(140 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(141 /* UndefinedKeyword */)]); } } /** @@ -113120,11 +114594,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(112 /* PrivateKeyword */)); + modifiers.push(ts.createToken(113 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(115 /* StaticKeyword */)); + modifiers.push(ts.createToken(116 /* StaticKeyword */)); } - modifiers.push(ts.createToken(132 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(133 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -113153,7 +114627,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 219 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 221 /* 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.createVariableStatement( @@ -113172,7 +114646,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 219 /* ExpressionStatement */) { + if (node.parent.kind === 221 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -113259,7 +114733,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 230 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -113429,7 +114903,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (4096 /* Void */ | 32768 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -113437,7 +114911,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 239 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -113753,30 +115227,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 276 /* EnumMember */: + case 278 /* EnumMember */: return false; } switch (node.kind) { - case 9 /* StringLiteral */: - return parent.kind !== 247 /* ImportDeclaration */ && - parent.kind !== 251 /* ImportSpecifier */; - case 206 /* SpreadElement */: - case 182 /* ObjectBindingPattern */: - case 184 /* BindingElement */: + case 10 /* StringLiteral */: + return parent.kind !== 249 /* ImportDeclaration */ && + parent.kind !== 253 /* ImportSpecifier */; + case 208 /* SpreadElement */: + case 184 /* ObjectBindingPattern */: + case 186 /* BindingElement */: return false; - case 71 /* Identifier */: - return parent.kind !== 184 /* BindingElement */ && - parent.kind !== 251 /* ImportSpecifier */ && - parent.kind !== 255 /* ExportSpecifier */; + case 72 /* Identifier */: + return parent.kind !== 186 /* BindingElement */ && + parent.kind !== 253 /* ImportSpecifier */ && + parent.kind !== 257 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 216 /* Block */: - case 277 /* SourceFile */: - case 243 /* ModuleBlock */: - case 269 /* CaseClause */: + case 218 /* Block */: + case 279 /* SourceFile */: + case 245 /* ModuleBlock */: + case 271 /* CaseClause */: return true; default: return false; @@ -113797,7 +115271,7 @@ var ts; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { if (!getConvertibleFieldAtPosition(context)) - return undefined; + return ts.emptyArray; return [{ name: actionName, description: actionDescription, @@ -113825,10 +115299,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 114 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 115 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 112 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 113 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -113866,7 +115340,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(115 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(116 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -113889,7 +115363,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 149 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 151 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -113971,7 +115445,7 @@ var ts; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) - return undefined; + return ts.emptyArray; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, @@ -114033,11 +115507,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return true; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -114125,12 +115599,12 @@ var ts; } function getNamespaceLikeImport(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? + case 249 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 251 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node.name; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -114161,20 +115635,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 249 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 248 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -114244,15 +115718,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -114265,7 +115739,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 251 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -114277,7 +115751,7 @@ var ts; if (namedBindingsUnused) { changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 250 /* NamedImports */) { + else if (namedBindings.kind === 252 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -114290,14 +115764,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: break; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); } @@ -114402,13 +115876,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 246 /* ImportEqualsDeclaration */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: return true; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -114420,7 +115894,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -114430,9 +115904,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -114441,7 +115915,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 249 /* NamespaceImport */) { + if (namedBindings.kind === 251 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -114451,11 +115925,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return keep(name) ? name : undefined; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return name; - case 182 /* ObjectBindingPattern */: { + case 184 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -114512,13 +115986,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -114526,17 +116000,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return cb(statement); - case 217 /* VariableStatement */: - return ts.forEach(statement.declarationList.declarations, cb); - case 219 /* ExpressionStatement */: { + case 219 /* VariableStatement */: + return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); + case 221 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -114544,11 +116018,29 @@ var ts; } } } + function forEachTopLevelDeclarationInBindingName(name, cb) { + switch (name.kind) { + case 72 /* Identifier */: + return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); + default: + return ts.Debug.assertNever(name); + } + } function nameOfTopLevelDeclaration(d) { - return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return ts.isExpressionStatement(d) ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { - return ts.isVariableDeclaration(d) ? d.parent.parent : d; + switch (d.kind) { + case 237 /* VariableDeclaration */: + return d.parent.parent; + case 186 /* BindingElement */: + return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); + default: + return d; + } } function addExportToChanges(sourceFile, decl, changes, useEs6Exports) { if (isExported(sourceFile, decl, useEs6Exports)) @@ -114575,25 +116067,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(85 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -114604,18 +116096,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -114623,7 +116115,7 @@ var ts; } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 58 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 59 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -114645,7 +116137,7 @@ var ts; var file = context.file, startPosition = context.startPosition; var info = getConvertibleArrowFunctionAtPosition(file, startPosition); if (!info) - return undefined; + return ts.emptyArray; return [{ name: refactorName, description: refactorDescription, @@ -114687,7 +116179,7 @@ var ts; return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { var node = ts.getTokenAtPosition(file, startPosition); @@ -114723,7 +116215,7 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 71 /* Identifier */ ? new IdentifierObject(71 /* Identifier */, pos, end) : + kind === 72 /* Identifier */ ? new IdentifierObject(72 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 12679168 /* ContextFlags */; @@ -114796,8 +116288,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 303 /* LastJSDocNode */; }); - return child.kind < 146 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 283 /* FirstJSDocNode */ || kid.kind > 305 /* LastJSDocNode */; }); + return child.kind < 148 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -114808,7 +116300,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 146 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 148 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -114854,7 +116346,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 71 /* Identifier */) { + if (token === 72 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.showSyntaxKind(parent) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -114866,7 +116358,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(304 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(306 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -114998,7 +116490,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 71 /* Identifier */; + IdentifierObject.prototype.kind = 72 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -115044,25 +116536,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 262144 /* Union */); + return !!(this.flags & 1048576 /* Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 524288 /* Intersection */); + return !!(this.flags & 2097152 /* Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 786432 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 192 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 64 /* StringLiteral */); + return !!(this.flags & 128 /* StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 128 /* NumberLiteral */); + return !!(this.flags & 256 /* NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 65536 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); @@ -115199,10 +116691,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -115222,31 +116714,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 255 /* ExportSpecifier */: - case 251 /* ImportSpecifier */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 166 /* TypeLiteral */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 257 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 168 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: { + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -115257,19 +116749,19 @@ var ts; } } // falls through - case 276 /* EnumMember */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 278 /* EnumMember */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: addDeclaration(node); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -115281,7 +116773,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -115290,7 +116782,7 @@ var ts; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -115603,7 +117095,7 @@ var ts; } var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - var sourceMapper = ts.getSourceMapper(getCanonicalFileName, currentDirectory, log, host, function () { return program; }); + var sourceMapper = ts.getSourceMapper(useCaseSensitiveFileNames, currentDirectory, log, host, function () { return program; }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -115684,11 +117176,11 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }; + compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile); + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); }; } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); @@ -115722,7 +117214,7 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -115879,15 +117371,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return !ts.isLabelName(node); - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 97 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 98 /* SuperKeyword */: return true; default: return false; @@ -115925,7 +117417,7 @@ var ts; var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return ts.Debug.assertDefined(program.getSourceFile(f)); }); + var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -115933,7 +117425,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, position); - if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) { var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); @@ -115994,16 +117486,16 @@ var ts; return undefined; } switch (node.kind) { - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: - case 9 /* StringLiteral */: - case 86 /* FalseKeyword */: - case 101 /* TrueKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 99 /* ThisKeyword */: - case 176 /* ThisType */: - case 71 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: + case 10 /* StringLiteral */: + case 87 /* FalseKeyword */: + case 102 /* TrueKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 100 /* ThisKeyword */: + case 178 /* ThisType */: + case 72 /* Identifier */: break; // Cant create the text span default: @@ -116019,7 +117511,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 === 242 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 244 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -116081,10 +117573,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = ts.createMapFromTemplate((_a = {}, - _a[17 /* OpenBraceToken */] = 18 /* CloseBraceToken */, - _a[19 /* OpenParenToken */] = 20 /* CloseParenToken */, - _a[21 /* OpenBracketToken */] = 22 /* CloseBracketToken */, - _a[29 /* GreaterThanToken */] = 27 /* LessThanToken */, + _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, + _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, + _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, + _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -116224,7 +117716,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 29 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -116483,7 +117975,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 257 /* ExternalModuleReference */ || + node.parent.kind === 259 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -116498,15 +117990,15 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 147 /* ComputedPropertyName */) { + if (node.parent.kind === 149 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && + (node.parent.parent.kind === 188 /* ObjectLiteralExpression */ || node.parent.parent.kind === 268 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -116548,7 +118040,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 188 /* ElementAccessExpression */ && + node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -116628,144 +118120,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 235 /* VariableDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return spanInVariableDeclaration(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return spanInParameterDeclaration(node); - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return spanInBlock(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInBlock(node.block); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 221 /* DoStatement */: + case 223 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return spanInForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 233 /* TryStatement */: + case 235 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 184 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 186 /* BindingElement */: // span on complete node return textSpan(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 150 /* Decorator */: + case 152 /* Decorator */: return spanInNodeArray(parent.decorators); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return spanInPreviousNode(node); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 18 /* CloseBraceToken */: + case 19 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 22 /* CloseBracketToken */: + case 23 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return spanInOpenParenToken(node); - case 20 /* CloseParenToken */: + case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 56 /* ColonToken */: + case 57 /* ColonToken */: return spanInColonToken(node); - case 29 /* GreaterThanToken */: - case 27 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 28 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return spanInWhileKeyword(node); - case 82 /* ElseKeyword */: - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 83 /* ElseKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return spanInNextNode(node); - case 145 /* OfKeyword */: + case 147 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -116777,14 +118269,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 === 71 /* Identifier */ || - node.kind === 206 /* SpreadElement */ || - node.kind === 273 /* PropertyAssignment */ || - node.kind === 274 /* ShorthandPropertyAssignment */) && + if ((node.kind === 72 /* Identifier */ || + node.kind === 208 /* SpreadElement */ || + node.kind === 275 /* PropertyAssignment */ || + node.kind === 276 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 202 /* BinaryExpression */) { + if (node.kind === 204 /* 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 @@ -116793,35 +118285,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 58 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 59 /* 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 === 26 /* CommaToken */) { + if (operatorToken.kind === 27 /* CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 150 /* Decorator */: + case 152 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: return textSpan(node); - case 202 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 26 /* CommaToken */) { + case 204 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -116830,21 +118322,21 @@ var ts; } } switch (node.parent.kind) { - case 273 /* PropertyAssignment */: + case 275 /* 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 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: { + case 237 /* VariableDeclaration */: + case 151 /* 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)) { @@ -116852,7 +118344,7 @@ var ts; } break; } - case 202 /* BinaryExpression */: { + case 204 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -116882,7 +118374,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 226 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -116894,7 +118386,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 225 /* ForOfStatement */) { + parent.parent.kind === 227 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -116935,7 +118427,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 240 /* ClassDeclaration */ && functionDeclaration.kind !== 157 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -116958,26 +118450,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 224 /* ForInStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 226 /* 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 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 227 /* 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 === 236 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 238 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -117002,21 +118494,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 184 /* BindingElement */) { + if (bindingPattern.parent.kind === 186 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); - var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 185 /* ArrayBindingPattern */ && node.kind !== 184 /* ObjectBindingPattern */); + var elements = node.kind === 187 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 210 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -117024,18 +118516,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 === 202 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 204 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -117043,25 +118535,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* EnumDeclaration */: - case 238 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 216 /* Block */: + case 218 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 272 /* CatchClause */: + case 274 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -117069,7 +118561,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 182 /* ObjectBindingPattern */: + case 184 /* 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); @@ -117085,7 +118577,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 183 /* ArrayBindingPattern */: + case 185 /* 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); @@ -117100,12 +118592,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 189 /* CallExpression */ || - node.parent.kind === 190 /* NewExpression */) { + if (node.parent.kind === 223 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 191 /* CallExpression */ || + node.parent.kind === 192 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 193 /* ParenthesizedExpression */) { + if (node.parent.kind === 195 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -117114,21 +118606,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 193 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 195 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -117138,20 +118630,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ || - node.parent.kind === 149 /* Parameter */) { + node.parent.kind === 275 /* PropertyAssignment */ || + node.parent.kind === 151 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 192 /* TypeAssertionExpression */) { + if (node.parent.kind === 194 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 221 /* DoStatement */) { + if (node.parent.kind === 223 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -117159,7 +118651,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.kind === 227 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -117257,7 +118749,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); // TODO: GH#18217 return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; // TODO: GH#18217 + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } @@ -117267,7 +118759,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); }); // TODO: GH#18217 + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); }; } } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 28b6a13abb5..f29014039b1 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -21,7 +21,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -491,10 +491,33 @@ var ts; return result; } ts.flatten = flatten; + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ function flatMap(array, mapfn) { var result; if (array) { - result = []; + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || ts.emptyArray; + } + ts.flatMap = flatMap; + function flatMapToMutable(array, mapfn) { + var result = []; + if (array) { for (var i = 0; i < array.length; i++) { var v = mapfn(array[i], i); if (v) { @@ -509,7 +532,7 @@ var ts; } return result; } - ts.flatMap = flatMap; + ts.flatMapToMutable = flatMapToMutable; function flatMapIterator(iter, mapfn) { var first = iter.next(); if (first.done) { @@ -748,7 +771,7 @@ var ts; */ function deduplicateSorted(array, comparer) { if (array.length === 0) - return []; + return ts.emptyArray; var last = array[0]; var deduplicated = [last]; for (var i = 1; i < array.length; i++) { @@ -779,7 +802,7 @@ var ts; } ts.insertSorted = insertSorted; function sortAndDeduplicate(array, comparer, equalityComparer) { - return deduplicateSorted(sort(array, comparer), equalityComparer || comparer); + return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive); } ts.sortAndDeduplicate = sortAndDeduplicate; function arrayIsEqualTo(array1, array2, equalityComparer) { @@ -932,7 +955,7 @@ var ts; * Returns a new sorted array. */ function sort(array, comparer) { - return array.slice().sort(comparer); + return (array.length === 0 ? array : array.slice().sort(comparer)); } ts.sort = sort; function arrayIterator(array) { @@ -1038,12 +1061,25 @@ var ts; * @param offset An offset into `array` at which to start the search. */ function binarySearch(array, value, keySelector, keyComparer, offset) { - if (!array || array.length === 0) { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); + } + ts.binarySearch = binarySearch; + /** + * Performs a binary search, finding the index at which an object with `key` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `key`. + * @param array A sorted array whose first element must be no larger than number + * @param key The key to be searched for in the array. + * @param keySelector A callback used to select the search key from each element of `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + */ + function binarySearchKey(array, key, keySelector, keyComparer, offset) { + if (!some(array)) { return -1; } var low = offset || 0; var high = array.length - 1; - var key = keySelector(value); while (low <= high) { var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle]); @@ -1060,7 +1096,7 @@ var ts; } return ~low; } - ts.binarySearch = binarySearch; + ts.binarySearchKey = binarySearchKey; function reduceLeft(array, f, initial, start, count) { if (array && array.length > 0) { var size = array.length; @@ -1984,6 +2020,33 @@ var ts; var counts; var marks; var measures; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; /** * Marks a performance event. * @@ -2438,368 +2501,370 @@ var ts; SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["BigIntLiteral"] = 9] = "BigIntLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 11] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 12] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 13] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 14] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 15] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 16] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 17] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 18] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 19] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 20] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 21] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 22] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 23] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 24] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 59] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 60] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 61] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 62] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 63] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 64] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 65] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 66] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 69] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 70] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 71] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 72] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 73] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 74] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 75] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 76] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 77] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 78] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 79] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 80] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 81] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 82] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 83] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 84] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 85] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 86] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 87] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 88] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 89] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 90] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 91] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 92] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 93] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 94] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 95] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 96] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 97] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 98] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 99] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 100] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 101] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 102] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 103] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 104] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 105] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 106] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 107] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 108] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 109] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 110] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 111] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 112] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 113] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 114] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 115] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 116] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 117] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 126] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 127] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 128] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 129] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 130] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 131] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 132] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 133] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 134] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 135] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 136] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 137] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 138] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 118] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 119] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 120] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 121] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 122] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 123] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 124] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 125] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 126] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 127] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 128] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 129] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 130] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 131] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 132] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 133] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 134] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 135] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 136] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 137] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 138] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 139] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 140] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 141] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 142] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 143] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 144] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 145] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 146] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 147] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 148] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 149] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 150] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 151] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 152] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 153] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 154] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 155] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 156] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 157] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 158] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 159] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 160] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 161] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 162] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 163] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 164] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 165] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 166] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 167] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 168] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 169] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 170] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 171] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 172] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 173] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 174] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 175] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 176] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 177] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 178] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 179] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 180] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 181] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 182] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 183] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 184] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 185] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 186] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 187] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 188] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 189] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 190] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 191] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 192] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 193] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 194] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 195] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 196] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 197] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 198] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 199] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 200] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 201] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 202] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 203] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 204] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 205] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 206] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 207] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 208] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 209] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 210] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 211] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 212] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 213] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 214] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 215] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 216] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 217] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 218] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 219] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 220] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 221] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 222] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 223] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 224] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 225] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 226] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 227] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 228] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 229] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 230] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 231] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 232] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 233] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 234] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 235] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 236] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 237] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 238] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 239] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 240] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 241] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 242] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 243] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 244] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 245] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 246] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 247] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 248] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 249] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 250] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 251] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 252] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 253] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 254] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 255] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 256] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 257] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 258] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 259] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 260] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 261] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 262] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 263] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 264] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 265] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 266] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 267] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 268] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 269] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 270] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 271] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 272] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 273] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 274] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 275] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 276] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 277] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 278] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 279] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 280] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 281] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 282] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 283] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 284] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 296] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 297] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 298] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 299] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 300] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 301] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 302] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 303] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 285] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 286] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 287] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 288] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 289] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 290] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 291] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 293] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 294] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 295] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 296] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 297] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 298] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 299] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 300] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 301] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 302] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 303] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 304] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 305] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 304] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 306] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 305] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 306] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 307] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 308] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 309] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 307] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 308] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 309] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 310] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 311] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 310] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 312] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 59] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 71] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 60] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 71] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 73] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 108] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 73] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 147] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 109] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 117] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 163] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 183] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 71] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 147] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 303] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 303] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 71] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 148] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 283] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 305] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 294] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 305] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 118] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 147] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3089,14 +3154,15 @@ var ts; // of a type, such as the global `Promise` type in lib.d.ts). TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; // with call signatures. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; (function (SymbolFlags) { @@ -3251,29 +3317,27 @@ var ts; TypeFlags[TypeFlags["Number"] = 8] = "Number"; TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 4096] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 16384] = "Null"; - TypeFlags[TypeFlags["Never"] = 32768] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 131072] = "Object"; - TypeFlags[TypeFlags["Union"] = 262144] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; - TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; - /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; - /* @internal */ - TypeFlags[TypeFlags["UnionOfPrimitiveTypes"] = 67108864] = "UnionOfPrimitiveTypes"; + TypeFlags[TypeFlags["BigInt"] = 64] = "BigInt"; + TypeFlags[TypeFlags["StringLiteral"] = 128] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 256] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 512] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 1024] = "EnumLiteral"; + TypeFlags[TypeFlags["BigIntLiteral"] = 2048] = "BigIntLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 4096] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 8192] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 16384] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 32768] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 65536] = "Null"; + TypeFlags[TypeFlags["Never"] = 131072] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 262144] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 524288] = "Object"; + TypeFlags[TypeFlags["Union"] = 1048576] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 2097152] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 4194304] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 8388608] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 16777216] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 33554432] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 67108864] = "NonPrimitive"; /* @internal */ TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ @@ -3283,40 +3347,41 @@ var ts; /* @internal */ TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 98304] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 2944] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 117724] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 67359327] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 131068] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 132] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 296] = "NumberLike"; + TypeFlags[TypeFlags["BigIntLike"] = 2112] = "BigIntLike"; + TypeFlags[TypeFlags["BooleanLike"] = 528] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 1056] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 67238908] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 8650752] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 58982400] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 4194304] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 63176704] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 66846720] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 67637251] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 16748579] = "NotPrimitiveUnion"; + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ @@ -3351,6 +3416,7 @@ var ts; ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ @@ -3362,6 +3428,13 @@ var ts; Variance[Variance["Bivariant"] = 3] = "Bivariant"; Variance[Variance["Independent"] = 4] = "Independent"; })(Variance = ts.Variance || (ts.Variance = {})); + /* @internal */ + var JsxReferenceKind; + (function (JsxReferenceKind) { + JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; + JsxReferenceKind[JsxReferenceKind["Function"] = 1] = "Function"; + JsxReferenceKind[JsxReferenceKind["Mixed"] = 2] = "Mixed"; + })(JsxReferenceKind = ts.JsxReferenceKind || (ts.JsxReferenceKind = {})); var SignatureKind; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; @@ -3422,6 +3495,15 @@ var ts; AssignmentDeclarationKind[AssignmentDeclarationKind["Property"] = 5] = "Property"; // F.prototype = { ... } AssignmentDeclarationKind[AssignmentDeclarationKind["Prototype"] = 6] = "Prototype"; + // Object.defineProperty(x, 'name', { value: any, writable?: boolean (false by default) }); + // Object.defineProperty(x, 'name', { get: Function, set: Function }); + // Object.defineProperty(x, 'name', { get: Function }); + // Object.defineProperty(x, 'name', { set: Function }); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyValue"] = 7] = "ObjectDefinePropertyValue"; + // Object.defineProperty(exports || module.exports, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePropertyExports"] = 8] = "ObjectDefinePropertyExports"; + // Object.defineProperty(Foo.prototype, 'name', ...); + AssignmentDeclarationKind[AssignmentDeclarationKind["ObjectDefinePrototypeProperty"] = 9] = "ObjectDefinePrototypeProperty"; })(AssignmentDeclarationKind = ts.AssignmentDeclarationKind || (ts.AssignmentDeclarationKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -3789,6 +3871,7 @@ var ts; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; + EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); var ListFormat; (function (ListFormat) { @@ -3803,64 +3886,66 @@ var ts; ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; - ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; - ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["AsteriskDelimited"] = 32] = "AsteriskDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 60] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 64] = "AllowTrailingComma"; // Whitespace - ListFormat[ListFormat["Indented"] = 64] = "Indented"; - ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; - ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Indented"] = 128] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 256] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 512] = "SpaceBetweenSiblings"; // Brackets/Braces - ListFormat[ListFormat["Braces"] = 512] = "Braces"; - ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; - ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; - ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; - ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; - ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; - ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; - ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["Braces"] = 1024] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 2048] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 4096] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 8192] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 15360] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 16384] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 32768] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 49152] = "Optional"; // Other - ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; - ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; - ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; - ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; - ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; + ListFormat[ListFormat["PreferNewLine"] = 65536] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 131072] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 262144] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 524288] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 1048576] = "SingleElement"; // Precomputed Formats - ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; - ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; - ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 384] = "SingleLineTypeLiteralMembers"; - ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 16449] = "MultiLineTypeLiteralMembers"; - ListFormat[ListFormat["TupleTypeElements"] = 272] = "TupleTypeElements"; - ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; - ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; - ListFormat[ListFormat["ObjectBindingPatternElements"] = 262576] = "ObjectBindingPatternElements"; - ListFormat[ListFormat["ArrayBindingPatternElements"] = 262448] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; - ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; - ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; - ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; - ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; - ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; - ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; - ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; - ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; - ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["Modifiers"] = 262656] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 512] = "HeritageClauses"; + ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 768] = "SingleLineTypeLiteralMembers"; + ListFormat[ListFormat["MultiLineTypeLiteralMembers"] = 32897] = "MultiLineTypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 528] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 516] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 520] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 525136] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 524880] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 526226] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 8914] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CommaListElements"] = 528] = "CommaListElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 2576] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 18960] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 262144] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 768] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 129] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 528] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 768] = "SingleLineFunctionBodyStatements"; ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; ListFormat[ListFormat["ClassHeritageClauses"] = 0] = "ClassHeritageClauses"; - ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; - ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; - ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; - ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; - ListFormat[ListFormat["NamedImportsOrExportsElements"] = 262576] = "NamedImportsOrExportsElements"; - ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 131072] = "JsxElementOrFragmentChildren"; - ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; - ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; - ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; - ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; - ListFormat[ListFormat["TypeArguments"] = 26896] = "TypeArguments"; - ListFormat[ListFormat["TypeParameters"] = 26896] = "TypeParameters"; - ListFormat[ListFormat["Parameters"] = 1296] = "Parameters"; - ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + ListFormat[ListFormat["ClassMembers"] = 129] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 129] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 145] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 129] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 525136] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementOrFragmentChildren"] = 262144] = "JsxElementOrFragmentChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 262656] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 163969] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 528] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 131073] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 49153] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 53776] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 53776] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 2576] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 8848] = "IndexSignatureParameters"; + ListFormat[ListFormat["JSDocComment"] = 33] = "JSDocComment"; })(ListFormat = ts.ListFormat || (ts.ListFormat = {})); /* @internal */ var PragmaKindFlags; @@ -5164,6 +5249,7 @@ var ts; use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), 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."), @@ -5220,14 +5306,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number' or an enum type."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), @@ -5434,9 +5520,9 @@ var ts; No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), @@ -5534,6 +5620,13 @@ var ts; Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), It_is_highly_likely_that_you_are_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "It_is_highly_likely_that_you_are_missing_a_semicolon_2734", "It is highly likely that you are missing a semicolon."), + Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), + Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), + BigInt_literals_are_not_available_when_targeting_lower_than_ESNext: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ESNext_2737", "BigInt literals are not available when targeting lower than ESNext."), + An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, ts.DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"), + Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."), + Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."), 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}'."), @@ -5850,6 +5943,9 @@ var ts; Did_you_mean_to_call_this_expression: diag(6212, ts.DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"), Did_you_mean_to_use_new_with_this_expression: diag(6213, ts.DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"), Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, ts.DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."), + Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."), + Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."), + Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5890,6 +5986,7 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."), Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."), Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."), + Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, ts.DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."), Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."), Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."), Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."), @@ -5917,6 +6014,14 @@ var ts; If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any_7041", "The containing arrow function captures the global value of 'this' which implicitly has type 'any'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), + Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, ts.DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, ts.DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), + Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."), + Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, ts.DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."), + Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."), + _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."), 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_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -6078,6 +6183,8 @@ var ts; Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), Generate_types_for_0: diag(95067, ts.DiagnosticCategory.Message, "Generate_types_for_0_95067", "Generate types for '{0}'"), Generate_types_for_all_packages_without_types: diag(95068, ts.DiagnosticCategory.Message, "Generate_types_for_all_packages_without_types_95068", "Generate types for all packages without types"), + Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), + Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), }; })(ts || (ts = {})); var ts; @@ -6085,93 +6192,94 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 71 /* Identifier */; + return token >= 72 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 29 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 117 /* AbstractKeyword */, - any: 119 /* AnyKeyword */, - as: 118 /* AsKeyword */, - boolean: 122 /* BooleanKeyword */, - break: 72 /* BreakKeyword */, - case: 73 /* CaseKeyword */, - catch: 74 /* CatchKeyword */, - class: 75 /* ClassKeyword */, - continue: 77 /* ContinueKeyword */, - const: 76 /* ConstKeyword */ + abstract: 118 /* AbstractKeyword */, + any: 120 /* AnyKeyword */, + as: 119 /* AsKeyword */, + bigint: 146 /* BigIntKeyword */, + boolean: 123 /* BooleanKeyword */, + break: 73 /* BreakKeyword */, + case: 74 /* CaseKeyword */, + catch: 75 /* CatchKeyword */, + class: 76 /* ClassKeyword */, + continue: 78 /* ContinueKeyword */, + const: 77 /* ConstKeyword */ }, - _a["" + "constructor"] = 123 /* ConstructorKeyword */, - _a.debugger = 78 /* DebuggerKeyword */, - _a.declare = 124 /* DeclareKeyword */, - _a.default = 79 /* DefaultKeyword */, - _a.delete = 80 /* DeleteKeyword */, - _a.do = 81 /* DoKeyword */, - _a.else = 82 /* ElseKeyword */, - _a.enum = 83 /* EnumKeyword */, - _a.export = 84 /* ExportKeyword */, - _a.extends = 85 /* ExtendsKeyword */, - _a.false = 86 /* FalseKeyword */, - _a.finally = 87 /* FinallyKeyword */, - _a.for = 88 /* ForKeyword */, - _a.from = 143 /* FromKeyword */, - _a.function = 89 /* FunctionKeyword */, - _a.get = 125 /* GetKeyword */, - _a.if = 90 /* IfKeyword */, - _a.implements = 108 /* ImplementsKeyword */, - _a.import = 91 /* ImportKeyword */, - _a.in = 92 /* InKeyword */, - _a.infer = 126 /* InferKeyword */, - _a.instanceof = 93 /* InstanceOfKeyword */, - _a.interface = 109 /* InterfaceKeyword */, - _a.is = 127 /* IsKeyword */, - _a.keyof = 128 /* KeyOfKeyword */, - _a.let = 110 /* LetKeyword */, - _a.module = 129 /* ModuleKeyword */, - _a.namespace = 130 /* NamespaceKeyword */, - _a.never = 131 /* NeverKeyword */, - _a.new = 94 /* NewKeyword */, - _a.null = 95 /* NullKeyword */, - _a.number = 134 /* NumberKeyword */, - _a.object = 135 /* ObjectKeyword */, - _a.package = 111 /* PackageKeyword */, - _a.private = 112 /* PrivateKeyword */, - _a.protected = 113 /* ProtectedKeyword */, - _a.public = 114 /* PublicKeyword */, - _a.readonly = 132 /* ReadonlyKeyword */, - _a.require = 133 /* RequireKeyword */, - _a.global = 144 /* GlobalKeyword */, - _a.return = 96 /* ReturnKeyword */, - _a.set = 136 /* SetKeyword */, - _a.static = 115 /* StaticKeyword */, - _a.string = 137 /* StringKeyword */, - _a.super = 97 /* SuperKeyword */, - _a.switch = 98 /* SwitchKeyword */, - _a.symbol = 138 /* SymbolKeyword */, - _a.this = 99 /* ThisKeyword */, - _a.throw = 100 /* ThrowKeyword */, - _a.true = 101 /* TrueKeyword */, - _a.try = 102 /* TryKeyword */, - _a.type = 139 /* TypeKeyword */, - _a.typeof = 103 /* TypeOfKeyword */, - _a.undefined = 140 /* UndefinedKeyword */, - _a.unique = 141 /* UniqueKeyword */, - _a.unknown = 142 /* UnknownKeyword */, - _a.var = 104 /* VarKeyword */, - _a.void = 105 /* VoidKeyword */, - _a.while = 106 /* WhileKeyword */, - _a.with = 107 /* WithKeyword */, - _a.yield = 116 /* YieldKeyword */, - _a.async = 120 /* AsyncKeyword */, - _a.await = 121 /* AwaitKeyword */, - _a.of = 145 /* OfKeyword */, + _a["" + "constructor"] = 124 /* ConstructorKeyword */, + _a.debugger = 79 /* DebuggerKeyword */, + _a.declare = 125 /* DeclareKeyword */, + _a.default = 80 /* DefaultKeyword */, + _a.delete = 81 /* DeleteKeyword */, + _a.do = 82 /* DoKeyword */, + _a.else = 83 /* ElseKeyword */, + _a.enum = 84 /* EnumKeyword */, + _a.export = 85 /* ExportKeyword */, + _a.extends = 86 /* ExtendsKeyword */, + _a.false = 87 /* FalseKeyword */, + _a.finally = 88 /* FinallyKeyword */, + _a.for = 89 /* ForKeyword */, + _a.from = 144 /* FromKeyword */, + _a.function = 90 /* FunctionKeyword */, + _a.get = 126 /* GetKeyword */, + _a.if = 91 /* IfKeyword */, + _a.implements = 109 /* ImplementsKeyword */, + _a.import = 92 /* ImportKeyword */, + _a.in = 93 /* InKeyword */, + _a.infer = 127 /* InferKeyword */, + _a.instanceof = 94 /* InstanceOfKeyword */, + _a.interface = 110 /* InterfaceKeyword */, + _a.is = 128 /* IsKeyword */, + _a.keyof = 129 /* KeyOfKeyword */, + _a.let = 111 /* LetKeyword */, + _a.module = 130 /* ModuleKeyword */, + _a.namespace = 131 /* NamespaceKeyword */, + _a.never = 132 /* NeverKeyword */, + _a.new = 95 /* NewKeyword */, + _a.null = 96 /* NullKeyword */, + _a.number = 135 /* NumberKeyword */, + _a.object = 136 /* ObjectKeyword */, + _a.package = 112 /* PackageKeyword */, + _a.private = 113 /* PrivateKeyword */, + _a.protected = 114 /* ProtectedKeyword */, + _a.public = 115 /* PublicKeyword */, + _a.readonly = 133 /* ReadonlyKeyword */, + _a.require = 134 /* RequireKeyword */, + _a.global = 145 /* GlobalKeyword */, + _a.return = 97 /* ReturnKeyword */, + _a.set = 137 /* SetKeyword */, + _a.static = 116 /* StaticKeyword */, + _a.string = 138 /* StringKeyword */, + _a.super = 98 /* SuperKeyword */, + _a.switch = 99 /* SwitchKeyword */, + _a.symbol = 139 /* SymbolKeyword */, + _a.this = 100 /* ThisKeyword */, + _a.throw = 101 /* ThrowKeyword */, + _a.true = 102 /* TrueKeyword */, + _a.try = 103 /* TryKeyword */, + _a.type = 140 /* TypeKeyword */, + _a.typeof = 104 /* TypeOfKeyword */, + _a.undefined = 141 /* UndefinedKeyword */, + _a.unique = 142 /* UniqueKeyword */, + _a.unknown = 143 /* UnknownKeyword */, + _a.var = 105 /* VarKeyword */, + _a.void = 106 /* VoidKeyword */, + _a.while = 107 /* WhileKeyword */, + _a.with = 108 /* WithKeyword */, + _a.yield = 117 /* YieldKeyword */, + _a.async = 121 /* AsyncKeyword */, + _a.await = 122 /* AwaitKeyword */, + _a.of = 147 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, ")": 20 /* CloseParenToken */, "[": 21 /* OpenBracketToken */, "]": 22 /* CloseBracketToken */, ".": 23 /* DotToken */, "...": 24 /* DotDotDotToken */, ";": 25 /* SemicolonToken */, ",": 26 /* CommaToken */, "<": 27 /* LessThanToken */, ">": 29 /* GreaterThanToken */, "<=": 30 /* LessThanEqualsToken */, ">=": 31 /* GreaterThanEqualsToken */, "==": 32 /* EqualsEqualsToken */, "!=": 33 /* ExclamationEqualsToken */, "===": 34 /* EqualsEqualsEqualsToken */, "!==": 35 /* ExclamationEqualsEqualsToken */, "=>": 36 /* EqualsGreaterThanToken */, "+": 37 /* PlusToken */, "-": 38 /* MinusToken */, "**": 40 /* AsteriskAsteriskToken */, "*": 39 /* AsteriskToken */, "/": 41 /* SlashToken */, "%": 42 /* PercentToken */, "++": 43 /* PlusPlusToken */, "--": 44 /* MinusMinusToken */, "<<": 45 /* LessThanLessThanToken */, ">": 46 /* GreaterThanGreaterThanToken */, ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, "&": 48 /* AmpersandToken */, "|": 49 /* BarToken */, "^": 50 /* CaretToken */, "!": 51 /* ExclamationToken */, "~": 52 /* TildeToken */, "&&": 53 /* AmpersandAmpersandToken */, "||": 54 /* BarBarToken */, "?": 55 /* QuestionToken */, ":": 56 /* ColonToken */, "=": 58 /* EqualsToken */, "+=": 59 /* PlusEqualsToken */, "-=": 60 /* MinusEqualsToken */, "*=": 61 /* AsteriskEqualsToken */, "**=": 62 /* AsteriskAsteriskEqualsToken */, "/=": 63 /* SlashEqualsToken */, "%=": 64 /* PercentEqualsToken */, "<<=": 65 /* LessThanLessThanEqualsToken */, ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 68 /* AmpersandEqualsToken */, "|=": 69 /* BarEqualsToken */, "^=": 70 /* CaretEqualsToken */, "@": 57 /* AtToken */ })); + var textToToken = ts.createMapFromTemplate(__assign({}, textToKeywordObj, { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 59 /* EqualsToken */, "+=": 60 /* PlusEqualsToken */, "-=": 61 /* MinusEqualsToken */, "*=": 62 /* AsteriskEqualsToken */, "**=": 63 /* AsteriskAsteriskEqualsToken */, "/=": 64 /* SlashEqualsToken */, "%=": 65 /* PercentEqualsToken */, "<<=": 66 /* LessThanLessThanEqualsToken */, ">>=": 67 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 69 /* AmpersandEqualsToken */, "|=": 70 /* BarEqualsToken */, "^=": 71 /* CaretEqualsToken */, "@": 58 /* AtToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6760,8 +6868,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; }, + isIdentifier: function () { return token === 72 /* Identifier */ || token > 108 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -6855,18 +6963,29 @@ var ts; end = pos; } } + var result; if (tokenFlags & 512 /* ContainsSeparator */) { - var result = mainFragment; + result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; } if (scientificFragment) { result += scientificFragment; } - return "" + +result; } else { - return "" + +(text.substring(start, end)); // No need to use all the fragments; no _ removal needed + result = text.substring(start, end); // No need to use all the fragments; no _ removal needed + } + if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { + return { + type: 8 /* NumericLiteral */, + value: "" + +result // if value is not an integer, it can be safely coerced to a number + }; + } + else { + tokenValue = result; + var type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint + return { type: type, value: tokenValue }; } } function scanOctalDigits() { @@ -6881,21 +7000,21 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count, canHaveSeparators) { - return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + var valueString = scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false, canHaveSeparators); + return valueString ? parseInt(valueString, 16) : -1; } /** * Scans as many hexadecimal digits as are available in the text, - * returning -1 if the given number of digits was unavailable. + * returning "" if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count, canHaveSeparators) { return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true, canHaveSeparators); } function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) { - var digits = 0; - var value = 0; + var valueChars = []; var allowSeparator = false; var isPreviousTokenSeparator = false; - while (digits < minCount || scanAsManyAsPossible) { + while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); if (canHaveSeparators && ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; @@ -6913,29 +7032,24 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; + if (ch >= 65 /* A */ && ch <= 70 /* F */) { + ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { + else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || + (ch >= 97 /* a */ && ch <= 102 /* f */))) { break; } + valueChars.push(ch); pos++; - digits++; isPreviousTokenSeparator = false; } - if (digits < minCount) { - value = -1; + if (valueChars.length < minCount) { + valueChars = []; } if (text.charCodeAt(pos - 1) === 95 /* _ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } - return value; + return String.fromCharCode.apply(String, valueChars); } function scanString(jsxAttributeString) { if (jsxAttributeString === void 0) { jsxAttributeString = false; } @@ -6987,7 +7101,7 @@ var ts; contents += text.substring(start, pos); tokenFlags |= 4 /* Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -6995,14 +7109,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; break; } // Escape character @@ -7095,7 +7209,8 @@ var ts; } } function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; var isInvalidExtendedEscape = false; // Validate the value of the digit if (escapedValue < 0) { @@ -7183,14 +7298,12 @@ var ts; } } } - return token = 71 /* Identifier */; + return token = 72 /* Identifier */; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; + var value = ""; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. - var numberOfDigits = 0; var separatorAllowed = false; var isPreviousTokenSeparator = false; while (true) { @@ -7212,27 +7325,42 @@ var ts; continue; } separatorAllowed = true; - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { + if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { break; } - value = value * base + valueOfCh; + value += text[pos]; pos++; - numberOfDigits++; isPreviousTokenSeparator = false; } - // Invalid binaryIntegerLiteral or octalIntegerLiteral - if (numberOfDigits === 0) { - return -1; - } if (text.charCodeAt(pos - 1) === 95 /* _ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); - return value; } return value; } + function checkBigIntSuffix() { + if (text.charCodeAt(pos) === 110 /* n */) { + tokenValue += "n"; + // Use base 10 instead of base 2 or base 8 for shorter literals + if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; + } + pos++; + return 9 /* 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 */ + ? parseInt(tokenValue.slice(2), 2) // skip "0b" + : tokenFlags & 256 /* OctalSpecifier */ + ? parseInt(tokenValue.slice(2), 8) // skip "0o" + : +tokenValue; + tokenValue = "" + numericValue; + return 8 /* NumericLiteral */; + } + } function scan() { + var _a; startPos = pos; tokenFlags = 0; var asteriskSeen = false; @@ -7305,48 +7433,48 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 33 /* ExclamationEqualsToken */; + return pos += 2, token = 34 /* ExclamationEqualsToken */; } pos++; - return token = 51 /* ExclamationToken */; + return token = 52 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PercentEqualsToken */; + return pos += 2, token = 65 /* PercentEqualsToken */; } pos++; - return token = 42 /* PercentToken */; + return token = 43 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 53 /* AmpersandAmpersandToken */; + return pos += 2, token = 54 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* AmpersandEqualsToken */; + return pos += 2, token = 69 /* AmpersandEqualsToken */; } pos++; - return token = 48 /* AmpersandToken */; + return token = 49 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 19 /* OpenParenToken */; + return token = 20 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 20 /* CloseParenToken */; + return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* AsteriskEqualsToken */; + return pos += 2, token = 62 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 63 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 40 /* AsteriskAsteriskToken */; + return pos += 2, token = 41 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7354,38 +7482,38 @@ var ts; asteriskSeen = true; continue; } - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 43 /* PlusPlusToken */; + return pos += 2, token = 44 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PlusEqualsToken */; + return pos += 2, token = 60 /* PlusEqualsToken */; } pos++; - return token = 37 /* PlusToken */; + return token = 38 /* PlusToken */; case 44 /* comma */: pos++; - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 44 /* MinusMinusToken */; + return pos += 2, token = 45 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* MinusEqualsToken */; + return pos += 2, token = 61 /* MinusEqualsToken */; } pos++; - return token = 38 /* MinusToken */; + return token = 39 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); + tokenValue = scanNumber().value; return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 24 /* DotDotDotToken */; + return pos += 3, token = 25 /* DotDotDotToken */; } pos++; - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -7436,43 +7564,43 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* SlashEqualsToken */; + return pos += 2, token = 64 /* SlashEqualsToken */; } pos++; - return token = 41 /* SlashToken */; + return token = 42 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; - var value = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); - if (value < 0) { + tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); + if (!tokenValue) { error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0x" + tokenValue; tokenFlags |= 64 /* HexSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 2); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 2); + if (!tokenValue) { error(ts.Diagnostics.Binary_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0b" + tokenValue; tokenFlags |= 128 /* BinarySpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(/* base */ 8); - if (value < 0) { + tokenValue = scanBinaryOrOctalDigits(/* base */ 8); + if (!tokenValue) { error(ts.Diagnostics.Octal_digit_expected); - value = 0; + tokenValue = "0"; } - tokenValue = "" + value; + tokenValue = "0o" + tokenValue; tokenFlags |= 256 /* OctalSpecifier */; - return token = 8 /* NumericLiteral */; + return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { @@ -7493,14 +7621,14 @@ var ts; case 55 /* _7 */: case 56 /* _8 */: case 57 /* _9 */: - tokenValue = scanNumber(); - return token = 8 /* NumericLiteral */; + (_a = scanNumber(), token = _a.type, tokenValue = _a.value); + return token; case 58 /* colon */: pos++; - return token = 56 /* ColonToken */; + return token = 57 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 25 /* SemicolonToken */; + return token = 26 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7513,20 +7641,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 66 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 45 /* LessThanLessThanToken */; + return pos += 2, token = 46 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 30 /* LessThanEqualsToken */; + return pos += 2, token = 31 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 28 /* LessThanSlashToken */; + return pos += 2, token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7539,15 +7667,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 34 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 32 /* EqualsEqualsToken */; + return pos += 2, token = 33 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 36 /* EqualsGreaterThanToken */; + return pos += 2, token = 37 /* EqualsGreaterThanToken */; } pos++; - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7559,25 +7687,25 @@ var ts; } } pos++; - return token = 29 /* GreaterThanToken */; + return token = 30 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 55 /* QuestionToken */; + return token = 56 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* CaretEqualsToken */; + return pos += 2, token = 71 /* CaretEqualsToken */; } pos++; - return token = 50 /* CaretToken */; + return token = 51 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 124 /* bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7589,22 +7717,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 54 /* BarBarToken */; + return pos += 2, token = 55 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* BarEqualsToken */; + return pos += 2, token = 70 /* BarEqualsToken */; } pos++; - return token = 49 /* BarToken */; + return token = 50 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 52 /* TildeToken */; + return token = 53 /* TildeToken */; case 64 /* at */: pos++; - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -7642,29 +7770,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 29 /* GreaterThanToken */) { + if (token === 30 /* 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 = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 67 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 46 /* GreaterThanGreaterThanToken */; + return token = 47 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 31 /* GreaterThanEqualsToken */; + return token = 32 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) { + if (token === 42 /* SlashToken */ || token === 64 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -7709,7 +7837,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 12 /* RegularExpressionLiteral */; + token = 13 /* RegularExpressionLiteral */; } return token; } @@ -7717,7 +7845,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -7734,14 +7862,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 28 /* LessThanSlashToken */; + return token = 29 /* LessThanSlashToken */; } pos++; - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -7773,7 +7901,7 @@ var ts; } pos++; } - return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -7799,7 +7927,7 @@ var ts; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 9 /* StringLiteral */; + return token = 10 /* StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -7823,36 +7951,36 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 57 /* AtToken */; + return token = 58 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 39 /* AsteriskToken */; + return token = 40 /* AsteriskToken */; case 123 /* openBrace */: - return token = 17 /* OpenBraceToken */; + return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: - return token = 18 /* CloseBraceToken */; + return token = 19 /* CloseBraceToken */; case 91 /* openBracket */: - return token = 21 /* OpenBracketToken */; + return token = 22 /* OpenBracketToken */; case 93 /* closeBracket */: - return token = 22 /* CloseBracketToken */; + return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 27 /* LessThanToken */; + return token = 28 /* LessThanToken */; case 61 /* equals */: - return token = 58 /* EqualsToken */; + return token = 59 /* EqualsToken */; case 44 /* comma */: - return token = 26 /* CommaToken */; + return token = 27 /* CommaToken */; case 46 /* dot */: - return token = 23 /* DotToken */; + return token = 24 /* DotToken */; case 96 /* backtick */: while (pos < end && text.charCodeAt(pos) !== 96 /* backtick */) { pos++; } tokenValue = text.substring(tokenPos + 1, pos); pos++; - return token = 13 /* NoSubstitutionTemplateLiteral */; + return token = 14 /* NoSubstitutionTemplateLiteral */; } if (isIdentifierStart(ch, 6 /* Latest */)) { while (isIdentifierPart(text.charCodeAt(pos), 6 /* Latest */) && pos < end) { @@ -8005,7 +8133,6 @@ var ts; getText: function () { return str; }, write: writeText, rawWrite: writeText, - writeTextOfNode: writeText, writeKeyword: writeText, writeOperator: writeText, writePunctuation: writeText, @@ -8014,7 +8141,9 @@ var ts; writeLiteral: writeText, writeParameter: writeText, writeProperty: writeText, - writeSymbol: writeText, + writeSymbol: function (s, _) { return writeText(s); }, + writeTrailingSemicolon: writeText, + writeComment: writeText, getTextPos: function () { return str.length; }, getLine: function () { return 0; }, getColumn: function () { return 0; }, @@ -8213,7 +8342,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 277 /* SourceFile */) { + while (node && node.kind !== 279 /* SourceFile */) { node = node.parent; } return node; @@ -8221,11 +8350,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return true; } return false; @@ -8359,7 +8488,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 === 304 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 306 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8378,7 +8507,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 281 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 283 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -8420,32 +8549,34 @@ var ts; function getLiteralText(node, sourceFile, neverAsciiEscape) { // 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 (!nodeIsSynthesized(node) && node.parent && !(ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */)) { + if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) || + ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; // 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 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.singleQuote) { return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; } else { return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } - case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return "`" + escapeText(node.text, 96 /* backtick */) + "`"; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: // tslint:disable-next-line no-invalid-template-strings return "`" + escapeText(node.text, 96 /* backtick */) + "${"; - case 15 /* TemplateMiddle */: + case 16 /* TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings return "}" + escapeText(node.text, 96 /* backtick */) + "${"; - case 16 /* TemplateTail */: + case 17 /* TemplateTail */: return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: + case 9 /* BigIntLiteral */: + case 13 /* RegularExpressionLiteral */: return node.text; } return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -8468,15 +8599,15 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; + return node.kind === 237 /* VariableDeclaration */ && node.parent.kind === 274 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 9 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -8500,11 +8631,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 244 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 277 /* SourceFile */ || - node.kind === 242 /* ModuleDeclaration */ || + return node.kind === 279 /* SourceFile */ || + node.kind === 244 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8521,9 +8652,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 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.isExternalModule(node.parent); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8539,22 +8670,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 272 /* CatchClause */: - case 242 /* ModuleDeclaration */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 274 /* CatchClause */: + case 244 /* ModuleDeclaration */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 216 /* Block */: + case 218 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8564,9 +8695,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: - case 291 /* JSDocSignature */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 293 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -8576,25 +8707,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -8604,8 +8735,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8614,15 +8745,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 217 /* VariableStatement */: - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 219 /* VariableStatement */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -8652,12 +8783,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isStringOrNumericLiteralLike(name.expression) ? ts.escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: return ts.Debug.assertNever(name); @@ -8666,11 +8798,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8715,7 +8847,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 216 /* Block */) { + if (node.body && node.body.kind === 218 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8729,7 +8861,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 277 /* SourceFile */: + case 279 /* 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 @@ -8738,25 +8870,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 240 /* TypeAliasDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 242 /* TypeAliasDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: errorNode = node.name; break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8805,11 +8937,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 98 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 191 /* CallExpression */ && n.expression.kind === 92 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { @@ -8817,20 +8949,20 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 219 /* ExpressionStatement */ - && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 221 /* ExpressionStatement */ + && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 10 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 149 /* Parameter */ || - node.kind === 148 /* TypeParameter */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 195 /* ArrowFunction */ || - node.kind === 193 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 151 /* Parameter */ || + node.kind === 150 /* TypeParameter */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 197 /* ArrowFunction */ || + node.kind === 195 /* ParenthesizedExpression */) ? 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 '/**/' @@ -8846,47 +8978,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= node.kind && node.kind <= 183 /* LastTypeNode */) { return true; } switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 134 /* NumberKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: return true; - case 105 /* VoidKeyword */: - return node.parent.kind !== 198 /* VoidExpression */; - case 209 /* ExpressionWithTypeArguments */: + case 106 /* VoidKeyword */: + return node.parent.kind !== 200 /* VoidExpression */; + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 148 /* TypeParameter */: - return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; + case 150 /* TypeParameter */: + return node.parent.kind === 181 /* MappedType */ || node.parent.kind === 176 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 71 /* Identifier */: + case 72 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 189 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */ || node.kind === 189 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 146 /* QualifiedName */: - case 187 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: { + case 148 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + case 100 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 165 /* TypeQuery */) { + if (parent.kind === 167 /* TypeQuery */) { return false; } - if (parent.kind === 181 /* ImportType */) { + if (parent.kind === 183 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8895,40 +9028,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 (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { + if (163 /* FirstTypeNode */ <= parent.kind && parent.kind <= 183 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return node === parent.constraint; - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return node === parent.constraint; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return node === parent.type; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node === parent.type; - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return node === parent.type; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return node === parent.type; - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8953,23 +9086,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitor(node); - case 244 /* CaseBlock */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 246 /* CaseBlock */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8979,26 +9112,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 241 /* EnumDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 243 /* EnumDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* 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); @@ -9021,10 +9154,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 167 /* ArrayType */) { + if (node && node.kind === 169 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 162 /* TypeReference */) { + else if (node && node.kind === 164 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9034,12 +9167,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 166 /* TypeLiteral */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 168 /* TypeLiteral */: return node.members; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return node.properties; } } @@ -9047,14 +9180,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 184 /* BindingElement */: - case 276 /* EnumMember */: - case 149 /* Parameter */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 274 /* ShorthandPropertyAssignment */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 278 /* EnumMember */: + case 151 /* Parameter */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 276 /* ShorthandPropertyAssignment */: + case 237 /* VariableDeclaration */: return true; } } @@ -9066,8 +9199,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 236 /* VariableDeclarationList */ - && node.parent.parent.kind === 217 /* VariableStatement */; + return node.parent.kind === 238 /* VariableDeclarationList */ + && node.parent.parent.kind === 219 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9078,13 +9211,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return true; } return false; @@ -9095,7 +9228,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 231 /* LabeledStatement */) { + if (node.statement.kind !== 233 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9103,17 +9236,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 218 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; + return node && node.kind === 156 /* MethodDeclaration */ && node.parent.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 186 /* ObjectLiteralExpression */ || - node.parent.kind === 207 /* ClassExpression */); + return node.kind === 156 /* MethodDeclaration */ && + (node.parent.kind === 188 /* ObjectLiteralExpression */ || + node.parent.kind === 209 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9126,7 +9259,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 273 /* PropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9163,14 +9296,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 277 /* SourceFile */); + ts.Debug.assert(node.kind !== 279 /* 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 147 /* ComputedPropertyName */: + case 149 /* 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 @@ -9185,9 +9318,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9198,26 +9331,26 @@ var ts; node = node.parent; } break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 242 /* ModuleDeclaration */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 241 /* EnumDeclaration */: - case 277 /* SourceFile */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 244 /* ModuleDeclaration */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 243 /* EnumDeclaration */: + case 279 /* SourceFile */: return node; } } @@ -9227,9 +9360,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: return container; } } @@ -9251,27 +9384,27 @@ var ts; return node; } switch (node.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: node = node.parent; break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return node; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 149 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 151 /* 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; @@ -9287,14 +9420,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { + if (func.kind === 196 /* FunctionExpression */ || func.kind === 197 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 193 /* ParenthesizedExpression */) { + while (parent.kind === 195 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 191 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9305,8 +9438,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 97 /* SuperKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 98 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9314,20 +9447,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) - && node.expression.kind === 99 /* ThisKeyword */; + return (kind === 189 /* PropertyAccessExpression */ || kind === 190 /* ElementAccessExpression */) + && node.expression.kind === 100 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: return node; } return undefined; @@ -9335,10 +9468,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return node.tag; - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9347,25 +9480,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // classes are valid targets return true; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 238 /* ClassDeclaration */; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + return parent.kind === 240 /* ClassDeclaration */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* 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 === 238 /* ClassDeclaration */; - case 149 /* Parameter */: + && parent.kind === 240 /* ClassDeclaration */; + case 151 /* 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 === 155 /* Constructor */ - || parent.kind === 154 /* MethodDeclaration */ - || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 238 /* ClassDeclaration */; + && (parent.kind === 157 /* Constructor */ + || parent.kind === 156 /* MethodDeclaration */ + || parent.kind === 159 /* SetAccessor */) + && grandparent.kind === 240 /* ClassDeclaration */; } return false; } @@ -9381,10 +9514,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 154 /* MethodDeclaration */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 159 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -9393,9 +9526,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 260 /* JsxOpeningElement */ || - parent.kind === 259 /* JsxSelfClosingElement */ || - parent.kind === 261 /* JsxClosingElement */) { + if (parent.kind === 262 /* JsxOpeningElement */ || + parent.kind === 261 /* JsxSelfClosingElement */ || + parent.kind === 263 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9403,56 +9536,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 12 /* RegularExpressionLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 210 /* AsExpression */: - case 192 /* TypeAssertionExpression */: - case 211 /* NonNullExpression */: - case 193 /* ParenthesizedExpression */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 202 /* BinaryExpression */: - case 203 /* ConditionalExpression */: - case 206 /* SpreadElement */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 208 /* OmittedExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 205 /* YieldExpression */: - case 199 /* AwaitExpression */: - case 212 /* MetaProperty */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 13 /* RegularExpressionLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 212 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 213 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 204 /* BinaryExpression */: + case 205 /* ConditionalExpression */: + case 208 /* SpreadElement */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 210 /* OmittedExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 207 /* YieldExpression */: + case 201 /* AwaitExpression */: + case 214 /* MetaProperty */: return true; - case 146 /* QualifiedName */: - while (node.parent.kind === 146 /* QualifiedName */) { + case 148 /* QualifiedName */: + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); - case 71 /* Identifier */: - if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node); + case 72 /* Identifier */: + if (node.parent.kind === 167 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 99 /* ThisKeyword */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 100 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -9462,49 +9596,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 186 /* BindingElement */: return parent.initializer === node; - case 219 /* ExpressionStatement */: - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 228 /* ReturnStatement */: - case 229 /* WithStatement */: - case 230 /* SwitchStatement */: - case 269 /* CaseClause */: - case 232 /* ThrowStatement */: + case 221 /* ExpressionStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 230 /* ReturnStatement */: + case 231 /* WithStatement */: + case 232 /* SwitchStatement */: + case 271 /* CaseClause */: + case 234 /* ThrowStatement */: return parent.expression === node; - case 223 /* ForStatement */: + case 225 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 238 /* VariableDeclarationList */) || forInStatement.expression === node; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return node === parent.expression; - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return node === parent.expression; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return node === parent.expression; - case 150 /* Decorator */: - case 268 /* JsxExpression */: - case 267 /* JsxSpreadAttribute */: - case 275 /* SpreadAssignment */: + case 152 /* Decorator */: + case 270 /* JsxExpression */: + case 269 /* JsxSpreadAttribute */: + case 277 /* SpreadAssignment */: return true; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -9512,7 +9646,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9521,7 +9655,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; + return node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 259 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -9549,15 +9683,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 137 /* StringKeyword */ || node.typeArguments[0].kind === 134 /* NumberKeyword */); + (node.typeArguments[0].kind === 138 /* StringKeyword */ || node.typeArguments[0].kind === 135 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 189 /* CallExpression */) { + if (callExpression.kind !== 191 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 71 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 72 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -9588,16 +9722,16 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.right === node) { name = node.parent.left; decl = name; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { name = node.parent.parent.name; decl = node.parent.parent; } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 59 /* EqualsToken */ && node.parent.parent.right === node.parent) { name = node.parent.parent.left; decl = name; } @@ -9612,13 +9746,13 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl); + return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -9631,16 +9765,25 @@ var ts; return init && getExpandoInitializer(init, isPrototypeAccess(node.name)); } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; + function hasExpandoValueProperty(node, isPrototypeAssignment) { + return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); } + if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) { + var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype"); + if (result) { + return result; + } + } } ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer; /** @@ -9656,11 +9799,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 196 /* FunctionExpression */ || e.kind === 197 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 194 /* FunctionExpression */ || - initializer.kind === 207 /* ClassExpression */ || - initializer.kind === 195 /* ArrowFunction */) { + if (initializer.kind === 196 /* FunctionExpression */ || + initializer.kind === 209 /* ClassExpression */ || + initializer.kind === 197 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9677,14 +9820,14 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 54 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 59 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -9692,8 +9835,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 === 54 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 58 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 59 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -9716,7 +9859,7 @@ var ts; return name.escapedText === initializer.escapedText; } if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 99 /* ThisKeyword */ || + return (initializer.expression.kind === 100 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -9750,8 +9893,31 @@ var ts; return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; + function isBindableObjectDefinePropertyCall(expr) { + return ts.length(expr.arguments) === 3 && + ts.isPropertyAccessExpression(expr.expression) && + ts.isIdentifier(expr.expression.expression) && + ts.idText(expr.expression.expression) === "Object" && + ts.idText(expr.expression.name) === "defineProperty" && + isStringOrNumericLiteralLike(expr.arguments[1]) && + isEntityNameExpression(expr.arguments[0]); + } + ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; function getAssignmentDeclarationKindWorker(expr) { - if (expr.operatorToken.kind !== 58 /* EqualsToken */ || + if (ts.isCallExpression(expr)) { + if (!isBindableObjectDefinePropertyCall(expr)) { + return 0 /* None */; + } + var entityName = expr.arguments[0]; + if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + return 8 /* ObjectDefinePropertyExports */; + } + if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + return 9 /* ObjectDefinePrototypeProperty */; + } + return 7 /* ObjectDefinePropertyValue */; + } + if (expr.operatorToken.kind !== 59 /* EqualsToken */ || !ts.isPropertyAccessExpression(expr.left)) { return 0 /* None */; } @@ -9763,10 +9929,10 @@ var ts; return getAssignmentDeclarationPropertyAccessKind(lhs); } function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 99 /* ThisKeyword */) { + if (lhs.expression.kind === 100 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (ts.isIdentifier(lhs.expression) && lhs.expression.escapedText === "module" && lhs.name.escapedText === "exports") { + else if (isModuleExportsPropertyAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } @@ -9805,7 +9971,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 221 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9814,7 +9980,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 237 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 239 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -9823,14 +9989,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.parent; - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return node.parent.parent; - case 189 /* CallExpression */: - return node.parent; - case 180 /* LiteralType */: + case 191 /* CallExpression */: + return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; + case 182 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9840,12 +10006,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return node.moduleSpecifier; - case 246 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 181 /* ImportType */: + case 248 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 259 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 183 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9854,11 +10020,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9866,19 +10032,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 249 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 149 /* Parameter */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 274 /* ShorthandPropertyAssignment */: - case 273 /* PropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 151 /* Parameter */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 276 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -9886,14 +10052,13 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 287 /* JSDocFunctionType */ && - node.parameters.length > 0 && - node.parameters[0].name && - node.parameters[0].name.escapedText === "new"; + var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined; + var name = ts.tryCast(param && param.name, ts.isIdentifier); + return !!name && name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 302 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 304 /* JSDocTypedefTag */ || node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9903,7 +10068,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ + node.expression.operatorToken.kind === 59 /* EqualsToken */ ? node.expression.right : undefined; } @@ -9912,18 +10077,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + node.expression.right.operatorToken.kind === 55 /* BarBarToken */ ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return node.initializer; } } @@ -9933,7 +10098,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 242 /* ModuleDeclaration */ + node.body.kind === 244 /* ModuleDeclaration */ ? node.body : undefined; } @@ -9948,11 +10113,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, node.jsDoc); } - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 148 /* TypeParameter */) { + if (node.kind === 150 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -9963,11 +10128,11 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 273 /* PropertyAssignment */ || - parent.kind === 152 /* PropertyDeclaration */ || - parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + if (parent.kind === 275 /* PropertyAssignment */ || + parent.kind === 154 /* PropertyDeclaration */ || + parent.kind === 221 /* ExpressionStatement */ && node.kind === 189 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 59 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -9978,7 +10143,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 59 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10001,7 +10166,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 71 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 72 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10036,7 +10201,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 === 288 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 290 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10049,31 +10214,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 59 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 193 /* ParenthesizedExpression */: - case 185 /* ArrayLiteralExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 187 /* ArrayLiteralExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: node = parent; break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10100,22 +10265,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 216 /* Block */: - case 217 /* VariableStatement */: - case 229 /* WithStatement */: - case 220 /* IfStatement */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 231 /* LabeledStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 233 /* TryStatement */: - case 272 /* CatchClause */: + case 218 /* Block */: + case 219 /* VariableStatement */: + case 231 /* WithStatement */: + case 222 /* IfStatement */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 233 /* LabeledStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 235 /* TryStatement */: + case 274 /* CatchClause */: return true; } return false; @@ -10132,33 +10297,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 175 /* ParenthesizedType */); + return walkUp(node, 177 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 193 /* ParenthesizedExpression */); + return walkUp(node, 195 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 193 /* ParenthesizedExpression */) { + while (node.kind === 195 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 196 /* DeleteExpression */; + return node && node.kind === 198 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10179,12 +10344,12 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 71 /* Identifier */: + case 72 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10207,8 +10372,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 147 /* ComputedPropertyName */ && + return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + node.parent.kind === 149 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10216,32 +10381,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 276 /* EnumMember */: - case 273 /* PropertyAssignment */: - case 187 /* PropertyAccessExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 278 /* EnumMember */: + case 275 /* PropertyAssignment */: + case 189 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 146 /* QualifiedName */) { + while (parent.kind === 148 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; + return parent.kind === 167 /* TypeQuery */ || parent.kind === 164 /* TypeReference */; } return false; - case 184 /* BindingElement */: - case 251 /* ImportSpecifier */: + case 186 /* BindingElement */: + case 253 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 255 /* ExportSpecifier */: - case 265 /* JsxAttribute */: + case 257 /* ExportSpecifier */: + case 267 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10256,15 +10421,16 @@ var ts; // export { x as } from ... // export = // export default + // module.exports = function isAliasSymbolDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 245 /* NamespaceExportDeclaration */ || - node.kind === 248 /* ImportClause */ && !!node.name || - node.kind === 249 /* NamespaceImport */ || - node.kind === 251 /* ImportSpecifier */ || - node.kind === 255 /* ExportSpecifier */ || - node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */; + return node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 247 /* NamespaceExportDeclaration */ || + node.kind === 250 /* ImportClause */ && !!node.name || + node.kind === 251 /* NamespaceImport */ || + node.kind === 253 /* ImportSpecifier */ || + node.kind === 257 /* ExportSpecifier */ || + node.kind === 254 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -10284,12 +10450,12 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 109 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; @@ -10301,7 +10467,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 86 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -10335,11 +10501,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; + return 73 /* FirstKeyword */ <= token && token <= 147 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; + return 118 /* FirstContextualKeyword */ <= token && token <= 147 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10351,6 +10517,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isIdentifierANonContextualKeyword(_a) { + var originalKeywordKind = _a.originalKeywordKind; + return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); + } + ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } @@ -10369,14 +10540,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 156 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10390,10 +10561,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10418,7 +10589,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 147 /* ComputedPropertyName */ && + return name.kind === 149 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10434,12 +10605,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return name.escapedText; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10455,9 +10626,9 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: return true; default: @@ -10466,11 +10637,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 72 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 71 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 72 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -10485,7 +10656,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 72 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -10494,11 +10665,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 149 /* Parameter */; + return root.kind === 151 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 184 /* BindingElement */) { + while (node.kind === 186 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10506,15 +10677,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 194 /* FunctionExpression */ - || kind === 237 /* FunctionDeclaration */ - || kind === 195 /* ArrowFunction */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 242 /* ModuleDeclaration */ - || kind === 277 /* SourceFile */; + return kind === 157 /* Constructor */ + || kind === 196 /* FunctionExpression */ + || kind === 239 /* FunctionDeclaration */ + || kind === 197 /* ArrowFunction */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 244 /* ModuleDeclaration */ + || kind === 279 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10533,38 +10704,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: return 1 /* Right */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operator) { - case 40 /* AsteriskAsteriskToken */: - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 41 /* AsteriskAsteriskToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 1 /* Right */; } } @@ -10573,15 +10744,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 192 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 202 /* BinaryExpression */) { + if (expression.kind === 204 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { + else if (expression.kind === 202 /* PrefixUnaryExpression */ || expression.kind === 203 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10591,116 +10762,116 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return 0; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return 1; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return 2; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return 4; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (operatorKind) { - case 26 /* CommaToken */: + case 27 /* CommaToken */: return 0; - case 58 /* EqualsToken */: - case 59 /* PlusEqualsToken */: - case 60 /* MinusEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 61 /* AsteriskEqualsToken */: - case 63 /* SlashEqualsToken */: - case 64 /* PercentEqualsToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* AmpersandEqualsToken */: - case 70 /* CaretEqualsToken */: - case 69 /* BarEqualsToken */: + case 59 /* EqualsToken */: + case 60 /* PlusEqualsToken */: + case 61 /* MinusEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: + case 64 /* SlashEqualsToken */: + case 65 /* PercentEqualsToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 69 /* AmpersandEqualsToken */: + case 71 /* CaretEqualsToken */: + case 70 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 200 /* PrefixUnaryExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 196 /* DeleteExpression */: - case 199 /* AwaitExpression */: + case 202 /* PrefixUnaryExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 198 /* DeleteExpression */: + case 201 /* AwaitExpression */: return 16; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return 17; - case 189 /* CallExpression */: + case 191 /* CallExpression */: return 18; - case 190 /* NewExpression */: + case 192 /* NewExpression */: return hasArguments ? 19 : 18; - case 191 /* TaggedTemplateExpression */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 193 /* TaggedTemplateExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 19; - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 71 /* Identifier */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 72 /* Identifier */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 207 /* ClassExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 193 /* ParenthesizedExpression */: - case 208 /* OmittedExpression */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 195 /* ParenthesizedExpression */: + case 210 /* OmittedExpression */: return 20; default: return -1; } } ts.getOperatorPrecedence = getOperatorPrecedence; - /* @internal */ function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: return 5; - case 53 /* AmpersandAmpersandToken */: + case 54 /* AmpersandAmpersandToken */: return 6; - case 49 /* BarToken */: + case 50 /* BarToken */: return 7; - case 50 /* CaretToken */: + case 51 /* CaretToken */: return 8; - case 48 /* AmpersandToken */: + case 49 /* AmpersandToken */: return 9; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return 10; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: - case 93 /* InstanceOfKeyword */: - case 92 /* InKeyword */: - case 118 /* AsKeyword */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: + case 94 /* InstanceOfKeyword */: + case 93 /* InKeyword */: + case 119 /* AsKeyword */: return 11; - case 45 /* LessThanLessThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* LessThanLessThanToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 37 /* PlusToken */: - case 38 /* MinusToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: return 13; - case 39 /* AsteriskToken */: - case 41 /* SlashToken */: - case 42 /* PercentToken */: + case 40 /* AsteriskToken */: + case 42 /* SlashToken */: + case 43 /* PercentToken */: return 14; - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -10768,7 +10939,7 @@ var ts; if (fileName) { return fileDiagnostics.get(fileName) || []; } - var fileDiags = ts.flatMap(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); + var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); }); if (!nonFileDiagnostics.length) { return fileDiags; } @@ -10826,7 +10997,7 @@ var ts; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || name.indexOf("-") > -1; + return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { @@ -10909,16 +11080,10 @@ var ts; lineStart = true; } } - function writeTextOfNode(text, node) { - var s = getTextOfNodeFromSourceText(text, node); - write(s); - updateLineCountAndPosFor(s); - } reset(); return { write: write, rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, writeLiteral: writeLiteral, writeLine: writeLine, increaseIndent: function () { indent++; }, @@ -10941,10 +11106,77 @@ var ts; writePunctuation: write, writeSpace: write, writeStringLiteral: write, - writeSymbol: write + writeSymbol: function (s, _) { return write(s); }, + writeTrailingSemicolon: write, + writeComment: write }; } ts.createTextWriter = createTextWriter; + function getTrailingSemicolonOmittingWriter(writer) { + var pendingTrailingSemicolon = false; + function commitPendingTrailingSemicolon() { + if (pendingTrailingSemicolon) { + writer.writeTrailingSemicolon(";"); + pendingTrailingSemicolon = false; + } + } + return __assign({}, writer, { writeTrailingSemicolon: function () { + pendingTrailingSemicolon = true; + }, + writeLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeLiteral(s); + }, + writeStringLiteral: function (s) { + commitPendingTrailingSemicolon(); + writer.writeStringLiteral(s); + }, + writeSymbol: function (s, sym) { + commitPendingTrailingSemicolon(); + writer.writeSymbol(s, sym); + }, + writePunctuation: function (s) { + commitPendingTrailingSemicolon(); + writer.writePunctuation(s); + }, + writeKeyword: function (s) { + commitPendingTrailingSemicolon(); + writer.writeKeyword(s); + }, + writeOperator: function (s) { + commitPendingTrailingSemicolon(); + writer.writeOperator(s); + }, + writeParameter: function (s) { + commitPendingTrailingSemicolon(); + writer.writeParameter(s); + }, + writeSpace: function (s) { + commitPendingTrailingSemicolon(); + writer.writeSpace(s); + }, + writeProperty: function (s) { + commitPendingTrailingSemicolon(); + writer.writeProperty(s); + }, + writeComment: function (s) { + commitPendingTrailingSemicolon(); + writer.writeComment(s); + }, + writeLine: function () { + commitPendingTrailingSemicolon(); + writer.writeLine(); + }, + increaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.increaseIndent(); + }, + decreaseIndent: function () { + commitPendingTrailingSemicolon(); + writer.decreaseIndent(); + } }); + } + ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11080,11 +11312,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 72 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 99 /* ThisKeyword */; + return id.originalKeywordKind === 100 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11095,10 +11327,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 157 /* SetAccessor */) { + else if (accessor.kind === 159 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11118,10 +11350,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 156 /* GetAccessor */ && !getAccessor) { + if (member.kind === 158 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 157 /* SetAccessor */ && !setAccessor) { + if (member.kind === 159 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11167,7 +11399,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 === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 291 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -11201,13 +11433,13 @@ var ts; function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { if (comments && comments.length > 0) { if (leadingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } var emitInterveningSeparator = false; for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var comment = comments_1[_i]; if (emitInterveningSeparator) { - writer.write(" "); + writer.writeSpace(" "); emitInterveningSeparator = false; } writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); @@ -11219,7 +11451,7 @@ var ts; } } if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + writer.writeSpace(" "); } } } @@ -11337,7 +11569,7 @@ var ts; } else { // Single line comment of style //.... - writer.write(text.substring(commentPos, commentEnd)); + writer.writeComment(text.substring(commentPos, commentEnd)); } } ts.writeCommentRange = writeCommentRange; @@ -11346,14 +11578,14 @@ var ts; var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text - writer.write(currentLineText); + writer.writeComment(currentLineText); if (end !== commentEnd) { writer.writeLine(); } } else { // Empty string - make sure we write empty line - writer.writeLiteral(newLine); + writer.rawWrite(newLine); } } function calculateIndent(text, pos, end) { @@ -11407,7 +11639,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 72 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -11415,29 +11647,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 115 /* StaticKeyword */: return 32 /* Static */; - case 114 /* PublicKeyword */: return 4 /* Public */; - case 113 /* ProtectedKeyword */: return 16 /* Protected */; - case 112 /* PrivateKeyword */: return 8 /* Private */; - case 117 /* AbstractKeyword */: return 128 /* Abstract */; - case 84 /* ExportKeyword */: return 1 /* Export */; - case 124 /* DeclareKeyword */: return 2 /* Ambient */; - case 76 /* ConstKeyword */: return 2048 /* Const */; - case 79 /* DefaultKeyword */: return 512 /* Default */; - case 120 /* AsyncKeyword */: return 256 /* Async */; - case 132 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 116 /* StaticKeyword */: return 32 /* Static */; + case 115 /* PublicKeyword */: return 4 /* Public */; + case 114 /* ProtectedKeyword */: return 16 /* Protected */; + case 113 /* PrivateKeyword */: return 8 /* Private */; + case 118 /* AbstractKeyword */: return 128 /* Abstract */; + case 85 /* ExportKeyword */: return 1 /* Export */; + case 125 /* DeclareKeyword */: return 2 /* Ambient */; + case 77 /* ConstKeyword */: return 2048 /* Const */; + case 80 /* DefaultKeyword */: return 512 /* Default */; + case 121 /* AsyncKeyword */: return 256 /* Async */; + case 133 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 54 /* BarBarToken */ - || token === 53 /* AmpersandAmpersandToken */ - || token === 51 /* ExclamationToken */; + return token === 55 /* BarBarToken */ + || token === 54 /* AmpersandAmpersandToken */ + || token === 52 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */; + return token >= 59 /* FirstAssignment */ && token <= 71 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -11450,14 +11682,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 108 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 109 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 58 /* EqualsToken */ + ? node.operatorToken.kind === 59 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -11465,8 +11697,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 186 /* ObjectLiteralExpression */ - || kind === 185 /* ArrayLiteralExpression */; + return kind === 188 /* ObjectLiteralExpression */ + || kind === 187 /* ArrayLiteralExpression */; } return false; } @@ -11476,7 +11708,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 71 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 72 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function isPropertyAccessEntityNameExpression(node) { @@ -11488,17 +11720,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 148 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 186 /* ObjectLiteralExpression */ && + return expression.kind === 188 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 185 /* ArrayLiteralExpression */ && + return expression.kind === 187 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11863,8 +12095,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 241 /* EnumDeclaration */: - case 242 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11941,35 +12173,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return accessKind(parent); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 202 /* BinaryExpression */: + return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 204 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 58 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 59 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 273 /* PropertyAssignment */: { + case 275 /* 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 274 /* ShorthandPropertyAssignment */: + case 276 /* 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 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 221 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12072,7 +12304,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 131072 /* Object */ ? type.objectFlags : 0; + return type.flags & 524288 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12343,9 +12575,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 148 /* TypeParameter */) { + if (d && d.kind === 150 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 241 /* InterfaceDeclaration */) { return current; } } @@ -12353,7 +12585,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 157 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12383,14 +12615,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 235 /* VariableDeclaration */) { + if (node.kind === 237 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 236 /* VariableDeclarationList */) { + if (node && node.kind === 238 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 217 /* VariableStatement */) { + if (node && node.kind === 219 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12536,27 +12768,27 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return expr.name; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 193 /* ParenthesizedExpression */: { + case 195 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 231 /* LabeledStatement */: { + case 233 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12580,17 +12812,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return declaration; - case 303 /* JSDocPropertyTag */: - case 297 /* JSDocParameterTag */: { + case 305 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 146 /* QualifiedName */) { + if (name.kind === 148 /* QualifiedName */) { return name.right; } break; } - case 202 /* BinaryExpression */: { + case 191 /* CallExpression */: + case 204 /* BinaryExpression */: { var expr = declaration; switch (ts.getAssignmentDeclarationKind(expr)) { case 1 /* ExportsProperty */: @@ -12598,13 +12831,17 @@ var ts; case 5 /* Property */: case 3 /* PrototypeProperty */: return expr.left.name; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return expr.arguments[1]; default: return undefined; } } - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 252 /* ExportAssignment */: { + case 254 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -12806,7 +13043,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 291 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12840,684 +13077,688 @@ var ts; return node.kind === 8 /* NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; + function isBigIntLiteral(node) { + return node.kind === 9 /* BigIntLiteral */; + } + ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 9 /* StringLiteral */; + return node.kind === 10 /* StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 10 /* JsxText */; + return node.kind === 11 /* JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 12 /* RegularExpressionLiteral */; + return node.kind === 13 /* RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 14 /* TemplateHead */; + return node.kind === 15 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 15 /* TemplateMiddle */; + return node.kind === 16 /* TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 16 /* TemplateTail */; + return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 71 /* Identifier */; + return node.kind === 72 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 146 /* QualifiedName */; + return node.kind === 148 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 147 /* ComputedPropertyName */; + return node.kind === 149 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 148 /* TypeParameter */; + return node.kind === 150 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 149 /* Parameter */; + return node.kind === 151 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 150 /* Decorator */; + return node.kind === 152 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 151 /* PropertySignature */; + return node.kind === 153 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 152 /* PropertyDeclaration */; + return node.kind === 154 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 153 /* MethodSignature */; + return node.kind === 155 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 155 /* Constructor */; + return node.kind === 157 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 158 /* CallSignature */; + return node.kind === 160 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 159 /* ConstructSignature */; + return node.kind === 161 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 160 /* IndexSignature */; + return node.kind === 162 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; + return node.kind === 159 /* SetAccessor */ || node.kind === 158 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 161 /* TypePredicate */; + return node.kind === 163 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 162 /* TypeReference */; + return node.kind === 164 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 163 /* FunctionType */; + return node.kind === 165 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 164 /* ConstructorType */; + return node.kind === 166 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 165 /* TypeQuery */; + return node.kind === 167 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 166 /* TypeLiteral */; + return node.kind === 168 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 167 /* ArrayType */; + return node.kind === 169 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 168 /* TupleType */; + return node.kind === 170 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 171 /* UnionType */; + return node.kind === 173 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 172 /* IntersectionType */; + return node.kind === 174 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 173 /* ConditionalType */; + return node.kind === 175 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 174 /* InferType */; + return node.kind === 176 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 175 /* ParenthesizedType */; + return node.kind === 177 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 176 /* ThisType */; + return node.kind === 178 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 177 /* TypeOperator */; + return node.kind === 179 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 178 /* IndexedAccessType */; + return node.kind === 180 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 179 /* MappedType */; + return node.kind === 181 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 180 /* LiteralType */; + return node.kind === 182 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 181 /* ImportType */; + return node.kind === 183 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 182 /* ObjectBindingPattern */; + return node.kind === 184 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 183 /* ArrayBindingPattern */; + return node.kind === 185 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 184 /* BindingElement */; + return node.kind === 186 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 185 /* ArrayLiteralExpression */; + return node.kind === 187 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 186 /* ObjectLiteralExpression */; + return node.kind === 188 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 187 /* PropertyAccessExpression */; + return node.kind === 189 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 188 /* ElementAccessExpression */; + return node.kind === 190 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 189 /* CallExpression */; + return node.kind === 191 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 190 /* NewExpression */; + return node.kind === 192 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 191 /* TaggedTemplateExpression */; + return node.kind === 193 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 192 /* TypeAssertionExpression */; + return node.kind === 194 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 193 /* ParenthesizedExpression */; + return node.kind === 195 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 306 /* PartiallyEmittedExpression */) { + while (node.kind === 308 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 194 /* FunctionExpression */; + return node.kind === 196 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 195 /* ArrowFunction */; + return node.kind === 197 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 196 /* DeleteExpression */; + return node.kind === 198 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 197 /* TypeOfExpression */; + return node.kind === 199 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 198 /* VoidExpression */; + return node.kind === 200 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 199 /* AwaitExpression */; + return node.kind === 201 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 200 /* PrefixUnaryExpression */; + return node.kind === 202 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 201 /* PostfixUnaryExpression */; + return node.kind === 203 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 202 /* BinaryExpression */; + return node.kind === 204 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 203 /* ConditionalExpression */; + return node.kind === 205 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 204 /* TemplateExpression */; + return node.kind === 206 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 205 /* YieldExpression */; + return node.kind === 207 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 206 /* SpreadElement */; + return node.kind === 208 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 207 /* ClassExpression */; + return node.kind === 209 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 208 /* OmittedExpression */; + return node.kind === 210 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 210 /* AsExpression */; + return node.kind === 212 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 211 /* NonNullExpression */; + return node.kind === 213 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 212 /* MetaProperty */; + return node.kind === 214 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 214 /* TemplateSpan */; + return node.kind === 216 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 215 /* SemicolonClassElement */; + return node.kind === 217 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 216 /* Block */; + return node.kind === 218 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 217 /* VariableStatement */; + return node.kind === 219 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 218 /* EmptyStatement */; + return node.kind === 220 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 219 /* ExpressionStatement */; + return node.kind === 221 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 220 /* IfStatement */; + return node.kind === 222 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 221 /* DoStatement */; + return node.kind === 223 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 222 /* WhileStatement */; + return node.kind === 224 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 223 /* ForStatement */; + return node.kind === 225 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 224 /* ForInStatement */; + return node.kind === 226 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 225 /* ForOfStatement */; + return node.kind === 227 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 226 /* ContinueStatement */; + return node.kind === 228 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 227 /* BreakStatement */; + return node.kind === 229 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; + return node.kind === 229 /* BreakStatement */ || node.kind === 228 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 228 /* ReturnStatement */; + return node.kind === 230 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 229 /* WithStatement */; + return node.kind === 231 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 230 /* SwitchStatement */; + return node.kind === 232 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 231 /* LabeledStatement */; + return node.kind === 233 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 232 /* ThrowStatement */; + return node.kind === 234 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 233 /* TryStatement */; + return node.kind === 235 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 234 /* DebuggerStatement */; + return node.kind === 236 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 235 /* VariableDeclaration */; + return node.kind === 237 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 236 /* VariableDeclarationList */; + return node.kind === 238 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 237 /* FunctionDeclaration */; + return node.kind === 239 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 238 /* ClassDeclaration */; + return node.kind === 240 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 239 /* InterfaceDeclaration */; + return node.kind === 241 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 240 /* TypeAliasDeclaration */; + return node.kind === 242 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 241 /* EnumDeclaration */; + return node.kind === 243 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */; + return node.kind === 244 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 243 /* ModuleBlock */; + return node.kind === 245 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 244 /* CaseBlock */; + return node.kind === 246 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 245 /* NamespaceExportDeclaration */; + return node.kind === 247 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 246 /* ImportEqualsDeclaration */; + return node.kind === 248 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 247 /* ImportDeclaration */; + return node.kind === 249 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 248 /* ImportClause */; + return node.kind === 250 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 249 /* NamespaceImport */; + return node.kind === 251 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 250 /* NamedImports */; + return node.kind === 252 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 251 /* ImportSpecifier */; + return node.kind === 253 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 252 /* ExportAssignment */; + return node.kind === 254 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 253 /* ExportDeclaration */; + return node.kind === 255 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 254 /* NamedExports */; + return node.kind === 256 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 255 /* ExportSpecifier */; + return node.kind === 257 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 256 /* MissingDeclaration */; + return node.kind === 258 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 257 /* ExternalModuleReference */; + return node.kind === 259 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 258 /* JsxElement */; + return node.kind === 260 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 259 /* JsxSelfClosingElement */; + return node.kind === 261 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 260 /* JsxOpeningElement */; + return node.kind === 262 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 261 /* JsxClosingElement */; + return node.kind === 263 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 262 /* JsxFragment */; + return node.kind === 264 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 263 /* JsxOpeningFragment */; + return node.kind === 265 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 264 /* JsxClosingFragment */; + return node.kind === 266 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 265 /* JsxAttribute */; + return node.kind === 267 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 266 /* JsxAttributes */; + return node.kind === 268 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 267 /* JsxSpreadAttribute */; + return node.kind === 269 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 268 /* JsxExpression */; + return node.kind === 270 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 269 /* CaseClause */; + return node.kind === 271 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 270 /* DefaultClause */; + return node.kind === 272 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 271 /* HeritageClause */; + return node.kind === 273 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 272 /* CatchClause */; + return node.kind === 274 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 273 /* PropertyAssignment */; + return node.kind === 275 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 274 /* ShorthandPropertyAssignment */; + return node.kind === 276 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 275 /* SpreadAssignment */; + return node.kind === 277 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 277 /* SourceFile */; + return node.kind === 279 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 278 /* Bundle */; + return node.kind === 280 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 279 /* UnparsedSource */; + return node.kind === 281 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 281 /* JSDocTypeExpression */; + return node.kind === 283 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 282 /* JSDocAllType */; + return node.kind === 284 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 283 /* JSDocUnknownType */; + return node.kind === 285 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 284 /* JSDocNullableType */; + return node.kind === 286 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 285 /* JSDocNonNullableType */; + return node.kind === 287 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 286 /* JSDocOptionalType */; + return node.kind === 288 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 287 /* JSDocFunctionType */; + return node.kind === 289 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 288 /* JSDocVariadicType */; + return node.kind === 290 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 289 /* JSDocComment */; + return node.kind === 291 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 293 /* JSDocAugmentsTag */; + return node.kind === 295 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 294 /* JSDocClassTag */; + return node.kind === 296 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 296 /* JSDocEnumTag */; + return node.kind === 298 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 299 /* JSDocThisTag */; + return node.kind === 301 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 297 /* JSDocParameterTag */; + return node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 298 /* JSDocReturnTag */; + return node.kind === 300 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 300 /* JSDocTypeTag */; + return node.kind === 302 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 301 /* JSDocTemplateTag */; + return node.kind === 303 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 302 /* JSDocTypedefTag */; + return node.kind === 304 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 303 /* JSDocPropertyTag */; + return node.kind === 305 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 303 /* JSDocPropertyTag */ || node.kind === 297 /* JSDocParameterTag */; + return node.kind === 305 /* JSDocPropertyTag */ || node.kind === 299 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 290 /* JSDocTypeLiteral */; + return node.kind === 292 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 295 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 291 /* JSDocSignature */; + return node.kind === 293 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13528,7 +13769,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 304 /* SyntaxList */; + return n.kind === 306 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13538,7 +13779,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 146 /* FirstNode */; + return kind >= 148 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13547,7 +13788,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 147 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13559,7 +13800,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13569,7 +13810,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; + return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13578,12 +13819,12 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 15 /* TemplateMiddle */ - || kind === 16 /* TemplateTail */; + return kind === 16 /* TemplateMiddle */ + || kind === 17 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isStringTextContainingNode(node) { - return node.kind === 9 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers @@ -13596,17 +13837,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 79 /* DefaultKeyword */: - case 84 /* ExportKeyword */: - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 115 /* StaticKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 80 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 116 /* StaticKeyword */: return true; } return false; @@ -13619,7 +13860,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 115 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 116 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13628,23 +13869,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 9 /* StringLiteral */ + return kind === 72 /* Identifier */ + || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 147 /* ComputedPropertyName */; + || kind === 149 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 182 /* ObjectBindingPattern */ - || kind === 183 /* ArrayBindingPattern */; + return kind === 72 /* Identifier */ + || kind === 184 /* ObjectBindingPattern */ + || kind === 185 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13659,13 +13900,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; default: return false; @@ -13674,14 +13915,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 164 /* ConstructorType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 166 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13696,29 +13937,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 155 /* Constructor */ - || kind === 152 /* PropertyDeclaration */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 160 /* IndexSignature */ - || kind === 215 /* SemicolonClassElement */; + return kind === 157 /* Constructor */ + || kind === 154 /* PropertyDeclaration */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 162 /* IndexSignature */ + || kind === 217 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); + return node && (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); + return node && (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; default: return false; @@ -13728,11 +13969,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 159 /* ConstructSignature */ - || kind === 158 /* CallSignature */ - || kind === 151 /* PropertySignature */ - || kind === 153 /* MethodSignature */ - || kind === 160 /* IndexSignature */; + return kind === 161 /* ConstructSignature */ + || kind === 160 /* CallSignature */ + || kind === 153 /* PropertySignature */ + || kind === 155 /* MethodSignature */ + || kind === 162 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13741,37 +13982,38 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 273 /* PropertyAssignment */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 275 /* SpreadAssignment */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 275 /* PropertyAssignment */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 277 /* SpreadAssignment */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) - || kind === 119 /* AnyKeyword */ - || kind === 142 /* UnknownKeyword */ - || kind === 134 /* NumberKeyword */ - || kind === 135 /* ObjectKeyword */ - || kind === 122 /* BooleanKeyword */ - || kind === 137 /* StringKeyword */ - || kind === 138 /* SymbolKeyword */ - || kind === 99 /* ThisKeyword */ - || kind === 105 /* VoidKeyword */ - || kind === 140 /* UndefinedKeyword */ - || kind === 95 /* NullKeyword */ - || kind === 131 /* NeverKeyword */ - || kind === 209 /* ExpressionWithTypeArguments */ - || kind === 282 /* JSDocAllType */ - || kind === 283 /* JSDocUnknownType */ - || kind === 284 /* JSDocNullableType */ - || kind === 285 /* JSDocNonNullableType */ - || kind === 286 /* JSDocOptionalType */ - || kind === 287 /* JSDocFunctionType */ - || kind === 288 /* JSDocVariadicType */; + return (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) + || kind === 120 /* AnyKeyword */ + || kind === 143 /* UnknownKeyword */ + || kind === 135 /* NumberKeyword */ + || kind === 146 /* BigIntKeyword */ + || kind === 136 /* ObjectKeyword */ + || kind === 123 /* BooleanKeyword */ + || kind === 138 /* StringKeyword */ + || kind === 139 /* SymbolKeyword */ + || kind === 100 /* ThisKeyword */ + || kind === 106 /* VoidKeyword */ + || kind === 141 /* UndefinedKeyword */ + || kind === 96 /* NullKeyword */ + || kind === 132 /* NeverKeyword */ + || kind === 211 /* ExpressionWithTypeArguments */ + || kind === 284 /* JSDocAllType */ + || kind === 285 /* JSDocUnknownType */ + || kind === 286 /* JSDocNullableType */ + || kind === 287 /* JSDocNonNullableType */ + || kind === 288 /* JSDocOptionalType */ + || kind === 289 /* JSDocFunctionType */ + || kind === 290 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13784,8 +14026,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return true; } return false; @@ -13796,8 +14038,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 183 /* ArrayBindingPattern */ - || kind === 182 /* ObjectBindingPattern */; + return kind === 185 /* ArrayBindingPattern */ + || kind === 184 /* ObjectBindingPattern */; } return false; } @@ -13805,15 +14047,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 185 /* ArrayLiteralExpression */ - || kind === 186 /* ObjectLiteralExpression */; + return kind === 187 /* ArrayLiteralExpression */ + || kind === 188 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 184 /* BindingElement */ - || kind === 208 /* OmittedExpression */; + return kind === 186 /* BindingElement */ + || kind === 210 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13822,9 +14064,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: return true; } return false; @@ -13845,8 +14087,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return true; } return false; @@ -13858,8 +14100,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return true; } return false; @@ -13868,26 +14110,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */ - || kind === 181 /* ImportType */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */ + || kind === 183 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 187 /* PropertyAccessExpression */ - || kind === 146 /* QualifiedName */; + return kind === 189 /* PropertyAccessExpression */ + || kind === 148 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 191 /* TaggedTemplateExpression */: - case 150 /* Decorator */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 193 /* TaggedTemplateExpression */: + case 152 /* Decorator */: return true; default: return false; @@ -13895,13 +14137,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; + return node.kind === 191 /* CallExpression */ || node.kind === 192 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 204 /* TemplateExpression */ - || kind === 13 /* NoSubstitutionTemplateLiteral */; + return kind === 206 /* TemplateExpression */ + || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13911,33 +14153,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: - case 190 /* NewExpression */: - case 189 /* CallExpression */: - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 262 /* JsxFragment */: - case 191 /* TaggedTemplateExpression */: - case 185 /* ArrayLiteralExpression */: - case 193 /* ParenthesizedExpression */: - case 186 /* ObjectLiteralExpression */: - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 71 /* Identifier */: - case 12 /* RegularExpressionLiteral */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 192 /* NewExpression */: + case 191 /* CallExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 264 /* JsxFragment */: + case 193 /* TaggedTemplateExpression */: + case 187 /* ArrayLiteralExpression */: + case 195 /* ParenthesizedExpression */: + case 188 /* ObjectLiteralExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 72 /* Identifier */: + case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 204 /* TemplateExpression */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 101 /* TrueKeyword */: - case 97 /* SuperKeyword */: - case 211 /* NonNullExpression */: - case 212 /* MetaProperty */: - case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 206 /* TemplateExpression */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 102 /* TrueKeyword */: + case 98 /* SuperKeyword */: + case 213 /* NonNullExpression */: + case 214 /* MetaProperty */: + case 92 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13950,13 +14193,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 192 /* TypeAssertionExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 194 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13965,11 +14208,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 43 /* PlusPlusToken */ || - expr.operator === 44 /* MinusMinusToken */; + case 202 /* PrefixUnaryExpression */: + return expr.operator === 44 /* PlusPlusToken */ || + expr.operator === 45 /* MinusMinusToken */; default: return false; } @@ -13986,15 +14229,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 203 /* ConditionalExpression */: - case 205 /* YieldExpression */: - case 195 /* ArrowFunction */: - case 202 /* BinaryExpression */: - case 206 /* SpreadElement */: - case 210 /* AsExpression */: - case 208 /* OmittedExpression */: - case 307 /* CommaListExpression */: - case 306 /* PartiallyEmittedExpression */: + case 205 /* ConditionalExpression */: + case 207 /* YieldExpression */: + case 197 /* ArrowFunction */: + case 204 /* BinaryExpression */: + case 208 /* SpreadElement */: + case 212 /* AsExpression */: + case 210 /* OmittedExpression */: + case 309 /* CommaListExpression */: + case 308 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14002,18 +14245,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 192 /* TypeAssertionExpression */ - || kind === 210 /* AsExpression */; + return kind === 194 /* TypeAssertionExpression */ + || kind === 212 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 306 /* PartiallyEmittedExpression */; + return node.kind === 308 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 305 /* NotEmittedStatement */; + return node.kind === 307 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14024,13 +14267,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return true; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14038,7 +14281,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; + return node.kind === 226 /* ForInStatement */ || node.kind === 227 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14062,113 +14305,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */ - || kind === 71 /* Identifier */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */ + || kind === 72 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 243 /* ModuleBlock */ - || kind === 242 /* ModuleDeclaration */; + return kind === 245 /* ModuleBlock */ + || kind === 244 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 71 /* Identifier */ - || kind === 242 /* ModuleDeclaration */; + return kind === 72 /* Identifier */ + || kind === 244 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 250 /* NamedImports */ - || kind === 249 /* NamespaceImport */; + return kind === 252 /* NamedImports */ + || kind === 251 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; + return node.kind === 244 /* ModuleDeclaration */ || node.kind === 243 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 195 /* ArrowFunction */ - || kind === 184 /* BindingElement */ - || kind === 238 /* ClassDeclaration */ - || kind === 207 /* ClassExpression */ - || kind === 155 /* Constructor */ - || kind === 241 /* EnumDeclaration */ - || kind === 276 /* EnumMember */ - || kind === 255 /* ExportSpecifier */ - || kind === 237 /* FunctionDeclaration */ - || kind === 194 /* FunctionExpression */ - || kind === 156 /* GetAccessor */ - || kind === 248 /* ImportClause */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 251 /* ImportSpecifier */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 265 /* JsxAttribute */ - || kind === 154 /* MethodDeclaration */ - || kind === 153 /* MethodSignature */ - || kind === 242 /* ModuleDeclaration */ - || kind === 245 /* NamespaceExportDeclaration */ - || kind === 249 /* NamespaceImport */ - || kind === 149 /* Parameter */ - || kind === 273 /* PropertyAssignment */ - || kind === 152 /* PropertyDeclaration */ - || kind === 151 /* PropertySignature */ - || kind === 157 /* SetAccessor */ - || kind === 274 /* ShorthandPropertyAssignment */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 148 /* TypeParameter */ - || kind === 235 /* VariableDeclaration */ - || kind === 302 /* JSDocTypedefTag */ - || kind === 295 /* JSDocCallbackTag */ - || kind === 303 /* JSDocPropertyTag */; + return kind === 197 /* ArrowFunction */ + || kind === 186 /* BindingElement */ + || kind === 240 /* ClassDeclaration */ + || kind === 209 /* ClassExpression */ + || kind === 157 /* Constructor */ + || kind === 243 /* EnumDeclaration */ + || kind === 278 /* EnumMember */ + || kind === 257 /* ExportSpecifier */ + || kind === 239 /* FunctionDeclaration */ + || kind === 196 /* FunctionExpression */ + || kind === 158 /* GetAccessor */ + || kind === 250 /* ImportClause */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 253 /* ImportSpecifier */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 267 /* JsxAttribute */ + || kind === 156 /* MethodDeclaration */ + || kind === 155 /* MethodSignature */ + || kind === 244 /* ModuleDeclaration */ + || kind === 247 /* NamespaceExportDeclaration */ + || kind === 251 /* NamespaceImport */ + || kind === 151 /* Parameter */ + || kind === 275 /* PropertyAssignment */ + || kind === 154 /* PropertyDeclaration */ + || kind === 153 /* PropertySignature */ + || kind === 159 /* SetAccessor */ + || kind === 276 /* ShorthandPropertyAssignment */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 150 /* TypeParameter */ + || kind === 237 /* VariableDeclaration */ + || kind === 304 /* JSDocTypedefTag */ + || kind === 297 /* JSDocCallbackTag */ + || kind === 305 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 237 /* FunctionDeclaration */ - || kind === 256 /* MissingDeclaration */ - || kind === 238 /* ClassDeclaration */ - || kind === 239 /* InterfaceDeclaration */ - || kind === 240 /* TypeAliasDeclaration */ - || kind === 241 /* EnumDeclaration */ - || kind === 242 /* ModuleDeclaration */ - || kind === 247 /* ImportDeclaration */ - || kind === 246 /* ImportEqualsDeclaration */ - || kind === 253 /* ExportDeclaration */ - || kind === 252 /* ExportAssignment */ - || kind === 245 /* NamespaceExportDeclaration */; + return kind === 239 /* FunctionDeclaration */ + || kind === 258 /* MissingDeclaration */ + || kind === 240 /* ClassDeclaration */ + || kind === 241 /* InterfaceDeclaration */ + || kind === 242 /* TypeAliasDeclaration */ + || kind === 243 /* EnumDeclaration */ + || kind === 244 /* ModuleDeclaration */ + || kind === 249 /* ImportDeclaration */ + || kind === 248 /* ImportEqualsDeclaration */ + || kind === 255 /* ExportDeclaration */ + || kind === 254 /* ExportAssignment */ + || kind === 247 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 227 /* BreakStatement */ - || kind === 226 /* ContinueStatement */ - || kind === 234 /* DebuggerStatement */ - || kind === 221 /* DoStatement */ - || kind === 219 /* ExpressionStatement */ - || kind === 218 /* EmptyStatement */ - || kind === 224 /* ForInStatement */ - || kind === 225 /* ForOfStatement */ - || kind === 223 /* ForStatement */ - || kind === 220 /* IfStatement */ - || kind === 231 /* LabeledStatement */ - || kind === 228 /* ReturnStatement */ - || kind === 230 /* SwitchStatement */ - || kind === 232 /* ThrowStatement */ - || kind === 233 /* TryStatement */ - || kind === 217 /* VariableStatement */ - || kind === 222 /* WhileStatement */ - || kind === 229 /* WithStatement */ - || kind === 305 /* NotEmittedStatement */ - || kind === 309 /* EndOfDeclarationMarker */ - || kind === 308 /* MergeDeclarationMarker */; + return kind === 229 /* BreakStatement */ + || kind === 228 /* ContinueStatement */ + || kind === 236 /* DebuggerStatement */ + || kind === 223 /* DoStatement */ + || kind === 221 /* ExpressionStatement */ + || kind === 220 /* EmptyStatement */ + || kind === 226 /* ForInStatement */ + || kind === 227 /* ForOfStatement */ + || kind === 225 /* ForStatement */ + || kind === 222 /* IfStatement */ + || kind === 233 /* LabeledStatement */ + || kind === 230 /* ReturnStatement */ + || kind === 232 /* SwitchStatement */ + || kind === 234 /* ThrowStatement */ + || kind === 235 /* TryStatement */ + || kind === 219 /* VariableStatement */ + || kind === 224 /* WhileStatement */ + || kind === 231 /* WithStatement */ + || kind === 307 /* NotEmittedStatement */ + || kind === 311 /* EndOfDeclarationMarker */ + || kind === 310 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 301 /* JSDocTemplateTag */ || ts.isInJSFile(node); + if (node.kind === 150 /* TypeParameter */) { + return node.parent.kind !== 303 /* JSDocTemplateTag */ || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14195,10 +14438,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 216 /* Block */) + if (node.kind !== 218 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { + if (node.parent.kind === 235 /* TryStatement */ || node.parent.kind === 274 /* CatchClause */) { return false; } } @@ -14208,81 +14451,81 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 257 /* ExternalModuleReference */ - || kind === 146 /* QualifiedName */ - || kind === 71 /* Identifier */; + return kind === 259 /* ExternalModuleReference */ + || kind === 148 /* QualifiedName */ + || kind === 72 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 99 /* ThisKeyword */ - || kind === 71 /* Identifier */ - || kind === 187 /* PropertyAccessExpression */; + return kind === 100 /* ThisKeyword */ + || kind === 72 /* Identifier */ + || kind === 189 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 258 /* JsxElement */ - || kind === 268 /* JsxExpression */ - || kind === 259 /* JsxSelfClosingElement */ - || kind === 10 /* JsxText */ - || kind === 262 /* JsxFragment */; + return kind === 260 /* JsxElement */ + || kind === 270 /* JsxExpression */ + || kind === 261 /* JsxSelfClosingElement */ + || kind === 11 /* JsxText */ + || kind === 264 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 265 /* JsxAttribute */ - || kind === 267 /* JsxSpreadAttribute */; + return kind === 267 /* JsxAttribute */ + || kind === 269 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ - || kind === 268 /* JsxExpression */; + return kind === 10 /* StringLiteral */ + || kind === 270 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 260 /* JsxOpeningElement */ - || kind === 259 /* JsxSelfClosingElement */; + return kind === 262 /* JsxOpeningElement */ + || kind === 261 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 269 /* CaseClause */ - || kind === 270 /* DefaultClause */; + return kind === 271 /* CaseClause */ + || kind === 272 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 303 /* LastJSDocNode */; + return node.kind >= 283 /* FirstJSDocNode */ && node.kind <= 305 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 291 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 303 /* LastJSDocTagNode */; + return node.kind >= 294 /* FirstJSDocTagNode */ && node.kind <= 305 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 157 /* SetAccessor */; + return node.kind === 159 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 156 /* GetAccessor */; + return node.kind === 158 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14312,12 +14555,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 265 /* JsxAttribute */ || node.kind === 267 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 267 /* JsxAttribute */ || node.kind === 269 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; + return node.kind === 164 /* TypeReference */ || node.kind === 211 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14346,15 +14589,14 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 9 /* StringLiteral */ || node.kind === 13 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; })(ts || (ts = {})); /* @internal */ (function (ts) { - /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; + return node.kind === 252 /* NamedImports */ || node.kind === 256 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -14399,10 +14641,9 @@ var ts; getSignatureConstructor: function () { return Signature; }, getSourceMapSourceConstructor: function () { return SourceMapSource; }, }; - /* @internal */ function formatStringFromArgs(text, args, baseIndex) { if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return ts.Debug.assertDefined(args[+index + baseIndex]); }); + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; function getLocaleSpecificMessage(message) { @@ -14431,7 +14672,6 @@ var ts; }; } ts.createFileDiagnostic = createFileDiagnostic; - /* @internal */ function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -14456,7 +14696,6 @@ var ts; }; } ts.createCompilerDiagnostic = createCompilerDiagnostic; - /* @internal */ function createCompilerDiagnosticFromMessageChain(chain) { return { file: undefined, @@ -14493,14 +14732,12 @@ var ts; function getDiagnosticFilePath(diagnostic) { return diagnostic.file ? diagnostic.file.path : undefined; } - /* @internal */ function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */; } ts.compareDiagnostics = compareDiagnostics; - /* @internal */ function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || @@ -14804,7 +15041,6 @@ var ts; return rootLength > 0 && rootLength === path.length; } ts.isDiskPathRoot = isDiskPathRoot; - /* @internal */ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { return !isRootedDiskPath(absoluteOrRelativePath) ? absoluteOrRelativePath @@ -15769,6 +16005,82 @@ var ts; } } ts.getOrUpdate = getOrUpdate; + /** + * Converts a bigint literal string, e.g. `0x1234n`, + * to its decimal string representation, e.g. `4660`. + */ + function parsePseudoBigInt(stringValue) { + var log2Base; + switch (stringValue.charCodeAt(1)) { // "x" in "0x123" + case 98 /* b */: + case 66 /* B */: // 0b or 0B + log2Base = 1; + break; + case 111 /* o */: + case 79 /* O */: // 0o or 0O + log2Base = 3; + break; + case 120 /* x */: + case 88 /* 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 */) { + nonZeroStart++; + } + return stringValue.slice(nonZeroStart, nIndex) || "0"; + } + // Omit leading "0b", "0o", or "0x", and trailing "n" + var startIndex = 2, endIndex = stringValue.length - 1; + var bitsNeeded = (endIndex - startIndex) * log2Base; + // Stores the value specified by the string as a LE array of 16-bit integers + // using Uint16 instead of Uint32 so combining steps can use bitwise operators + var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0)); + // Add the digits, one at a time + for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) { + 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 */ + : 10 + digitChar - + (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + var shiftedDigit = digit << (bitOffset & 15); + segments[segment] |= shiftedDigit; + var residual = shiftedDigit >>> 16; + if (residual) + segments[segment + 1] |= residual; // overflows segment + } + // Repeatedly divide segments by 10 and add remainder to base10Value + var base10Value = ""; + var firstNonzeroSegment = segments.length - 1; + var segmentsRemaining = true; + while (segmentsRemaining) { + var mod10 = 0; + segmentsRemaining = false; + for (var segment = firstNonzeroSegment; segment >= 0; segment--) { + var newSegment = mod10 << 16 | segments[segment]; + var segmentValue = (newSegment / 10) | 0; + segments[segment] = segmentValue; + mod10 = newSegment - segmentValue * 10; + if (segmentValue && !segmentsRemaining) { + firstNonzeroSegment = segment; + segmentsRemaining = true; + } + } + base10Value = mod10 + base10Value; + } + return base10Value; + } + ts.parsePseudoBigInt = parsePseudoBigInt; + function pseudoBigIntToString(_a) { + var negative = _a.negative, base10Value = _a.base10Value; + return (negative && base10Value !== "0" ? "-" : "") + base10Value; + } + ts.pseudoBigIntToString = pseudoBigIntToString; })(ts || (ts = {})); var ts; (function (ts) { @@ -15788,10 +16100,10 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 277 /* SourceFile */) { + if (kind === 279 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 71 /* Identifier */) { + else if (kind === 72 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -15840,19 +16152,19 @@ 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 <= 145 /* LastToken */) { + if (!node || node.kind <= 147 /* LastToken */) { return; } switch (node.kind) { - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15860,9 +16172,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15870,7 +16182,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -15878,51 +16190,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertySignature */: + case 153 /* 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 273 /* PropertyAssignment */: + case 275 /* 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 235 /* VariableDeclaration */: + case 237 /* 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 184 /* BindingElement */: + case 186 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15934,302 +16246,302 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 168 /* TupleType */: + case 170 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 174 /* InferType */: + case 176 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 181 /* ImportType */: + case 183 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 175 /* ParenthesizedType */: - case 177 /* TypeOperator */: + case 177 /* ParenthesizedType */: + case 179 /* TypeOperator */: return visitNode(cbNode, node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 179 /* MappedType */: + case 181 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return visitNode(cbNode, node.literal); - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitNode(cbNode, node.name); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return visitNode(cbNode, node.label); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 150 /* Decorator */: + case 152 /* Decorator */: return visitNode(cbNode, node.expression); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 239 /* InterfaceDeclaration */: + case 241 /* 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 240 /* TypeAliasDeclaration */: + case 242 /* 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 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 169 /* OptionalType */: - case 170 /* RestType */: - case 281 /* JSDocTypeExpression */: - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 286 /* JSDocOptionalType */: - case 288 /* JSDocVariadicType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 283 /* JSDocTypeExpression */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 288 /* JSDocOptionalType */: + case 290 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 289 /* JSDocComment */: + case 291 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 297 /* JSDocParameterTag */: - case 303 /* JSDocPropertyTag */: + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -16238,17 +16550,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 298 /* JSDocReturnTag */: + case 300 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 302 /* JSDocTypedefTag */: + case 304 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 281 /* JSDocTypeExpression */) { + node.typeExpression.kind === 283 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -16256,20 +16568,20 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 295 /* JSDocCallbackTag */: + case 297 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocThisTag */: + case 301 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocEnumTag */: + case 298 /* JSDocEnumTag */: return visitNode(cbNode, node.typeExpression); - case 291 /* JSDocSignature */: + case 293 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 290 /* JSDocTypeLiteral */: + case 292 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -16277,7 +16589,7 @@ var ts; } } return; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -16495,18 +16807,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(219 /* ExpressionStatement */); + var statement = createNode(221 /* ExpressionStatement */); switch (token()) { - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 38 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 56 /* ColonToken */; })) { + case 39 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -16514,8 +16826,8 @@ var ts; } break; case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 56 /* ColonToken */; })) { + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -16651,7 +16963,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(279 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16856,20 +17168,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 71 /* Identifier */) { + if (token() === 72 /* 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() === 116 /* YieldKeyword */ && inYieldContext()) { + if (token() === 117 /* 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() === 121 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 122 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 107 /* LastReservedWord */; + return token() > 108 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -16912,29 +17224,29 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 25 /* SemicolonToken */) { + if (token() === 26 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(25 /* SemicolonToken */); + return parseExpected(26 /* SemicolonToken */); } } function createNode(kind, pos) { nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 72 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -16976,7 +17288,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 71 /* Identifier */) { + if (kind === 72 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -16997,9 +17309,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(71 /* Identifier */); + var node = createNode(72 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 71 /* Identifier */) { + if (token() !== 72 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -17008,7 +17320,7 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17018,16 +17330,16 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -17039,13 +17351,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(147 /* ComputedPropertyName */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(149 /* ComputedPropertyName */); + parseExpected(22 /* 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. node.expression = allowInAnd(parseExpression); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -17060,20 +17372,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 83 /* EnumKeyword */; - case 84 /* ExportKeyword */: + return nextToken() === 84 /* EnumKeyword */; + case 85 /* ExportKeyword */: nextToken(); - if (token() === 79 /* DefaultKeyword */) { + if (token() === 80 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier(); - case 79 /* DefaultKeyword */: + return token() !== 40 /* AsteriskToken */ && token() !== 119 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 80 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 115 /* StaticKeyword */: - case 125 /* GetKeyword */: - case 136 /* SetKeyword */: + case 116 /* StaticKeyword */: + case 126 /* GetKeyword */: + case 137 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -17084,18 +17396,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 21 /* OpenBracketToken */ - || token() === 17 /* OpenBraceToken */ - || token() === 39 /* AsteriskToken */ - || token() === 24 /* DotDotDotToken */ + return token() === 22 /* OpenBracketToken */ + || token() === 18 /* OpenBraceToken */ + || token() === 40 /* AsteriskToken */ + || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ || - token() === 109 /* InterfaceKeyword */ || - (token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 76 /* ClassKeyword */ || token() === 90 /* FunctionKeyword */ || + token() === 110 /* InterfaceKeyword */ || + (token() === 118 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 121 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -17113,9 +17425,9 @@ var ts; // 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() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -17123,17 +17435,17 @@ var ts; // 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() === 25 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: switch (token()) { - case 21 /* OpenBracketToken */: - case 39 /* AsteriskToken */: - case 24 /* DotDotDotToken */: - case 23 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* OpenBracketToken */: + case 40 /* 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`) return true; default: return isLiteralPropertyName(); @@ -17141,11 +17453,11 @@ var ts; case 18 /* RestProperties */: return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* 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() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -17160,37 +17472,39 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern(); case 19 /* TypeParameters */: return isIdentifier(); case 15 /* ArrayLiteralMembers */: - if (token() === 26 /* CommaToken */) { - return true; + 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`) + return true; } // falls through case 11 /* ArgumentExpressions */: - return token() === 24 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); case 17 /* JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); case 20 /* TypeArguments */: case 21 /* TupleElementTypes */: - return token() === 26 /* CommaToken */ || isStartOfType(); + return token() === 27 /* CommaToken */ || isStartOfType(); case 22 /* HeritageClauses */: return isHeritageClause(); case 23 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 17 /* OpenBraceToken */); - if (nextToken() === 18 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* OpenBraceToken */); + if (nextToken() === 19 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -17199,7 +17513,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 86 /* ExtendsKeyword */ || next === 109 /* ImplementsKeyword */; } return true; } @@ -17216,8 +17530,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 108 /* ImplementsKeyword */ || - token() === 85 /* ExtendsKeyword */) { + if (token() === 109 /* ImplementsKeyword */ || + token() === 86 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -17245,37 +17559,37 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 23 /* ImportOrExportSpecifiers */: - return token() === 18 /* CloseBraceToken */; + return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 74 /* CaseKeyword */ || token() === 80 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */; + return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 21 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 22 /* CloseBracketToken */; + return token() === 23 /* CloseBracketToken */; case 17 /* JSDocParameters */: case 16 /* Parameters */: case 18 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 20 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 26 /* CommaToken */; + return token() !== 27 /* CommaToken */; case 22 /* HeritageClauses */: - return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */; + return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; + return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -17295,7 +17609,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() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -17465,20 +17779,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 155 /* Constructor */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 215 /* SemicolonClassElement */: + case 157 /* Constructor */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 217 /* SemicolonClassElement */: return true; - case 154 /* MethodDeclaration */: + case 156 /* 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 === 71 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 72 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 124 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -17487,8 +17801,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: return true; } } @@ -17497,58 +17811,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 217 /* VariableStatement */: - case 216 /* Block */: - case 220 /* IfStatement */: - case 219 /* ExpressionStatement */: - case 232 /* ThrowStatement */: - case 228 /* ReturnStatement */: - case 230 /* SwitchStatement */: - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 223 /* ForStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 218 /* EmptyStatement */: - case 233 /* TryStatement */: - case 231 /* LabeledStatement */: - case 221 /* DoStatement */: - case 234 /* DebuggerStatement */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 219 /* VariableStatement */: + case 218 /* Block */: + case 222 /* IfStatement */: + case 221 /* ExpressionStatement */: + case 234 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 232 /* SwitchStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 225 /* ForStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 220 /* EmptyStatement */: + case 235 /* TryStatement */: + case 233 /* LabeledStatement */: + case 223 /* DoStatement */: + case 236 /* DebuggerStatement */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 276 /* EnumMember */; + return node.kind === 278 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 151 /* PropertySignature */: - case 158 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 153 /* PropertySignature */: + case 160 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 235 /* VariableDeclaration */) { + if (node.kind !== 237 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -17569,7 +17883,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 149 /* Parameter */) { + if (node.kind !== 151 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -17626,7 +17940,7 @@ var ts; var startPos = scanner.getStartPos(); list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -17636,13 +17950,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(26 /* CommaToken */); + parseExpected(27 /* CommaToken */); // 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() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -17693,8 +18007,8 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); - while (parseOptional(23 /* DotToken */)) { - if (token() === 27 /* LessThanToken */) { + while (parseOptional(24 /* DotToken */)) { + if (token() === 28 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -17705,7 +18019,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(146 /* QualifiedName */, entity.pos); + var node = createNode(148 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -17736,33 +18050,33 @@ 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(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(204 /* TemplateExpression */); + var template = createNode(206 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 16 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(214 /* TemplateSpan */); + var span = createNode(216 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 18 /* CloseBraceToken */) { + if (token() === 19 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(16 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */)); + literal = parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -17772,18 +18086,17 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind) { var node = createNode(kind); - var text = scanner.getTokenValue(); - node.text = text; + node.text = scanner.getTokenValue(); if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -17805,24 +18118,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 28 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: { + case 165 /* FunctionType */: + case 166 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17830,20 +18143,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(161 /* TypePredicate */, lhs.pos); + var node = createNode(163 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(176 /* ThisType */); + var node = createNode(178 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(282 /* JSDocAllType */); + var result = createNode(284 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(286 /* JSDocOptionalType */, result); + return createPostfixType(288 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17851,7 +18164,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(285 /* JSDocNonNullableType */); + var result = createNode(287 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17869,66 +18182,66 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 26 /* CommaToken */ || - token() === 18 /* CloseBraceToken */ || - token() === 20 /* CloseParenToken */ || - token() === 29 /* GreaterThanToken */ || - token() === 58 /* EqualsToken */ || - token() === 49 /* BarToken */) { - var result = createNode(283 /* JSDocUnknownType */, pos); + if (token() === 27 /* CommaToken */ || + token() === 19 /* CloseBraceToken */ || + token() === 21 /* CloseParenToken */ || + token() === 30 /* GreaterThanToken */ || + token() === 59 /* EqualsToken */ || + token() === 50 /* BarToken */) { + var result = createNode(285 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(284 /* JSDocNullableType */, pos); + var result = createNode(286 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(289 /* JSDocFunctionType */); nextToken(); - fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(162 /* TypeReference */); + var node = createNode(164 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { + var parameter = createNode(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */ || token() === 95 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); + var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(290 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 58 /* EqualsToken */) { - return createPostfixType(286 /* JSDocOptionalType */, type); + if (token() === 59 /* EqualsToken */) { + return createPostfixType(288 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(165 /* TypeQuery */); - parseExpected(103 /* TypeOfKeyword */); + var node = createNode(167 /* TypeQuery */); + parseExpected(104 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(85 /* ExtendsKeyword */)) { + if (parseOptional(86 /* 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 @@ -17947,39 +18260,39 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(58 /* EqualsToken */)) { + if (parseOptional(59 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 27 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */); + if (token() === 28 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(56 /* ColonToken */)) { + if (parseOptional(57 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter(isJSDocParameter) { - return token() === 24 /* DotDotDotToken */ || + return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 /* AtToken */ || + token() === 58 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(149 /* Parameter */); - if (token() === 99 /* ThisKeyword */) { + var node = createNodeWithJSDoc(151 /* Parameter */); + if (token() === 100 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -17994,7 +18307,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(55 /* QuestionToken */); + node.questionToken = parseOptionalToken(56 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18016,16 +18329,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 36 /* EqualsGreaterThanToken */) { + if (returnToken === 37 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(56 /* ColonToken */)) { + else if (parseOptional(57 /* ColonToken */)) { return true; } - else if (isType && token() === 36 /* EqualsGreaterThanToken */) { + else if (isType && token() === 37 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); nextToken(); return true; } @@ -18046,7 +18359,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(19 /* OpenParenToken */)) { + if (!parseExpected(20 /* OpenParenToken */)) { signature.parameters = createMissingList(); return false; } @@ -18059,12 +18372,12 @@ var ts; parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - return parseExpected(20 /* CloseParenToken */); + return parseExpected(21 /* CloseParenToken */); } 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(26 /* CommaToken */)) { + if (parseOptional(27 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -18072,15 +18385,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 159 /* ConstructSignature */) { - parseExpected(94 /* NewKeyword */); + if (kind === 161 /* ConstructSignature */) { + parseExpected(95 /* NewKeyword */); } - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - return token() === 21 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -18100,7 +18413,7 @@ var ts; // [] // nextToken(); - if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) { + if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -18119,39 +18432,39 @@ 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* 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() !== 55 /* QuestionToken */) { + if (token() !== 56 /* 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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; + return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 160 /* IndexSignature */; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.kind = 162 /* IndexSignature */; + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 153 /* MethodSignature */; + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.kind = 155 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(56 /* ColonToken */, 4 /* Type */, node); + fillSignature(57 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 151 /* PropertySignature */; + node.kind = 153 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { // 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. @@ -18163,7 +18476,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return true; } var idToken = false; @@ -18173,7 +18486,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -18184,21 +18497,21 @@ 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() === 19 /* OpenParenToken */ || - token() === 27 /* LessThanToken */ || - token() === 55 /* QuestionToken */ || - token() === 56 /* ColonToken */ || - token() === 26 /* CommaToken */ || + return token() === 20 /* OpenParenToken */ || + token() === 28 /* LessThanToken */ || + token() === 56 /* QuestionToken */ || + token() === 57 /* ColonToken */ || + token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(158 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + return parseSignatureMember(160 /* CallSignature */); } - if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(159 /* ConstructSignature */); + if (token() === 95 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(161 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -18209,30 +18522,30 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 23 /* DotToken */; + return nextToken() === 24 /* DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 19 /* OpenParenToken */: - case 27 /* LessThanToken */: - case 23 /* DotToken */: + case 20 /* OpenParenToken */: + case 28 /* LessThanToken */: + case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(166 /* TypeLiteral */); + var node = createNode(168 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { members = createMissingList(); @@ -18241,89 +18554,89 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { - return nextToken() === 132 /* ReadonlyKeyword */; + if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + return nextToken() === 133 /* ReadonlyKeyword */; } - if (token() === 132 /* ReadonlyKeyword */) { + if (token() === 133 /* ReadonlyKeyword */) { nextToken(); } - return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 93 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(148 /* TypeParameter */); + var node = createNode(150 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(92 /* InKeyword */); + parseExpected(93 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(179 /* MappedType */); - parseExpected(17 /* OpenBraceToken */); - if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + var node = createNode(181 /* MappedType */); + parseExpected(18 /* OpenBraceToken */); + if (token() === 133 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { - parseExpectedToken(132 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { + parseExpectedToken(133 /* ReadonlyKeyword */); } } - parseExpected(21 /* OpenBracketToken */); + parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); - parseExpected(22 /* CloseBracketToken */); - if (token() === 55 /* QuestionToken */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { + parseExpected(23 /* CloseBracketToken */); + if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 55 /* QuestionToken */) { - parseExpectedToken(55 /* QuestionToken */); + if (node.questionToken.kind !== 56 /* QuestionToken */) { + parseExpectedToken(56 /* QuestionToken */); } } node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(24 /* DotDotDotToken */)) { - var node = createNode(170 /* RestType */, pos); + if (parseOptional(25 /* DotDotDotToken */)) { + var node = createNode(172 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 169 /* OptionalType */; + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 286 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 171 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + var node = createNode(170 /* TupleType */); + node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(175 /* ParenthesizedType */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(177 /* ParenthesizedType */); + parseExpected(20 /* OpenParenToken */); node.type = parseType(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(94 /* NewKeyword */) ? 164 /* ConstructorType */ : 163 /* FunctionType */; + var kind = parseOptional(95 /* NewKeyword */) ? 166 /* ConstructorType */ : 165 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 23 /* DotToken */ ? undefined : node; + return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(180 /* LiteralType */); + var node = createNode(182 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 38 /* MinusToken */; + unaryMinusExpression = createNode(202 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 39 /* MinusToken */; nextToken(); } - var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */ + var expression = token() === 102 /* TrueKeyword */ || token() === 87 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -18336,79 +18649,82 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 91 /* ImportKeyword */; + return token() === 92 /* ImportKeyword */; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(181 /* ImportType */); - if (parseOptional(103 /* TypeOfKeyword */)) { + var node = createNode(183 /* ImportType */); + if (parseOptional(104 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(91 /* ImportKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(92 /* ImportKeyword */); + parseExpected(20 /* OpenParenToken */); node.argument = parseType(); - parseExpected(20 /* CloseParenToken */); - if (parseOptional(23 /* DotToken */)) { + parseExpected(21 /* CloseParenToken */); + if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } node.typeArguments = tryParseTypeArguments(); return finishNode(node); } - function nextTokenIsNumericLiteral() { - return nextToken() === 8 /* NumericLiteral */; + function nextTokenIsNumericOrBigIntLiteral() { + nextToken(); + return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 138 /* SymbolKeyword */: - case 122 /* BooleanKeyword */: - case 140 /* UndefinedKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 139 /* SymbolKeyword */: + case 123 /* BooleanKeyword */: + case 141 /* UndefinedKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 61 /* AsteriskEqualsToken */: + case 62 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 51 /* ExclamationToken */: + case 52 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseLiteralTypeNode(); - case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 105 /* VoidKeyword */: - case 95 /* NullKeyword */: + case 39 /* MinusToken */: + return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); + case 106 /* VoidKeyword */: + case 96 /* NullKeyword */: return parseTokenNode(); - case 99 /* ThisKeyword */: { + case 100 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseTupleType(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportType(); default: return parseTypeReference(); @@ -18416,42 +18732,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 141 /* UniqueKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 99 /* ThisKeyword */: - case 103 /* TypeOfKeyword */: - case 131 /* NeverKeyword */: - case 17 /* OpenBraceToken */: - case 21 /* OpenBracketToken */: - case 27 /* LessThanToken */: - case 49 /* BarToken */: - case 48 /* AmpersandToken */: - case 94 /* NewKeyword */: - case 9 /* StringLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 142 /* UniqueKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 100 /* ThisKeyword */: + case 104 /* TypeOfKeyword */: + case 132 /* NeverKeyword */: + case 18 /* OpenBraceToken */: + case 22 /* OpenBracketToken */: + case 28 /* LessThanToken */: + case 50 /* BarToken */: + case 49 /* AmpersandToken */: + case 95 /* NewKeyword */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 135 /* ObjectKeyword */: - case 39 /* AsteriskToken */: - case 55 /* QuestionToken */: - case 51 /* ExclamationToken */: - case 24 /* DotDotDotToken */: - case 126 /* InferKeyword */: - case 91 /* ImportKeyword */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 136 /* ObjectKeyword */: + case 40 /* AsteriskToken */: + case 56 /* QuestionToken */: + case 52 /* ExclamationToken */: + case 25 /* DotDotDotToken */: + case 127 /* InferKeyword */: + case 92 /* ImportKeyword */: return true; - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return !inStartOfParameter; - case 38 /* MinusToken */: - return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); - case 19 /* OpenParenToken */: + case 39 /* MinusToken */: + return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); + case 20 /* 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); @@ -18461,35 +18779,35 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 20 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 51 /* ExclamationToken */: - type = createPostfixType(285 /* JSDocNonNullableType */, type); + case 52 /* ExclamationToken */: + type = createPostfixType(287 /* JSDocNonNullableType */, type); break; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(284 /* JSDocNullableType */, type); + type = createPostfixType(286 /* JSDocNullableType */, type); break; - case 21 /* OpenBracketToken */: - parseExpected(21 /* OpenBracketToken */); + case 22 /* OpenBracketToken */: + parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(178 /* IndexedAccessType */, type.pos); + var node = createNode(180 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(167 /* ArrayType */, type.pos); + var node = createNode(169 /* ArrayType */, type.pos); node.elementType = type; - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } break; @@ -18506,16 +18824,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(177 /* TypeOperator */); + var node = createNode(179 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(174 /* InferType */); - parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(148 /* TypeParameter */); + var node = createNode(176 /* InferType */); + parseExpected(127 /* InferKeyword */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -18523,10 +18841,10 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 128 /* KeyOfKeyword */: - case 141 /* UniqueKeyword */: + case 129 /* KeyOfKeyword */: + case 142 /* UniqueKeyword */: return parseTypeOperator(operator); - case 126 /* InferKeyword */: + case 127 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -18546,27 +18864,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(174 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(173 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { return true; } - return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 99 /* ThisKeyword */) { + if (isIdentifier() || token() === 100 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) { + if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -18576,7 +18894,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) { + if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -18584,17 +18902,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() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || - token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 56 /* QuestionToken */ || token() === 59 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 20 /* CloseParenToken */) { + if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -18606,7 +18924,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(163 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -18617,7 +18935,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 127 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 128 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -18628,49 +18946,50 @@ var ts; return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 94 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 95 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(173 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(86 /* ExtendsKeyword */)) { + var node = createNode(175 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(55 /* QuestionToken */); + parseExpected(56 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(56 /* ColonToken */) ? parseType() : undefined; + return parseOptional(57 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 19 /* OpenParenToken */: - case 21 /* OpenBracketToken */: - case 17 /* OpenBraceToken */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 94 /* NewKeyword */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 71 /* Identifier */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 20 /* OpenParenToken */: + case 22 /* OpenBracketToken */: + case 18 /* OpenBraceToken */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 95 /* NewKeyword */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 72 /* Identifier */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -18681,18 +19000,18 @@ var ts; return true; } switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - case 27 /* LessThanToken */: - case 121 /* AwaitKeyword */: - case 116 /* YieldKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 44 /* PlusPlusToken */: + case 45 /* MinusMinusToken */: + case 28 /* LessThanToken */: + case 122 /* AwaitKeyword */: + case 117 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -18710,10 +19029,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 17 /* OpenBraceToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && - token() !== 57 /* AtToken */ && + return token() !== 18 /* OpenBraceToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && + token() !== 58 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -18727,7 +19046,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -18736,7 +19055,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(58 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(59 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -18781,7 +19100,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -18797,7 +19116,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 116 /* YieldKeyword */) { + if (token() === 117 /* 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()) { @@ -18826,15 +19145,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(205 /* YieldExpression */); + var node = createNode(207 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 39 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -18845,20 +19164,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(195 /* ArrowFunction */, asyncModifier.pos); + node = createNode(197 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(195 /* ArrowFunction */, identifier.pos); + node = createNode(197 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(149 /* Parameter */, identifier.pos); + var parameter = createNode(151 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -18883,8 +19202,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -18894,10 +19213,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 121 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 36 /* EqualsGreaterThanToken */) { + if (token() === 37 /* 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. @@ -18907,28 +19226,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 19 /* OpenParenToken */) { - if (second === 20 /* CloseParenToken */) { + if (first === 20 /* OpenParenToken */) { + if (second === 21 /* 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 36 /* EqualsGreaterThanToken */: - case 56 /* ColonToken */: - case 17 /* OpenBraceToken */: + case 37 /* EqualsGreaterThanToken */: + case 57 /* ColonToken */: + case 18 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -18940,42 +19259,42 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) { + if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 24 /* DotDotDotToken */) { + if (second === 25 /* DotDotDotToken */) { return 1 /* 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 !== 120 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 121 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 99 /* ThisKeyword */) { + if (!isIdentifier() && second !== 100 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 56 /* ColonToken */: + case 57 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 55 /* QuestionToken */: + case 56 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 58 /* EqualsToken */ || token() === 20 /* CloseParenToken */) { + if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 59 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; - case 26 /* CommaToken */: - case 58 /* EqualsToken */: - case 20 /* CloseParenToken */: + case 27 /* CommaToken */: + case 59 /* EqualsToken */: + case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; } @@ -18983,7 +19302,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 27 /* LessThanToken */); + ts.Debug.assert(first === 28 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -18993,17 +19312,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 85 /* ExtendsKeyword */) { + if (third === 86 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 58 /* EqualsToken */: - case 29 /* GreaterThanToken */: + case 59 /* EqualsToken */: + case 30 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 26 /* CommaToken */) { + else if (third === 27 /* CommaToken */) { return true; } return false; @@ -19022,7 +19341,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19035,23 +19354,23 @@ 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() === 120 /* AsyncKeyword */) { + if (token() === 121 /* 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() === 36 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 72 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(195 /* ArrowFunction */); + var node = createNodeWithJSDoc(197 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19061,7 +19380,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(56 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -19072,19 +19391,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && token() !== 18 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } - if (token() !== 25 /* SemicolonToken */ && - token() !== 89 /* FunctionKeyword */ && - token() !== 75 /* ClassKeyword */ && + if (token() !== 26 /* SemicolonToken */ && + token() !== 90 /* FunctionKeyword */ && + token() !== 76 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -19109,20 +19428,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(55 /* QuestionToken */); + var questionToken = parseOptionalToken(56 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(205 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(56 /* ColonToken */); + node.colonToken = parseExpectedToken(57 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + : createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -19130,7 +19449,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; + return t === 93 /* InKeyword */ || t === 147 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -19159,16 +19478,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() === 40 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 92 /* InKeyword */ && inDisallowInContext()) { + if (token() === 93 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -19189,51 +19508,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 92 /* InKeyword */) { + if (inDisallowInContext() && token() === 93 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(202 /* BinaryExpression */, left.pos); + var node = createNode(204 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(210 /* AsExpression */, left.pos); + var node = createNode(212 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(200 /* PrefixUnaryExpression */); + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(196 /* DeleteExpression */); + var node = createNode(198 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(197 /* TypeOfExpression */); + var node = createNode(199 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(198 /* VoidExpression */); + var node = createNode(200 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 121 /* AwaitKeyword */) { + if (token() === 122 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -19243,7 +19562,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(199 /* AwaitExpression */); + var node = createNode(201 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -19267,7 +19586,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 40 /* AsteriskAsteriskToken */ ? + return token() === 41 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -19284,10 +19603,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 40 /* AsteriskAsteriskToken */) { + if (token() === 41 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 194 /* 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 { @@ -19312,23 +19631,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 80 /* DeleteKeyword */: + case 81 /* DeleteKeyword */: return parseDeleteExpression(); - case 103 /* TypeOfKeyword */: + case 104 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return parseVoidExpression(); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 121 /* AwaitKeyword */: + case 122 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -19351,16 +19670,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: - case 51 /* ExclamationToken */: - case 80 /* DeleteKeyword */: - case 103 /* TypeOfKeyword */: - case 105 /* VoidKeyword */: - case 121 /* AwaitKeyword */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: + case 52 /* ExclamationToken */: + case 81 /* DeleteKeyword */: + case 104 /* TypeOfKeyword */: + case 106 /* VoidKeyword */: + case 122 /* AwaitKeyword */: return false; - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -19383,21 +19702,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(200 /* PrefixUnaryExpression */); + if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { + var node = createNode(202 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(203 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -19438,7 +19757,7 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 91 /* ImportKeyword */) { + if (token() === 92 /* 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: @@ -19453,8 +19772,8 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(212 /* MetaProperty */, fullStart); - node.keywordToken = 91 /* ImportKeyword */; + var node = createNode(214 /* MetaProperty */, fullStart); + node.keywordToken = 92 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; @@ -19464,7 +19783,7 @@ var ts; } } else { - expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 98 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression. As such, we need to consume the rest of it here to be complete. @@ -19523,22 +19842,22 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* 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. - var node = createNode(187 /* PropertyAccessExpression */, expression.pos); + var node = createNode(189 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 260 /* JsxOpeningElement */) { - var node = createNode(258 /* JsxElement */, opening.pos); + if (opening.kind === 262 /* JsxOpeningElement */) { + var node = createNode(260 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -19547,15 +19866,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 263 /* JsxOpeningFragment */) { - var node = createNode(262 /* JsxFragment */, opening.pos); + else if (opening.kind === 265 /* JsxOpeningFragment */) { + var node = createNode(264 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 261 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -19566,15 +19885,15 @@ 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() === 27 /* LessThanToken */) { + if (inExpressionContext && token() === 28 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(202 /* BinaryExpression */, result.pos); + var badNode = createNode(204 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 + badNode.operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -19582,8 +19901,8 @@ var ts; return result; } function parseJsxText() { - var node = createNode(10 /* JsxText */); - node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */; + var node = createNode(11 /* JsxText */); + node.containsOnlyWhiteSpaces = currentToken === 12 /* JsxTextAllWhiteSpaces */; currentToken = scanner.scanJsxToken(); return finishNode(node); } @@ -19599,15 +19918,15 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 28 /* LessThanSlashToken */: + case 29 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; - case 10 /* JsxText */: - case 11 /* JsxTextAllWhiteSpaces */: + case 11 /* JsxText */: + case 12 /* JsxTextAllWhiteSpaces */: return parseJsxText(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 27 /* LessThanToken */: + case 28 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -19628,16 +19947,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(266 /* JsxAttributes */); + var jsxAttributes = createNode(268 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(27 /* LessThanToken */); - if (token() === 29 /* GreaterThanToken */) { + parseExpected(28 /* LessThanToken */); + if (token() === 30 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(265 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -19645,23 +19964,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 29 /* GreaterThanToken */) { + if (token() === 30 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(260 /* JsxOpeningElement */, fullStart); + node = createNode(262 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(41 /* SlashToken */); + parseExpected(42 /* SlashToken */); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(259 /* JsxSelfClosingElement */, fullStart); + node = createNode(261 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -19675,10 +19994,10 @@ 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() === 99 /* ThisKeyword */ ? + var expression = token() === 100 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(24 /* DotToken */)) { + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -19686,33 +20005,33 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(268 /* JsxExpression */); - if (!parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(270 /* JsxExpression */); + if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } - if (token() !== 18 /* CloseBraceToken */) { - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + if (token() !== 19 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { - parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(265 /* JsxAttribute */); + var node = createNode(267 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 58 /* EqualsToken */) { + if (token() === 59 /* EqualsToken */) { switch (scanJsxAttributeValue()) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: @@ -19723,72 +20042,72 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(267 /* JsxSpreadAttribute */); - parseExpected(17 /* OpenBraceToken */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(269 /* JsxSpreadAttribute */); + parseExpected(18 /* OpenBraceToken */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(261 /* JsxClosingElement */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(263 /* JsxClosingElement */); + parseExpected(29 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(264 /* JsxClosingFragment */); - parseExpected(28 /* LessThanSlashToken */); + var node = createNode(266 /* JsxClosingFragment */); + parseExpected(29 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); } else { - parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(192 /* TypeAssertionExpression */); - parseExpected(27 /* LessThanToken */); + var node = createNode(194 /* TypeAssertionExpression */); + parseExpected(28 /* LessThanToken */); node.type = parseType(); - parseExpected(29 /* GreaterThanToken */); + parseExpected(30 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(23 /* DotToken */); + var dotToken = parseOptionalToken(24 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(189 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(211 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(213 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { + var indexedAccess = createNode(190 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; - if (token() === 22 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -19797,7 +20116,7 @@ var ts; } indexedAccess.argumentExpression = argument; } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } @@ -19809,13 +20128,13 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; + return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(193 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; - tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); return finishNode(tagExpression); @@ -19823,7 +20142,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 27 /* LessThanToken */) { + if (token() === 28 /* LessThanToken */) { // 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 @@ -19836,15 +20155,15 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(189 /* CallExpression */, expression.pos); + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(189 /* CallExpression */, expression.pos); + else if (token() === 20 /* OpenParenToken */) { + var callExpr = createNode(191 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19854,17 +20173,17 @@ var ts; } } function parseArgumentList() { - parseExpected(19 /* OpenParenToken */); + parseExpected(20 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(27 /* LessThanToken */)) { + if (!parseOptional(28 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(29 /* GreaterThanToken */)) { + if (!parseExpected(30 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -19876,34 +20195,34 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 19 /* OpenParenToken */: // foo( - case 13 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 14 /* TemplateHead */: // foo `...${100}...` + case 20 /* OpenParenToken */: // foo( + case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. - case 23 /* DotToken */: // foo. - case 20 /* CloseParenToken */: // foo) - case 22 /* CloseBracketToken */: // foo] - case 56 /* ColonToken */: // foo: - case 25 /* SemicolonToken */: // foo; - case 55 /* QuestionToken */: // foo? - case 32 /* EqualsEqualsToken */: // foo == - case 34 /* EqualsEqualsEqualsToken */: // foo === - case 33 /* ExclamationEqualsToken */: // foo != - case 35 /* ExclamationEqualsEqualsToken */: // foo !== - case 53 /* AmpersandAmpersandToken */: // foo && - case 54 /* BarBarToken */: // foo || - case 50 /* CaretToken */: // foo ^ - case 48 /* AmpersandToken */: // foo & - case 49 /* BarToken */: // foo | - case 18 /* CloseBraceToken */: // foo } + case 24 /* DotToken */: // foo. + case 21 /* CloseParenToken */: // foo) + case 23 /* CloseBracketToken */: // foo] + case 57 /* ColonToken */: // foo: + case 26 /* SemicolonToken */: // foo; + case 56 /* QuestionToken */: // foo? + case 33 /* EqualsEqualsToken */: // foo == + case 35 /* EqualsEqualsEqualsToken */: // foo === + case 34 /* ExclamationEqualsToken */: // foo != + case 36 /* ExclamationEqualsEqualsToken */: // foo !== + case 54 /* AmpersandAmpersandToken */: // foo && + case 55 /* BarBarToken */: // foo || + case 51 /* CaretToken */: // foo ^ + case 49 /* AmpersandToken */: // foo & + case 50 /* BarToken */: // foo | + case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // 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. return true; - case 26 /* CommaToken */: // foo, - case 17 /* OpenBraceToken */: // foo { + case 27 /* CommaToken */: // foo, + case 18 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -19915,22 +20234,23 @@ var ts; function parsePrimaryExpression() { switch (token()) { case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 95 /* NullKeyword */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 96 /* NullKeyword */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return parseTokenNode(); - case 19 /* OpenParenToken */: + case 20 /* OpenParenToken */: return parseParenthesizedExpression(); - case 21 /* OpenBracketToken */: + case 22 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 120 /* AsyncKeyword */: + case 121 /* 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. @@ -19938,76 +20258,76 @@ var ts; break; } return parseFunctionExpression(); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassExpression(); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionExpression(); - case 94 /* NewKeyword */: + case 95 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) { + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 14 /* TemplateHead */: + case 15 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); - parseExpected(19 /* OpenParenToken */); + var node = createNodeWithJSDoc(195 /* ParenthesizedExpression */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(206 /* SpreadElement */); - parseExpected(24 /* DotDotDotToken */); + var node = createNode(208 /* SpreadElement */); + parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : + return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* CommaToken */ ? createNode(210 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(185 /* ArrayLiteralExpression */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(187 /* ArrayLiteralExpression */); + parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); - if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 275 /* SpreadAssignment */; + if (parseOptionalToken(25 /* DotDotDotToken */)) { + node.kind = 277 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(51 /* ExclamationToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20015,30 +20335,30 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 274 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(58 /* EqualsToken */); + node.kind = 276 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(59 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 273 /* PropertyAssignment */; - parseExpected(56 /* ColonToken */); + node.kind = 275 /* PropertyAssignment */; + parseExpected(57 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(186 /* ObjectLiteralExpression */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(188 /* ObjectLiteralExpression */); + parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -20051,10 +20371,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(194 /* FunctionExpression */); + var node = createNodeWithJSDoc(196 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -20062,7 +20382,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -20074,10 +20394,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(94 /* NewKeyword */); - if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(212 /* MetaProperty */, fullStart); - node_2.keywordToken = 94 /* NewKeyword */; + parseExpected(95 /* NewKeyword */); + if (parseOptional(24 /* DotToken */)) { + var node_2 = createNode(214 /* MetaProperty */, fullStart); + node_2.keywordToken = 95 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } @@ -20093,23 +20413,23 @@ var ts; } break; } - var node = createNode(190 /* NewExpression */, fullStart); + var node = createNode(192 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; - if (node.typeArguments || token() === 19 /* OpenParenToken */) { + if (node.typeArguments || token() === 20 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(216 /* Block */); - if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(218 /* Block */); + if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -20136,52 +20456,52 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(218 /* EmptyStatement */); - parseExpected(25 /* SemicolonToken */); + var node = createNode(220 /* EmptyStatement */); + parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(220 /* IfStatement */); - parseExpected(90 /* IfKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(222 /* IfStatement */); + parseExpected(91 /* IfKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(83 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(221 /* DoStatement */); - parseExpected(81 /* DoKeyword */); + var node = createNode(223 /* DoStatement */); + parseExpected(82 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); // 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(25 /* SemicolonToken */); + parseOptional(26 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(222 /* WhileStatement */); - parseExpected(106 /* WhileKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(224 /* WhileStatement */); + parseExpected(107 /* WhileKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(88 /* ForKeyword */); - var awaitToken = parseOptionalToken(121 /* AwaitKeyword */); - parseExpected(19 /* OpenParenToken */); + parseExpected(89 /* ForKeyword */); + var awaitToken = parseOptionalToken(122 /* AwaitKeyword */); + parseExpected(20 /* OpenParenToken */); var initializer; - if (token() !== 25 /* SemicolonToken */) { - if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) { + if (token() !== 26 /* SemicolonToken */) { + if (token() === 105 /* VarKeyword */ || token() === 111 /* LetKeyword */ || token() === 77 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -20189,33 +20509,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(225 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(147 /* OfKeyword */) : parseOptional(147 /* OfKeyword */)) { + var forOfStatement = createNode(227 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(224 /* ForInStatement */, pos); + else if (parseOptional(93 /* InKeyword */)) { + var forInStatement = createNode(226 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(223 /* ForStatement */, pos); + var forStatement = createNode(225 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(25 /* SemicolonToken */); - if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(25 /* SemicolonToken */); - if (token() !== 20 /* CloseParenToken */) { + parseExpected(26 /* SemicolonToken */); + if (token() !== 21 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -20223,7 +20543,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 229 /* BreakStatement */ ? 73 /* BreakKeyword */ : 78 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -20231,8 +20551,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(228 /* ReturnStatement */); - parseExpected(96 /* ReturnKeyword */); + var node = createNode(230 /* ReturnStatement */); + parseExpected(97 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -20240,42 +20560,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(229 /* WithStatement */); - parseExpected(107 /* WithKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(231 /* WithStatement */); + parseExpected(108 /* WithKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(269 /* CaseClause */); - parseExpected(73 /* CaseKeyword */); + var node = createNode(271 /* CaseClause */); + parseExpected(74 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(270 /* DefaultClause */); - parseExpected(79 /* DefaultKeyword */); - parseExpected(56 /* ColonToken */); + var node = createNode(272 /* DefaultClause */); + parseExpected(80 /* DefaultKeyword */); + parseExpected(57 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 74 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(230 /* SwitchStatement */); - parseExpected(98 /* SwitchKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(232 /* SwitchStatement */); + parseExpected(99 /* SwitchKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(244 /* CaseBlock */); - parseExpected(17 /* OpenBraceToken */); + parseExpected(21 /* CloseParenToken */); + var caseBlock = createNode(246 /* CaseBlock */); + parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -20287,32 +20607,32 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(232 /* ThrowStatement */); - parseExpected(100 /* ThrowKeyword */); + var node = createNode(234 /* ThrowStatement */); + parseExpected(101 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(233 /* TryStatement */); - parseExpected(102 /* TryKeyword */); + var node = createNode(235 /* TryStatement */); + parseExpected(103 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 75 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 87 /* FinallyKeyword */) { - parseExpected(87 /* FinallyKeyword */); + if (!node.catchClause || token() === 88 /* FinallyKeyword */) { + parseExpected(88 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(272 /* CatchClause */); - parseExpected(74 /* CatchKeyword */); - if (parseOptional(19 /* OpenParenToken */)) { + var result = createNode(274 /* CatchClause */); + parseExpected(75 /* CatchKeyword */); + if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -20322,8 +20642,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(234 /* DebuggerStatement */); - parseExpected(78 /* DebuggerKeyword */); + var node = createNode(236 /* DebuggerStatement */); + parseExpected(79 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -20333,13 +20653,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 231 /* LabeledStatement */; + if (expression.kind === 72 /* Identifier */ && parseOptional(57 /* ColonToken */)) { + node.kind = 233 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 219 /* ExpressionStatement */; + node.kind = 221 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -20351,25 +20671,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 76 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 90 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* 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 @@ -20392,41 +20712,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 117 /* AbstractKeyword */: - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 132 /* ReadonlyKeyword */: + case 118 /* AbstractKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 133 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 144 /* GlobalKeyword */: + case 145 /* GlobalKeyword */: nextToken(); - return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; - case 91 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 72 /* Identifier */ || token() === 85 /* ExportKeyword */; + case 92 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 84 /* ExportKeyword */: + return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 85 /* ExportKeyword */: nextToken(); - if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ || - token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ || - token() === 118 /* AsKeyword */) { + if (token() === 59 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 80 /* DefaultKeyword */ || + token() === 119 /* AsKeyword */) { return true; } continue; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: nextToken(); continue; default: @@ -20439,50 +20759,50 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 57 /* AtToken */: - case 25 /* SemicolonToken */: - case 17 /* OpenBraceToken */: - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 89 /* FunctionKeyword */: - case 75 /* ClassKeyword */: - case 83 /* EnumKeyword */: - case 90 /* IfKeyword */: - case 81 /* DoKeyword */: - case 106 /* WhileKeyword */: - case 88 /* ForKeyword */: - case 77 /* ContinueKeyword */: - case 72 /* BreakKeyword */: - case 96 /* ReturnKeyword */: - case 107 /* WithKeyword */: - case 98 /* SwitchKeyword */: - case 100 /* ThrowKeyword */: - case 102 /* TryKeyword */: - case 78 /* DebuggerKeyword */: + case 58 /* AtToken */: + case 26 /* SemicolonToken */: + case 18 /* OpenBraceToken */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 90 /* FunctionKeyword */: + case 76 /* ClassKeyword */: + case 84 /* EnumKeyword */: + case 91 /* IfKeyword */: + case 82 /* DoKeyword */: + case 107 /* WhileKeyword */: + case 89 /* ForKeyword */: + case 78 /* ContinueKeyword */: + case 73 /* BreakKeyword */: + case 97 /* ReturnKeyword */: + case 108 /* WithKeyword */: + case 99 /* SwitchKeyword */: + case 101 /* ThrowKeyword */: + case 103 /* TryKeyword */: + case 79 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return true; - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 76 /* ConstKeyword */: - case 84 /* ExportKeyword */: + case 77 /* ConstKeyword */: + case 85 /* ExportKeyword */: return isStartOfDeclaration(); - case 120 /* AsyncKeyword */: - case 124 /* DeclareKeyword */: - case 109 /* InterfaceKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 139 /* TypeKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 125 /* DeclareKeyword */: + case 110 /* InterfaceKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 140 /* TypeKeyword */: + case 145 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 116 /* StaticKeyword */: + case 133 /* 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); @@ -20492,7 +20812,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */; + return isIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -20501,67 +20821,67 @@ var ts; } function parseStatement() { switch (token()) { - case 25 /* SemicolonToken */: + case 26 /* SemicolonToken */: return parseEmptyStatement(); - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); - case 110 /* LetKeyword */: + case 105 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); + case 111 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(237 /* VariableDeclaration */)); } break; - case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); - case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); - case 90 /* IfKeyword */: + case 90 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(239 /* FunctionDeclaration */)); + case 76 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(240 /* ClassDeclaration */)); + case 91 /* IfKeyword */: return parseIfStatement(); - case 81 /* DoKeyword */: + case 82 /* DoKeyword */: return parseDoStatement(); - case 106 /* WhileKeyword */: + case 107 /* WhileKeyword */: return parseWhileStatement(); - case 88 /* ForKeyword */: + case 89 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(226 /* ContinueStatement */); - case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(227 /* BreakStatement */); - case 96 /* ReturnKeyword */: + case 78 /* ContinueKeyword */: + return parseBreakOrContinueStatement(228 /* ContinueStatement */); + case 73 /* BreakKeyword */: + return parseBreakOrContinueStatement(229 /* BreakStatement */); + case 97 /* ReturnKeyword */: return parseReturnStatement(); - case 107 /* WithKeyword */: + case 108 /* WithKeyword */: return parseWithStatement(); - case 98 /* SwitchKeyword */: + case 99 /* SwitchKeyword */: return parseSwitchStatement(); - case 100 /* ThrowKeyword */: + case 101 /* ThrowKeyword */: return parseThrowStatement(); - case 102 /* TryKeyword */: + case 103 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 74 /* CatchKeyword */: - case 87 /* FinallyKeyword */: + case 75 /* CatchKeyword */: + case 88 /* FinallyKeyword */: return parseTryStatement(); - case 78 /* DebuggerKeyword */: + case 79 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 57 /* AtToken */: + case 58 /* AtToken */: return parseDeclaration(); - case 120 /* AsyncKeyword */: - case 109 /* InterfaceKeyword */: - case 139 /* TypeKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 83 /* EnumKeyword */: - case 84 /* ExportKeyword */: - case 91 /* ImportKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 114 /* PublicKeyword */: - case 117 /* AbstractKeyword */: - case 115 /* StaticKeyword */: - case 132 /* ReadonlyKeyword */: - case 144 /* GlobalKeyword */: + case 121 /* AsyncKeyword */: + case 110 /* InterfaceKeyword */: + case 140 /* TypeKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 84 /* EnumKeyword */: + case 85 /* ExportKeyword */: + case 92 /* ImportKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 115 /* PublicKeyword */: + case 118 /* AbstractKeyword */: + case 116 /* StaticKeyword */: + case 133 /* ReadonlyKeyword */: + case 145 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -20570,7 +20890,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 124 /* DeclareKeyword */; + return modifier.kind === 125 /* DeclareKeyword */; } function parseDeclaration() { var node = createNodeWithJSDoc(0 /* Unknown */); @@ -20589,33 +20909,33 @@ var ts; } function parseDeclarationWorker(node) { switch (token()) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: + case 105 /* VarKeyword */: + case 111 /* LetKeyword */: + case 77 /* ConstKeyword */: return parseVariableStatement(node); - case 89 /* FunctionKeyword */: + case 90 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 75 /* ClassKeyword */: + case 76 /* ClassKeyword */: return parseClassDeclaration(node); - case 109 /* InterfaceKeyword */: + case 110 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 139 /* TypeKeyword */: + case 140 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 83 /* EnumKeyword */: + case 84 /* EnumKeyword */: return parseEnumDeclaration(node); - case 144 /* GlobalKeyword */: - case 129 /* ModuleKeyword */: - case 130 /* NamespaceKeyword */: + case 145 /* GlobalKeyword */: + case 130 /* ModuleKeyword */: + case 131 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 91 /* ImportKeyword */: + case 92 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: nextToken(); switch (token()) { - case 79 /* DefaultKeyword */: - case 58 /* EqualsToken */: + case 80 /* DefaultKeyword */: + case 59 /* EqualsToken */: return parseExportAssignment(node); - case 118 /* AsKeyword */: + case 119 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -20624,7 +20944,7 @@ var ts; if (node.decorators || node.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(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(258 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -20635,10 +20955,10 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -20646,25 +20966,25 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 26 /* CommaToken */) { - return createNode(208 /* OmittedExpression */); + if (token() === 27 /* CommaToken */) { + return createNode(210 /* OmittedExpression */); } - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(184 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); + var node = createNode(186 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 56 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(56 /* ColonToken */); + parseExpected(57 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -20672,27 +20992,27 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(182 /* ObjectBindingPattern */); - parseExpected(17 /* OpenBraceToken */); + var node = createNode(184 /* ObjectBindingPattern */); + parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(183 /* ArrayBindingPattern */); - parseExpected(21 /* OpenBracketToken */); + var node = createNode(185 /* ArrayBindingPattern */); + parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier(); + return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); @@ -20701,10 +21021,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(235 /* VariableDeclaration */); + var node = createNode(237 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 71 /* Identifier */ && - token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 72 /* Identifier */ && + token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20714,14 +21034,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(236 /* VariableDeclarationList */); + var node = createNode(238 /* VariableDeclarationList */); switch (token()) { - case 104 /* VarKeyword */: + case 105 /* VarKeyword */: break; - case 110 /* LetKeyword */: + case 111 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -20737,7 +21057,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 147 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -20749,44 +21069,44 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 217 /* VariableStatement */; + node.kind = 219 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 237 /* FunctionDeclaration */; - parseExpected(89 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + node.kind = 239 /* FunctionDeclaration */; + parseExpected(90 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 155 /* Constructor */; - parseExpected(123 /* ConstructorKeyword */); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + node.kind = 157 /* Constructor */; + parseExpected(124 /* ConstructorKeyword */); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 154 /* MethodDeclaration */; + node.kind = 156 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(56 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 152 /* PropertyDeclaration */; - if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 154 /* PropertyDeclaration */; + if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -20806,12 +21126,12 @@ var ts; return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); node.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. - node.questionToken = parseOptionalToken(55 /* QuestionToken */); - if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + node.questionToken = parseOptionalToken(56 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -20819,13 +21139,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(56 /* ColonToken */, 0 /* None */, node); + fillSignature(57 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 57 /* AtToken */) { + if (token() === 58 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -20842,7 +21162,7 @@ var ts; } nextToken(); } - if (token() === 39 /* AsteriskToken */) { + if (token() === 40 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -20852,24 +21172,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 21 /* OpenBracketToken */) { + if (token() === 22 /* 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 === 136 /* SetKeyword */ || idToken === 125 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 137 /* SetKeyword */ || idToken === 126 /* 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 19 /* OpenParenToken */: // Method declaration - case 27 /* LessThanToken */: // Generic Method declaration - case 51 /* ExclamationToken */: // Non-null assertion on property name - case 56 /* ColonToken */: // Type Annotation for declaration - case 58 /* EqualsToken */: // Initializer for declaration - case 55 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* OpenParenToken */: // Method declaration + case 28 /* LessThanToken */: // Generic Method declaration + case 52 /* ExclamationToken */: // Non-null assertion on property name + case 57 /* ColonToken */: // Type Annotation for declaration + case 59 /* EqualsToken */: // Initializer for declaration + case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -20887,10 +21207,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(57 /* AtToken */)) { + if (!parseOptional(58 /* AtToken */)) { break; } - var decorator = createNode(150 /* Decorator */, decoratorStart); + var decorator = createNode(152 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -20910,7 +21230,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 77 /* 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)) { @@ -20929,7 +21249,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 120 /* AsyncKeyword */) { + if (token() === 121 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -20939,21 +21259,21 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 25 /* SemicolonToken */) { - var result = createNode(215 /* SemicolonClassElement */); + if (token() === 26 /* SemicolonToken */) { + var result = createNode(217 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* GetAccessor */); + if (parseContextualModifier(126 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 158 /* GetAccessor */); } - if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 157 /* SetAccessor */); + if (parseContextualModifier(137 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 159 /* SetAccessor */); } - if (token() === 123 /* ConstructorKeyword */) { + if (token() === 124 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); } if (isIndexSignature()) { @@ -20962,37 +21282,37 @@ 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() === 9 /* StringLiteral */ || + token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 39 /* AsteriskToken */ || - token() === 21 /* OpenBracketToken */) { + token() === 40 /* AsteriskToken */ || + token() === 22 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(node); } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // '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(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 209 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 240 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(75 /* ClassKeyword */); + parseExpected(76 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21010,7 +21330,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 109 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21022,33 +21342,33 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(271 /* HeritageClause */); + ts.Debug.assert(tok === 86 /* ExtendsKeyword */ || tok === 109 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(273 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(209 /* ExpressionWithTypeArguments */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 27 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */) + return token() === 28 /* LessThanToken */ + ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; + return token() === 86 /* ExtendsKeyword */ || token() === 109 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 239 /* InterfaceDeclaration */; - parseExpected(109 /* InterfaceKeyword */); + node.kind = 241 /* InterfaceDeclaration */; + parseExpected(110 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21056,11 +21376,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 240 /* TypeAliasDeclaration */; - parseExpected(139 /* TypeKeyword */); + node.kind = 242 /* TypeAliasDeclaration */; + parseExpected(140 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -21070,18 +21390,18 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(276 /* EnumMember */); + var node = createNodeWithJSDoc(278 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 241 /* EnumDeclaration */; - parseExpected(83 /* EnumKeyword */); + node.kind = 243 /* EnumDeclaration */; + parseExpected(84 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(17 /* OpenBraceToken */)) { + if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -21089,10 +21409,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(243 /* ModuleBlock */); - if (parseExpected(17 /* OpenBraceToken */)) { + var node = createNode(245 /* ModuleBlock */); + if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -21100,20 +21420,20 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 242 /* ModuleDeclaration */; + node.kind = 244 /* ModuleDeclaration */; // 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 */; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(23 /* DotToken */) + node.body = parseOptional(24 /* DotToken */) ? parseModuleOrNamespaceDeclaration(createNode(0 /* Unknown */), 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 242 /* ModuleDeclaration */; - if (token() === 144 /* GlobalKeyword */) { + node.kind = 244 /* ModuleDeclaration */; + if (token() === 145 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -21122,7 +21442,7 @@ var ts; node.name = parseLiteralNode(); node.name.text = internIdentifier(node.name.text); } - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -21132,68 +21452,68 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 144 /* GlobalKeyword */) { + if (token() === 145 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(130 /* NamespaceKeyword */)) { + else if (parseOptional(131 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(129 /* ModuleKeyword */); - if (token() === 9 /* StringLiteral */) { + parseExpected(130 /* ModuleKeyword */); + if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } } return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 133 /* RequireKeyword */ && + return token() === 134 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 19 /* OpenParenToken */; + return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 41 /* SlashToken */; + return nextToken() === 42 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 245 /* NamespaceExportDeclaration */; - parseExpected(118 /* AsKeyword */); - parseExpected(130 /* NamespaceKeyword */); + node.kind = 247 /* NamespaceExportDeclaration */; + parseExpected(119 /* AsKeyword */); + parseExpected(131 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(91 /* ImportKeyword */); + parseExpected(92 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 144 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 247 /* ImportDeclaration */; + node.kind = 249 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 39 /* AsteriskToken */ || // import * - token() === 17 /* OpenBraceToken */) { // import { + token() === 40 /* AsteriskToken */ || // import * + token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(143 /* FromKeyword */); + parseExpected(144 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 246 /* ImportEqualsDeclaration */; + node.kind = 248 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(58 /* EqualsToken */); + parseExpected(59 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -21205,7 +21525,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(248 /* ImportClause */, fullStart); + var importClause = createNode(250 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -21214,8 +21534,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); + parseOptional(27 /* CommaToken */)) { + importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(252 /* NamedImports */); } return finishNode(importClause); } @@ -21225,15 +21545,15 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(257 /* ExternalModuleReference */); - parseExpected(133 /* RequireKeyword */); - parseExpected(19 /* OpenParenToken */); + var node = createNode(259 /* ExternalModuleReference */); + parseExpected(134 /* RequireKeyword */); + parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(20 /* CloseParenToken */); + parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { - if (token() === 9 /* StringLiteral */) { + if (token() === 10 /* StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -21248,9 +21568,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(249 /* NamespaceImport */); - parseExpected(39 /* AsteriskToken */); - parseExpected(118 /* AsKeyword */); + var namespaceImport = createNode(251 /* NamespaceImport */); + parseExpected(40 /* AsteriskToken */); + parseExpected(119 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -21263,14 +21583,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 252 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(255 /* ExportSpecifier */); + return parseImportOrExportSpecifier(257 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(251 /* ImportSpecifier */); + return parseImportOrExportSpecifier(253 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -21284,9 +21604,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 118 /* AsKeyword */) { + if (token() === 119 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(118 /* AsKeyword */); + parseExpected(119 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -21295,24 +21615,24 @@ var ts; else { node.name = identifierName; } - if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 253 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 253 /* ExportDeclaration */; - if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(143 /* FromKeyword */); + node.kind = 255 /* ExportDeclaration */; + if (parseOptional(40 /* AsteriskToken */)) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(254 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(256 /* 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() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(143 /* FromKeyword */); + if (token() === 144 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(144 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -21320,12 +21640,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 252 /* ExportAssignment */; - if (parseOptional(58 /* EqualsToken */)) { + node.kind = 254 /* ExportAssignment */; + if (parseOptional(59 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(79 /* DefaultKeyword */); + parseExpected(80 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -21340,10 +21660,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ - || node.kind === 247 /* ImportDeclaration */ - || node.kind === 252 /* ExportAssignment */ - || node.kind === 253 /* ExportDeclaration */ + || node.kind === 248 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 259 /* ExternalModuleReference */ + || node.kind === 249 /* ImportDeclaration */ + || node.kind === 254 /* ExportAssignment */ + || node.kind === 255 /* ExportDeclaration */ ? node : undefined; } @@ -21356,7 +21676,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 91 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 92 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -21407,11 +21727,11 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(281 /* JSDocTypeExpression */); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); + var result = createNode(283 /* JSDocTypeExpression */); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } fixupParentReferences(result); return finishNode(result); @@ -21499,7 +21819,7 @@ var ts; } loop: while (true) { switch (token()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -21519,7 +21839,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -21570,7 +21890,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(289 /* JSDocComment */, start); + var result = createNode(291 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -21604,20 +21924,19 @@ var ts; } } var precedingLineBreak = scanner.hasPrecedingLineBreak(); - while ((precedingLineBreak && token() === 39 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; } - else if (token() === 39 /* AsteriskToken */) { + else if (token() === 40 /* AsteriskToken */) { precedingLineBreak = false; } nextJSDocToken(); } } function parseTag(indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getTokenPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); skipWhitespaceOrAsterisk(); @@ -21625,40 +21944,40 @@ var ts; switch (tagName.escapedText) { case "augments": case "extends": - tag = parseAugmentsTag(atToken, tagName); + tag = parseAugmentsTag(start, tagName); break; case "class": case "constructor": - tag = parseClassTag(atToken, tagName); + tag = parseClassTag(start, tagName); break; case "this": - tag = parseThisTag(atToken, tagName); + tag = parseThisTag(start, tagName); break; case "enum": - tag = parseEnumTag(atToken, tagName); + tag = parseEnumTag(start, tagName); break; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(atToken, tagName, 2 /* Parameter */, indent); + return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, indent); case "return": case "returns": - tag = parseReturnTag(atToken, tagName); + tag = parseReturnTag(start, tagName); break; case "template": - tag = parseTemplateTag(atToken, tagName); + tag = parseTemplateTag(start, tagName); break; case "type": - tag = parseTypeTag(atToken, tagName); + tag = parseTypeTag(start, tagName); break; case "typedef": - tag = parseTypedefTag(atToken, tagName, indent); + tag = parseTypedefTag(start, tagName, indent); break; case "callback": - tag = parseCallbackTag(atToken, tagName, indent); + tag = parseCallbackTag(start, tagName, indent); break; default: - tag = parseUnknownTag(atToken, tagName); + tag = parseUnknownTag(start, tagName); break; } if (!tag.comment) { @@ -21688,7 +22007,7 @@ var ts; } indent = 0; break; - case 57 /* AtToken */: + case 58 /* AtToken */: scanner.setTextPos(scanner.getTextPos() - 1); // falls through case 1 /* EndOfFileToken */: @@ -21707,9 +22026,9 @@ var ts; indent += whitespace.length; } break; - case 17 /* OpenBraceToken */: + case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextJSDocToken() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextJSDocToken(); pushComment(scanner.getTokenText()); @@ -21717,7 +22036,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -21737,9 +22056,8 @@ var ts; removeTrailingWhitespace(comments); return comments.length === 0 ? undefined : comments.join(""); } - function parseUnknownTag(atToken, tagName) { - var result = createNode(292 /* JSDocTag */, atToken.pos); - result.atToken = atToken; + function parseUnknownTag(start, tagName) { + var result = createNode(294 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -21758,37 +22076,37 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { - if (token() === 13 /* NoSubstitutionTemplateLiteral */) { + if (token() === 14 /* NoSubstitutionTemplateLiteral */) { // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild return { name: createIdentifier(/*isIdentifier*/ true), isBracketed: false }; } // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptional(21 /* OpenBracketToken */); + var isBracketed = parseOptional(22 /* OpenBracketToken */); var name = parseJSDocEntityName(); if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(58 /* EqualsToken */)) { + if (parseOptionalToken(59 /* EqualsToken */)) { parseExpression(); } - parseExpected(22 /* CloseBracketToken */); + parseExpected(23 /* CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; } } - function parseParameterOrPropertyTag(atToken, tagName, target, indent) { + function parseParameterOrPropertyTag(start, tagName, target, indent) { var typeExpression = tryParseTypeExpression(); var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); @@ -21798,15 +22116,14 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(303 /* JSDocPropertyTag */, atToken.pos) : - createNode(297 /* JSDocParameterTag */, atToken.pos); - var comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); + createNode(305 /* JSDocPropertyTag */, start) : + createNode(299 /* JSDocParameterTag */, start); + var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; result.name = name; @@ -21817,20 +22134,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(283 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) { + if (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -21838,81 +22155,74 @@ var ts; } } } - function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 298 /* JSDocReturnTag */; })) { + function parseReturnTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(298 /* JSDocReturnTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(300 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } - function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 300 /* JSDocTypeTag */; })) { + function parseTypeTag(start, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 302 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(300 /* JSDocTypeTag */, atToken.pos); - result.atToken = atToken; + var result = createNode(302 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } - function parseAugmentsTag(atToken, tagName) { - var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); - result.atToken = atToken; + function parseAugmentsTag(start, tagName) { + var result = createNode(295 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(209 /* ExpressionWithTypeArguments */); + var usedBrace = parseOptional(18 /* OpenBraceToken */); + var node = createNode(211 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); if (usedBrace) { - parseExpected(18 /* CloseBraceToken */); + parseExpected(19 /* CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); - while (parseOptional(23 /* DotToken */)) { - var prop = createNode(187 /* PropertyAccessExpression */, node.pos); + while (parseOptional(24 /* DotToken */)) { + var prop = createNode(189 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); } return node; } - function parseClassTag(atToken, tagName) { - var tag = createNode(294 /* JSDocClassTag */, atToken.pos); - tag.atToken = atToken; + function parseClassTag(start, tagName) { + var tag = createNode(296 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } - function parseThisTag(atToken, tagName) { - var tag = createNode(299 /* JSDocThisTag */, atToken.pos); - tag.atToken = atToken; + function parseThisTag(start, tagName) { + var tag = createNode(301 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseEnumTag(atToken, tagName) { - var tag = createNode(296 /* JSDocEnumTag */, atToken.pos); - tag.atToken = atToken; + function parseEnumTag(start, tagName) { + var tag = createNode(298 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } - function parseTypedefTag(atToken, tagName, indent) { + function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(302 /* JSDocTypedefTag */, atToken.pos); - typedefTag.atToken = atToken; + var typedefTag = createNode(304 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -21924,12 +22234,11 @@ var ts; var child = void 0; var jsdocTypeLiteral = void 0; var childTypeTag = void 0; - var start_3 = atToken.pos; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, start); } - if (child.kind === 300 /* JSDocTypeTag */) { + if (child.kind === 302 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21942,7 +22251,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 169 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -21960,8 +22269,8 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); + if (parseOptional(24 /* DotToken */)) { + var jsDocNamespaceNode = createNode(244 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21974,25 +22283,23 @@ var ts; } return typeNameOrNamespaceName; } - function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); - callbackTag.atToken = atToken; + function parseCallbackTag(start, tagName, indent) { + var callbackTag = createNode(297 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var start = scanner.getStartPos(); - var jsdocSignature = createNode(291 /* JSDocSignature */, start); + var jsdocSignature = createNode(293 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(57 /* AtToken */)) { + if (parseOptionalJsdoc(58 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 298 /* JSDocReturnTag */) { + if (tag && tag.kind === 300 /* JSDocReturnTag */) { return tag; } } @@ -22034,10 +22341,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextJSDocToken()) { - case 57 /* AtToken */: + case 58 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 297 /* JSDocParameterTag */ || child.kind === 303 /* JSDocPropertyTag */) && + if (child && (child.kind === 299 /* JSDocParameterTag */ || child.kind === 305 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -22050,13 +22357,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 39 /* AsteriskToken */: + case 40 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 71 /* Identifier */: + case 72 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -22065,16 +22372,15 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 57 /* AtToken */); - var atToken = createNode(57 /* AtToken */); - atToken.end = scanner.getTextPos(); + ts.Debug.assert(token() === 58 /* AtToken */); + var start = scanner.getStartPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); skipWhitespace(); var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(atToken, tagName); + return target === 1 /* Property */ && parseTypeTag(start, tagName); case "prop": case "property": t = 1 /* Property */; @@ -22090,26 +22396,25 @@ var ts; if (!(target & t)) { return false; } - return parseParameterOrPropertyTag(atToken, tagName, target, indent); + return parseParameterOrPropertyTag(start, tagName, target, indent); } - function parseTemplateTag(atToken, tagName) { + function parseTemplateTag(start, tagName) { // the template tag looks like '@template {Constraint} T,U,V' var constraint; - if (token() === 17 /* OpenBraceToken */) { + if (token() === 18 /* OpenBraceToken */) { constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(148 /* TypeParameter */); + var typeParameter = createNode(150 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); - } while (parseOptionalJsdoc(26 /* CommaToken */)); - var result = createNode(301 /* JSDocTemplateTag */, atToken.pos); - result.atToken = atToken; + } while (parseOptionalJsdoc(27 /* CommaToken */)); + var result = createNode(303 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22128,16 +22433,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* 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(23 /* DotToken */)) { + while (parseOptional(24 /* DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(21 /* OpenBracketToken */)) { - parseExpected(22 /* CloseBracketToken */); + if (parseOptional(22 /* OpenBracketToken */)) { + parseExpected(23 /* CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -22145,11 +22450,11 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(72 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(71 /* Identifier */, pos); + var result = createNode(72 /* Identifier */, pos); result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); nextJSDocToken(); @@ -22275,9 +22580,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 71 /* Identifier */: + case 72 /* Identifier */: return true; } return false; @@ -22855,10 +23160,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 71 /* Identifier */) { + if (lhs.kind === 72 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 99 /* ThisKeyword */) { + if (lhs.kind === 100 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -22915,7 +23220,8 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], - ["esnext.intl", "lib.esnext.intl.d.ts"] + ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.bigint", "lib.esnext.bigint.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -22972,6 +23278,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, { name: "traceResolution", type: "boolean", @@ -23022,11 +23335,11 @@ var ts; description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date }, { - name: "pretty", + name: "showConfig", type: "boolean", - showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + isCommandLineOnly: true, + description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, // Basic { @@ -23619,7 +23932,7 @@ var ts; { name: "maxNodeModuleJsDepth", type: "number", - // TODO: GH#27108 affectsModuleResolution: true, + affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, @@ -24075,6 +24388,9 @@ var ts; } var result = ts.parseJsonText(configFileName, configFileText); var cwd = host.getCurrentDirectory(); + result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd)); } ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile; @@ -24214,7 +24530,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 273 /* PropertyAssignment */) { + if (element.kind !== 275 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -24270,16 +24586,16 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 101 /* TrueKeyword */: + case 102 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -24296,13 +24612,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 200 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 202 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -24319,7 +24635,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -24359,6 +24675,115 @@ var ts; } return false; } + /** + * Generate an uncommented, complete tsconfig for use with "--showConfig" + * @param configParseResult options to be generated into tsconfig.json + * @param configFileName name of the parsed config file - output paths will be generated relative to this + * @param host provides current directory and case sensitivity services + */ + /** @internal */ + function convertToTSConfig(configParseResult, configFileName, host) { + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var files = ts.map(ts.filter(configParseResult.fileNames, !configParseResult.configFileSpecs ? function (_) { return false; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), f, getCanonicalFileName); }); + var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); + var config = __assign({ compilerOptions: __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { + var _a; + return (__assign({}, prev, (_a = {}, _a[cur[0]] = cur[1], _a))); + }, {}), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs), + exclude: configParseResult.configFileSpecs.validatedExcludeSpecs + } : {}), { compilerOnSave: !!configParseResult.compileOnSave ? true : undefined }); + return config; + } + ts.convertToTSConfig = convertToTSConfig; + function filterSameAsDefaultInclude(specs) { + if (!ts.length(specs)) + return undefined; + if (ts.length(specs) !== 1) + return specs; + if (specs[0] === "**/*") + return undefined; + return specs; + } + function matchesSpecs(path, includeSpecs, excludeSpecs) { + if (!includeSpecs) + return function (_) { return false; }; + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + if (includeRe) { + if (excludeRe) { + return function (path) { return includeRe.test(path) && !excludeRe.test(path); }; + } + return function (path) { return includeRe.test(path); }; + } + if (excludeRe) { + return function (path) { return !excludeRe.test(path); }; + } + return function (_) { return false; }; + } + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + // this is of a type CommandLineOptionOfPrimitiveType + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + // There is a typeMap associated with this command-line option so use it to map value back to its name + return ts.forEachEntry(customTypeMap, function (mapValue, key) { + if (mapValue === value) { + return key; + } + }); + } + function serializeCompilerOptions(options, pathOptions) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); + var _loop_3 = function (name) { + if (ts.hasProperty(options, name)) { + // tsconfig only options cannot be specified via command line, + // so we can assume that only types that can appear here string | number | boolean + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + return "continue"; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap_1) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + if (pathOptions && optionDefinition.isFilePath) { + result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)); + } + else { + result.set(name, value); + } + } + else { + if (optionDefinition.type === "list") { + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 + } + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); + } + } + } + } + }; + for (var name in options) { + _loop_3(name); + } + return result; + } /** * Generate tsconfig configuration when running command line "--init" * @param options commandlineOptions to be generated into tsconfig.json @@ -24369,62 +24794,6 @@ var ts; var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var compilerOptionsMap = serializeCompilerOptions(compilerOptions); return writeConfigurations(); - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - // this is of a type CommandLineOptionOfPrimitiveType - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - // There is a typeMap associated with this command-line option so use it to map value back to its name - return ts.forEachEntry(customTypeMap, function (mapValue, key) { - if (mapValue === value) { - return key; - } - }); - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - var _loop_3 = function (name) { - if (ts.hasProperty(options, name)) { - // tsconfig only options cannot be specified via command line, - // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { - return "continue"; - } - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap_1) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result.set(name, value); - } - else { - if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1)); - } - } - } - } - }; - for (var name in options) { - _loop_3(name); - } - return result; - } function getDefaultValueForOption(option) { switch (option.type) { case "number": @@ -24813,20 +25182,24 @@ var ts; } function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) { extendedConfig = ts.normalizeSlashes(extendedConfig); - // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../"))) { - errors.push(createDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return undefined; - } - var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return undefined; + 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 */)) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; + } } + return extendedConfigPath; } - return extendedConfigPath; + // If the path isn't a rooted or relative path, resolve like a module + var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, /*cache*/ undefined, /*projectRefs*/ undefined, /*lookupConfig*/ true); + if (resolved.resolvedModule) { + return resolved.resolvedModule.resolvedFileName; + } + errors.push(createDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return undefined; } function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors) { var _a; @@ -25276,7 +25649,7 @@ var ts; } } /** - * Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed. + * Produces a cleaned version of compiler options with personally identifying info (aka, paths) removed. * Also converts enum values back to strings. */ /* @internal */ @@ -25347,7 +25720,8 @@ var ts; Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; Extensions[Extensions["Json"] = 2] = "Json"; - Extensions[Extensions["DtsOnly"] = 3] = "DtsOnly"; /** Only '.d.ts' */ + Extensions[Extensions["TSConfig"] = 3] = "TSConfig"; + Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly"; /** Only '.d.ts' */ })(Extensions || (Extensions = {})); /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ function resolvedTypeScriptOnly(resolved) { @@ -25393,6 +25767,9 @@ var ts; return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state) || readPackageJsonPathField(jsonContent, "types", baseDirectory, state); } + function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) { + return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state); + } function readPackageJsonMainField(jsonContent, baseDirectory, state) { return readPackageJsonPathField(jsonContent, "main", baseDirectory, state); } @@ -25492,8 +25869,11 @@ var 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. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { var traceEnabled = isTraceEnabled(options, host); + if (redirectedReference) { + options = redirectedReference.commandLine.options; + } var failedLookupLocations = []; var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -25514,6 +25894,9 @@ var ts; trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); } } + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var resolved = primaryLookup(); var primary = true; @@ -25523,13 +25906,12 @@ var ts; } var resolvedTypeReferenceDirective; if (resolved) { - if (!options.preserveSymlinks) { - resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); - } + var fileName = resolved.fileName, packageId = resolved.packageId; + var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -25538,7 +25920,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - return ts.forEach(typeRoots, function (typeRoot) { + return ts.firstDefined(typeRoots, function (typeRoot) { var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); var directoryExists = ts.directoryProbablyExists(candidateDirectory, host); @@ -25563,13 +25945,14 @@ var ts; } var result = void 0; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { - result = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined); + var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); + result = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = toSearchResult(nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true)); + result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - var resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25629,29 +26012,56 @@ var ts; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createModuleResolutionCache(currentDirectory, getCanonicalFileName) { - return createModuleResolutionCacheWithMaps(ts.createMap(), ts.createMap(), currentDirectory, getCanonicalFileName); + return createModuleResolutionCacheWithMaps(createCacheWithRedirects(), createCacheWithRedirects(), currentDirectory, getCanonicalFileName); } ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ + function createCacheWithRedirects() { + var ownMap = ts.createMap(); + var redirectsMap = ts.createMap(); + return { + ownMap: ownMap, + redirectsMap: redirectsMap, + getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, + clear: clear + }; + function getOrCreateMapOfCacheRedirects(redirectedReference) { + if (!redirectedReference) { + return ownMap; + } + var path = redirectedReference.sourceFile.path; + var redirects = redirectsMap.get(path); + if (!redirects) { + redirects = ts.createMap(); + redirectsMap.set(path, redirects); + } + return redirects; + } + function clear() { + ownMap.clear(); + redirectsMap.clear(); + } + } + ts.createCacheWithRedirects = createCacheWithRedirects; + /*@internal*/ function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName }; - function getOrCreateCacheForDirectory(directoryName) { + function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - var perFolderCache = directoryToModuleNameMap.get(path); - if (!perFolderCache) { - perFolderCache = ts.createMap(); - directoryToModuleNameMap.set(path, perFolderCache); - } - return perFolderCache; + return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap); } - function getOrCreateCacheForModuleName(nonRelativeModuleName) { + function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); - if (!perModuleNameCache) { - perModuleNameCache = createPerModuleNameCache(); - moduleNameToDirectoryMap.set(nonRelativeModuleName, perModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); } - return perModuleNameCache; + return result; } function createPerModuleNameCache() { var directoryPathMap = ts.createMap(); @@ -25726,13 +26136,19 @@ var ts; return perFolderCache && perFolderCache.get(moduleName); } ts.resolveModuleNameFromCache = resolveModuleNameFromCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache) { + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); + if (redirectedReference) { + compilerOptions = redirectedReference.commandLine.options; + } if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + if (redirectedReference) { + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + } } var containingDirectory = ts.getDirectoryPath(containingFile); - var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); + var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference); var result = perFolderCache && perFolderCache.get(moduleName); if (result) { if (traceEnabled) { @@ -25754,10 +26170,10 @@ var ts; } switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); + result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); @@ -25766,7 +26182,7 @@ var ts; perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { // put result in per-module name cache - cache.getOrCreateCacheForModuleName(moduleName).set(containingDirectory, result); + cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result); } } } @@ -25842,6 +26258,9 @@ var ts; * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. */ function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) { + var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state); + if (resolved) + return resolved.value; if (!ts.isExternalModuleNameRelative(moduleName)) { return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state); } @@ -25849,6 +26268,16 @@ var ts; return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state); } } + function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { + var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + if (baseUrl && paths && !ts.pathIsRelative(moduleName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); + } + } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { if (!state.compilerOptions.rootDirs) { return undefined; @@ -25918,22 +26347,13 @@ var ts; return undefined; } function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var baseUrl = state.compilerOptions.baseUrl; if (!baseUrl) { return undefined; } if (state.traceEnabled) { trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName); } - if (paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - var resolved = tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, /*onlyRecordFailures*/ false, state); - if (resolved) { - return resolved.value; - } - } var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName)); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate); @@ -25960,22 +26380,22 @@ var ts; return resolvedModule && resolvedModule.resolvedFileName; } ts.tryResolveJSModule = tryResolveJSModule; + var jsOnlyExtensions = [Extensions.JavaScript]; + var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; + var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { - return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true); + return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false); + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { + return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, jsOnly) { + function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; - var result = jsOnly ? - tryResolve(Extensions.JavaScript) : - (tryResolve(Extensions.TypeScript) || - tryResolve(Extensions.JavaScript) || - (compilerOptions.resolveJsonModule ? tryResolve(Extensions.Json) : undefined)); + var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); if (result && result.value) { var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); @@ -25985,13 +26405,13 @@ var ts; var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); if (resolved) { - return toSearchResult({ resolved: resolved, isExternalLibraryImport: ts.stringContains(resolved.path, ts.nodeModulesPathPart) }); + return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) }); } if (!ts.isExternalModuleNameRelative(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); } - var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache); + var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved_1) return undefined; var resolvedValue = resolved_1.value; @@ -26057,6 +26477,11 @@ var ts; } /*@internal*/ ts.nodeModulesPathPart = "/node_modules/"; + /*@internal*/ + function pathContainsNodeModules(path) { + return ts.stringContains(path, ts.nodeModulesPathPart); + } + ts.pathContainsNodeModules = pathContainsNodeModules; /** * This will be called on the successfully resolved path from `loadModuleFromFile`. * (Not neeeded for `loadModuleFromNodeModules` as that looks up the `package.json` as part of resolution.) @@ -26107,9 +26532,9 @@ var ts; * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { - if (extensions === Extensions.Json) { + if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, onlyRecordFailures, state); + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); @@ -26143,6 +26568,7 @@ var ts; return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); case Extensions.JavaScript: return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + case Extensions.TSConfig: case Extensions.Json: return tryExtension(".json" /* Json */); } @@ -26227,11 +26653,27 @@ var ts; } } function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { - var packageFile = jsonContent && (extensions !== Extensions.JavaScript && extensions !== Extensions.Json - ? readPackageJsonTypesFields(jsonContent, candidate, state) || - // When resolving typescript modules, try resolving using main field as well - (extensions === Extensions.TypeScript ? readPackageJsonMainField(jsonContent, candidate, state) : undefined) - : readPackageJsonMainField(jsonContent, candidate, state)); + var packageFile; + if (jsonContent) { + switch (extensions) { + case Extensions.JavaScript: + case Extensions.Json: + packageFile = readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.TypeScript: + // When resolving typescript modules, try resolving using main field as well + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state); + break; + case Extensions.DtsOnly: + packageFile = readPackageJsonTypesFields(jsonContent, candidate, state); + break; + case Extensions.TSConfig: + packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state); + break; + default: + return ts.Debug.assertNever(extensions); + } + } var loader = function (extensions, candidate, onlyRecordFailures, state) { var fromFile = tryFile(candidate, onlyRecordFailures, state); if (fromFile) { @@ -26250,7 +26692,7 @@ var ts; }; var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined; var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host); - var indexPath = ts.combinePaths(candidate, "index"); + var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index"); if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) { var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, /*ignoreCase*/ false); if (state.traceEnabled) { @@ -26277,6 +26719,7 @@ var ts; switch (extensions) { case Extensions.JavaScript: return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + case Extensions.TSConfig: case Extensions.Json: return extension === ".json" /* Json */; case Extensions.TypeScript: @@ -26294,15 +26737,15 @@ var ts; return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } ts.parsePackageName = parsePackageName; - function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache) { - return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache); + function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) { + return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference); } function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) { // Extensions parameter here doesn't actually matter, because typesOnly ensures we're just doing @types lookup, which is always DtsOnly. - return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined); + return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined); } - function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); + function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state); @@ -26323,7 +26766,7 @@ var ts; if (packageResult) { return packageResult; } - if (extensions !== Extensions.JavaScript && extensions !== Extensions.Json) { + if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) { var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types"); var nodeModulesAtTypesExists = nodeModulesFolderExists; if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) { @@ -26456,7 +26899,7 @@ var ts; return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } - function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache) { + 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 }; @@ -26470,7 +26913,7 @@ var ts; return { value: resolvedUsingSettings }; } if (!ts.isExternalModuleNameRelative(moduleName)) { - var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName); + var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); // Climb up parent directories looking for a module. var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); @@ -26536,24 +26979,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 243 /* ModuleBlock */: { + case 245 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -26575,9 +27018,9 @@ var ts; }); return state_1; } - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(node); - case 71 /* Identifier */: + case 72 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -26738,7 +27181,7 @@ var ts; // 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 === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -26747,7 +27190,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -26759,36 +27202,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return "__constructor" /* Constructor */; - case 163 /* FunctionType */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: return "__call" /* Call */; - case 164 /* ConstructorType */: - case 159 /* ConstructSignature */: + case 166 /* ConstructorType */: + case 161 /* ConstructSignature */: return "__new" /* New */; - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return "__index" /* Index */; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 149 /* Parameter */: + case 151 /* 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 === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 289 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (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; @@ -26886,7 +27329,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 === 252 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 254 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; } @@ -26913,7 +27356,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 257 /* ExportSpecifier */ || (node.kind === 248 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -26980,7 +27423,7 @@ var ts; // 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 !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -27012,7 +27455,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property intialization checks. - currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 157 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -27025,13 +27468,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -27074,8 +27517,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 239 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -27108,78 +27551,78 @@ var ts; return; } switch (node.kind) { - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: bindWhileStatement(node); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: bindDoStatement(node); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: bindForStatement(node); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: bindIfStatement(node); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: bindTryStatement(node); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: bindSwitchStatement(node); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: bindCaseBlock(node); break; - case 269 /* CaseClause */: + case 271 /* CaseClause */: bindCaseClause(node); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: bindLabeledStatement(node); break; - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: bindCallExpressionFlow(node); break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 277 /* SourceFile */: { + case 279 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -27190,26 +27633,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return hasNarrowableArgument(expr); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 200 /* PrefixUnaryExpression */: - return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 197 /* TypeOfExpression */: + case 202 /* PrefixUnaryExpression */: + return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 199 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || + return expr.kind === 72 /* Identifier */ || expr.kind === 100 /* ThisKeyword */ || expr.kind === 98 /* SuperKeyword */ || ts.isPropertyAccessExpression(expr) && isNarrowableReference(expr.expression) || ts.isElementAccessExpression(expr) && expr.argumentExpression && (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && @@ -27224,7 +27667,7 @@ var ts; } } } - if (expr.expression.kind === 187 /* PropertyAccessExpression */ && + if (expr.expression.kind === 189 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -27238,32 +27681,32 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableReference(expr.left); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -27298,8 +27741,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 101 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 86 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 102 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 87 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -27337,34 +27780,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* IfStatement */: - case 222 /* WhileStatement */: - case 221 /* DoStatement */: + case 222 /* IfStatement */: + case 224 /* WhileStatement */: + case 223 /* DoStatement */: return parent.expression === node; - case 223 /* ForStatement */: - case 203 /* ConditionalExpression */: + case 225 /* ForStatement */: + case 205 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 193 /* ParenthesizedExpression */) { + if (node.kind === 195 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 202 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 54 /* BarBarToken */); + return node.kind === 204 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 55 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 193 /* ParenthesizedExpression */ || - node.parent.kind === 200 /* PrefixUnaryExpression */ && - node.parent.operator === 51 /* ExclamationToken */) { + while (node.parent.kind === 195 /* ParenthesizedExpression */ || + node.parent.kind === 202 /* PrefixUnaryExpression */ && + node.parent.operator === 52 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -27405,7 +27848,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 233 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -27439,13 +27882,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 225 /* ForOfStatement */) { + if (node.kind === 227 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 236 /* VariableDeclarationList */) { + if (node.initializer.kind !== 238 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -27467,7 +27910,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 228 /* ReturnStatement */) { + if (node.kind === 230 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -27487,7 +27930,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 229 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -27583,7 +28026,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 272 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -27650,14 +28093,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 223 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -27668,10 +28111,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 185 /* ArrayLiteralExpression */) { + else if (node.kind === 187 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 206 /* SpreadElement */) { + if (e.kind === 208 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -27679,16 +28122,16 @@ var ts; } } } - else if (node.kind === 186 /* ObjectLiteralExpression */) { + else if (node.kind === 188 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 273 /* PropertyAssignment */) { + if (p.kind === 275 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 274 /* ShorthandPropertyAssignment */) { + else if (p.kind === 276 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 275 /* SpreadAssignment */) { + else if (p.kind === 277 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -27696,7 +28139,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -27707,7 +28150,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 51 /* ExclamationToken */) { + if (node.operator === 52 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -27717,20 +28160,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -27744,7 +28187,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { + if (operator === 59 /* EqualsToken */ && node.left.kind === 190 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27755,7 +28198,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -27802,10 +28245,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 193 /* ParenthesizedExpression */) { + while (expr.kind === 195 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { + if (expr.kind === 196 /* FunctionExpression */ || expr.kind === 197 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -27813,7 +28256,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 187 /* PropertyAccessExpression */) { + if (node.expression.kind === 189 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -27822,54 +28265,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 186 /* ObjectLiteralExpression */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 266 /* JsxAttributes */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 188 /* ObjectLiteralExpression */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 268 /* JsxAttributes */: return 1 /* IsContainer */; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 181 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 155 /* Constructor */: - case 237 /* FunctionDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 158 /* CallSignature */: - case 291 /* JSDocSignature */: - case 287 /* JSDocFunctionType */: - case 163 /* FunctionType */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 164 /* ConstructorType */: + case 157 /* Constructor */: + case 239 /* FunctionDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 160 /* CallSignature */: + case 293 /* JSDocSignature */: + case 289 /* JSDocFunctionType */: + case 165 /* FunctionType */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 166 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 272 /* CatchClause */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: - case 244 /* CaseBlock */: + case 274 /* CatchClause */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: + case 246 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 216 /* Block */: + case 218 /* 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 @@ -27902,45 +28345,45 @@ 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 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 277 /* SourceFile */: + case 279 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 186 /* ObjectLiteralExpression */: - case 239 /* InterfaceDeclaration */: - case 266 /* JsxAttributes */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 188 /* ObjectLiteralExpression */: + case 241 /* InterfaceDeclaration */: + case 268 /* 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 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 291 /* JSDocSignature */: - case 160 /* IndexSignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 287 /* JSDocFunctionType */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 240 /* TypeAliasDeclaration */: - case 179 /* MappedType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 293 /* JSDocSignature */: + case 162 /* IndexSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 242 /* TypeAliasDeclaration */: + case 181 /* 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 @@ -27961,11 +28404,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 277 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { + var body = node.kind === 279 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 279 /* SourceFile */ || body.kind === 245 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { + if (stat.kind === 255 /* ExportDeclaration */ || stat.kind === 254 /* ExportAssignment */) { return true; } } @@ -27993,7 +28436,7 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 9 /* StringLiteral */) { + if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; if (ts.hasZeroOrOneAsteriskCharacter(text)) { pattern = ts.tryParsePattern(text); @@ -28049,7 +28492,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 277 /* SpreadAssignment */ || prop.name.kind !== 72 /* Identifier */) { continue; } var identifier = prop.name; @@ -28061,7 +28504,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 275 /* PropertyAssignment */ || prop.kind === 276 /* ShorthandPropertyAssignment */ || prop.kind === 156 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -28093,10 +28536,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -28127,7 +28570,7 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 71 /* Identifier */) { + if (!typeAlias.fullName || typeAlias.fullName.kind === 72 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); } @@ -28145,8 +28588,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 108 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 116 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 109 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 117 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !(node.flags & 4194304 /* Ambient */)) { // Report error only if there are no parse errors in file @@ -28182,7 +28625,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 71 /* Identifier */) { + if (inStrictMode && node.expression.kind === 72 /* 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); @@ -28193,7 +28636,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 71 /* Identifier */) { + if (name && name.kind === 72 /* 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 @@ -28234,8 +28677,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 277 /* SourceFile */ && - blockScopeContainer.kind !== 242 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 279 /* SourceFile */ && + blockScopeContainer.kind !== 244 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -28261,7 +28704,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { + if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -28330,7 +28773,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 145 /* LastToken */) { + if (node.kind > 147 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -28392,7 +28835,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 71 /* Identifier */: + case 72 /* 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. @@ -28405,13 +28848,13 @@ var ts; break; } // falls through - case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { + case 100 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 276 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -28425,7 +28868,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -28450,142 +28893,155 @@ var ts; // Nothing to do break; default: - ts.Debug.fail("Unknown special property assignment kind"); + ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return checkStrictModeCatchClause(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkStrictModeWithStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 176 /* ThisType */: + case 178 /* ThisType */: seenThisKeyword = true; return; - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: break; // Binding the children will handle everything - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return bindTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return bindParameter(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return bindPropertyWorker(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 276 /* EnumMember */: + case 278 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* 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 */ : 67212223 /* MethodExcludes */); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 163 /* FunctionType */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: + case 166 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 179 /* MappedType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 181 /* MappedType */: return bindAnonymousTypeWorker(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return bindFunctionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: + var assignmentKind = ts.getAssignmentDeclarationKind(node); + switch (assignmentKind) { + case 7 /* ObjectDefinePropertyValue */: + return bindObjectDefinePropertyAssignment(node); + case 8 /* ObjectDefinePropertyExports */: + return bindObjectDefinePropertyExport(node); + case 9 /* ObjectDefinePrototypeProperty */: + return bindObjectDefinePrototypeProperty(node); + case 0 /* None */: + break; // Nothing to do + default: + return ts.Debug.fail("Unknown call expression assignment declaration kind"); + } if (ts.isInJSFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 207 /* ClassExpression */: - case 238 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 240 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return bindJsxAttributes(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return bindImportClause(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return bindExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return bindExportAssignment(node); - case 277 /* SourceFile */: + case 279 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 216 /* Block */: + case 218 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 297 /* JSDocParameterTag */: - if (node.parent.kind === 291 /* JSDocSignature */) { + case 299 /* JSDocParameterTag */: + if (node.parent.kind === 293 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 292 /* JSDocTypeLiteral */) { break; } // falls through - case 303 /* JSDocPropertyTag */: + case 305 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 288 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -28672,6 +29128,21 @@ var ts; } return true; } + function bindObjectDefinePropertyExport(node) { + if (!setCommonJsModuleIndicator(node)) { + return; + } + var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + } + return symbol; + }); + if (symbol) { + var flags = 4 /* Property */ | 1048576 /* ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + } + } function bindExportsPropertyAssignment(node) { // When we create a property via 'exports.foo = bar', the 'exports.foo' property access // expression is the declaration @@ -28708,17 +29179,17 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* 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 === 58 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 59 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -28731,18 +29202,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -28751,10 +29222,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 99 /* ThisKeyword */) { + if (node.expression.kind === 100 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 279 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -28770,6 +29241,10 @@ var ts; var lhs = node.left; bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); } + function bindObjectDefinePrototypeProperty(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); + } /** * For `x.prototype.y = z`, declare a member `y` on `x` if `x` is a function or class, or not declared. * Note that jsdoc preceding an ExpressionStatement like `x.prototype.y;` is also treated as a declaration. @@ -28785,6 +29260,12 @@ var ts; classPrototype.parent = lhs; bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); } + function bindObjectDefinePropertyAssignment(node) { + var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); + var isToplevel = node.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); + } function bindSpecialPropertyAssignment(node) { var lhs = node.left; // Class declarations in Typescript do not allow property declarations @@ -28813,16 +29294,12 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ - : propertyAccess.parent.parent.kind === 277 /* SourceFile */; + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; - namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_1); return symbol; @@ -28834,6 +29311,9 @@ var ts; } }); } + return namespaceSymbol; + } + function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) { return; } @@ -28841,10 +29321,18 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(propertyAccess)); + var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; - declareSymbol(symbolTable, namespaceSymbol, propertyAccess, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var isToplevel = ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 279 /* SourceFile */ + : propertyAccess.parent.parent.kind === 279 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** * Javascript expando values are: @@ -28861,6 +29349,9 @@ var ts; return true; } var node = symbol.valueDeclaration; + if (ts.isCallExpression(node)) { + return !!ts.getAssignedExpandoInitializer(node); + } var init = !node ? undefined : ts.isVariableDeclaration(node) ? node.initializer : ts.isBinaryExpression(node) ? node.right : @@ -28869,7 +29360,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 === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); } return false; } @@ -28911,7 +29402,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 238 /* ClassDeclaration */) { + if (node.kind === 240 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -28977,7 +29468,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 297 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { + if (node.kind === 299 /* JSDocParameterTag */ && container.kind !== 293 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -29054,7 +29545,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 174 /* InferType */) { + else if (node.parent.kind === 176 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -29082,11 +29573,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 220 /* EmptyStatement */) || // report error on class declarations - node.kind === 238 /* ClassDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 244 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -29130,18 +29621,17 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return true; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; } } - /* @internal */ function isExportsOrModuleExportsOrAlias(sourceFile, node) { return ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node) || @@ -29176,58 +29666,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 149 /* Parameter */: + case 151 /* Parameter */: return computeParameter(node, subtreeFlags); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 155 /* Constructor */: + case 157 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -29251,7 +29741,7 @@ var ts; transformFlags |= 8192 /* ContainsLexicalThis */; } } - if (expression.kind === 91 /* ImportKeyword */) { + if (expression.kind === 92 /* ImportKeyword */) { transformFlags |= 16777216 /* ContainsDynamicImport */; // A dynamic 'import()' call that contains a lexical 'this' will // require a captured 'this' when emitting down-level. @@ -29279,17 +29769,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 188 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 59 /* EqualsToken */ && leftKind === 187 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 40 /* AsteriskAsteriskToken */ - || operatorTokenKind === 62 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ + || operatorTokenKind === 63 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 32 /* AssertES2016 */; } @@ -29333,8 +29823,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 210 /* AsExpression */ - || expressionKind === 192 /* TypeAssertionExpression */) { + if (expressionKind === 212 /* AsExpression */ + || expressionKind === 194 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -29391,11 +29881,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 85 /* ExtendsKeyword */: + case 86 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 108 /* ImplementsKeyword */: + case 109 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -29714,59 +30204,59 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 637535553 /* NodeExcludes */; switch (kind) { - case 120 /* AsyncKeyword */: - case 199 /* AwaitExpression */: + case 121 /* AsyncKeyword */: + case 201 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; break; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 124 /* DeclareKeyword */: - case 76 /* ConstKeyword */: - case 241 /* EnumDeclaration */: - case 276 /* EnumMember */: - case 211 /* NonNullExpression */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 125 /* DeclareKeyword */: + case 77 /* ConstKeyword */: + case 243 /* EnumDeclaration */: + case 278 /* EnumMember */: + case 213 /* NonNullExpression */: + case 133 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 258 /* JsxElement */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: - case 10 /* JsxText */: - case 261 /* JsxClosingElement */: - case 262 /* JsxFragment */: - case 263 /* JsxOpeningFragment */: - case 264 /* JsxClosingFragment */: - case 265 /* JsxAttribute */: - case 266 /* JsxAttributes */: - case 267 /* JsxSpreadAttribute */: - case 268 /* JsxExpression */: + case 260 /* JsxElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 11 /* JsxText */: + case 263 /* JsxClosingElement */: + case 264 /* JsxFragment */: + case 265 /* JsxOpeningFragment */: + case 266 /* JsxClosingFragment */: + case 267 /* JsxAttribute */: + case 268 /* JsxAttributes */: + case 269 /* JsxSpreadAttribute */: + case 270 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: - case 204 /* TemplateExpression */: - case 191 /* TaggedTemplateExpression */: - case 274 /* ShorthandPropertyAssignment */: - case 115 /* StaticKeyword */: - case 212 /* MetaProperty */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + case 206 /* TemplateExpression */: + case 193 /* TaggedTemplateExpression */: + case 276 /* ShorthandPropertyAssignment */: + case 116 /* StaticKeyword */: + case 214 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: if (node.hasExtendedUnicodeEscape) { transformFlags |= 192 /* AssertES2015 */; } @@ -29776,60 +30266,64 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ForOfStatement */: + case 9 /* BigIntLiteral */: + transformFlags |= 8 /* AssertESNext */; + break; + case 227 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 4194304 /* ContainsYield */; break; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 135 /* ObjectKeyword */: - case 137 /* StringKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 161 /* TypePredicate */: - case 162 /* TypeReference */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 165 /* TypeQuery */: - case 166 /* TypeLiteral */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 174 /* InferType */: - case 175 /* ParenthesizedType */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: - case 245 /* NamespaceExportDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 136 /* ObjectKeyword */: + case 138 /* StringKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 163 /* TypePredicate */: + case 164 /* TypeReference */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 167 /* TypeQuery */: + case 168 /* TypeLiteral */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 176 /* InferType */: + case 177 /* ParenthesizedType */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: + case 247 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -29846,43 +30340,43 @@ var ts; transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 131072 /* ContainsRestOrSpread */; break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; break; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */ | 33554432 /* Super */; excludeFlags = 536872257 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 8192 /* ContainsLexicalThis */; break; - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { transformFlags |= 8 /* AssertESNext */ | 262144 /* ContainsObjectRestOrSpread */; } excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 2097152 /* ContainsBindingPattern */; excludeFlags = 637666625 /* BindingPatternExcludes */; break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 131072 /* ContainsRestOrSpread */; } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsTypeScriptClassSyntax */; break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: excludeFlags = 638358849 /* ObjectLiteralExcludes */; if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -29900,8 +30394,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 185 /* ArrayLiteralExpression */: - case 190 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: + case 192 /* NewExpression */: excludeFlags = 637666625 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 131072 /* ContainsRestOrSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -29909,26 +30403,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -29942,68 +30436,68 @@ var ts; * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather * than calling this function. */ - /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { + if (kind >= 163 /* FirstTypeNode */ && kind <= 183 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 185 /* ArrayLiteralExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 187 /* ArrayLiteralExpression */: return 637666625 /* ArrayLiteralOrCallOrNewExcludes */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return 647001409 /* ModuleExcludes */; - case 149 /* Parameter */: + case 151 /* Parameter */: return 637535553 /* ParameterExcludes */; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return 653604161 /* ArrowFunctionExcludes */; - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: return 653620545 /* FunctionExcludes */; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return 639894849 /* VariableDeclarationListExcludes */; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 638121281 /* ClassExcludes */; - case 155 /* Constructor */: + case 157 /* Constructor */: return 653616449 /* ConstructorExcludes */; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return 653616449 /* MethodOrAccessorExcludes */; - case 119 /* AnyKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 137 /* StringKeyword */: - case 135 /* ObjectKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 105 /* VoidKeyword */: - case 148 /* TypeParameter */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 120 /* AnyKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 132 /* NeverKeyword */: + case 138 /* StringKeyword */: + case 136 /* ObjectKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 106 /* VoidKeyword */: + case 150 /* TypeParameter */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return 638358849 /* ObjectLiteralExcludes */; - case 272 /* CatchClause */: + case 274 /* CatchClause */: return 637797697 /* CatchClauseExcludes */; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: return 637666625 /* BindingPatternExcludes */; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 306 /* PartiallyEmittedExpression */: - case 193 /* ParenthesizedExpression */: - case 97 /* SuperKeyword */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 308 /* PartiallyEmittedExpression */: + case 195 /* ParenthesizedExpression */: + case 98 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return 570426689 /* PropertyAccessExcludes */; default: return 637535553 /* NodeExcludes */; @@ -30064,7 +30558,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -30080,16 +30574,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { visitIndexType(type); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -30178,7 +30672,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 === 165 /* TypeQuery */) { + if (d.type && d.type.kind === 167 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -30268,6 +30762,7 @@ var ts; var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); @@ -30443,10 +30938,6 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { - var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); - return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; - }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isParameter); @@ -30479,6 +30970,7 @@ var ts; getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, + getObjectFlags: ts.getObjectFlags, isArrayLikeType: isArrayLikeType, isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, @@ -30486,7 +30978,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentExport: function (node, target) { return getSuggestionForNonexistentExport(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -30564,21 +31056,24 @@ var ts; var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(16384 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(65536 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */ | 134217728 /* ContainsWideningType */, "null"); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); - var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); - falseType.flags |= 33554432 /* FreshLiteral */; - trueType.flags |= 33554432 /* FreshLiteral */; + 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"); trueType.regularType = regularTrueType; + trueType.freshType = trueType; + regularTrueType.regularType = regularTrueType; regularTrueType.freshType = trueType; falseType.regularType = regularFalseType; + falseType.freshType = falseType; + regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = createBooleanType([regularFalseType, regularTrueType]); // Also mark all combinations of fresh/regular booleans as "Boolean" so they print as `boolean` instead of `true | false` @@ -30586,15 +31081,18 @@ var ts; createBooleanType([regularFalseType, trueType]); createBooleanType([falseType, regularTrueType]); createBooleanType([falseType, trueType]); - var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(4096 /* Void */, "void"); - var neverType = createIntrinsicType(32768 /* Never */, "never"); - var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); + 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 implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; + var numberOrBigIntType = getUnionType([numberType, bigintType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); + emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -30607,16 +31105,15 @@ var ts; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - var markerSuperType = createType(65536 /* TypeParameter */); - var markerSubType = createType(65536 /* TypeParameter */); + var markerSuperType = createType(262144 /* TypeParameter */); + var markerSubType = createType(262144 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(65536 /* TypeParameter */); + var markerOtherType = createType(262144 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignaturesArray = [resolvingSignature]; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var globals = ts.createSymbolTable(); /** Key is "/path/to/a.ts|/path/to/b.ts". */ @@ -30663,6 +31160,9 @@ var ts; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; var deferredGlobalExtractSymbol; + var deferredGlobalExcludeSymbol; + var deferredGlobalPickSymbol; + var deferredGlobalBigIntType; var allPotentiallyUnusedIdentifiers = ts.createMap(); // key is file name var flowLoopStart = 0; var flowLoopCount = 0; @@ -30670,6 +31170,7 @@ var ts; var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); + var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); var resolutionTargets = []; var resolutionResults = []; var resolutionPropertyNames = []; @@ -30695,86 +31196,99 @@ var ts; TypeFacts[TypeFacts["None"] = 0] = "None"; TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; - TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; - TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; - TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; - TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; - TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; - TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; - TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; - TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; - TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; - TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; - TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; - TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; - TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; - TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; - TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; - TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; - TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; - TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; - TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; - TypeFacts[TypeFacts["All"] = 4194303] = "All"; + TypeFacts[TypeFacts["TypeofEQBigInt"] = 4] = "TypeofEQBigInt"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 8] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 16] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 32] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 64] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 128] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 256] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 512] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBigInt"] = 1024] = "TypeofNEBigInt"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 2048] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 4096] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 8192] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 16384] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 32768] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 65536] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 131072] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 262144] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 524288] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 1048576] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 2097152] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 4194304] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 8388608] = "Falsy"; + TypeFacts[TypeFacts["All"] = 16777215] = "All"; // The following members encode facts about particular kinds of types for use in the getTypeFacts function. // The presence of a particular fact means that the given test is true for some (and possibly all) values // of that kind of type. - TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; - TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; - TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; - TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; - TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; - TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; - TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; - TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; - TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; - TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; - TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; - TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; - TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; - TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; - TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; - TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; - TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; - TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; - TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; - TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; - TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; - TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; - TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; - TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; - TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; - TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; - TypeFacts[TypeFacts["ObjectStrictFacts"] = 1972176] = "ObjectStrictFacts"; - TypeFacts[TypeFacts["ObjectFacts"] = 4184016] = "ObjectFacts"; - TypeFacts[TypeFacts["FunctionStrictFacts"] = 1970144] = "FunctionStrictFacts"; - TypeFacts[TypeFacts["FunctionFacts"] = 4181984] = "FunctionFacts"; - TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; - TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; - TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 4079615] = "EmptyObjectStrictFacts"; - TypeFacts[TypeFacts["EmptyObjectFacts"] = 4194303] = "EmptyObjectFacts"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 3735041] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 12582401] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 16317953] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 16776705] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 12123649] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 12582401] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 7929345] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 16776705] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 3734786] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 12582146] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 16317698] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 16776450] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroNumberStrictFacts"] = 12123394] = "ZeroNumberStrictFacts"; + TypeFacts[TypeFacts["ZeroNumberFacts"] = 12582146] = "ZeroNumberFacts"; + TypeFacts[TypeFacts["NonZeroNumberStrictFacts"] = 7929090] = "NonZeroNumberStrictFacts"; + TypeFacts[TypeFacts["NonZeroNumberFacts"] = 16776450] = "NonZeroNumberFacts"; + TypeFacts[TypeFacts["BaseBigIntStrictFacts"] = 3734276] = "BaseBigIntStrictFacts"; + TypeFacts[TypeFacts["BaseBigIntFacts"] = 12581636] = "BaseBigIntFacts"; + TypeFacts[TypeFacts["BigIntStrictFacts"] = 16317188] = "BigIntStrictFacts"; + TypeFacts[TypeFacts["BigIntFacts"] = 16775940] = "BigIntFacts"; + TypeFacts[TypeFacts["ZeroBigIntStrictFacts"] = 12122884] = "ZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["ZeroBigIntFacts"] = 12581636] = "ZeroBigIntFacts"; + TypeFacts[TypeFacts["NonZeroBigIntStrictFacts"] = 7928580] = "NonZeroBigIntStrictFacts"; + TypeFacts[TypeFacts["NonZeroBigIntFacts"] = 16775940] = "NonZeroBigIntFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 3733256] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 12580616] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 16316168] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 16774920] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 12121864] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 12580616] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 7927560] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 16774920] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 7925520] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 16772880] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 7888800] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 16736160] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 7880640] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 16728000] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 9830144] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 9363232] = "NullFacts"; + TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts"; + TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts"; })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMapFromTemplate({ string: 1 /* TypeofEQString */, number: 2 /* TypeofEQNumber */, - boolean: 4 /* TypeofEQBoolean */, - symbol: 8 /* TypeofEQSymbol */, - undefined: 16384 /* EQUndefined */, - object: 16 /* TypeofEQObject */, - function: 32 /* TypeofEQFunction */ + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ }); var typeofNEFacts = ts.createMapFromTemplate({ - string: 128 /* TypeofNEString */, - number: 256 /* TypeofNENumber */, - boolean: 512 /* TypeofNEBoolean */, - symbol: 1024 /* TypeofNESymbol */, - undefined: 131072 /* NEUndefined */, - object: 2048 /* TypeofNEObject */, - function: 4096 /* TypeofNEFunction */ + string: 256 /* TypeofNEString */, + number: 512 /* TypeofNENumber */, + bigint: 1024 /* TypeofNEBigInt */, + boolean: 2048 /* TypeofNEBoolean */, + symbol: 4096 /* TypeofNESymbol */, + undefined: 524288 /* NEUndefined */, + object: 8192 /* TypeofNEObject */, + function: 16384 /* TypeofNEFunction */ }); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, + bigint: bigintType, boolean: booleanType, symbol: esSymbolType, undefined: undefinedType @@ -30996,7 +31510,7 @@ var ts; (source.flags | target.flags) & 67108864 /* Assignment */) { ts.Debug.assert(source !== target); if (!(target.flags & 33554432 /* Transient */)) { - target = cloneSymbol(target); + target = cloneSymbol(resolveSymbol(target)); } // 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) { @@ -31027,7 +31541,7 @@ var ts; else if (target.flags & 1024 /* NamespaceModule */) { error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } - else { + else { // error var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); var message = isEitherEnum @@ -31092,7 +31606,8 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); + var targetSymbol = target.get(id); + target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -31154,7 +31669,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 279 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -31212,17 +31727,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 184 /* BindingElement */) { + if (declaration.kind === 186 /* 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, 184 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 186 /* 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, 235 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 237 /* VariableDeclaration */), usage); } - else if (declaration.kind === 235 /* VariableDeclaration */) { + else if (declaration.kind === 237 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -31241,12 +31756,12 @@ 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 === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 257 /* ExportSpecifier */ || (usage.parent.kind === 254 /* 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 === 252 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 254 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -31254,9 +31769,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 217 /* VariableStatement */: - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: + case 219 /* VariableStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -31277,16 +31792,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 152 /* PropertyDeclaration */ && + current.parent.kind === 154 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 154 /* MethodDeclaration */) { + if (declaration.kind === 156 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -31328,12 +31843,12 @@ 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 & 67897832 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { + if (meaning & result.flags & 67897832 /* Type */ && lastLocation.kind !== 291 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 149 /* Parameter */ || - lastLocation.kind === 148 /* TypeParameter */ + lastLocation.kind === 151 /* Parameter */ || + lastLocation.kind === 150 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -31350,13 +31865,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 151 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 173 /* ConditionalType */) { + else if (location.kind === 175 /* 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; @@ -31370,14 +31885,14 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -31401,7 +31916,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 257 /* ExportSpecifier */)) { break; } } @@ -31415,13 +31930,13 @@ var ts; } } break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -31438,9 +31953,9 @@ var ts; } } break; - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* 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! @@ -31459,7 +31974,7 @@ var ts; } break loop; } - if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 209 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -31467,9 +31982,9 @@ var ts; } } break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 86 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { if (nameNotFoundMessage) { @@ -31487,9 +32002,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 241 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -31497,19 +32012,19 @@ var ts; } } break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -31522,7 +32037,7 @@ var ts; } } break; - case 150 /* Decorator */: + case 152 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -31531,7 +32046,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 === 149 /* Parameter */) { + if (location.parent && location.parent.kind === 151 /* Parameter */) { location = location.parent; } // @@ -31544,8 +32059,8 @@ var ts; location = location.parent; } break; - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -31564,7 +32079,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 279 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -31637,8 +32152,7 @@ var ts; } // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { - var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { + if (ts.some(result.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -31647,12 +32161,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 242 /* ModuleDeclaration */: // For `namespace N { N; }` + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 244 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -31664,7 +32178,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 148 /* TypeParameter */) { + if (decl.kind === 150 /* 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 @@ -31719,10 +32233,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -31789,7 +32303,7 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 243 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -31824,13 +32338,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return node; - case 248 /* ImportClause */: + case 250 /* ImportClause */: return node.parent; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -31840,7 +32354,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -32032,20 +32546,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 252 /* ExportAssignment */: - case 202 /* BinaryExpression */: + case 254 /* ExportAssignment */: + case 204 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -32106,11 +32620,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 252 /* ExportAssignment */) { + if (node.kind === 254 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 255 /* ExportSpecifier */) { + else if (node.kind === 257 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -32128,17 +32642,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 71 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 72 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* QualifiedName */) { + if (entityName.kind === 72 /* Identifier */ || entityName.parent.kind === 148 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 248 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -32154,7 +32668,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); var symbol; - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name).escapedText); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -32162,9 +32676,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { - var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 148 /* QualifiedName */ || name.kind === 189 /* PropertyAccessExpression */) { + var left = name.kind === 148 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 148 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -32247,6 +32761,9 @@ var ts; } function getDeclarationOfJSPrototypeContainer(symbol) { var decl = symbol.parent.valueDeclaration; + if (!decl) { + return undefined; + } var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) : ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) : undefined; @@ -32365,10 +32882,15 @@ var ts; return getPackagesSet().has(ts.getTypesPackageName(packageName)); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; + if (moduleSymbol) { + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + return getMergedSymbol(exported) || moduleSymbol; + } + return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || moduleSymbol.exports.size === 1) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } var merged = cloneSymbol(exported); @@ -32389,7 +32911,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 279 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -32457,7 +32979,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -32602,7 +33124,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 157 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -32625,7 +33147,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(131072 /* Object */); + var type = createType(524288 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -32680,12 +33202,12 @@ var ts; } } switch (location.kind) { - case 277 /* SourceFile */: + case 279 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -32749,7 +33271,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // 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, 255 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -32785,7 +33307,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, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 257 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -32800,10 +33322,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: continue; default: return false; @@ -32920,10 +33442,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -32970,14 +33492,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 165 /* TypeQuery */ || + if (entityName.parent.kind === 167 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 147 /* ComputedPropertyName */) { + entityName.parent.kind === 149 /* ComputedPropertyName */) { // Typeof value meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || - entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 148 /* QualifiedName */ || entityName.kind === 189 /* PropertyAccessExpression */ || + entityName.parent.kind === 248 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -33026,15 +33548,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 166 /* ConstructorType */ : 165 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 161 /* ConstructSignature */ : 160 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 return writer; } } @@ -33099,7 +33621,8 @@ var ts; getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) } : undefined }, encounteredError: false, - visitedSymbols: undefined, + visitedTypes: undefined, + symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; @@ -33123,48 +33646,55 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + return ts.createKeywordTypeNode(143 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* StringKeyword */); + return ts.createKeywordTypeNode(138 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(134 /* NumberKeyword */); + return ts.createKeywordTypeNode(135 /* NumberKeyword */); + } + if (type.flags & 64 /* BigInt */) { + context.approximateLength += 6; + return ts.createKeywordTypeNode(146 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(122 /* BooleanKeyword */); + return ts.createKeywordTypeNode(123 /* BooleanKeyword */); } - if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { + if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToName(parentSymbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); + var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type + ? parentName + : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); + return enumLiteralName; } - if (type.flags & 544 /* EnumLike */) { - var name = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ false); - context.approximateLength += ts.symbolName(type.symbol).length; - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + if (type.flags & 1056 /* EnumLike */) { + return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); } - if (type.flags & 64 /* StringLiteral */) { + if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & 128 /* NumberLiteral */) { + if (type.flags & 256 /* NumberLiteral */) { context.approximateLength += (("" + type.value).length); return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 256 /* BooleanLiteral */) { + if (type.flags & 2048 /* BigIntLiteral */) { + context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; + return ts.createLiteralTypeNode((ts.createLiteral(type.value))); + } + if (type.flags & 512 /* BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; @@ -33175,33 +33705,33 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(142 /* UniqueKeyword */, ts.createKeywordTypeNode(139 /* SymbolKeyword */)); } - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(105 /* VoidKeyword */); + return ts.createKeywordTypeNode(106 /* VoidKeyword */); } - if (type.flags & 8192 /* Undefined */) { + if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(141 /* UndefinedKeyword */); } - if (type.flags & 16384 /* Null */) { + if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(95 /* NullKeyword */); + return ts.createKeywordTypeNode(96 /* NullKeyword */); } - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(131 /* NeverKeyword */); + return ts.createKeywordTypeNode(132 /* NeverKeyword */); } - if (type.flags & 1024 /* ESSymbol */) { + if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(138 /* SymbolKeyword */); + return ts.createKeywordTypeNode(139 /* SymbolKeyword */); } - if (type.flags & 16777216 /* NonPrimitive */) { + if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(135 /* ObjectKeyword */); + return ts.createKeywordTypeNode(136 /* ObjectKeyword */); } - if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { + if (type.flags & 262144 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -33215,16 +33745,16 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 65536 /* TypeParameter */ && + type.flags & 262144 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && @@ -33244,14 +33774,14 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); } - if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { - var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { + var types = type.flags & 1048576 /* 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) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 173 /* UnionType */ : 174 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -33262,23 +33792,23 @@ var ts; } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 1048576 /* Index */) { + if (type.flags & 4194304 /* Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 2097152 /* IndexedAccess */) { + if (type.flags & 8388608 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 4194304 /* Conditional */) { + if (type.flags & 16777216 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -33289,12 +33819,12 @@ var ts; context.approximateLength += 15; return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 8388608 /* Substitution */) { + if (type.flags & 33554432 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 131072 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -33313,6 +33843,7 @@ var ts; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); } function createAnonymousTypeNode(type) { + var typeId = "" + type.id; var symbol = type.symbol; var id; if (symbol) { @@ -33324,12 +33855,12 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 209 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67220415 /* Value */); } - else if (context.visitedSymbols && context.visitedSymbols.has(id)) { + else if (context.visitedTypes && context.visitedTypes.has(typeId)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { @@ -33338,18 +33869,34 @@ var ts; } else { context.approximateLength += 3; - return ts.createKeywordTypeNode(119 /* AnyKeyword */); + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } } else { // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedSymbols) { - context.visitedSymbols = ts.createMap(); + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); } - context.visitedSymbols.set(id, true); + if (!context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + context.approximateLength += 3; + if (!(context.flags & 1 /* NoTruncation */)) { + return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); + } + return ts.createKeywordTypeNode(120 /* AnyKeyword */); + } + context.symbolDepth.set(id, depth + 1); + context.visitedTypes.set(typeId, true); var result = createTypeNodeFromObjectType(type); - context.visitedSymbols.delete(id); + context.visitedTypes.delete(typeId); + context.symbolDepth.set(id, depth); return result; } } @@ -33363,11 +33910,11 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; + return declaration.parent.kind === 279 /* SourceFile */ || declaration.parent.kind === 245 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively + return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } @@ -33384,12 +33931,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 165 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* ConstructorType */, context); return signatureNode; } } @@ -33521,11 +34068,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 160 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -33576,12 +34123,12 @@ var ts; var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(55 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length) { var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 155 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -33594,9 +34141,9 @@ var ts; else { var savedFlags = context.flags; context.flags |= !!(ts.getCheckFlags(propertySymbol) & 2048 /* ReverseMapped */) ? 33554432 /* InReverseMappedType */ : 0; - var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(120 /* AnyKeyword */); context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -33647,7 +34194,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 137 /* StringKeyword */ : 134 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 138 /* StringKeyword */ : 135 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -33660,7 +34207,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(132 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(133 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -33671,7 +34218,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 157 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -33690,12 +34237,12 @@ var ts; returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 119 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 120 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(119 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(120 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -33724,9 +34271,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 151 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 297 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 299 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -33735,16 +34282,16 @@ var ts; var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; - var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; + var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 72 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 148 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -33758,7 +34305,7 @@ var ts; } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 184 /* BindingElement */) { + if (clone.kind === 186 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -33857,7 +34404,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 279 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -34057,10 +34604,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 24576 /* Nullable */)) { - if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { - var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 262144 /* Union */) { + 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 */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -34072,9 +34619,9 @@ var ts; result.push(t); } } - if (flags & 16384 /* Null */) + if (flags & 65536 /* Null */) result.push(nullType); - if (flags & 8192 /* Undefined */) + if (flags & 32768 /* Undefined */) result.push(undefinedType); return result || types; } @@ -34089,8 +34636,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); - if (node.kind === 240 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 177 /* ParenthesizedType */; }); + if (node.kind === 242 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -34098,11 +34645,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 243 /* ModuleBlock */ && + node.parent.kind === 245 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 279 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -34125,27 +34672,30 @@ var ts; var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { + if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + return ts.symbolName(symbol); + } return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 237 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 209 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 128 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 8192 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -34162,27 +34712,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 295 /* JSDocCallbackTag */: - case 302 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: // 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 184 /* BindingElement */: + case 186 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 235 /* VariableDeclaration */: + case 237 /* 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 237 /* FunctionDeclaration */: - case 241 /* EnumDeclaration */: - case 246 /* ImportEqualsDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + case 243 /* EnumDeclaration */: + case 248 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -34190,53 +34740,53 @@ var ts; 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 !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 248 /* ImportEqualsDeclaration */ && parent.kind !== 279 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 155 /* Constructor */: - case 159 /* ConstructSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 149 /* Parameter */: - case 243 /* ModuleBlock */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 162 /* TypeReference */: - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 175 /* ParenthesizedType */: + case 157 /* Constructor */: + case 161 /* ConstructSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 151 /* Parameter */: + case 245 /* ModuleBlock */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 164 /* TypeReference */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 177 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: return false; // Type parameters are always visible - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: // Source file and namespace export are always visible - case 277 /* SourceFile */: - case 245 /* NamespaceExportDeclaration */: + case 279 /* SourceFile */: + case 247 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return false; default: return false; @@ -34245,10 +34795,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 254 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 255 /* ExportSpecifier */) { + else if (node.parent.kind === 257 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -34344,12 +34894,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 235 /* VariableDeclaration */: - case 236 /* VariableDeclarationList */: - case 251 /* ImportSpecifier */: - case 250 /* NamedImports */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 237 /* VariableDeclaration */: + case 238 /* VariableDeclarationList */: + case 253 /* ImportSpecifier */: + case 252 /* NamedImports */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: return false; default: return true; @@ -34379,28 +34929,36 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 149 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); - if (source.flags & 32768 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); + if (source.flags & 131072 /* Never */) { return emptyObjectType; } - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } - var members = ts.createSymbolTable(); - var names = ts.createUnderscoreEscapedMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; - names.set(ts.getTextOfPropertyName(name), true); + var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); + if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) { + if (omitKeyType.flags & 131072 /* Never */) { + return source; + } + var pickTypeAlias = getGlobalPickSymbol(); + var excludeTypeAlias = getGlobalExcludeSymbol(); + if (!pickTypeAlias || !excludeTypeAlias) { + return errorType; + } + var pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]); + return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]); } - for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { - var prop = _b[_a]; - if (!names.has(prop.escapedName) + var members = ts.createSymbolTable(); + for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), omitKeyType) && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) && isSpreadableProperty(prop)) { - members.set(prop.escapedName, getNonReadonlySymbol(prop)); + members.set(prop.escapedName, getSpreadSymbol(prop)); } } var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); @@ -34424,8 +34982,12 @@ var ts; if (isTypeAny(parentType)) { return parentType; } + // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation + if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + parentType = getNonNullableType(parentType); + } var type; - if (pattern.kind === 182 /* ObjectBindingPattern */) { + if (pattern.kind === 184 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -34443,51 +35005,9 @@ var ts; else { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; - var isLate = isLateBindableName(name); - var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); - if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { - var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); - } - return anyType; - } - var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); - if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { - if (getIndexTypeOfType(parentType, 1 /* Number */)) { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); - } - else { - error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(parentType)); - } - } - return indexerType || anyType; - } - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - var nameType = isLate ? checkComputedPropertyName(name) : undefined; - var text = isLate ? getLateBoundNameFromType(nameType) : - isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : - ts.getTextOfPropertyName(name); - // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { - parentType = getNonNullableType(parentType); - } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { - if (noImplicitAny) { - error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); - } - return anyType; - } - var declaredType = getConstraintForLocation(getTypeOfPropertyOfType(parentType, text), declaration.name); - type = declaredType && getFlowTypeOfReference(declaration, declaredType) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return errorType; - } + var exprType = getLiteralTypeFromPropertyName(name); + var declaredType = checkIndexedAccessIndexType(getIndexedAccessType(parentType, exprType, name), name); + type = getFlowTypeOfReference(declaration, getConstraintForLocation(declaredType, declaration.name)); } } else { @@ -34523,8 +35043,8 @@ var ts; } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 8192 /* Undefined */)) { - type = getTypeWithFacts(type, 131072 /* NEUndefined */); + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */)) { + type = getTypeWithFacts(type, 524288 /* NEUndefined */); } return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkDeclarationInitializer(declaration)], 2 /* Subtype */) : @@ -34539,11 +35059,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 95 /* NullKeyword */ || expr.kind === 71 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 96 /* NullKeyword */ || expr.kind === 72 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 187 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -34553,11 +35073,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 224 /* ForInStatement */) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 226 /* ForInStatement */) { + var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); + return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* 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, @@ -34576,7 +35096,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 237 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* 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 @@ -34590,11 +35110,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); + if (func.kind === 159 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 158 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -34658,7 +35178,7 @@ var ts; var types; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - var expression = ts.isBinaryExpression(declaration) ? declaration : + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { @@ -34673,9 +35193,11 @@ var ts; definedInMethod = true; } } - jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + if (!ts.isCallExpression(expression)) { + jsdocType = getJSDocTypeFromAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } if (!jsdocType) { - (types || (types = [])).push(ts.isBinaryExpression(expression) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } var type = jsdocType; @@ -34689,11 +35211,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(98304 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -34734,8 +35256,33 @@ var ts; } /** If we don't have an explicit JSDoc type, get the type from the initializer. */ function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) { + if (ts.isCallExpression(expression)) { + if (resolvedSymbol) { + return getTypeOfSymbol(resolvedSymbol); // This shouldn't happen except under some hopefully forbidden merges of export assignments and object define assignments + } + var objectLitType = checkExpressionCached(expression.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + return valueType; + } + var getFunc = getTypeOfPropertyOfType(objectLitType, "get"); + if (getFunc) { + var getSig = getSingleCallSignature(getFunc); + if (getSig) { + return getReturnTypeOfSignature(getSig); + } + } + var setFunc = getTypeOfPropertyOfType(objectLitType, "set"); + if (setFunc) { + var setSig = getSingleCallSignature(setFunc); + if (setSig) { + return getTypeOfFirstParameterOfSignature(setSig); + } + } + return anyType; + } var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 131072 /* Object */ && + if (type.flags & 524288 /* Object */ && kind === 2 /* ModuleExports */ && symbol.escapedName === "export=" /* ExportEquals */) { var exportedType_1 = resolveStructuredTypeMembers(type); @@ -34769,9 +35316,9 @@ var ts; 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 === 155 /* Constructor */ || - thisContainer.kind === 237 /* FunctionDeclaration */ || - (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 157 /* Constructor */ || + thisContainer.kind === 239 /* FunctionDeclaration */ || + (thisContainer.kind === 196 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -34846,7 +35393,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 186 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -34869,7 +35416,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 182 /* ObjectBindingPattern */ + return pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -34891,7 +35438,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -34908,7 +35455,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 151 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -34948,12 +35495,12 @@ var ts; return emptyObjectType; } var type_1 = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression)); - if (type_1.flags & 131072 /* Object */) { + if (type_1.flags & 524288 /* Object */) { return getRegularTypeOfObjectLiteral(type_1); } return type_1; } - if (declaration.kind === 252 /* ExportAssignment */) { + if (declaration.kind === 254 /* ExportAssignment */) { return widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } // Handle variable, parameter or property @@ -34962,7 +35509,7 @@ var ts; } var type; if (ts.isInJSFile(declaration) && - (ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { type = getWidenedTypeFromAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) @@ -34999,6 +35546,14 @@ var ts; || ts.isBindingElement(declaration)) { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); } + // getTypeOfSymbol dispatches some JS merges incorrectly because their symbol flags are not mutually exclusive. + // Re-dispatch based on valueDeclaration.kind instead. + else if (ts.isEnumDeclaration(declaration)) { + type = getTypeOfFuncClassEnumModule(symbol); + } + else if (ts.isEnumMember(declaration)) { + type = getTypeOfEnumMember(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } @@ -35009,7 +35564,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 156 /* GetAccessor */) { + if (accessor.kind === 158 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -35036,8 +35591,8 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 159 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -35080,7 +35635,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 158 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -35088,7 +35643,7 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -35120,8 +35675,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 202 /* BinaryExpression */ || - declaration.kind === 187 /* PropertyAccessExpression */ && declaration.parent.kind === 202 /* BinaryExpression */) { + else if (declaration.kind === 204 /* BinaryExpression */ || + declaration.kind === 189 /* PropertyAccessExpression */ && declaration.parent.kind === 204 /* BinaryExpression */) { return getWidenedTypeFromAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -35233,7 +35788,7 @@ var ts; var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, check); } return false; @@ -35257,35 +35812,35 @@ var ts; return undefined; } switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 239 /* InterfaceDeclaration */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 153 /* MethodSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 287 /* JSDocFunctionType */: - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 240 /* TypeAliasDeclaration */: - case 301 /* JSDocTemplateTag */: - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: - case 179 /* MappedType */: - case 173 /* ConditionalType */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 241 /* InterfaceDeclaration */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 155 /* MethodSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 289 /* JSDocFunctionType */: + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 242 /* TypeAliasDeclaration */: + case 303 /* JSDocTemplateTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: + case 181 /* MappedType */: + case 175 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 179 /* MappedType */) { + if (node.kind === 181 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 173 /* ConditionalType */) { + else if (node.kind === 175 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && + (node.kind === 240 /* ClassDeclaration */ || node.kind === 209 /* ClassExpression */ || node.kind === 241 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -35293,7 +35848,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, 239 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -35302,9 +35857,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 238 /* ClassDeclaration */ || - node.kind === 207 /* ClassExpression */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 240 /* ClassDeclaration */ || + node.kind === 209 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -35331,7 +35886,7 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } @@ -35374,7 +35929,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 & (131072 /* Object */ | 524288 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* 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); @@ -35384,7 +35939,18 @@ var ts; return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { - error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); + if (baseConstructorType.flags & 262144 /* TypeParameter */) { + var constraint = getConstraintFromTypeParameter(baseConstructorType); + var ctorReturn = unknownType; + if (constraint) { + var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + if (ctorSig[0]) { + ctorReturn = getReturnTypeOfSignature(ctorSig[0]); + } + } + addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; @@ -35413,7 +35979,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -35480,14 +36046,14 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || - !!(type.flags & 524288 /* Intersection */) && ts.every(type.types, isValidBaseType); + return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 241 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -35523,7 +36089,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 239 /* InterfaceDeclaration */) { + if (declaration.kind === 241 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -35564,7 +36130,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -35581,7 +36147,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 242 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -35605,10 +36171,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 9 /* StringLiteral */) { + if (expr.kind === 10 /* StringLiteral */) { return true; } - else if (expr.kind === 202 /* BinaryExpression */) { + else if (expr.kind === 204 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -35619,15 +36185,15 @@ var ts; return !(member.flags & 4194304 /* Ambient */); } switch (expr.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 200 /* PrefixUnaryExpression */: - return expr.operator === 38 /* MinusToken */ && + case 202 /* PrefixUnaryExpression */: + return expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -35641,10 +36207,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { + if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -35656,7 +36222,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -35668,7 +36234,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 241 /* EnumDeclaration */) { + if (declaration.kind === 243 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getFreshTypeOfLiteralType(getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member))); // TODO: GH#18217 @@ -35679,8 +36245,8 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 262144 /* Union */) { - enumType_1.flags |= 512 /* EnumLiteral */; + if (enumType_1.flags & 1048576 /* Union */) { + enumType_1.flags |= 1024 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; @@ -35703,7 +36269,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(65536 /* TypeParameter */); + var type = createType(262144 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -35747,22 +36313,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 122 /* BooleanKeyword */: - case 138 /* SymbolKeyword */: - case 135 /* ObjectKeyword */: - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: - case 180 /* LiteralType */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 146 /* BigIntKeyword */: + case 123 /* BooleanKeyword */: + case 139 /* SymbolKeyword */: + case 136 /* ObjectKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: + case 182 /* LiteralType */: return true; - case 167 /* ArrayType */: + case 169 /* ArrayType */: return isThislessType(node.elementType); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -35788,7 +36355,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 157 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -35804,12 +36371,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -35853,7 +36420,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -35896,10 +36463,10 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 2048 /* UniqueESSymbol */) { + if (type.flags & 8192 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -36064,7 +36631,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -36193,7 +36760,7 @@ var ts; function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) { for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { var s = signatureList_1[_i]; - if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { + if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) { return s; } } @@ -36227,8 +36794,7 @@ var ts; // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional // parameters and may differ in return types. When signatures differ in return types, the resulting return // type is the union of the constituent return types. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + function getUnionSignatures(signatureLists) { var result; for (var i = 0; i < signatureLists.length; i++) { for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { @@ -36274,8 +36840,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(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 0 /* Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); var stringIndexInfo = getUnionIndexInfo(type.types, 0 /* String */); var numberIndexInfo = getUnionIndexInfo(type.types, 1 /* Number */); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -36371,7 +36937,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -36405,7 +36971,7 @@ var ts; var modifiers = getMappedTypeModifiers(type.mappedType); var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; - var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType), readonlyMask && indexInfo.isReadonly); + var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly); var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; @@ -36415,6 +36981,7 @@ var ts; inferredProp.nameType = prop.nameType; inferredProp.propertyType = getTypeOfSymbol(prop); inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -36433,12 +37000,12 @@ 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 ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; - addMemberForKeyType(getLiteralTypeFromPropertyName(prop, include)); + addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); } if (modifiersType.flags & 1 /* Any */ || getIndexInfoOfType(modifiersType, 0 /* String */)) { addMemberForKeyType(stringType); @@ -36448,11 +37015,9 @@ var ts; } } else { - // First, if the constraint type is a type parameter, obtain the base constraint. Then, - // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. - // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + // If the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. + // Then iterate over the constituents of the key type. + var iterationType = constraintType.flags & 4194304 /* Index */ ? getIndexType(getApparentType(constraintType.type)) : constraintType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -36464,7 +37029,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 8576 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -36476,7 +37041,7 @@ var ts; // 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. prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; @@ -36512,8 +37077,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 177 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; + return constraintDeclaration.kind === 179 /* TypeOperator */ && + constraintDeclaration.operator === 129 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -36529,16 +37094,16 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 38 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 38 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -36557,7 +37122,7 @@ var ts; } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -36574,10 +37139,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 262144 /* Union */) { + else if (type.flags & 1048576 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -36585,7 +37150,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -36594,7 +37159,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -36618,7 +37183,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 - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { break; } } @@ -36628,12 +37193,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 786432 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { - return obj.properties.some(function (property) { + var list = obj.properties; + return list.some(function (property) { var name = property.name && ts.getTextOfPropertyName(property.name); var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); return !!expected && typeIsLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); @@ -36641,7 +37207,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 262144 /* Union */)) { + if (!(unionType.flags & 1048576 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -36660,9 +37226,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -36682,7 +37248,11 @@ var ts; function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = !(rootTrueType.flags & 33554432 /* Substitution */) + ? rootTrueType + : (rootTrueType.substitute).flags & 3 /* AnyOrUnknown */ + ? rootTrueType.typeVariable + : getIntersectionType([rootTrueType.substitute, rootTrueType.typeVariable]); type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -36699,7 +37269,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 32768 /* Never */)) { + if (!(instantiated.flags & 131072 /* Never */)) { return instantiated; } } @@ -36714,23 +37284,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 15794176 /* Instantiable */) { + if (t.flags & 63176704 /* 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 & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 262144 /* Union */)) { + if (!(constraint.flags & 1048576 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 16809468 /* DisjointDomains */) { + else if (t.flags & 67238908 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -36742,7 +37312,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 16809468 /* DisjointDomains */) { + if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -36752,11 +37322,11 @@ var ts; return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { + if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 1048576 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -36805,13 +37375,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 65536 /* TypeParameter */) { + if (t.flags & 262144 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 786432 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -36821,24 +37391,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 1048576 /* Index */) { + if (t.flags & 4194304 /* Index */) { return keyofConstraintType; } - if (t.flags & 2097152 /* IndexedAccess */) { + if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType, /*accessNode*/ undefined, errorType) : undefined; return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 4194304 /* Conditional */) { + if (t.flags & 16777216 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 8388608 /* Substitution */) { + if (t.flags & 33554432 /* Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -36910,21 +37480,22 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + var t = type.flags & 63176704 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 68 /* StringLike */ ? globalStringType : - t.flags & 168 /* NumberLike */ ? globalNumberType : - t.flags & 272 /* BooleanLike */ ? globalBooleanType : - t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : - t.flags & 1048576 /* Index */ ? keyofConstraintType : - t; + t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 132 /* StringLike */ ? globalStringType : + t.flags & 296 /* NumberLike */ ? globalNumberType : + t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 6 /* ESNext */) : + 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; } function createUnionOrIntersectionProperty(containingType, name) { var props; var indexTypes; - var isUnion = containingType.flags & 262144 /* Union */; + var isUnion = containingType.flags & 1048576 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -37037,7 +37608,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -37055,13 +37626,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -37075,7 +37646,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 917504 /* StructuredType */) { + if (type.flags & 3670016 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -37131,10 +37702,10 @@ 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 === 286 /* JSDocOptionalType */ + node.type && node.type.kind === 288 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -37168,7 +37739,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 288 /* JSDocOptionalType */; } function createIdentifierTypePredicate(parameterName, parameterIndex, type) { return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -37193,30 +37764,32 @@ var ts; } function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); - if (numTypeParameters) { - var numTypeArguments = ts.length(typeArguments); - if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { - if (!typeArguments) { - typeArguments = []; - } - // Map an unsatisfied type parameter with a default type. - // If a type parameter does not have a default type, or if the default type - // is a forward reference, the empty object type is used. - for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - for (var i = numTypeArguments; i < numTypeParameters; i++) { - var mapper = createTypeMapper(typeParameters, typeArguments); - var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { - defaultType = anyType; - } - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); - } - typeArguments.length = typeParameters.length; - } + if (!numTypeParameters) { + return []; } - return typeArguments; + var numTypeArguments = ts.length(typeArguments); + if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) { + var result = typeArguments ? typeArguments.slice() : []; + // Map an unsatisfied type parameter with a default type. + // If a type parameter does not have a default type, or if the default type + // is a forward reference, the empty object type is used. + var baseDefaultType_1 = getDefaultTypeArgumentType(isJavaScriptImplicitAny); + var circularityMapper = createTypeMapper(typeParameters, ts.map(typeParameters, function () { return baseDefaultType_1; })); + for (var i = numTypeArguments; i < numTypeParameters; i++) { + result[i] = instantiateType(getConstraintFromTypeParameter(typeParameters[i]) || baseDefaultType_1, circularityMapper); + } + for (var i = numTypeArguments; i < numTypeParameters; i++) { + var mapper = createTypeMapper(typeParameters, result); + var defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { + defaultType = anyType; + } + result[i] = defaultType ? instantiateType(defaultType, mapper) : baseDefaultType_1; + } + result.length = typeParameters.length; + return result; + } + return typeArguments && typeArguments.slice(); } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); @@ -37252,7 +37825,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 180 /* LiteralType */) { + if (type && type.kind === 182 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -37266,16 +37839,16 @@ 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 === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && + if ((declaration.kind === 158 /* GetAccessor */ || declaration.kind === 159 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = declaration.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 155 /* Constructor */ ? + var classType = declaration.kind === 157 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -37333,13 +37906,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - return node.name.kind === 147 /* ComputedPropertyName */ + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + return node.name.kind === 149 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -37414,7 +37987,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, func) { var parameterName = node.parameterName; var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 71 /* Identifier */) { + if (parameterName.kind === 72 /* Identifier */) { return createIdentifierTypePredicate(parameterName.escapedText, getTypePredicateParameterIndex(func.parameters, parameterName), type); } else { @@ -37424,7 +37997,7 @@ var ts; function getTypePredicateParameterIndex(parameterList, parameter) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 71 /* Identifier */ && param.name.escapedText === parameter.escapedText) { + if (param.name.kind === 72 /* Identifier */ && param.name.escapedText === parameter.escapedText) { return i; } } @@ -37464,7 +38037,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 155 /* Constructor */) { + if (declaration.kind === 157 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -37474,12 +38047,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 158 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 159 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -37557,7 +38130,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 + var isConstructor = signature.declaration.kind === 157 /* Constructor */ || signature.declaration.kind === 161 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -37571,7 +38144,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 134 /* NumberKeyword */ : 137 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 135 /* NumberKeyword */ : 138 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -37598,7 +38171,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 150 /* TypeParameter */); return decl && ts.getEffectiveConstraintOfTypeParameter(decl); } function getInferredTypeParameterConstraint(typeParameter) { @@ -37606,13 +38179,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 174 /* InferType */) { + if (declaration.parent.kind === 176 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), 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 grandParent = declaration.parent.parent; - if (grandParent.kind === 162 /* TypeReference */) { + if (grandParent.kind === 164 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -37637,7 +38210,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 151 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -37661,7 +38234,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 150 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -37794,9 +38367,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -37840,7 +38413,7 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : + res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { @@ -37897,13 +38470,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(8388608 /* Substitution */); + var result = createType(33554432 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 170 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -37912,9 +38485,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 291 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 175 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -37925,7 +38498,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 162 /* TypeReference */ || node.kind === 181 /* ImportType */); + return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 164 /* TypeReference */ || node.kind === 183 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -37983,7 +38556,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -38026,9 +38599,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 243 /* EnumDeclaration */: return declaration; } } @@ -38037,7 +38610,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 131072 /* Object */)) { + if (!(type.flags & 524288 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -38114,6 +38687,15 @@ var ts; function getGlobalExtractSymbol() { return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } + function getGlobalExcludeSymbol() { + return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalPickSymbol() { + return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + } + function getGlobalBigIntType(reportErrors) { + return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors)) || emptyObjectType; + } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ @@ -38162,7 +38744,7 @@ var ts; if (arity) { typeParameters = new Array(arity); for (var i = 0; i < arity; i++) { - var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + var typeParameter = typeParameters[i] = createType(262144 /* TypeParameter */); if (i < maxLength) { var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); property.type = typeParameter; @@ -38184,7 +38766,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(65536 /* TypeParameter */); + type.thisType = createType(262144 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -38219,8 +38801,8 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var restElement_1 = lastElement && lastElement.kind === 172 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 171 /* OptionalType */ && n !== restElement_1; }) + 1; var elementTypes = ts.map(node.elementTypes, function (n) { var type = getTypeFromTypeNode(n); return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; @@ -38267,16 +38849,17 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { + if (t.flags & 109440 /* Unit */ && combined & 109440 /* Unit */) { return true; } combined |= t.flags; - if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || - combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || - combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || - combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || - combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || - combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { + if (combined & 98304 /* Nullable */ && combined & (524288 /* Object */ | 67108864 /* NonPrimitive */) || + combined & 67108864 /* NonPrimitive */ && combined & (67238908 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || + combined & 132 /* StringLike */ && combined & (67238908 /* DisjointDomains */ & ~132 /* StringLike */) || + combined & 296 /* NumberLike */ && combined & (67238908 /* DisjointDomains */ & ~296 /* NumberLike */) || + combined & 2112 /* BigIntLike */ && combined & (67238908 /* DisjointDomains */ & ~2112 /* BigIntLike */) || + combined & 12288 /* ESSymbolLike */ && combined & (67238908 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || + combined & 49152 /* VoidLike */ && combined & (67238908 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return true; } } @@ -38284,20 +38867,18 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Union */) { + if (flags & 1048576 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + if (!(flags & 131072 /* Never */ || flags & 2097152 /* Intersection */ && isEmptyIntersectionType(type))) { includes |= flags & ~939524096 /* ConstructionFlags */; - if (flags & 3 /* AnyOrUnknown */) { - if (type === wildcardType) - includes |= 268435456 /* Wildcard */; - } - else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (type === wildcardType) + includes |= 268435456 /* Wildcard */; + if (!strictNullChecks && flags & 98304 /* Nullable */) { if (!(flags & 134217728 /* ContainsWideningType */)) includes |= 134217728 /* NonWideningType */; } @@ -38333,11 +38914,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 512 /* EnumLiteral */) { + if (first.flags & 1024 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -38362,10 +38943,11 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || - t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || - t.flags & 448 /* Literal */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 128 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || + t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38388,25 +38970,27 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + if (unionReduction !== 0 /* None */) { + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; + } + switch (unionReduction) { + case 1 /* Literal */: + if (includes & 8576 /* StringOrNumberLiteralOrUnique */ | 512 /* BooleanLiteral */) { + removeRedundantLiteralTypes(typeSet, includes); + } + break; + case 2 /* Subtype */: + removeSubtypes(typeSet); + break; + } + if (typeSet.length === 0) { + return includes & 65536 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : + neverType; + } } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & 2240 /* StringOrNumberLiteralOrUnique */ | 256 /* BooleanLiteral */) { - removeRedundantLiteralTypes(typeSet, includes); - } - break; - case 2 /* Subtype */: - removeSubtypes(typeSet); - break; - } - if (typeSet.length === 0) { - return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : - includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : - neverType; - } - return getUnionTypeFromSortedList(typeSet, includes & 16748579 /* NotPrimitiveUnion */ ? 0 : 67108864 /* UnionOfPrimitiveTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, !(includes & 66994211 /* NotPrimitiveUnion */), aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -38443,7 +39027,7 @@ var ts; : !ts.isIdentifierTypePredicate(b); } // This function assumes the constituent type list is sorted and deduplicated. - function getUnionTypeFromSortedList(types, unionOfUnitTypes, aliasSymbol, aliasTypeArguments) { + function getUnionTypeFromSortedList(types, primitiveTypesOnly, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { return neverType; } @@ -38453,10 +39037,11 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* Union */ | propagatedFlags); unionTypes.set(id, type); type.types = types; + type.primitiveTypesOnly = primitiveTypesOnly; /* Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. @@ -38478,11 +39063,14 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 536870912 /* EmptyObject */; + if (isEmptyAnonymousObjectType(type)) { + if (!(includes & 536870912 /* EmptyObject */)) { + includes |= 536870912 /* EmptyObject */; + typeSet.push(type); + } } else { includes |= flags & ~939524096 /* ConstructionFlags */; @@ -38490,7 +39078,7 @@ var ts; if (type === wildcardType) includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type)) { + else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !ts.contains(typeSet, type)) { typeSet.push(type); } } @@ -38510,9 +39098,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || - t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; + 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 */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -38525,10 +39114,11 @@ 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 & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - undefined; + var primitive = type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + undefined; if (!primitive || !containsType(u.types, primitive)) { return false; } @@ -38541,13 +39131,16 @@ 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 (t.flags & 67108864 /* UnionOfPrimitiveTypes */) !== 0; }); + var index = ts.findIndex(types, function (t) { return !!(t.flags & 1048576 /* Union */) && t.primitiveTypesOnly; }); + if (index < 0) { + return false; + } var i = index + 1; // Remove all but the first union of primitive types and collect them in // the unionTypes array. while (i < types.length) { var t = types[i]; - if (t.flags & 67108864 /* UnionOfPrimitiveTypes */) { + if (t.flags & 1048576 /* Union */ && t.primitiveTypesOnly) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -38576,7 +39169,7 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 67108864 /* UnionOfPrimitiveTypes */); + types[index] = getUnionTypeFromSortedList(result, /*primitiveTypesOnly*/ true); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -38592,22 +39185,23 @@ var ts; function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 32768 /* Never */) { + if (includes & 131072 /* Never */) { return neverType; } if (includes & 1 /* Any */) { return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 24576 /* Nullable */) { - return includes & 8192 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* Nullable */) { + return includes & 32768 /* Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || - includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || - includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { + 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 */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { - typeSet.push(emptyObjectType); + if (includes & 536870912 /* EmptyObject */ && includes & 524288 /* Object */) { + ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { return unknownType; @@ -38615,8 +39209,8 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 262144 /* Union */) { - if (includes & 67108864 /* UnionOfPrimitiveTypes */ && intersectUnionsOfPrimitiveTypes(typeSet)) { + if (includes & 1048576 /* 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. @@ -38624,15 +39218,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); - type = createType(524288 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(2097152 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -38649,7 +39243,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(1048576 /* Index */); + var result = createType(4194304 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -38659,14 +39253,22 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } - function getLiteralTypeFromPropertyName(prop, include) { + function getLiteralTypeFromPropertyName(name) { + return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) : + getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); + } + function getBigIntLiteralType(node) { + return getLiteralType({ + negative: false, + base10Value: ts.parsePseudoBigInt(node.text) + }); + } + function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : - getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { return type; @@ -38674,8 +39276,8 @@ var ts; } return neverType; } - function getLiteralTypeFromPropertyNames(type, include) { - return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromPropertyName(t, include); })); + function getLiteralTypeFromProperties(type, include) { + return getUnionType(ts.map(getPropertiesOfType(type), function (t) { return getLiteralTypeFromProperty(t, include); })); } function getNonEnumNumberIndexInfo(type) { var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); @@ -38683,16 +39285,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromProperties(type, 128 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 /* StringLiteral */ | 8192 /* UniqueESSymbol */)]) : + getLiteralTypeFromProperties(type, 8576 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -38703,17 +39305,17 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 32768 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 128 /* KeyOfKeyword */: + case 129 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 141 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ + case 142 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 139 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; @@ -38722,7 +39324,7 @@ var ts; return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(2097152 /* IndexedAccess */); + var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; @@ -38743,28 +39345,32 @@ var ts; if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { return true; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { return isJSLiteralType(getResolvedBaseConstraint(type)); } return false; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol, missingType) { - var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; - var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - undefined; + var accessExpression = accessNode && accessNode.kind === 190 /* ElementAccessExpression */ ? accessNode : undefined; + var propName = isTypeUsableAsLateBoundName(indexType) + ? getLateBoundNameFromType(indexType) + : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) + ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) + : accessNode && ts.isPropertyName(accessNode) + // late bound names are handled in the first branch, so here we only need to handle normal names + ? ts.getPropertyNameForPropertyNameNode(accessNode) + : undefined; if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 100 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); return missingType; @@ -38780,22 +39386,22 @@ var ts; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; })) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; }); } } - if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 32768 /* Never */)) { + if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { + if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -38803,7 +39409,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 32768 /* Never */) { + if (indexType.flags & 131072 /* Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -38836,8 +39442,8 @@ var ts; return anyType; } if (accessNode) { - var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { + var indexNode = getIndexNodeForAccessExpression(accessNode); + if (indexType.flags & (128 /* StringLiteral */ | 256 /* 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 */)) { @@ -38852,14 +39458,33 @@ var ts; } return missingType; } + function getIndexNodeForAccessExpression(accessNode) { + return accessNode.kind === 190 /* ElementAccessExpression */ + ? accessNode.argumentExpression + : accessNode.kind === 180 /* IndexedAccessType */ + ? accessNode.indexType + : accessNode.kind === 149 /* ComputedPropertyName */ + ? accessNode.expression + : accessNode; + } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); + return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */); } function getSimplifiedType(type) { - return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + } + function distributeIndexOverObjectType(objectType, indexType) { + // (T | U)[K] -> T[K] | U[K] + if (objectType.flags & 1048576 /* Union */) { + return mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); + } + // (T & U)[K] -> T[K] & U[K] + if (objectType.flags & 2097152 /* Intersection */) { + return getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + } } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -38873,18 +39498,14 @@ var ts; var objectType = getSimplifiedType(type.objectType); var indexType = getSimplifiedType(type.indexType); // T[A | B] -> T[A] | T[B] - if (indexType.flags & 262144 /* Union */) { + if (indexType.flags & 1048576 /* Union */) { return type.simplified = mapType(indexType, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t)); }); } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 15794176 /* Instantiable */)) { - // (T | U)[K] -> T[K] | U[K] - if (objectType.flags & 262144 /* Union */) { - return type.simplified = mapType(objectType, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); }); - } - // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 524288 /* Intersection */) { - return type.simplified = getIntersectionType(ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType)); })); + if (!(indexType.flags & 63176704 /* Instantiable */)) { + var simplified = distributeIndexOverObjectType(objectType, indexType); + if (simplified) { + return type.simplified = simplified; } } // So ultimately: @@ -38896,7 +39517,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 65536 /* TypeParameter */) { + if (objectType.flags & 262144 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -38919,7 +39540,7 @@ var ts; // 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 === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 180 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -38935,7 +39556,7 @@ 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 = getApparentType(objectType); - if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { @@ -38966,7 +39587,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -38988,7 +39609,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; + return type.flags & 33554432 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -38999,7 +39620,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 63176704 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -39038,7 +39659,7 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(4194304 /* Conditional */); + var result = createType(16777216 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -39070,7 +39691,7 @@ var ts; return true; } while (node) { - if (node.kind === 173 /* ConditionalType */) { + if (node.kind === 175 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -39093,7 +39714,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -39213,6 +39834,9 @@ var ts; function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } + function isNonGenericObjectType(type) { + return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + } /** * Since the source of spread types are object literals, which are not binary, * this function should be called in a left folding style, with left = previous result of getSpreadType @@ -39225,21 +39849,37 @@ var ts; if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { return unknownType; } - if (left.flags & 32768 /* Never */) { + if (left.flags & 131072 /* Never */) { return right; } - if (right.flags & 32768 /* Never */) { + if (right.flags & 131072 /* Never */) { return left; } - if (left.flags & 262144 /* Union */) { + if (left.flags & 1048576 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 262144 /* Union */) { + if (right.flags & 1048576 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { + if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { return left; } + if (isGenericObjectType(left) || isGenericObjectType(right)) { + if (isEmptyObjectType(left)) { + return right; + } + // 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 */) { + var types = left.types; + var lastLeft = types[types.length - 1]; + if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { + return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, typeFlags, objectFlags)])); + } + } + return getIntersectionType([left, right]); + } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); var stringIndexInfo; @@ -39259,7 +39899,7 @@ var ts; skippedPrivateMembers.set(rightProp.escapedName, true); } else if (isSpreadableProperty(rightProp)) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSpreadSymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -39274,7 +39914,7 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -39283,27 +39923,28 @@ var ts; } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSpreadSymbol(leftProp)); } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; - spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); + spread.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 1024 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */) - ? !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }) - : !(prop.flags & 65536 /* SetAccessor */); // Setter without getter is not spreadable + return !(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }); } - function getNonReadonlySymbol(prop) { - if (!isReadonlySymbol(prop)) { + function getSpreadSymbol(prop) { + var isReadonly = isReadonlySymbol(prop); + var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (!isReadonly && !isSetonlyAccessor) { return prop; } var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); var result = createSymbol(flags, prop.escapedName); - result.type = getTypeOfSymbol(prop); + result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = prop.nameType; result.syntheticOrigin = prop; @@ -39322,10 +39963,11 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 448 /* Literal */ && !(type.flags & 33554432 /* FreshLiteral */)) { - if (!type.freshType) { // NOTE: Safe because all freshable intrinsics always have fresh types already - var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); + if (type.flags & 2944 /* Literal */) { + if (!type.freshType) { + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; + freshType.freshType = freshType; type.freshType = freshType; } return type.freshType; @@ -39333,21 +39975,27 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + return type.flags & 2944 /* Literal */ ? type.regularType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : type; } + function isFreshLiteralType(type) { + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', // where NNN is the text representation of a numeric literal and SSS are the characters // of a string literal. For literal enum members we use 'EEE#NNN' and 'EEE@SSS', where // EEE is a unique id for the containing enum type. - var qualifier = typeof value === "number" ? "#" : "@"; - var key = enumId ? enumId + qualifier + value : qualifier + value; + var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; + var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value); var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 256 /* NumberLiteral */ : + typeof value === "string" ? 128 /* StringLiteral */ : 2048 /* BigIntLiteral */) | + (enumId ? 1024 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); + type.regularType = type; } return type; } @@ -39359,7 +40007,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(2048 /* UniqueESSymbol */); + var type = createType(8192 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -39374,9 +40022,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 241 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 157 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -39392,87 +40040,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 119 /* AnyKeyword */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: + case 120 /* AnyKeyword */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: return anyType; - case 142 /* UnknownKeyword */: + case 143 /* UnknownKeyword */: return unknownType; - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return stringType; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return numberType; - case 122 /* BooleanKeyword */: + case 146 /* BigIntKeyword */: + return bigintType; + case 123 /* BooleanKeyword */: return booleanType; - case 138 /* SymbolKeyword */: + case 139 /* SymbolKeyword */: return esSymbolType; - case 105 /* VoidKeyword */: + case 106 /* VoidKeyword */: return voidType; - case 140 /* UndefinedKeyword */: + case 141 /* UndefinedKeyword */: return undefinedType; - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullType; - case 131 /* NeverKeyword */: + case 132 /* NeverKeyword */: return neverType; - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 176 /* ThisType */: - case 99 /* ThisKeyword */: + case 178 /* ThisType */: + case 100 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return getTypeFromTypeReference(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return booleanType; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 175 /* ParenthesizedType */: - case 170 /* RestType */: - case 285 /* JSDocNonNullableType */: - case 281 /* JSDocTypeExpression */: + case 177 /* ParenthesizedType */: + case 172 /* RestType */: + case 287 /* JSDocNonNullableType */: + case 283 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 166 /* TypeLiteral */: - case 290 /* JSDocTypeLiteral */: - case 287 /* JSDocFunctionType */: - case 291 /* JSDocSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 168 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 289 /* JSDocFunctionType */: + case 293 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 174 /* InferType */: + case 176 /* InferType */: return getTypeFromInferTypeNode(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 71 /* Identifier */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 148 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -39553,10 +40203,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; + return type.flags & 262144 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(65536 /* TypeParameter */); + var result = createType(262144 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -39602,7 +40252,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -39682,8 +40332,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 146 /* QualifiedName */ || - node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 148 /* QualifiedName */ || + node.parent.kind === 164 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -39691,19 +40341,19 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 218 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 176 /* ThisType */: + case 178 /* ThisType */: return !!tp.isThisType; - case 71 /* Identifier */: + case 72 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -39711,9 +40361,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 1048576 /* Index */) { + if (constraintType.flags & 4194304 /* Index */) { var typeVariable = constraintType.type; - if (typeVariable.flags & 65536 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeParameter */) { return typeVariable; } } @@ -39743,7 +40393,7 @@ var ts; } type.instantiating = true; var result = mapType(mappedTypeVariable, function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */) && t !== wildcardType) { + if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType) { var replacementMapper = createReplacementMapper(typeVariable, t, mapper); return isArrayType(t) ? createArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : isReadonlyArrayType(t) ? createReadonlyArrayType(instantiateMappedTypeTemplate(type, numberType, /*isOptional*/ true, replacementMapper)) : @@ -39774,7 +40424,7 @@ var ts; var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 131072 /* NEUndefined */) : + strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper) { @@ -39819,7 +40469,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -39842,10 +40492,10 @@ var ts; } function instantiateTypeWorker(type, mapper) { var flags = type.flags; - if (flags & 65536 /* TypeParameter */) { + if (flags & 262144 /* TypeParameter */) { return mapper(type); } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or @@ -39864,32 +40514,32 @@ var ts; } return type; } - if (flags & 262144 /* Union */ && !(flags & 32764 /* Primitive */)) { + if (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 524288 /* Intersection */) { + if (flags & 2097152 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (flags & 1048576 /* Index */) { + if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } return type; } function getWildcardInstantiation(type) { - return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : + return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -39898,34 +40548,34 @@ 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 !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 202 /* BinaryExpression */: - return node.operatorToken.kind === 54 /* BarBarToken */ && + case 204 /* BinaryExpression */: + return node.operatorToken.kind === 55 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 266 /* JsxAttributes */: - return ts.some(node.properties, isContextSensitive); - case 265 /* JsxAttribute */: { + case 268 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); + case 267 /* 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 268 /* JsxExpression */: { + case 270 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -39942,7 +40592,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 195 /* ArrowFunction */) { + if (node.kind !== 197 /* 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); @@ -39955,14 +40605,14 @@ var ts; function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 216 /* Block */ ? false : isContextSensitive(body); + return body.kind === 218 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -39973,7 +40623,7 @@ var ts; return result; } } - else if (type.flags & 524288 /* Intersection */) { + else if (type.flags & 2097152 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -39988,6 +40638,9 @@ var ts; function compareTypesAssignable(source, target) { return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; } + function compareTypesSubtypeOf(source, target) { + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); } @@ -40003,11 +40656,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : - target === globalObjectType ? !!(source.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 131072 /* Object */) && isFunctionObjectType(source) : + 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) || emptyObjectType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)); } /** @@ -40045,7 +40698,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 4194304 /* Conditional */ || (type.flags & 524288 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage) { if (!node || isOrHasGenericConditional(target)) @@ -40054,23 +40707,23 @@ var ts; return true; } switch (node.kind) { - case 268 /* JsxExpression */: - case 193 /* ParenthesizedExpression */: + case 270 /* JsxExpression */: + case 195 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: - case 26 /* CommaToken */: + case 59 /* EqualsToken */: + case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage); } break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return elaborateJsxAttributes(node, source, target, relation); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation); } return false; @@ -40082,7 +40735,7 @@ var ts; var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 32768 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = {}; checkTypeAssignableTo(source, target, node, headMessage, /*containingChain*/ undefined, resultObj); @@ -40139,8 +40792,10 @@ var ts; var reportedError = false; 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 sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); var targetPropType = getIndexedAccessType(target, nameType, /*accessNode*/ undefined, errorType); + if (targetPropType === errorType || targetPropType.flags & 8388608 /* IndexedAccess */) + continue; // Don't elaborate on indexes on generic variables + var sourcePropType = getIndexedAccessType(source, nameType, /*accessNode*/ undefined, errorType); if (sourcePropType !== errorType && targetPropType !== errorType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined); if (elaborated) { @@ -40162,7 +40817,7 @@ var ts; var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; var issuedElaboration = false; if (!targetProp) { - var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(nameType, 296 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || getIndexInfoOfType(target, 0 /* String */) || undefined; if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) { @@ -40173,7 +40828,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) { - addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + 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))); } } } @@ -40266,17 +40921,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 32768 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 157 /* SetAccessor */: return [3 /*break*/, 2]; - case 156 /* GetAccessor */: return [3 /*break*/, 2]; - case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 159 /* SetAccessor */: return [3 /*break*/, 2]; + case 158 /* GetAccessor */: return [3 /*break*/, 2]; + case 156 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 276 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 275 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -40335,8 +40990,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && - kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 156 /* MethodDeclaration */ && + kind !== 155 /* MethodSignature */ && kind !== 157 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -40370,7 +41025,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); + (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : @@ -40462,12 +41117,15 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 16777216 /* NonPrimitive */ ? true : - type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 524288 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* Object */ ? 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) : false; } + function isEmptyAnonymousObjectType(type) { + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && isEmptyObjectType(type); + } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { if (sourceSymbol === targetSymbol) { return true; @@ -40504,43 +41162,45 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) return true; - if (t & 32768 /* Never */) + if (t & 131072 /* Never */) return false; - if (s & 68 /* StringLike */ && t & 4 /* String */) + if (s & 132 /* StringLike */ && t & 4 /* String */) return true; - if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && - t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && + t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 168 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && - t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && + if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && + t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) return true; - if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) + if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + return true; + if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) return true; if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { - if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { + if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 448 /* Literal */ && t & 448 /* Literal */ && + if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) + if (s & 32768 /* Undefined */ && (!strictNullChecks || t & (32768 /* Undefined */ | 16384 /* Void */))) return true; - if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) + if (s & 65536 /* Null */ && (!strictNullChecks || t & 65536 /* Null */)) return true; - if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) + if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */) return true; - if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) + if (s & 8192 /* UniqueESSymbol */ || t & 8192 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -40548,30 +41208,30 @@ var ts; // 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 */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { + if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { + if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -40591,6 +41251,7 @@ var ts; */ function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; + var relatedInfo; var maybeKeys; var sourceStack; var targetStack; @@ -40598,7 +41259,7 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var isIntersectionConstituent = false; + var suppressNextError = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (overflow) { @@ -40625,15 +41286,27 @@ var ts; } } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (relatedInfo) { + addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + } if (errorOutputContainer) { errorOutputContainer.error = diag; } diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { + function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); + } + function associateRelatedInfo(info) { + ts.Debug.assert(!!errorInfo); + if (!relatedInfo) { + relatedInfo = [info]; + } + else { + relatedInfo.push(info); + } } function reportRelationError(message, source, target) { var sourceType = typeToString(source); @@ -40666,7 +41339,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 786432 /* UnionOrIntersection */)) { + if (!(type.flags & 3145728 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -40674,7 +41347,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 24576 /* Nullable */) { + if (t.flags & 98304 /* Nullable */) { continue; } if (seenNonNullable) { @@ -40690,24 +41363,24 @@ var ts; * * Ternary.Maybe if they are related with assumptions of other relationships, or * * Ternary.False if they are not related. */ - function isRelatedTo(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage, isApparentIntersectionConstituent) { if (reportErrors === void 0) { reportErrors = false; } - if (source.flags & 448 /* Literal */ && source.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(source)) { source = source.regularType; } - if (target.flags & 448 /* Literal */ && target.flags & 33554432 /* FreshLiteral */) { + if (isFreshLiteralType(target)) { target = target.regularType; } - if (source.flags & 8388608 /* Substitution */) { + if (source.flags & 33554432 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 8388608 /* Substitution */) { + if (target.flags & 33554432 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8388608 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 2097152 /* IndexedAccess */) { + if (target.flags & 8388608 /* IndexedAccess */) { target = getSimplifiedType(target); } // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. @@ -40719,10 +41392,10 @@ var ts; // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" // when dealing with generics. // * We also don't deal with primitive source types, since we already halt elaboration below. - if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && - target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { - var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); - if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); + if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { target = nullStrippedTarget; } } @@ -40732,11 +41405,12 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { - var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + if (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */) { + var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -40751,11 +41425,11 @@ var ts; source = getRegularTypeOfObjectLiteral(source); } } - if (relation !== comparableRelation && !isIntersectionConstituent && - source.flags & (32764 /* Primitive */ | 131072 /* Object */ | 524288 /* Intersection */) && source !== globalObjectType && - target.flags & (131072 /* Object */ | 524288 /* Intersection */) && isWeakType(target) && + if (relation !== comparableRelation && !isApparentIntersectionConstituent && + source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && + target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && - !hasCommonProperties(source, target)) { + !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -40771,25 +41445,24 @@ var ts; } var result = 0 /* False */; var saveErrorInfo = errorInfo; - var saveIsIntersectionConstituent = isIntersectionConstituent; - isIntersectionConstituent = false; + var isIntersectionConstituent = !!isApparentIntersectionConstituent; // 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 & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { - if (target.flags & 262144 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); + if (target.flags & 1048576 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); } - else if (target.flags & 524288 /* Intersection */) { - isIntersectionConstituent = true; + else if (target.flags & 2097152 /* Intersection */) { + isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 524288 /* Intersection */) { + else if (source.flags & 2097152 /* Intersection */) { // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually @@ -40805,13 +41478,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { - if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { + if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 524288 /* Intersection */) { + if (!result && source.flags & 2097152 /* Intersection */) { // 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 @@ -40821,22 +41494,23 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { + if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { errorInfo = saveErrorInfo; } } } - isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { + var maybeSuppress = suppressNextError; + suppressNextError = false; + if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* 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) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -40846,6 +41520,10 @@ var ts; return result; } } + if (!headMessage && maybeSuppress) { + // Used by, eg, missing property checking to replace the top-level message with a more informative one + return result; + } reportRelationError(headMessage, source, target); } return result; @@ -40853,10 +41531,10 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 131072 /* Object */ || flags & 2097152 /* IndexedAccess */ || flags & 4194304 /* Conditional */ || flags & 1048576 /* Index */ || flags & 8388608 /* Substitution */) { - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); + if (flags & 524288 /* Object */ || flags & 8388608 /* IndexedAccess */ || flags & 16777216 /* Conditional */ || flags & 4194304 /* Index */ || flags & 33554432 /* Substitution */) { + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); } - if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { + if (flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; @@ -40869,7 +41547,7 @@ var ts; if (!noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 524288 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -40880,16 +41558,17 @@ var ts; return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } var _loop_6 = function (prop) { - if (!isPropertyFromSpread(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { + if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. if (!errorNode) return { value: ts.Debug.fail() }; - if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. + // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -40925,8 +41604,8 @@ var ts; } return false; } - function isPropertyFromSpread(prop, container) { - return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent !== container.valueDeclaration; + function shouldCheckAsExcessProperty(prop, container) { + return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration; } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; @@ -40943,7 +41622,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -40964,9 +41643,9 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 131072 /* Object */) { + if (target.flags & 524288 /* Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); if (overlapObjFlags & 4 /* Reference */) { return source.target === target.target; @@ -40994,11 +41673,13 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - if (sourceProperties) { - var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); - if (sourcePropertiesFiltered) { - return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + if (target.flags & 1048576 /* Union */) { + var sourceProperties = getPropertiesOfObjectType(source); + if (sourceProperties) { + var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); + if (sourcePropertiesFiltered) { + return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + } } } return undefined; @@ -41008,7 +41689,7 @@ var ts; 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, reportErrors); + var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, /*isIntersectionConstituent*/ true); if (!related) { return 0 /* False */; } @@ -41018,7 +41699,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -41043,9 +41724,10 @@ var ts; } return result; } - function typeArgumentsRelatedTo(source, target, variances, reportErrors) { - var sources = source.typeArguments || ts.emptyArray; - var targets = target.typeArguments || ts.emptyArray; + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + if (sources === void 0) { sources = ts.emptyArray; } + if (targets === void 0) { targets = ts.emptyArray; } + if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { return 0 /* False */; } @@ -41099,7 +41781,7 @@ var ts; // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function recursiveTypeRelatedTo(source, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0 /* False */; } @@ -41142,7 +41824,7 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; - var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -41165,21 +41847,21 @@ var ts; function getConstraintForRelation(type) { return relation === definitelyAssignableRelation ? undefined : getConstraintOfType(type); } - function structuredTypeRelatedTo(source, target, reportErrors) { + function structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { var flags = source.flags & target.flags; - if (relation === identityRelation && !(flags & 131072 /* Object */)) { - if (flags & 1048576 /* Index */) { + if (relation === identityRelation && !(flags & 524288 /* Object */)) { + if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } var result_2 = 0 /* False */; - if (flags & 2097152 /* IndexedAccess */) { + if (flags & 8388608 /* IndexedAccess */) { if (result_2 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result_2; } } } - if (flags & 4194304 /* Conditional */) { + if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result_2 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result_2 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -41192,7 +41874,7 @@ var ts; } } } - if (flags & 8388608 /* Substitution */) { + if (flags & 33554432 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; @@ -41200,9 +41882,22 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 65536 /* TypeParameter */) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + // 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 (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && + source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && + !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { + var variances = getAliasVariances(source.aliasSymbol); + if (result = typeArgumentsRelatedTo(source.aliasTypeArguments, target.aliasTypeArguments, variances, reportErrors)) { + return result; + } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; + } + if (target.flags & 262144 /* 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 */ && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); @@ -41212,9 +41907,9 @@ var ts; } } } - else if (target.flags & 1048576 /* Index */) { + else if (target.flags & 4194304 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 1048576 /* Index */) { + if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -41235,7 +41930,7 @@ var ts; } } } - else if (target.flags & 2097152 /* IndexedAccess */) { + else if (target.flags & 8388608 /* IndexedAccess */) { // A type S is related to a type T[K], where T and K aren't both type variables, if S is related to C, // where C is the base constraint of T[K] if (relation !== identityRelation && !(isGenericObjectType(target.objectType) && isGenericIndexType(target.indexType))) { @@ -41252,22 +41947,24 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 8388608 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (!isGenericMappedType(source) && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + // A source type T is related to a target type { [P in Q]: X } if Q is related to keyof T and T[Q] is related to X. + if (!isGenericMappedType(source) && isRelatedTo(getConstraintTypeFromMappedType(target), getIndexType(source))) { var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { return result; } } + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; } } - if (source.flags & 2162688 /* TypeVariable */) { - if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + if (source.flags & 8650752 /* TypeVariable */) { + if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { // 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, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); @@ -41278,29 +41975,32 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { + if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } } - else { - var instantiated = getTypeWithThisArgument(constraint, source); - if (result = isRelatedTo(instantiated, target, reportErrors)) { - errorInfo = 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, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = 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, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { + errorInfo = saveErrorInfo; + return result; } } - else if (source.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 4194304 /* Conditional */) { - if (target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */) { + if (target.flags & 16777216 /* 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. @@ -41349,7 +42049,7 @@ var ts; if (relation === definitelyAssignableRelation && isGenericMappedType(source)) { return 0 /* False */; } - var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } @@ -41359,7 +42059,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - if (result = typeArgumentsRelatedTo(source, target, variances, reportErrors)) { + if (result = typeArgumentsRelatedTo(source.typeArguments, target.typeArguments, variances, reportErrors)) { return result; } // The type arguments did not relate appropriately, but it may be because we have no variance @@ -41394,7 +42094,7 @@ var ts; // 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 (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors); @@ -41444,7 +42144,24 @@ var ts; var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties)); + if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code && + headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) { + suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it + } + if (props.length === 1) { + var propName = symbolToString(unmatchedProperty); + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, typeToString(source), typeToString(target)); + if (ts.length(unmatchedProperty.declarations)) { + associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); + } + } + else if (props.length > 5) { // arbitrary cutoff for too-long list form + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, typeToString(source), typeToString(target), ts.map(props.slice(0, 4), function (p) { return symbolToString(p); }).join(", "), props.length - 4); + } + else { + reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); + } } return 0 /* False */; } @@ -41491,8 +42208,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { - var targetProp = properties_3[_b]; + for (var _b = 0, properties_2 = properties; _b < properties_2.length; _b++) { + var targetProp = properties_2[_b]; if (!(targetProp.flags & 4194304 /* Prototype */)) { var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp && sourceProp !== targetProp) { @@ -41563,7 +42280,7 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { + if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -41691,7 +42408,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 8192 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -41810,20 +42527,19 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 524288 /* Intersection */) { + if (type.flags & 2097152 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; } - function hasCommonProperties(source, target) { - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + function hasCommonProperties(source, target, isComparingJsxAttributes) { for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { @@ -41839,62 +42555,71 @@ var ts; result.objectFlags |= 8192 /* MarkerType */; return result; } + 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 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 if we're not in strictFunctionTypes mode or if the function // has been invoked recursively for the given generic type. + function getVariancesWorker(typeParameters, cache, createMarkerType) { + if (typeParameters === void 0) { typeParameters = ts.emptyArray; } + var variances = cache.variances; + if (!variances) { + // The emptyArray singleton is used to signal a recursive invocation. + cache.variances = ts.emptyArray; + variances = []; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var tp = typeParameters_1[_i]; + // 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 */; + } + variances.push(variance); + } + cache.variances = variances; + } + return variances; + } function getVariances(type) { if (!strictFunctionTypes) { return ts.emptyArray; } - var typeParameters = type.typeParameters || ts.emptyArray; - var variances = type.variances; - if (!variances) { - if (type === globalArrayType || type === globalReadonlyArrayType) { - // Arrays are known to be covariant, no need to spend time computing this - variances = [1 /* Covariant */]; - } - else { - // The emptyArray singleton is used to signal a recursive invocation. - type.variances = ts.emptyArray; - variances = []; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - // 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 = getMarkerTypeReference(type, tp, markerSuperType); - var typeWithSub = getMarkerTypeReference(type, 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(getMarkerTypeReference(type, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; - } - variances.push(variance); - } - } - type.variances = variances; + if (type === globalArrayType || type === globalReadonlyArrayType) { + // Arrays are known to be covariant, no need to spend time computing this (emptyArray implies covariance for all parameters) + return ts.emptyArray; } - return variances; + return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference); } // 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(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 16384 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 65536 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); @@ -41987,13 +42712,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 131072 /* Object */) { + if (depth >= 5 && type.flags & 524288 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 131072 /* Object */ && t.symbol === symbol) { + if (t.flags & 524288 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -42099,7 +42824,7 @@ var ts; for (var i = 0; i < targetLen; i++) { var s = getTypeAtPosition(source, i); var t = getTypeAtPosition(target, i); - var related = compareTypes(s, t); + var related = compareTypes(t, s); if (!related) { return 0 /* False */; } @@ -42144,9 +42869,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -42163,7 +42888,7 @@ var ts; // 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 return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -42183,35 +42908,37 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); + return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 27072 /* Unit */); + return !!(type.flags & 109440 /* Unit */); } function isLiteralType(type) { return type.flags & 16 /* Boolean */ ? true : - type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : - type; + return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* StringLiteral */ ? stringType : + type.flags & 256 /* NumberLiteral */ ? numberType : + type.flags & 2048 /* BigIntLiteral */ ? bigintType : + type.flags & 512 /* BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + type; } function getWidenedLiteralType(type) { - return type.flags & 512 /* EnumLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : - type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : - type.flags & 256 /* BooleanLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? booleanType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, 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 */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -42237,6 +42964,10 @@ var ts; function getLengthOfTupleType(type) { return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); } + function isZeroBigInt(_a) { + var value = _a.value; + return value.base10Value === "0"; + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -42249,15 +42980,16 @@ 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 & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : - type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : - type.flags & 256 /* BooleanLiteral */ ? (type === falseType || type === regularFalseType) ? 256 /* BooleanLiteral */ : 0 : - type.flags & 29148 /* PossiblyFalsy */; + 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 */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 117632 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { @@ -42266,12 +42998,14 @@ var ts; function getDefinitelyFalsyPartOfType(type) { return type.flags & 4 /* String */ ? emptyStringType : type.flags & 8 /* Number */ ? zeroType : - type === regularFalseType || - type === falseType || - type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || - type.flags & 64 /* StringLiteral */ && type.value === "" || - type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : - neverType; + type.flags & 64 /* BigInt */ ? zeroBigIntType : + type === regularFalseType || + type === falseType || + type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */) || + type.flags & 128 /* StringLiteral */ && type.value === "" || + type.flags & 256 /* NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + neverType; } /** * Add undefined or null or both to a type if they are missing. @@ -42279,15 +43013,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); return missing === 0 ? type : - missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 16384 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -42297,7 +43031,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -42340,7 +43074,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -42350,7 +43084,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; + regularNew.flags = resolved.flags; regularNew.objectFlags |= 128 /* ObjectLiteral */ | (ts.getObjectFlags(resolved) & 16384 /* JSLiteral */); type.regularType = regularNew; return regularNew; @@ -42438,15 +43172,15 @@ var ts; } function getWidenedTypeWithContext(type, context) { if (type.flags & 402653184 /* RequiresWidening */) { - if (type.flags & 24576 /* Nullable */) { + if (type.flags & 98304 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* 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 {}). @@ -42472,7 +43206,7 @@ var ts; function reportWideningErrorsInType(type) { var errorReported = false; if (type.flags & 134217728 /* ContainsWideningType */) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -42516,39 +43250,42 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 202 /* BinaryExpression */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; + case 204 /* BinaryExpression */: + case 154 /* PropertyDeclaration */: + case 153 /* 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 149 /* Parameter */: + case 151 /* Parameter */: diagnostic = declaration.dotDotDotToken ? - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; + 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 184 /* BindingElement */: + case 186 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 237 /* FunctionDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 289 /* JSDocFunctionType */: + error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); + return; + case 239 /* FunctionDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } - diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; + diagnostic = noImplicitAny ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type : ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage; break; - case 179 /* MappedType */: + case 181 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } return; default: - diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; + diagnostic = noImplicitAny ? ts.Diagnostics.Variable_0_implicitly_has_an_1_type : ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; } errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } @@ -42627,11 +43364,11 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 15794176 /* Instantiable */ || + return !!(type.flags & 63176704 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -42640,13 +43377,13 @@ var ts; return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 3145728 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, 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 & 64 /* StringLiteral */)) { + if (!(t.flags & 128 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -42667,25 +43404,25 @@ var ts; * property is computed by inferring from the source property type to X for the type * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ - function inferTypeForHomomorphicMappedType(source, target) { - var key = source.id + "," + target.id; + function inferTypeForHomomorphicMappedType(source, target, constraint) { + var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } reverseMappedCache.set(key, undefined); - var type = createReverseMappedType(source, target); + var type = createReverseMappedType(source, target, constraint); reverseMappedCache.set(key, type); return type; } - function createReverseMappedType(source, target) { + function createReverseMappedType(source, target, constraint) { var properties = getPropertiesOfType(source); if (properties.length === 0 && !getIndexInfoOfType(source, 0 /* String */)) { return undefined; } // If any property contains context sensitive functions that have been skipped, the source type // is incomplete and we can't infer a meaningful input type. - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var prop = properties_3[_i]; if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } @@ -42693,13 +43430,13 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isReadonlyArrayType(source)) { - return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target)); + return createReadonlyArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target); }); + var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.associatedNames); @@ -42709,30 +43446,46 @@ var ts; var reversed = createObjectType(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; + reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType); + return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); } - function inferReverseMappedType(sourceType, target) { - var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target)); + function inferReverseMappedType(sourceType, target, constraint) { + var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); var templateType = getTemplateTypeFromMappedType(target); var inference = createInferenceInfo(typeParameter); inferTypes([inference], sourceType, templateType); return getTypeFromInference(inference); } - function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; - if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (!sourceProp) { - return targetProp; - } + function getUnmatchedProperties(source, target, requireOptionalProperties) { + var properties, _i, properties_4, targetProp, sourceProp; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + properties = target.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + _i = 0, properties_4 = properties; + _a.label = 1; + case 1: + if (!(_i < properties_4.length)) return [3 /*break*/, 4]; + targetProp = properties_4[_i]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */))) return [3 /*break*/, 3]; + sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (!!sourceProp) return [3 /*break*/, 3]; + return [4 /*yield*/, targetProp]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; } - } - return undefined; + }); + } + function getUnmatchedProperty(source, target, requireOptionalProperties) { + return getUnmatchedProperties(source, target, requireOptionalProperties).next().value; } function tupleTypesDefinitelyUnrelated(source, target) { return target.target.minLength > source.target.minLength || @@ -42782,8 +43535,8 @@ var ts; } return; } - if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || - source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { + if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && !(source.flags & 1024 /* EnumLiteral */ && target.flags & 1024 /* EnumLiteral */) || + source.flags & 2097152 /* Intersection */ && target.flags & 2097152 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -42806,7 +43559,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { + else if (t.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -42821,7 +43574,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 2162688 /* TypeVariable */) { + if (target.flags & 8650752 /* 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 @@ -42829,7 +43582,7 @@ 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.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType || (priority & 8 /* ReturnType */ && (source === autoType || source === autoArrayType))) { return; } var inference = getInferenceInfoForType(target); @@ -42851,12 +43604,30 @@ var ts; inference.candidates = ts.appendIfUnique(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } return; } + else { + // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine + var simplified = getSimplifiedType(target); + if (simplified !== target) { + inferFromTypesOnce(source, simplified); + } + else if (target.flags & 8388608 /* IndexedAccess */) { + var indexType = getSimplifiedType(target.indexType); + // 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 & 63176704 /* Instantiable */) { + var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType), indexType); + if (simplified_1 && simplified_1 !== target) { + inferFromTypesOnce(source, simplified_1); + } + } + } + } } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { // If source and target are references to the same generic type, infer from type arguments @@ -42873,12 +43644,12 @@ var ts; } } } - else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { + else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -42887,20 +43658,20 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { + else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { + else if (source.flags & 16777216 /* Conditional */ && target.flags & 16777216 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 4194304 /* Conditional */) { + else if (target.flags & 16777216 /* Conditional */) { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } - else if (target.flags & 786432 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -42925,7 +43696,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 262144 /* Union */) { + else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -42934,12 +43705,12 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 63176704 /* 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 & (131072 /* Object */ | 524288 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* 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 @@ -42952,7 +43723,7 @@ var ts; } source = apparentSource; } - if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { + if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -42962,7 +43733,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 131072 /* Object */ && + var isNonConstructorObject = target.flags & 524288 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -42978,6 +43749,13 @@ var ts; } } } + function inferFromTypesOnce(source, target) { + var key = source.id + "," + target.id; + if (!visited || !visited.get(key)) { + (visited || (visited = ts.createMap())).set(key, true); + inferFromTypes(source, target); + } + } } function inferFromContravariantTypes(source, target) { if (strictFunctionTypes || priority & 64 /* AlwaysStrict */) { @@ -42990,7 +43768,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 2162688 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -43000,6 +43778,44 @@ var ts; } return undefined; } + function inferFromMappedTypeConstraint(source, target, constraintType) { + if (constraintType.flags & 1048576 /* Union */) { + var result = false; + for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { + var type = _a[_i]; + result = inferFromMappedTypeConstraint(source, target, type) || result; + } + return result; + } + if (constraintType.flags & 4194304 /* 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 + // such that direct inferences to T get priority over inferences to Partial, for example. + var inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + var savePriority = priority; + priority |= 2 /* HomomorphicMappedType */; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + return true; + } + if (constraintType.flags & 262144 /* TypeParameter */) { + // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type + // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. + var savePriority = priority; + priority |= 4 /* MappedTypeConstraint */; + inferFromTypes(getIndexType(source), constraintType); + priority = savePriority; + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return true; + } + return false; + } function inferFromObjectTypes(source, target) { if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer @@ -43009,31 +43825,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 1048576 /* 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 - // such that direct inferences to T get priority over inferences to Partial, for example. - var inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - var inferredType = inferTypeForHomomorphicMappedType(source, target); - if (inferredType) { - var savePriority = priority; - priority |= 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - return; - } - if (constraintType.flags & 65536 /* TypeParameter */) { - // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type - // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. - var savePriority = priority; - priority |= 4 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; - inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + if (inferFromMappedTypeConstraint(source, target, constraintType)) { return; } } @@ -43073,8 +43865,8 @@ var ts; } } var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var targetProp = properties_5[_i]; var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -43097,7 +43889,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ || kind === 155 /* Constructor */; + bivariant = bivariant || kind === 156 /* MethodDeclaration */ || kind === 155 /* MethodSignature */ || kind === 157 /* Constructor */; forEachMatchingParameterType(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -43151,11 +43943,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 4194304 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 32764 /* Primitive */ | 1048576 /* Index */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -43204,7 +43996,7 @@ var ts; var inferredContravariantType = getContravariantInference(inference); // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype and not 'never'. - inferredType = inferredCovariantType && !(inferredCovariantType.flags & 32768 /* Never */) && + inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ? inferredCovariantType : inferredContravariantType; } @@ -43263,17 +44055,17 @@ var ts; case "console": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom; case "$": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig; case "describe": case "suite": case "it": case "test": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig; case "process": case "require": case "Buffer": case "module": - return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode; + return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig; case "Map": case "Set": case "Promise": @@ -43299,7 +44091,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 === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 167 /* TypeQuery */ ? true : n.kind === 72 /* Identifier */ || n.kind === 148 /* 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 @@ -43308,20 +44100,20 @@ var ts; // occurring in an apparent type position with '@' because the control flow type // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; } - if (node.kind === 99 /* ThisKeyword */) { + if (node.kind === 100 /* ThisKeyword */) { return "0"; } - if (node.kind === 187 /* PropertyAccessExpression */) { + if (node.kind === 189 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 184 /* BindingElement */) { + if (node.kind === 186 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 186 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -43330,14 +44122,14 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 182 /* ObjectBindingPattern */) { + if (parent.kind === 184 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; default: @@ -43351,29 +44143,29 @@ var ts; } function isMatchingReference(source, target) { switch (source.kind) { - case 71 /* Identifier */: - return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && + case 72 /* Identifier */: + return target.kind === 72 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 237 /* VariableDeclaration */ || target.kind === 186 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 99 /* ThisKeyword */: - return target.kind === 99 /* ThisKeyword */; - case 97 /* SuperKeyword */: - return target.kind === 97 /* SuperKeyword */; - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 100 /* ThisKeyword */: + return target.kind === 100 /* ThisKeyword */; + case 98 /* SuperKeyword */: + return target.kind === 98 /* SuperKeyword */; + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return (ts.isPropertyAccessExpression(target) || ts.isElementAccessExpression(target)) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 184 /* BindingElement */: - if (target.kind !== 187 /* PropertyAccessExpression */) + case 186 /* BindingElement */: + if (target.kind !== 189 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 186 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 235 /* VariableDeclaration */) { + if (source.parent.parent.kind === 237 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -43386,7 +44178,7 @@ var ts; undefined; } function containsMatchingReference(source, target) { - while (source.kind === 187 /* PropertyAccessExpression */) { + while (source.kind === 189 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -43399,23 +44191,23 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 187 /* PropertyAccessExpression */ && + return target.kind === 189 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 71 /* Identifier */) { + if (expr.kind === 72 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 187 /* PropertyAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantType(type) { - if (type.flags & 262144 /* Union */) { - if (type.flags & (16 /* Boolean */ | 512 /* EnumLiteral */)) { + if (type.flags & 1048576 /* Union */) { + if (type.flags & (16 /* Boolean */ | 1024 /* EnumLiteral */)) { return true; } var combined = 0; @@ -43423,14 +44215,14 @@ var ts; var t = _a[_i]; combined |= t.flags; } - if (combined & 27072 /* Unit */ && !(combined & 15794176 /* Instantiable */)) { + if (combined & 109440 /* Unit */ && !(combined & 63176704 /* Instantiable */)) { return true; } } return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 262144 /* Union */) { + if (type && type.flags & 1048576 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { @@ -43441,6 +44233,10 @@ var ts; } return false; } + function hasNarrowableDeclaredType(expr) { + var type = getDeclaredTypeOfReference(expr); + return !!(type && type.flags & 1048576 /* Union */); + } function findDiscriminantProperties(sourceProperties, target) { var result; for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { @@ -43467,7 +44263,7 @@ var ts; } } } - if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 189 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -43481,7 +44277,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 262144 /* Union */)) { + if (!(source.flags & 1048576 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -43497,11 +44293,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 32768 /* Never */) { + if (assignedType.flags & 131072 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 33554432 /* FreshLiteral */ && assignedType.flags & 256 /* BooleanLiteral */) { + if (assignedType.flags & 512 /* 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. @@ -43532,57 +44328,66 @@ var ts; function getTypeFacts(type) { var flags = type.flags; if (flags & 4 /* String */) { - return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; + return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; } - if (flags & 64 /* StringLiteral */) { + if (flags & 128 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? - isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : - isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; } if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; + return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; } - if (flags & 128 /* NumberLiteral */) { + if (flags & 256 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : - isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; + isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + } + if (flags & 64 /* BigInt */) { + return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + } + if (flags & 2048 /* BigIntLiteral */) { + var isZero = isZeroBigInt(type); + return strictNullChecks ? + isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; } if (flags & 16 /* Boolean */) { - return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; + return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; } - if (flags & 272 /* BooleanLike */) { + if (flags & 528 /* BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 131072 /* Object */) { + if (flags & 524288 /* Object */) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 4079615 /* EmptyObjectStrictFacts */ : 4194303 /* EmptyObjectFacts */ : + strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : - strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : + strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { - return 2457472 /* UndefinedFacts */; + if (flags & (16384 /* Void */ | 32768 /* Undefined */)) { + return 9830144 /* UndefinedFacts */; } - if (flags & 16384 /* Null */) { - return 2340752 /* NullFacts */; + if (flags & 65536 /* Null */) { + return 9363232 /* NullFacts */; } - if (flags & 3072 /* ESSymbolLike */) { - return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; + if (flags & 12288 /* ESSymbolLike */) { + return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; } - if (flags & 16777216 /* NonPrimitive */) { - return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; + if (flags & 67108864 /* NonPrimitive */) { + return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } - if (flags & 15794176 /* Instantiable */) { + if (flags & 63176704 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 786432 /* UnionOrIntersection */) { + if (flags & 3145728 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } - return 4194303 /* All */; + return 16777215 /* All */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -43590,7 +44395,7 @@ var ts; function getTypeWithDefault(type, defaultExpression) { if (defaultExpression) { var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 131072 /* NEUndefined */), defaultType]); + return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); } return type; } @@ -43610,15 +44415,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 187 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 275 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 204 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 227 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -43635,21 +44440,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return stringType; - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return undefinedType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -43657,7 +44462,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 182 /* ObjectBindingPattern */ ? + var type = pattern.kind === 184 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -43675,39 +44480,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 224 /* ForInStatement */) { + if (node.parent.parent.kind === 226 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 225 /* ForOfStatement */) { + if (node.parent.parent.kind === 227 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 235 /* VariableDeclaration */ ? + return node.kind === 237 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? + return getConstraintForLocation(node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } function isEmptyArrayAssignment(node) { - return node.kind === 235 /* VariableDeclaration */ && node.initializer && + return node.kind === 237 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && + node.kind !== 186 /* BindingElement */ && node.parent.kind === 204 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return getReferenceCandidate(node.left); - case 26 /* CommaToken */: + case 27 /* CommaToken */: return getReferenceCandidate(node.right); } } @@ -43715,13 +44520,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 193 /* ParenthesizedExpression */ || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 195 /* ParenthesizedExpression */ || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */ && parent.left === node || + parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -43743,8 +44548,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 269 /* CaseClause */) { - if (clause.expression.kind === 9 /* StringLiteral */) { + if (clause.kind === 271 /* CaseClause */) { + if (clause.expression.kind === 10 /* StringLiteral */) { witnesses.push(clause.expression.text); continue; } @@ -43755,13 +44560,13 @@ var ts; return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* 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 & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 262144 /* Union */) { + if (source.flags & 1048576 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -43770,30 +44575,30 @@ var ts; } return true; } - if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 262144 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfPrimitiveTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.primitiveTypesOnly); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return type; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return mapper(type); } var types = type.types; @@ -43823,12 +44628,14 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) || + isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : - t; + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : + t; }); } return typeWithPrimitives; @@ -43862,9 +44669,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 32768 /* Never */ ? + return elementType.flags & 131072 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 262144 /* Union */ ? + createArrayType(elementType.flags & 1048576 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -43882,7 +44689,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - if (!(t.flags & 32768 /* Never */)) { + if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -43904,15 +44711,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 189 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 191 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 190 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 202 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 58 /* EqualsToken */ && + parent.parent.kind === 204 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 59 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -43923,7 +44730,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 97 /* SuperKeyword */) { + if (node.expression.kind !== 98 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -43945,7 +44752,7 @@ var ts; if (flowAnalysisDisabled) { return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -43955,8 +44762,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent && reference.parent.kind === 213 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -44028,9 +44835,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && - reference.kind !== 187 /* PropertyAccessExpression */ && - reference.kind !== 188 /* ElementAccessExpression */ && - reference.kind !== 99 /* ThisKeyword */) { + reference.kind !== 189 /* PropertyAccessExpression */ && + reference.kind !== 190 /* ElementAccessExpression */ && + reference.kind !== 100 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -44068,7 +44875,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 262144 /* Union */) { + if (declaredType.flags & 1048576 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); } return declaredType; @@ -44082,19 +44889,23 @@ 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 === 194 /* FunctionExpression */ || init.kind === 195 /* ArrowFunction */)) { + if (init && (init.kind === 196 /* FunctionExpression */ || init.kind === 197 /* 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 === 226 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + } // Assignment doesn't affect reference return undefined; } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 189 /* CallExpression */ ? + var expr = node.kind === 191 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -44102,7 +44913,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -44111,7 +44922,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, 168 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -44125,7 +44936,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -44142,7 +44953,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 131072 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -44158,7 +44969,7 @@ var ts; else if (isMatchingReferenceDiscriminant(expr, type)) { type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); } - else if (expr.kind === 197 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 199 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } return createFlowType(type, isIncomplete(flowType)); @@ -44274,8 +45085,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 262144 /* Union */) || - expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (!(computedType.flags & 1048576 /* Union */) || + expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { return false; } var access = expr; @@ -44296,10 +45107,10 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); + return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } if (isMatchingReferenceDiscriminant(expr, declaredType)) { - return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 1048576 /* Truthy */ : 2097152 /* Falsy */); }); + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; @@ -44317,7 +45128,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (1048576 /* Union */ | 524288 /* Object */)) || (type.flags & 262144 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -44325,19 +45136,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 199 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -44356,15 +45167,15 @@ var ts; return declaredType; } break; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 92 /* InKeyword */: + case 93 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); } break; - case 26 /* CommaToken */: + case 27 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -44373,28 +45184,28 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 24576 /* Nullable */) { + if (valueType.flags & 98304 /* Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; + var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 16384 /* Null */ ? - assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : - assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; + assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : + valueType.flags & 65536 /* Null */ ? + assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : + assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 16909315 /* NotUnionOrUnit */) { + if (type.flags & 67637251 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 131072 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -44406,22 +45217,22 @@ var ts; // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { - // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, target)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, a + // 'typeof x === ...' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, target) && hasNarrowableDeclaredType(target)) { return declaredType; } return type; } - if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { + if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } var facts = assumeTrue ? - typeofEQFacts.get(literal.text) || 64 /* TypeofEQHostObject */ : - typeofNEFacts.get(literal.text) || 8192 /* TypeofNEHostObject */; + typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : + typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); function narrowTypeForTypeof(type) { if (type.flags & 2 /* Unknown */ && literal.text === "object") { @@ -44438,7 +45249,7 @@ var ts; if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 15794176 /* Instantiable */) { + if (type.flags & 63176704 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -44457,13 +45268,37 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + } + function getImpliedTypeFromTypeofCase(type, text) { + switch (text) { + case "function": + return type.flags & 1 /* Any */ ? type : globalFunctionType; + case "object": + return type.flags & 2 /* Unknown */ ? getUnionType([nonPrimitiveType, nullType]) : type; + default: + return typeofTypesByName.get(text) || type; + } + } + function narrowTypeForTypeofSwitch(candidate) { + return function (type) { + if (isTypeSubtypeOf(candidate, type)) { + return candidate; + } + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(candidate, constraint)) { + return getIntersectionType([type, candidate]); + } + } + return type; + }; } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); @@ -44482,7 +45317,7 @@ var ts; // that we don't have to worry about undefined // in the witness array. var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; }); - // The adjust clause start and end after removing the `default` statement. + // The adjusted clause start and end after removing the `default` statement. var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart; var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd; clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd); @@ -44492,6 +45327,9 @@ var ts; clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd); switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause); } + if (hasDefaultClause) { + return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }); + } /* The implied type is the raw type suggested by a value being caught in this clause. @@ -44520,33 +45358,18 @@ var ts; boolean. We know that number cannot be selected because it is caught in the first clause. */ - if (!(hasDefaultClause || (type.flags & 262144 /* Union */))) { - var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return typeofTypesByName.get(text) || neverType; })), switchFacts); - if (impliedType.flags & 262144 /* Union */) { - impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOfType(type) || type); - } - if (!(impliedType.flags & 32768 /* Never */)) { - if (isTypeSubtypeOf(impliedType, type)) { - return impliedType; - } - if (type.flags & 15794176 /* Instantiable */) { - var constraint = getBaseConstraintOfType(type) || anyType; - if (isTypeSubtypeOf(impliedType, constraint)) { - return getIntersectionType([type, impliedType]); - } - } - } + var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts); + if (impliedType.flags & 1048576 /* Union */) { + impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type)); } - return hasDefaultClause ? - filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; }) : - getTypeWithFacts(type, switchFacts); + return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { - // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, left)) { + // For a reference of the form 'x.y', where 'x' has a narrowable declared type, an + // 'x instanceof T' type guard resets the narrowed type of 'y' to its declared type. + if (containsMatchingReference(reference, left) && hasNarrowableDeclaredType(left)) { return declaredType; } return type; @@ -44583,9 +45406,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 & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 32768 /* Never */)) { + if (!(assignableType.flags & 131072 /* Never */)) { return assignableType; } } @@ -44625,7 +45448,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 190 /* ElementAccessExpression */ || invokedExpression.kind === 189 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -44642,20 +45465,20 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 71 /* Identifier */: - case 99 /* ThisKeyword */: - case 97 /* SuperKeyword */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 72 /* Identifier */: + case 100 /* ThisKeyword */: + case 98 /* SuperKeyword */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 200 /* PrefixUnaryExpression */: - if (expr.operator === 51 /* ExclamationToken */) { + case 202 /* PrefixUnaryExpression */: + if (expr.operator === 52 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -44669,7 +45492,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 === 71 /* Identifier */) { + if (location.kind === 72 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -44690,9 +45513,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 243 /* ModuleBlock */ || - node.kind === 277 /* SourceFile */ || - node.kind === 152 /* PropertyDeclaration */; + node.kind === 245 /* ModuleBlock */ || + node.kind === 279 /* SourceFile */ || + node.kind === 154 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -44711,10 +45534,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 151 /* Parameter */) { symbol.isAssigned = true; } } @@ -44729,21 +45552,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 149 /* Parameter */ && + declaration.kind === 151 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 8192 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; + getFalsyFlags(declaredType) & 32768 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 187 /* PropertyAccessExpression */ || - parent.kind === 189 /* CallExpression */ && parent.expression === node || - parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 189 /* PropertyAccessExpression */ || + parent.kind === 191 /* CallExpression */ && parent.expression === node || + parent.kind === 190 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 186 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); + return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 98304 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -44774,7 +45597,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -44795,7 +45618,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 238 /* ClassDeclaration */ + if (declaration.kind === 240 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -44807,14 +45630,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 207 /* ClassExpression */) { + else if (declaration.kind === 209 /* 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 !== 277 /* SourceFile */) { + while (container.kind !== 279 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 154 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -44858,7 +45681,7 @@ 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 === 149 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 151 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -44867,8 +45690,8 @@ var ts; // 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 === 194 /* FunctionExpression */ || - flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 196 /* FunctionExpression */ || + flowContainer.kind === 197 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -44877,9 +45700,9 @@ var ts; // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || - node.parent.kind === 211 /* NonNullExpression */ || - declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 257 /* ExportSpecifier */) || + node.parent.kind === 213 /* NonNullExpression */ || + declaration.kind === 237 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -44888,7 +45711,7 @@ var ts; // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType || type === autoArrayType) { + if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) { if (flowType === autoType || flowType === autoArrayType) { if (noImplicitAny) { error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); @@ -44897,7 +45720,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* 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; @@ -44913,7 +45736,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -44936,7 +45759,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -44954,8 +45777,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 223 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && + if (container.kind === 225 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 238 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -44973,7 +45796,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 193 /* ParenthesizedExpression */) { + while (current.parent.kind === 195 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -44981,9 +45804,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 202 /* PrefixUnaryExpression */ || current.parent.kind === 203 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; + isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -44994,7 +45817,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { + if (container.kind === 154 /* PropertyDeclaration */ || container.kind === 157 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -45062,37 +45885,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 155 /* Constructor */) { + if (container.kind === 157 /* 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 === 195 /* ArrowFunction */) { + if (container.kind === 197 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 242 /* ModuleDeclaration */: + case 244 /* 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 241 /* EnumDeclaration */: + case 243 /* 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 155 /* Constructor */: + case 157 /* 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 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -45103,9 +45926,15 @@ var ts; var type = tryGetThisTypeAt(node, container); if (!type && noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' - error(node, capturedByArrowFunction && container.kind === 277 /* SourceFile */ ? + var diag = error(node, capturedByArrowFunction && container.kind === 279 /* SourceFile */ ? ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); + if (!ts.isSourceFile(container)) { + var outsideThis = tryGetThisTypeAt(container); + if (outsideThis) { + addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container)); + } + } } return type || anyType; } @@ -45131,7 +45960,7 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 194 /* FunctionExpression */ || container.kind === 237 /* FunctionDeclaration */) && + (container.kind === 196 /* FunctionExpression */ || container.kind === 239 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { var classType = getJSClassType(container.symbol); if (classType) { @@ -45157,7 +45986,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 194 /* FunctionExpression */ && + if (container.kind === 196 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -45167,24 +45996,49 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 154 /* MethodDeclaration */ && - container.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 156 /* MethodDeclaration */ && + container.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 194 /* FunctionExpression */ && - container.parent.kind === 273 /* PropertyAssignment */ && - container.parent.parent.kind === 186 /* ObjectLiteralExpression */ && + else if (container.kind === 196 /* FunctionExpression */ && + container.parent.kind === 275 /* PropertyAssignment */ && + container.parent.parent.kind === 188 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* 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 === 196 /* 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 */) { + return container.parent.parent.parent.arguments[0].expression; + } + // Object.defineProperty(x, "method", { value() { } }); + // Object.defineProperty(x, "method", { set(x: () => void) {} }); + // Object.defineProperty(x, "method", { get() { return () => {} } }); + else if (ts.isMethodDeclaration(container) && + ts.isIdentifier(container.name) && + (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") && + ts.isObjectLiteralExpression(container.parent) && + ts.isCallExpression(container.parent.parent) && + container.parent.parent.arguments[2] === container.parent && + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + return container.parent.parent.arguments[0].expression; + } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 289 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -45198,15 +46052,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 151 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 189 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 191 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 195 /* ArrowFunction */) { + while (container && container.kind === 197 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -45219,14 +46073,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); - if (current && current.kind === 147 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 149 /* ComputedPropertyName */; }); + if (current && current.kind === 149 /* 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 === 186 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -45234,7 +46088,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 155 /* Constructor */) { + if (!isCallExpression && container.kind === 157 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -45303,7 +46157,7 @@ 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 === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 156 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -45317,7 +46171,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (container.parent.kind === 188 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -45338,7 +46192,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 155 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 157 /* 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; @@ -45353,7 +46207,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 === 155 /* Constructor */; + return container.kind === 157 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -45361,21 +46215,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 188 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */; } else { - return container.kind === 154 /* MethodDeclaration */ || - container.kind === 153 /* MethodSignature */ || - container.kind === 156 /* GetAccessor */ || - container.kind === 157 /* SetAccessor */ || - container.kind === 152 /* PropertyDeclaration */ || - container.kind === 151 /* PropertySignature */ || - container.kind === 155 /* Constructor */; + return container.kind === 156 /* MethodDeclaration */ || + container.kind === 155 /* MethodSignature */ || + container.kind === 158 /* GetAccessor */ || + container.kind === 159 /* SetAccessor */ || + container.kind === 154 /* PropertyDeclaration */ || + container.kind === 153 /* PropertySignature */ || + container.kind === 157 /* Constructor */; } } } @@ -45383,10 +46237,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 154 /* MethodDeclaration */ || - func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 156 /* MethodDeclaration */ || + func.kind === 158 /* GetAccessor */ || + func.kind === 159 /* SetAccessor */) && func.parent.kind === 188 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 196 /* FunctionExpression */ && func.parent.kind === 275 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -45394,11 +46248,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -45425,7 +46279,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 273 /* PropertyAssignment */) { + if (literal.parent.kind !== 275 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -45439,9 +46293,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 204 /* BinaryExpression */ && parent.operatorToken.kind === 59 /* EqualsToken */) { var target = parent.left; - if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { + if (target.kind === 189 /* PropertyAccessExpression */ || target.kind === 190 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -45501,7 +46355,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 149 /* Parameter */) { + if (declaration.kind === 151 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -45513,7 +46367,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 184 /* BindingElement */) { + if (parentDeclaration.kind !== 186 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -45603,10 +46457,13 @@ var ts; // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); + if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { + return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 191 /* TaggedTemplateExpression */) { + if (template.parent.kind === 193 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -45615,7 +46472,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: if (node !== right) { return undefined; } @@ -45624,15 +46481,15 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 54 /* BarBarToken */: + case 55 /* BarBarToken */: // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); return !type && node === right && !ts.isDefaultedExpandoInitializer(binaryExpression) ? getTypeOfExpression(left) : type; - case 53 /* AmpersandAmpersandToken */: - case 26 /* CommaToken */: + case 54 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression) : undefined; default: return undefined; @@ -45699,13 +46556,17 @@ var ts; } var thisType = checkThisExpression(thisAccess.expression); return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + case 7 /* ObjectDefinePropertyValue */: + case 8 /* ObjectDefinePropertyExports */: + case 9 /* ObjectDefinePrototypeProperty */: + return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - if (t.flags & 917504 /* StructuredType */) { + if (t.flags & 3670016 /* StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return getTypeOfSymbol(prop); @@ -45716,8 +46577,8 @@ var ts; return restType; } } - return isNumericLiteralName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || - getIndexTypeOfContextualType(type, 0 /* String */); + return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1 /* Number */) || + getIndexTypeOfContextualType(t, 0 /* String */); } return undefined; }, /*noReductions*/ true); @@ -45761,7 +46622,6 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || getIndexTypeOfContextualType(arrayContextualType, 1 /* Number */) || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -45803,35 +46663,36 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 71 /* Identifier */: - case 140 /* UndefinedKeyword */: + case 9 /* BigIntLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 72 /* Identifier */: + case 141 /* UndefinedKeyword */: return true; - case 187 /* PropertyAccessExpression */: - case 193 /* ParenthesizedExpression */: + case 189 /* PropertyAccessExpression */: + case 195 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 273 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 275 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 265 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 267 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (contextualType && contextualType.flags & 262144 /* Union */) { + if (contextualType && contextualType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, contextualType); } @@ -45868,54 +46729,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 184 /* BindingElement */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 186 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 195 /* ArrowFunction */: - case 228 /* ReturnStatement */: + case 197 /* ArrowFunction */: + case 230 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 189 /* CallExpression */: - case 190 /* NewExpression */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 185 /* ArrayLiteralExpression */: { + case 187 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 214 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); + case 216 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 206 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 193 /* ParenthesizedExpression */: { + case 195 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 265 /* JsxAttribute */: - case 267 /* JsxSpreadAttribute */: + case 267 /* JsxAttribute */: + case 269 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -45931,67 +46792,10 @@ var ts; // (as below) instead! return node.parent.contextualType; } - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - var valueType = checkExpression(node.tagName); - if (isTypeAny(valueType)) { - // Short-circuit if the class tag is using an element type 'any' - return anyType; - } - var isJs = ts.isInJSFile(node); - return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); + return getContextualTypeForArgumentAtIndex(node, 0); } - function getJsxSignaturesParameterTypes(valueType, isJs, context) { - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 4 /* String */) { - return anyType; - } - else if (valueType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = valueType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - } - return anyType; - } - // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(valueType, 1 /* Construct */); - var ctor = true; - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(valueType, 0 /* Call */); - ctor = false; - if (signatures.length === 0) { - // We found no signatures at all, which is an error - return errorType; - } - } - var links = getNodeLinks(context); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(valueType); - var cachedResolved = links.resolvedSignatures.get(cacheKey); - if (cachedResolved && cachedResolved !== resolvingSignaturesArray) { - signatures = cachedResolved; - } - else if (!cachedResolved) { - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); - links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures)); - } - return getUnionType(ts.map(signatures, ctor ? function (t) { return getJsxPropsTypeFromClassType(t, isJs, context, /*reportErrors*/ false); } : function (t) { return getJsxPropsTypeFromCallSignature(t, context); }), 0 /* None */); + function getEffectiveFirstArgumentForJsxSignature(signature, node) { + return getJsxReferenceKind(node) !== 0 /* Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); @@ -46006,22 +46810,40 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getStaticTypeOfReferencedJsxConstructor(context) { + if (isJsxIntrinsicIdentifier(context.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context); + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + var tagType = checkExpressionCached(context.tagName); + if (tagType.flags & 128 /* StringLiteral */) { + var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); + if (!result) { + return errorType; + } + var fakeSignature = createSignatureForJSXIntrinsic(context, result); + return getOrCreateTypeFromSignature(fakeSignature); + } + return tagType; + } function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var ctorType = getStaticTypeOfReferencedJsxConstructor(context); if (ts.length(declaredManagedType.typeParameters) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); + var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); } } return attributesType; } - function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { + function getJsxPropsTypeFromClassType(sig, context) { var ns = getJsxNamespaceAt(context); var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined @@ -46034,7 +46856,7 @@ var ts; : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation); if (!attributesType) { // There is no property named 'props' on this instance type - if (reportErrors && !!forcedLookupLocation && !!ts.length(context.attributes.properties)) { + if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) { error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation)); } return emptyObjectType; @@ -46052,7 +46874,7 @@ var ts; var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams - ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isJs)) + ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context))) : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); @@ -46088,7 +46910,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; + return node.kind === 196 /* FunctionExpression */ || node.kind === 197 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -46107,7 +46929,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -46116,7 +46938,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 262144 /* Union */)) { + if (!(type.flags & 1048576 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -46155,8 +46977,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 184 /* BindingElement */ && !!node.initializer) || - (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 186 /* BindingElement */ && !!node.initializer) || + (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 59 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -46167,7 +46989,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 208 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -46192,12 +47014,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 208 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 208 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -46224,15 +47046,15 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 185 /* ArrayBindingPattern */ || pattern.kind === 187 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementCount; i < patternElements.length; i++) { var e = patternElements[i]; if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { - if (e.kind !== 208 /* OmittedExpression */) { + else if (i < patternElements.length - 1 || !(e.kind === 186 /* BindingElement */ && e.dotDotDotToken || e.kind === 208 /* SpreadElement */)) { + if (e.kind !== 210 /* OmittedExpression */) { error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -46250,12 +47072,12 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return isNumericComputedName(name); - case 71 /* Identifier */: + case 72 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return isNumericLiteralName(name.text); default: return false; @@ -46264,7 +47086,7 @@ 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), 168 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -46299,8 +47121,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 24576 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -46327,10 +47149,10 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 33554432 /* FreshLiteral */; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 184 /* ObjectBindingPattern */ || contextualType.pattern.kind === 188 /* ObjectLiteralExpression */); var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -46343,13 +47165,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 149 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 273 /* PropertyAssignment */ || - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 275 /* PropertyAssignment */ || + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 275 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 276 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -46362,7 +47184,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -46373,8 +47195,8 @@ var ts; 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 === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 275 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 276 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -46399,12 +47221,12 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 275 /* SpreadAssignment */) { + else if (memberDecl.kind === 277 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); propertiesArray = []; propertiesTable = ts.createSymbolTable(); hasComputedStringProperty = false; @@ -46416,7 +47238,7 @@ var ts; error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 32768 /* FreshLiteral */); offset = i + 1; continue; } @@ -46426,10 +47248,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 === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 158 /* GetAccessor */ || memberDecl.kind === 159 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -46463,7 +47285,7 @@ var ts; } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, /*objectFlags*/ 0); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, 32768 /* FreshLiteral */); } return spread; } @@ -46472,9 +47294,8 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; - result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); - result.objectFlags |= 128 /* ObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags & 939524096 /* PropagatingFlags */; + result.objectFlags |= 128 /* ObjectLiteral */ | freshObjectLiteralFlag; if (isJSObjectLiteral) { result.objectFlags |= 16384 /* JSLiteral */; } @@ -46484,20 +47305,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 24576 /* Nullable */)) { - propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); - } + propagatedFlags |= result.flags & 939524096 /* PropagatingFlags */; return result; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || - getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 131072 /* Object */ && !isGenericMappedType(type) || - type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); + return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { - checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node); } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); @@ -46505,7 +47323,7 @@ var ts; } function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -46513,18 +47331,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } + checkJsxChildren(node); } function checkJsxElement(node, _checkMode) { checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxFragment(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment, checkMode); + function checkJsxFragment(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment); if (compilerOptions.jsx === 2 /* React */ && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) { error(node, compilerOptions.jsxFactory ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma); } + checkJsxChildren(node); return getJsxElementTypeAt(node) || anyType; } /** @@ -46538,7 +47358,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 === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 72 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -46557,18 +47377,19 @@ var ts; function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createSymbolTable(); - var spread = emptyObjectType; + var spread = emptyJsxObjectType; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var propagatingFlags = 0; + var typeFlags = 0; + var objectFlags = 4096 /* 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); - propagatingFlags |= (exprType.flags & 939524096 /* PropagatingFlags */); + typeFlags |= exprType.flags & 939524096 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | 33554432 /* Transient */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -46583,9 +47404,9 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 269 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); attributesTable = ts.createSymbolTable(); } var exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -46593,7 +47414,7 @@ var ts; hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, openingLikeElement.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, exprType, attributes.symbol, typeFlags, objectFlags); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -46602,11 +47423,11 @@ var ts; } if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags); } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 260 /* 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); @@ -46626,25 +47447,26 @@ var ts; (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, /*hasRestElement*/ false) || createArrayType(getUnionType(childrenTypes))); var childPropMap = ts.createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); - spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, propagatingFlags, 4096 /* JsxAttributes */); + spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), attributes.symbol, typeFlags, objectFlags); } } if (hasSpreadAnyType) { return anyType; } - if (typeToIntersect && spread !== emptyObjectType) { + if (typeToIntersect && spread !== emptyJsxObjectType) { return getIntersectionType([typeToIntersect, spread]); } - return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); + return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread); /** * Create anonymous type from given attributes symbol table. * @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable * @param attributesTable a symbol table of attributes property */ function createJsxAttributesType() { + objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= (propagatingFlags |= 268435456 /* ContainsObjectLiteral */); - result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | typeFlags; + result.objectFlags |= 128 /* ObjectLiteral */ | objectFlags; return result; } } @@ -46654,7 +47476,7 @@ 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 === 10 /* JsxText */) { + if (child.kind === 11 /* JsxText */) { if (!child.containsOnlyWhiteSpaces) { childrenTypes.push(stringType); } @@ -46717,57 +47539,6 @@ var ts; } return links.resolvedSymbol; } - function instantiateJsxSignatures(node, signatures) { - var instantiatedSignatures = []; - var candidateForTypeArgumentError; - var hasTypeArgumentError = !!node.typeArguments; - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; - if (signature.typeParameters) { - var isJavascript = ts.isInJSFile(node); - var typeArgumentInstantiated = getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, /*reportErrors*/ false); - if (typeArgumentInstantiated) { - hasTypeArgumentError = false; - instantiatedSignatures.push(typeArgumentInstantiated); - } - else { - if (node.typeArguments && hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - candidateForTypeArgumentError = signature; - } - var inferenceContext = createInferenceContext(signature.typeParameters, signature, /*flags*/ isJavascript ? 2 /* AnyDefault */ : 0 /* None */); - var typeArguments = inferJsxTypeArguments(signature, node, inferenceContext); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); - } - } - else { - instantiatedSignatures.push(signature); - } - } - if (node.typeArguments && hasTypeArgumentError) { - if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true); - } - // Length check to avoid issuing an arity error on length=0, the "Type argument list cannot be empty" grammar error alone is fine - else if (node.typeArguments.length !== 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, node.typeArguments)); - } - } - return instantiatedSignatures; - } - function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { - if (reportErrors === void 0) { reportErrors = false; } - if (!node.typeArguments) { - return; - } - if (!hasCorrectTypeArgumentArity(signature, node.typeArguments)) { - return; - } - var args = checkTypeArguments(signature, node.typeArguments, reportErrors); - if (!args) { - return; - } - return getSignatureInstantiation(signature, args, isJavascript); - } function getJsxNamespaceAt(location) { var links = location && getNodeLinks(location); if (links && links.jsxNamespace) { @@ -46838,217 +47609,63 @@ var ts; function getJsxElementChildrenPropertyName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } - function getApparentTypeOfJsxPropsType(propsType) { - if (!propsType) { - return undefined; - } - if (propsType.flags & 524288 /* Intersection */) { - var propsApparentType = []; - for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { - var t = _a[_i]; - propsApparentType.push(getApparentType(t)); - } - return getIntersectionType(propsApparentType); - } - return getApparentType(propsType); - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return only attributes type of successfully resolved call signature. - * This function assumes that the caller handled other possible element type of the JSX element (e.g. stateful component) - * Unlike tryGetAllJsxStatelessFunctionAttributesType, this function is a default behavior of type-checkers. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. - var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined, /*isForSignatureHelp*/ false); - if (callSignature !== unknownSignature) { - var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); - var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - paramType = intersectTypes(intrinsicAttributes, paramType); - } - return paramType; - } - } - } - } - return undefined; - } - /** - * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. - * Return all attributes type of resolved call signature including candidate signatures. - * This function assumes that the caller handled other possible element type of the JSX element. - * This function is a behavior used by language service when looking up completion in JSX element. - * @param openingLikeElement a JSX opening-like element to find attributes type - * @param elementType a type of the opening-like element. This elementType can't be an union type - * @param elemInstanceType an element instance type (the result of newing or invoking this tag) - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global - */ - function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); - if (jsxStatelessElementType) { - // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. - var candidatesOutArray = []; - getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, /*isForSignatureHelp*/ false); - var result = void 0; - var allMatchingAttributesType = void 0; - for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { - var candidate = candidatesOutArray_1[_i]; - var callReturnType = getReturnTypeOfSignature(candidate); - // TODO: GH#18217: callReturnType should always be defined... - var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - paramType = getApparentTypeOfJsxPropsType(paramType); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { - var shouldBeCandidate = true; - for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { - var attribute = _b[_a]; - if (ts.isJsxAttribute(attribute) && - isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 - shouldBeCandidate = false; - break; - } - } - if (shouldBeCandidate) { - result = intersectTypes(result, paramType); - } - allMatchingAttributesType = intersectTypes(allMatchingAttributesType, paramType); - } - } - // If we can't find any matching, just return everything. - if (!result) { - result = allMatchingAttributesType; - } - // Intersect in JSX.IntrinsicAttributes if it exists - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== errorType) { - result = intersectTypes(intrinsicAttributes, result); - } - return result; - } - } - return undefined; - } - function getInstantiatedJsxSignatures(openingLikeElement, elementType, reportErrors) { - var links = getNodeLinks(openingLikeElement); - if (!links.resolvedSignatures) { - links.resolvedSignatures = ts.createMap(); - } - var cacheKey = "" + getTypeId(elementType); - if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) === resolvingSignaturesArray) { - return; - } - else if (links.resolvedSignatures.get(cacheKey)) { - return links.resolvedSignatures.get(cacheKey); - } - links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + function getUninstantiatedJsxSignaturesOfType(elementType) { // Resolve the signatures, preferring constructor var signatures = getSignaturesOfType(elementType, 1 /* Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures signatures = getSignaturesOfType(elementType, 0 /* Call */); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - if (reportErrors) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(openingLikeElement.tagName)); - } + } + if (signatures.length === 0 && elementType.flags & 1048576 /* Union */) { + // If each member has some combination of new/call signatures; make a union signature list for those + signatures = getUnionSignatures(ts.map(elementType.types, getUninstantiatedJsxSignaturesOfType)); + } + return signatures; + } + function getIntrinsicAttributesTypeFromStringLiteralType(type, location) { + // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type + // For example: + // var CustomTag: "h1" = "h1"; + // Hello World + var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location); + if (intrinsicElementsType !== errorType) { + var stringLiteralTypeName = type.value; + var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); + if (intrinsicProp) { + return getTypeOfSymbol(intrinsicProp); + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + return indexSignatureType; + } + return undefined; + } + // If we need to report an error, we already done so here. So just return any to prevent any more error downstream + return anyType; + } + function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { + if (refKind === 1 /* Function */) { + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + if (sfcReturnConstraint) { + checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else if (refKind === 0 /* Component */) { + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (classConstraint) { + // Issue an error if this return type isn't assignable to JSX.ElementClass or JSX.Element, failing that + checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + } + else { // Mixed + var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); + var classConstraint = getJsxElementClassTypeAt(openingLikeElement); + if (!sfcReturnConstraint || !classConstraint) { return; } + var combined = getUnionType([sfcReturnConstraint, classConstraint]); + checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } - // Instantiate in context of source type - var results = instantiateJsxSignatures(openingLikeElement, signatures); - links.resolvedSignatures.set(cacheKey, results); - return results; - } - /** - * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. - * For instance: - * declare function Foo(attr: { p1: string}): JSX.Element; - * ; // This function will try resolve "Foo" and return an attributes type of "Foo" which is "{ p1: string }" - * - * The function is intended to initially be called from getAttributesTypeFromJsxOpeningLikeElement which already handle JSX-intrinsic-element.. - * This function will try to resolve custom JSX attributes type in following order: string literal, stateless function, and stateful component - * - * @param openingLikeElement a non-intrinsic JSXOPeningLikeElement - * @param shouldIncludeAllStatelessAttributesType a boolean indicating whether to include all attributes types from all stateless function signature - * @param sourceAttributesType Is the attributes type the user passed, and is used to create inferences in the target type if present - * @param elementType an instance type of the given opening-like element. If undefined, the function will check type openinglikeElement's tagname. - * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global (imported from react.d.ts) - * @return attributes type if able to resolve the type of node - * anyType if there is no type ElementAttributesProperty or there is an error - * emptyObjectType if there is no "prop" in the element instance type - */ - function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 262144 /* Union */) { - var types = elementType.types; - return getUnionType(types.map(function (type) { - return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); - }), 2 /* Subtype */); - } - // Shortcircuit any - if (isTypeAny(elementType)) { - return elementType; - } - // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 4 /* String */) { - return anyType; - } - else if (elementType.flags & 64 /* StringLiteral */) { - // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type - // For example: - // var CustomTag: "h1" = "h1"; - // Hello World - var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== errorType) { - var stringLiteralTypeName = elementType.value; - var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); - if (intrinsicProp) { - return getTypeOfSymbol(intrinsicProp); - } - var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); - if (indexSignatureType) { - return indexSignatureType; - } - error(openingLikeElement, ts.Diagnostics.Property_0_does_not_exist_on_type_1, stringLiteralTypeName, "JSX." + JsxNames.IntrinsicElements); - } - // If we need to report an error, we already done so here. So just return any to prevent any more error downstream - return anyType; - } - // Get the element instance type (the result of newing or invoking this tag) - var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); - if (!ts.length(instantiatedSignatures)) { - return errorType; - } - var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); - // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. - // Otherwise get only attributes type from the signature picked by choose-overload logic. - var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? - tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : - defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); - if (statelessAttributesType) { - return statelessAttributesType; - } - // Issue an error if this return type isn't assignable to JSX.ElementClass - if (elementClassType) { - checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); - } - var isJs = ts.isInJSFile(openingLikeElement); - return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -47072,53 +47689,6 @@ var ts; } return links.resolvedJsxElementAttributesType; } - /** - * Get attributes type of the given custom opening-like JSX element. - * This function is intended to be called from a caller that handles intrinsic JSX element already. - * @param node a custom JSX opening-like element - * @param shouldIncludeAllStatelessAttributesType a boolean value used by language service to get all possible attributes type from an overload stateless function component - */ - function getCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType) { - return resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, checkExpression(node.tagName), getJsxElementClassTypeAt(node)); - } - /** - * Get all possible attributes type, especially from an overload stateless function component, of the given JSX opening-like element. - * This function is called by language service (see: completions-tryGetGlobalSymbols). - * @param node a JSX opening-like element to get attributes type for - */ - function getAllAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - // Because in language service, the given JSX opening-like element may be incomplete and therefore, - // we can't resolve to exact signature if the element is a stateless function component so the best thing to do is return all attributes type from all overloads. - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ true); - } - } - /** - * Get the attributes type, which indicates the attributes that are valid on the given JSXOpeningLikeElement. - * @param node a JSXOpeningLikeElement node - * @return an attributes type of the given node - */ - function getAttributesTypeFromJsxOpeningLikeElement(node) { - if (isJsxIntrinsicIdentifier(node.tagName)) { - return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); - } - else { - return getCustomJsxElementAttributesType(node, /*shouldIncludeAllStatelessAttributesType*/ false); - } - } - /** - * Given a JSX attribute, returns the symbol for the corresponds property - * of the element attributes type. Will return unknownSymbol for attributes - * that have no matching element attributes type property. - */ - function getJsxAttributePropertySymbol(attrib) { - var attributesType = getAttributesTypeFromJsxOpeningLikeElement(attrib.parent.parent); - var prop = getPropertyOfType(attributesType, attrib.name.escapedText); - return prop || unknownSymbol; - } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); if (type === errorType) @@ -47152,7 +47722,7 @@ var ts; } } } - function checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode) { + function checkJsxOpeningLikeElementOrOpeningFragment(node) { var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node); if (isNodeOpeningLikeElement) { checkGrammarJsxElement(node); @@ -47174,10 +47744,8 @@ var ts; } } if (isNodeOpeningLikeElement) { - checkJsxAttributesAssignableToTagNameAttributes(node, checkMode); - } - else { - checkJsxChildren(node.parent); + var sig = getResolvedSignature(node); + checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(node), getReturnTypeOfSignature(sig), node); } } /** @@ -47194,7 +47762,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 131072 /* Object */) { + if (targetType.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -47204,7 +47772,7 @@ var ts; return true; } } - else if (targetType.flags & 786432 /* UnionOrIntersection */) { + else if (targetType.flags & 3145728 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -47212,55 +47780,12 @@ var ts; } } } - else if (targetType.flags & 4194304 /* Conditional */) { + else if (targetType.flags & 16777216 /* Conditional */) { return isKnownProperty(targetType.root.trueType, name, isComparingJsxAttributes) || isKnownProperty(targetType.root.falseType, name, isComparingJsxAttributes); } return false; } - /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ - function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement, checkMode) { - // The function involves following steps: - // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. - // During these steps, we will try to resolve the tagName as intrinsic name, stateless function, stateful component (in the order) - // 2. Solved JSX attributes type given by users, sourceAttributesType, which is by resolving "attributes" property of the JSX opening-like element. - // 3. Check if the two are assignable to each other - // targetAttributesType is a type of an attribute from resolving tagName of an opening-like JSX element. - var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? - getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : - getCustomJsxElementAttributesType(openingLikeElement, /*shouldIncludeAllStatelessAttributesType*/ false); - // sourceAttributesType is a type of an attributes properties. - // i.e
- // attr1 and attr2 are treated as JSXAttributes attached in the JsxOpeningLikeElement as "attributes". - var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); - // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties - var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); - // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. - // This will allow excess properties in spread type as it is very common pattern to spread outer attributes into React component in its render method. - if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { - for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { - var attribute = _a[_i]; - if (!ts.isJsxAttribute(attribute)) { - continue; - } - var attrName = attribute.name; - var isNotIgnoredJsxProperty = (isUnhyphenatedJsxName(ts.idText(attrName)) || !!(getPropertyOfType(targetAttributesType, attrName.escapedText))); - if (isNotIgnoredJsxProperty && !isKnownProperty(targetAttributesType, attrName.escapedText, /*isComparingJsxAttributes*/ true)) { - error(attribute, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(attrName), typeToString(targetAttributesType)); - // We break here so that errors won't be cascading - break; - } - } - } - else if (!isSourceAttributeTypeAssignableToTarget) { - checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); - } - } function checkJsxExpression(node, checkMode) { if (node.expression) { var type = checkExpression(node.expression, checkMode); @@ -47300,7 +47825,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 146 /* QualifiedName */ ? node.right : node.kind === 181 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 148 /* QualifiedName */ ? node.right : node.kind === 183 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -47372,13 +47897,13 @@ var ts; return false; } var thisType = getTypeFromTypeNode(thisParameter.type); - enclosingClass = ((thisType.flags & 65536 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); + enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); } // No further restrictions for static properties if (flags & 32 /* Static */) { return true; } - if (type.flags & 65536 /* TypeParameter */) { + if (type.flags & 262144 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -47398,19 +47923,26 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function getNonNullableTypeIfNeeded(type) { + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; + if (kind) { + return getNonNullableType(type); + } + return type; + } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? + error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; + return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } @@ -47443,7 +47975,7 @@ var ts; return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 262144 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } return errorType; } @@ -47454,9 +47986,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 99 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 100 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 97 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 98 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); @@ -47468,9 +48000,9 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 187 /* PropertyAccessExpression */ || + if (node.kind !== 189 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -47478,11 +48010,11 @@ 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 && left.kind === 99 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && left.kind === 100 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 157 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -47494,7 +48026,7 @@ var ts; assumeUninitialized = true; } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) { error(right, 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; @@ -47513,8 +48045,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && - node.parent.kind !== 162 /* TypeReference */ && + else if (valueDeclaration.kind === 240 /* ClassDeclaration */ && + node.parent.kind !== 164 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -47526,9 +48058,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return true; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -47566,7 +48098,7 @@ var ts; function reportNonexistentProperty(propNode, containingType) { var errorInfo; var relatedInfo; - if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { + if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -47675,16 +48207,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 97 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 146 /* QualifiedName */: + case 189 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 98 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 148 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 181 /* ImportType */: + case 183 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind !== 181 /* ImportType */ && node.expression.kind === 97 /* SuperKeyword */, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind !== 183 /* ImportType */ && node.expression.kind === 98 /* SuperKeyword */, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -47711,20 +48243,20 @@ var ts; var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, isSuper, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJSFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); + : ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer.kind === 238 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 71 /* Identifier */) { + else if (initializer.kind === 72 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -47741,13 +48273,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 71 /* Identifier */) { + if (e.kind === 72 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 224 /* ForInStatement */ && + if (node.kind === 226 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -47765,7 +48297,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 190 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 192 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -47781,7 +48313,7 @@ var ts; if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -47796,7 +48328,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -47823,8 +48355,7 @@ var ts; return true; } function callLikeExpressionMayHaveTypeArguments(node) { - // TODO: Also include tagged templates (https://github.com/Microsoft/TypeScript/issues/11947) - return ts.isCallOrNewExpression(node); + return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); } function resolveUntypedCall(node) { if (callLikeExpressionMayHaveTypeArguments(node)) { @@ -47832,10 +48363,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 150 /* Decorator */) { + else if (ts.isJsxOpeningLikeElement(node)) { + checkExpression(node.attributes); + } + else if (node.kind !== 152 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -47862,8 +48396,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var signature = signatures_4[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -47899,22 +48433,23 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 208 /* SpreadElement */ || arg.kind === 215 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } + function acceptsVoid(t) { + return !!(t.flags & 16384 /* Void */); + } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } - if (ts.isJsxOpeningLikeElement(node)) { - // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". - return true; - } var argCount; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments - if (node.kind === 191 /* TaggedTemplateExpression */) { + var effectiveParameterCount = getParameterCount(signature); + var effectiveMinimumArguments = getMinArgumentCount(signature); + if (node.kind === 193 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 204 /* TemplateExpression */) { + if (node.template.kind === 206 /* 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. @@ -47925,17 +48460,26 @@ 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 === 13 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 150 /* Decorator */) { + else if (node.kind === 152 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } + else if (ts.isJsxOpeningLikeElement(node)) { + callIsIncomplete = node.attributes.end === node.end; + if (callIsIncomplete) { + return true; + } + argCount = effectiveMinimumArguments === 0 ? args.length : 1; + effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1; // class may have argumentless ctor functions - still resolve ctor and compare vs props member type + effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1); // sfc may specify context argument - handled by framework and not typechecked + } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 190 /* NewExpression */); + ts.Debug.assert(node.kind === 192 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -47948,12 +48492,21 @@ var ts; } } // Too many arguments implies incorrect arity. - if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { + if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= getMinArgumentCount(signature); - return callIsIncomplete || hasEnoughArguments; + // JSX signatures can have extra parameters provided by the library which we don't check + if (callIsIncomplete || argCount >= effectiveMinimumArguments) { + return true; + } + for (var i = argCount; i < effectiveMinimumArguments; i++) { + var type = getTypeAtPosition(signature, i); + if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + return false; + } + } + return true; } function hasCorrectTypeArgumentArity(signature, typeArguments) { // If the user supplied type arguments, but the number of type arguments does not match @@ -47965,7 +48518,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -47987,14 +48540,9 @@ var ts; } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); } - function inferJsxTypeArguments(signature, node, context) { - // Skip context sensitive pass - var skipContextParamType = getTypeAtPosition(signature, 0); - var checkAttrTypeSkipContextSensitive = checkExpressionWithContextualType(node.attributes, skipContextParamType, identityMapper); - inferTypes(context.inferences, checkAttrTypeSkipContextSensitive, skipContextParamType); - // Standard pass - var paramType = getTypeAtPosition(signature, 0); - var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context); + function inferJsxTypeArguments(node, signature, excludeArgument, context) { + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] !== undefined ? identityMapper : context); inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } @@ -48010,11 +48558,14 @@ var ts; inference.inferredType = undefined; } } + if (ts.isJsxOpeningLikeElement(node)) { + return inferJsxTypeArguments(node, signature, excludeArgument, context); + } // If a contextual type is available, infer from that type to the return type of the call expression. For // example, given a 'function wrap(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 !== 150 /* Decorator */) { + if (node.kind !== 152 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -48047,7 +48598,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); // For context sensitive arguments we pass the identityMapper, which is a signal to treat all // context sensitive function expressions as wildcards @@ -48063,7 +48614,7 @@ var ts; return getInferredTypes(context); } function getArrayifiedType(type) { - if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 15794176 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { + if (forEachType(type, function (t) { return !(t.flags & (1 /* Any */ | 63176704 /* Instantiable */) || isArrayType(t) || isTupleType(t)); })) { return createArrayType(getIndexTypeOfType(type, 1 /* Number */) || errorType); } return type; @@ -48074,13 +48625,13 @@ 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 arg.kind === 213 /* SyntheticExpression */ ? + return arg.kind === 215 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context)); } } var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */); var types = []; var spreadIndex = -1; for (var i = index; i < argCount; i++) { @@ -48116,6 +48667,19 @@ var ts; } return typeArgumentTypes; } + function getJsxReferenceKind(node) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + return 2 /* Mixed */; + } + var tagType = getApparentType(checkExpression(node.tagName)); + if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { + return 0 /* Component */; + } + if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { + return 1 /* Function */; + } + return 2 /* Mixed */; + } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. * @param node a JSX opening-like element we are trying to figure its call signature @@ -48123,37 +48687,20 @@ var ts; * @param relation a relationship to check parameter and argument type * @param excludeArgument */ - function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { - // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: - // 1. callIsIncomplete - // 2. attributes property has same number of properties as the parameter object type. - // We can figure that out by resolving attributes property and check number of properties in the resolved type - // If the call has correct arity, we will then check if the argument type and parameter type is assignable - var callIsIncomplete = node.attributes.end === node.end; // If we are missing the close "/>", the call is incomplete - if (callIsIncomplete) { - return true; - } - var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; + function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors) { // Stateless function components can have maximum of three arguments: "props", "context", and "updater". // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, // can be specified by users through attributes property. - var paramType = getTypeAtPosition(signature, 0); - var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*contextualMapper*/ undefined); - var argProperties = getPropertiesOfType(attributesType); - for (var _i = 0, argProperties_1 = argProperties; _i < argProperties_1.length; _i++) { - var arg = argProperties_1[_i]; - if (!getPropertyOfType(paramType, arg.escapedName) && isUnhyphenatedJsxName(arg.escapedName)) { - return false; - } - } - return checkTypeRelatedTo(attributesType, paramType, relation, /*errorNode*/ undefined, headMessage); + var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); + var attributesType = checkExpressionWithContextualType(node.attributes, paramType, excludeArgument && excludeArgument[0] ? identityMapper : undefined); + return checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes); } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { if (ts.isJsxOpeningLikeElement(node)) { - return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); + return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, excludeArgument, reportErrors); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 190 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 192 /* 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. @@ -48170,7 +48717,7 @@ 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 !== 208 /* OmittedExpression */) { + if (arg.kind !== 210 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), @@ -48193,15 +48740,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 189 /* CallExpression */) { + if (node.kind === 191 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { + if (callee.kind === 189 /* PropertyAccessExpression */ || callee.kind === 190 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(213 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(215 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -48211,21 +48758,21 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 191 /* TaggedTemplateExpression */) { + if (node.kind === 193 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 204 /* TemplateExpression */) { + if (template.kind === 206 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - if (node.kind === 150 /* Decorator */) { + if (node.kind === 152 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { - return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; + return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray; } var args = node.arguments || ts.emptyArray; var length = args.length; @@ -48251,30 +48798,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* 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 149 /* Parameter */: + case 151 /* 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 === 155 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 157 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 !== 152 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 154 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -48288,17 +48835,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return 1; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return 2; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* 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 149 /* Parameter */: + case 151 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -48311,8 +48858,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -48356,8 +48903,8 @@ var ts; function getTypeArgumentArityError(node, signatures, typeArguments) { var min = Infinity; var max = -Infinity; - for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { - var sig = signatures_6[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); max = Math.max(max, ts.length(sig.typeParameters)); } @@ -48365,14 +48912,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp, fallbackError) { - var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 150 /* Decorator */; + var isTaggedTemplate = node.kind === 193 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 152 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); + 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 !== 97 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 98 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -48380,7 +48928,9 @@ var ts; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); if (!candidates.length) { - diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + if (reportErrors) { + diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); + } return resolveErrorCall(node); } var args = getEffectiveCallArguments(node); @@ -48425,7 +48975,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 = isForSignatureHelp && node.kind === 189 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = isForSignatureHelp && node.kind === 191 /* 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 @@ -48449,34 +48999,32 @@ var ts; // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. - if (candidateForArgumentError) { - if (isJsxOpeningOrSelfClosingElement) { - // We do not report any error here because any error will be handled in "resolveCustomJsxElementAttributesType". - return candidateForArgumentError; + if (reportErrors) { + if (candidateForArgumentError) { + // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] + // The importance of excludeArgument is to prevent us from typing function expression parameters + // in arguments too early. If possible, we'd like to only type them once we know the correct + // overload. However, this matters for the case where the call is correct. When the call is + // an error, we don't need to exclude any arguments, although it would cause no harm to do so. + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } - // excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...] - // The importance of excludeArgument is to prevent us from typing function expression parameters - // in arguments too early. If possible, we'd like to only type them once we know the correct - // overload. However, this matters for the case where the call is correct. When the call is - // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); - } - else if (candidateForArgumentArityError) { - diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); - } - else if (candidateForTypeArgumentError) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); - } - else { - var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); - if (signaturesWithCorrectTypeArgumentArity.length === 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + else if (candidateForArgumentArityError) { + diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); } - else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + else if (candidateForTypeArgumentError) { + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, /*reportErrors*/ true, fallbackError); } - else if (fallbackError) { - diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + else { + var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); }); + if (signaturesWithCorrectTypeArgumentArity.length === 0) { + diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); + } + else if (!isDecorator) { + diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + } + else if (fallbackError) { + diagnostics.add(ts.createDiagnosticForNode(node, fallbackError)); + } } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); @@ -48679,7 +49227,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, isForSignatureHelp) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -48734,7 +49282,7 @@ var ts; } else { var relatedInformation = void 0; - if (node.arguments.length === 1 && isTypeAssertion(ts.first(node.arguments))) { + if (node.arguments.length === 1) { var text = ts.getSourceFileOfNode(node).text; if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); @@ -48758,8 +49306,8 @@ 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 & 65536 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 262144 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 /* Union */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, isForSignatureHelp) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -48837,7 +49385,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 524288 /* Intersection */) { + if (firstBase.flags & 2097152 /* Intersection */) { var types = firstBase.types; var mixinCount = ts.countWhere(types, isMixinConstructorType); var i = 0; @@ -48937,16 +49485,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -48982,6 +49530,58 @@ var ts; } return resolveCall(node, callSignatures, candidatesOutArray, isForSignatureHelp, 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, 67897832 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 67897832 /* Type */, node); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(120 /* AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + parameterSymbol.type = result; + return createSignature(declaration, + /*typeParameters*/ undefined, + /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, + /*returnTypePredicate*/ undefined, 1, + /*hasRestparameter*/ false, + /*hasLiteralTypes*/ false); + } + function resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); + var fakeSignature = createSignatureForJSXIntrinsic(node, result); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), result, node.tagName, node.attributes); + return fakeSignature; + } + var exprTypes = checkExpression(node.tagName); + var apparentType = getApparentType(exprTypes); + if (apparentType === errorType) { + return resolveErrorCall(node); + } + if (exprTypes.flags & 128 /* StringLiteral */) { + var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(exprTypes, node); + if (!intrinsicType) { + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, exprTypes.value, "JSX." + JsxNames.IntrinsicElements); + return resolveUntypedCall(node); + } + else { + var fakeSignature = createSignatureForJSXIntrinsic(node, intrinsicType); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined), intrinsicType, node.tagName, node.attributes); + return fakeSignature; + } + } + var signatures = getUninstantiatedJsxSignaturesOfType(apparentType); + if (exprTypes.flags & 4 /* String */ || isUntypedFunctionCall(exprTypes, apparentType, signatures.length, /*constructSignatures*/ 0)) { + return resolveUntypedCall(node); + } + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return resolveErrorCall(node); + } + return resolveCall(node, signatures, candidatesOutArray, isForSignatureHelp); + } /** * Sometimes, we have a decorator that could accept zero arguments, * but is receiving too many arguments as part of the decorator invocation. @@ -48994,49 +49594,19 @@ var ts; signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } - /** - * This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component. - * The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName - * and pass the type as elementType. The elementType can not be a union (as such case should be handled by the caller of this function) - * Note: at this point, we are still not sure whether the opening-like element is a stateless function component or not. - * @param openingLikeElement an opening-like JSX element to try to resolve as JSX stateless function - * @param elementType an element type of the opneing-like element by checking opening-like element's tagname. - * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; - * the function will fill it up with appropriate candidate signatures - */ - function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray, isForSignatureHelp) { - ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); - var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); - if (callSignatures && callSignatures.length > 0) { - return resolveCall(openingLikeElement, callSignatures, candidatesOutArray, isForSignatureHelp); - } - return undefined; - } function resolveSignature(node, candidatesOutArray, isForSignatureHelp) { switch (node.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, isForSignatureHelp); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, isForSignatureHelp); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, isForSignatureHelp); - case 150 /* Decorator */: + case 152 /* Decorator */: return resolveDecorator(node, candidatesOutArray, isForSignatureHelp); - case 260 /* JsxOpeningElement */: - case 259 /* JsxSelfClosingElement */: - // This code-path is called by language service - var exprTypes = checkExpression(node.tagName); - return forEachType(exprTypes, function (exprType) { - var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray, isForSignatureHelp); - if (sfcResult && sfcResult !== unknownSignature) { - return sfcResult; - } - var sigs = getInstantiatedJsxSignatures(node, exprType); - if (candidatesOutArray && ts.length(sigs)) { - candidatesOutArray.push.apply(candidatesOutArray, sigs); - } - return ts.length(sigs) ? sigs[0] : unknownSignature; - }) || unknownSignature; + case 262 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + return resolveJsxOpeningLikeElement(node, candidatesOutArray, isForSignatureHelp); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -49088,7 +49658,7 @@ var ts; return false; } function isJSConstructorType(type) { - if (type.flags & 131072 /* Object */) { + if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); } @@ -49123,10 +49693,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 187 /* PropertyAccessExpression */) { + while (parent && parent.kind === 189 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 59 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -49152,15 +49722,15 @@ var ts; if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return voidType; } - if (node.kind === 190 /* NewExpression */) { + if (node.kind === 192 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 155 /* Constructor */ && - declaration.kind !== 159 /* ConstructSignature */ && - declaration.kind !== 164 /* ConstructorType */ && + declaration.kind !== 157 /* Constructor */ && + declaration.kind !== 161 /* ConstructSignature */ && + declaration.kind !== 166 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -49168,7 +49738,7 @@ var ts; // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. var funcSymbol = checkExpression(node.expression).symbol; - if (!funcSymbol && node.expression.kind === 71 /* Identifier */) { + if (!funcSymbol && node.expression.kind === 72 /* Identifier */) { funcSymbol = getResolvedSymbol(node.expression); } var type = funcSymbol && getJSClassType(funcSymbol); @@ -49188,7 +49758,7 @@ 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 & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } var jsAssignmentType; @@ -49234,7 +49804,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -49287,9 +49857,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 237 /* FunctionDeclaration */ + ? 239 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 235 /* VariableDeclaration */ + ? 237 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -49325,10 +49895,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 94 /* NewKeyword */) { + if (node.keywordToken === 95 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 91 /* ImportKeyword */) { + if (node.keywordToken === 92 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -49339,7 +49909,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 === 155 /* Constructor */) { + else if (container.kind === 157 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -49510,7 +50080,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 71 /* Identifier */) { + if (element.name.kind === 72 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -49524,7 +50094,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* Identifier */) { // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType) { links.type = getTypeFromBindingPattern(decl.name); @@ -49574,7 +50144,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 216 /* Block */) { + if (func.body.kind !== 218 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -49684,7 +50254,7 @@ var ts; 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]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } // Remove inequalities for types that appear in the // active clause because they appear before other @@ -49694,7 +50264,7 @@ var ts; } // Add inequalities for types before the active clause unconditionally. for (var i = 0; i < start; i++) { - facts |= typeofNEFacts.get(witnesses[i]) || 8192 /* TypeofNEHostObject */; + facts |= typeofNEFacts.get(witnesses[i]) || 32768 /* TypeofNEHostObject */; } } // When in an active clause without default the set of @@ -49702,7 +50272,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]) || 64 /* TypeofEQHostObject */; + facts |= typeofEQFacts.get(witnesses[i]) || 128 /* TypeofEQHostObject */; } // Remove equalities for types that appear before the // active clause. @@ -49716,14 +50286,14 @@ var ts; if (!node.possiblyExhaustive) { return false; } - if (node.expression.kind === 197 /* TypeOfExpression */) { + if (node.expression.kind === 199 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); // 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_5 = getBaseConstraintOfType(operandType) || operandType; - return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 32768 /* Never */); + return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -49739,7 +50309,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 232 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -49761,7 +50331,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, 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 & 32768 /* Never */) { + if (type.flags & 131072 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -49782,11 +50352,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return true; - case 154 /* MethodDeclaration */: - return func.parent.kind === 186 /* ObjectLiteralExpression */; + case 156 /* MethodDeclaration */: + return func.parent.kind === 188 /* ObjectLiteralExpression */; default: return false; } @@ -49805,16 +50375,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 4096 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 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 === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 155 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 218 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 32768 /* Never */) { + if (returnType && returnType.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -49843,7 +50413,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -49863,7 +50433,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 196 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -49908,7 +50478,7 @@ var ts; getAwaitedType(type) || errorType : type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 156 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -49924,7 +50494,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 216 /* Block */) { + if (node.body.kind === 218 /* Block */) { checkSourceElement(node.body); } else { @@ -49947,34 +50517,66 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { + if (!isTypeAssignableTo(type, numberOrBigIntType)) { error(operand, diagnostic); return false; } return true; } + function isReadonlyAssignmentDeclaration(d) { + if (!ts.isCallExpression(d)) { + return false; + } + if (!ts.isBindableObjectDefinePropertyCall(d)) { + return false; + } + var objectLitType = checkExpressionCached(d.arguments[2]); + var valueType = getTypeOfPropertyOfType(objectLitType, "value"); + if (valueType) { + var writableProp = getPropertyOfType(objectLitType, "writable"); + var writableType = writableProp && getTypeOfSymbol(writableProp); + if (!writableType || writableType === falseType || writableType === regularFalseType) { + return true; + } + // We include this definition whereupon we walk back and check the type at the declaration because + // The usual definition of `Object.defineProperty` will _not_ cause literal types to be preserved in the + // argument types, should the type be contextualized by the call itself. + if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) { + var initializer = writableProp.valueDeclaration.initializer; + var rawOriginalType = checkExpression(initializer); + if (rawOriginalType === falseType || rawOriginalType === regularFalseType) { + return true; + } + } + return false; + } + var setProp = getPropertyOfType(objectLitType, "set"); + return !setProp; + } function isReadonlySymbol(symbol) { // The following symbols are considered read-only: // Properties with a 'readonly' modifier // Variables declared with 'const' // Get accessors without matching set accessors // 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 */); + symbol.flags & 8 /* EnumMember */ || + ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && - expr.expression.kind === 99 /* ThisKeyword */) { + (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) && + expr.expression.kind === 100 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 155 /* Constructor */)) { + if (!(func && func.kind === 157 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -49987,13 +50589,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { + if (expr.kind === 189 /* PropertyAccessExpression */ || expr.kind === 190 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 249 /* NamespaceImport */; + return !!declaration && declaration.kind === 251 /* NamespaceImport */; } } } @@ -50002,7 +50604,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { + if (node.kind !== 72 /* Identifier */ && node.kind !== 189 /* PropertyAccessExpression */ && node.kind !== 190 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -50011,7 +50613,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { + if (expr.kind !== 189 /* PropertyAccessExpression */ && expr.kind !== 190 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -50048,37 +50650,52 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operand.kind === 8 /* NumericLiteral */) { - if (node.operator === 38 /* MinusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - } - else if (node.operator === 37 /* PlusToken */) { - return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); - } + switch (node.operand.kind) { + case 8 /* NumericLiteral */: + switch (node.operator) { + case 39 /* MinusToken */: + return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); + case 38 /* PlusToken */: + return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); + } + break; + case 9 /* BigIntLiteral */: + if (node.operator === 39 /* MinusToken */) { + return getFreshTypeOfLiteralType(getLiteralType({ + negative: true, + base10Value: ts.parsePseudoBigInt(node.operand.text) + })); + } } switch (node.operator) { - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - return numberType; - case 51 /* ExclamationToken */: + if (node.operator === 38 /* PlusToken */) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + } + return numberType; + } + return getUnaryResultType(operandType); + case 52 /* ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); - return facts === 1048576 /* Truthy */ ? falseType : - facts === 2097152 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); + return facts === 4194304 /* Truthy */ ? falseType : + facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 43 /* PlusPlusToken */: - case 44 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + case 44 /* PlusPlusToken */: + case 45 /* 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 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } - return numberType; + return getUnaryResultType(operandType); } return errorType; } @@ -50087,11 +50704,20 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); + var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } + return getUnaryResultType(operandType); + } + function getUnaryResultType(operandType) { + if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + ? numberOrBigIntType + : bigintType; + } + // If it's not a bigint type, implicit coercion will result in a number return numberType; } // Return true if type might be of the given kind. A union or intersection type might be of a given @@ -50100,7 +50726,7 @@ var ts; if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 786432 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var t = types_15[_i]; @@ -50115,21 +50741,22 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { return false; } - return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 132 /* 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); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 262144 /* Union */ ? + return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } @@ -50149,7 +50776,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, 32764 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* 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 @@ -50168,10 +50795,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -50181,8 +50808,8 @@ var ts; if (strictNullChecks && properties.length === 0) { return checkNonNullType(sourceType, node); } - for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { - var p = properties_7[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var p = properties_6[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties, rightIsThis); } return sourceType; @@ -50190,9 +50817,9 @@ var ts; /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties, rightIsThis) { if (rightIsThis === void 0) { rightIsThis = false; } - if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { + if (property.kind === 275 /* PropertyAssignment */ || property.kind === 276 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -50201,13 +50828,13 @@ var ts; var type = getTypeOfObjectLiteralDestructuringProperty(objectLiteralType, name, property, rightIsThis); if (type) { // non-shorthand property assignments should always have initializers - return checkDestructuringAssignment(property.kind === 274 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 276 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } else { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 275 /* SpreadAssignment */) { + else if (property.kind === 277 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -50259,8 +50886,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 208 /* OmittedExpression */) { - if (element.kind !== 206 /* SpreadElement */) { + if (element.kind !== 210 /* OmittedExpression */) { + if (element.kind !== 208 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType : everyType(sourceType, isTupleLikeType) ? getTupleElementType(sourceType, elementIndex) : @@ -50284,7 +50911,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 204 /* BinaryExpression */ && restExpression.operatorToken.kind === 59 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -50301,14 +50928,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 276 /* 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)) & 8192 /* Undefined */)) { - sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768 /* Undefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -50317,21 +50944,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 204 /* BinaryExpression */ && target.operatorToken.kind === 59 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 186 /* ObjectLiteralExpression */) { + if (target.kind === 188 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 185 /* ArrayLiteralExpression */) { + if (target.kind === 187 /* 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 === 275 /* SpreadAssignment */ ? + var error = target.parent.kind === 277 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -50350,58 +50977,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 71 /* Identifier */: - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 191 /* TaggedTemplateExpression */: - case 204 /* TemplateExpression */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 72 /* Identifier */: + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 193 /* TaggedTemplateExpression */: + case 206 /* TemplateExpression */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 140 /* UndefinedKeyword */: - case 194 /* FunctionExpression */: - case 207 /* ClassExpression */: - case 195 /* ArrowFunction */: - case 185 /* ArrayLiteralExpression */: - case 186 /* ObjectLiteralExpression */: - case 197 /* TypeOfExpression */: - case 211 /* NonNullExpression */: - case 259 /* JsxSelfClosingElement */: - case 258 /* JsxElement */: + case 9 /* BigIntLiteral */: + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 141 /* UndefinedKeyword */: + case 196 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 197 /* ArrowFunction */: + case 187 /* ArrayLiteralExpression */: + case 188 /* ObjectLiteralExpression */: + case 199 /* TypeOfExpression */: + case 213 /* NonNullExpression */: + case 261 /* JsxSelfClosingElement */: + case 260 /* JsxElement */: return true; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 51 /* ExclamationToken */: - case 37 /* PlusToken */: - case 38 /* MinusToken */: - case 52 /* TildeToken */: + case 52 /* ExclamationToken */: + case 38 /* PlusToken */: + case 39 /* MinusToken */: + case 53 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 198 /* VoidExpression */: // Explicit opt-out - case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 200 /* VoidExpression */: // Explicit opt-out + case 194 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 212 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { @@ -50411,11 +51039,11 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 99 /* ThisKeyword */); + if (operator === 59 /* EqualsToken */ && (left.kind === 188 /* ObjectLiteralExpression */ || left.kind === 187 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 100 /* ThisKeyword */); } var leftType; - if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { + if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -50423,28 +51051,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 39 /* AsteriskToken */: - case 40 /* AsteriskAsteriskToken */: - case 61 /* AsteriskEqualsToken */: - case 62 /* AsteriskAsteriskEqualsToken */: - case 41 /* SlashToken */: - case 63 /* SlashEqualsToken */: - case 42 /* PercentToken */: - case 64 /* PercentEqualsToken */: - case 38 /* MinusToken */: - case 60 /* MinusEqualsToken */: - case 45 /* LessThanLessThanToken */: - case 65 /* LessThanLessThanEqualsToken */: - case 46 /* GreaterThanGreaterThanToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: + case 40 /* AsteriskToken */: + case 41 /* AsteriskAsteriskToken */: + case 62 /* AsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: + case 42 /* SlashToken */: + case 64 /* SlashEqualsToken */: + case 43 /* PercentToken */: + case 65 /* PercentEqualsToken */: + case 39 /* MinusToken */: + case 61 /* MinusEqualsToken */: + case 46 /* LessThanLessThanToken */: + case 66 /* LessThanLessThanEqualsToken */: + case 47 /* GreaterThanGreaterThanToken */: + case 67 /* GreaterThanGreaterThanEqualsToken */: + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -50453,36 +51081,61 @@ 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 & 272 /* BooleanLike */) && - (rightType.flags & 272 /* BooleanLike */) && + if ((leftType.flags & 528 /* BooleanLike */) && + (rightType.flags & 528 /* 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; } else { // otherwise just check each operand separately and report errors as normal - var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type); + 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 */)) || + // Or, if neither could be bigint, implicit coercion results in a number result + !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + resultType_1 = numberType; } + // At least one is assignable to bigint, so both should be only assignable to bigint + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + switch (operator) { + case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + reportOperatorError(); + } + resultType_1 = bigintType; + } + else { + reportOperatorError(); + resultType_1 = errorType; + } + if (leftOk && rightOk) { + checkAssignmentOperator(resultType_1); + } + return resultType_1; } - return numberType; - case 37 /* PlusToken */: - case 59 /* PlusEqualsToken */: + case 38 /* PlusToken */: + case 60 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 132 /* StringLike */) && !isTypeAssignableToKind(rightType, 132 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* 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, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* 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, 132 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 132 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -50499,26 +51152,27 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 59 /* PlusEqualsToken */) { + if (operator === 60 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 27 /* LessThanToken */: - case 29 /* GreaterThanToken */: - case 30 /* LessThanEqualsToken */: - case 31 /* GreaterThanEqualsToken */: + case 28 /* LessThanToken */: + case 30 /* GreaterThanToken */: + case 31 /* LessThanEqualsToken */: + case 32 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); - if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { + if (!(isTypeComparableTo(leftType, rightType) || isTypeComparableTo(rightType, leftType) || + (isTypeAssignableTo(leftType, numberOrBigIntType) && isTypeAssignableTo(rightType, numberOrBigIntType)))) { reportOperatorError(); } } return booleanType; - case 32 /* EqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: - case 34 /* EqualsEqualsEqualsToken */: - case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -50529,19 +51183,19 @@ var ts; reportOperatorError(); } return booleanType; - case 93 /* InstanceOfKeyword */: + case 94 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 92 /* InKeyword */: + case 93 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 53 /* AmpersandAmpersandToken */: - return getTypeFacts(leftType) & 1048576 /* Truthy */ ? + case 54 /* AmpersandAmpersandToken */: + return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 54 /* BarBarToken */: - return getTypeFacts(leftType) & 2097152 /* Falsy */ ? + case 55 /* BarBarToken */: + return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 58 /* EqualsToken */: + case 59 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, right); if (isAssignmentDeclaration(declKind)) { @@ -50551,7 +51205,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 26 /* CommaToken */: + case 27 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -50577,12 +51231,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 71 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 72 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 12288 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -50592,15 +51246,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 49 /* BarToken */: - case 69 /* BarEqualsToken */: - return 54 /* BarBarToken */; - case 50 /* CaretToken */: - case 70 /* CaretEqualsToken */: - return 35 /* ExclamationEqualsEqualsToken */; - case 48 /* AmpersandToken */: - case 68 /* AmpersandEqualsToken */: - return 53 /* AmpersandAmpersandToken */; + case 50 /* BarToken */: + case 70 /* BarEqualsToken */: + return 55 /* BarBarToken */; + case 51 /* CaretToken */: + case 71 /* CaretEqualsToken */: + return 36 /* ExclamationEqualsEqualsToken */; + case 49 /* AmpersandToken */: + case 69 /* AmpersandEqualsToken */: + return 54 /* AmpersandAmpersandToken */; default: return undefined; } @@ -50647,11 +51301,11 @@ var ts; } function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { switch (operatorToken.kind) { - case 34 /* EqualsEqualsEqualsToken */: - case 32 /* EqualsEqualsToken */: + case 35 /* EqualsEqualsEqualsToken */: + case 33 /* EqualsEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); - case 35 /* ExclamationEqualsEqualsToken */: - case 33 /* ExclamationEqualsToken */: + case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* ExclamationEqualsToken */: return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); } return undefined; @@ -50729,14 +51383,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } }); return stringType; } function getContextNode(node) { - if (node.kind === 266 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 268 /* 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; @@ -50772,7 +51426,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; + return node.kind === 194 /* TypeAssertionExpression */ || node.kind === 212 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -50781,7 +51435,7 @@ var ts; ts.isDeclarationReadonly(declaration) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 24576 /* Nullable */) { + if (widened.flags & 98304 /* Nullable */) { reportImplicitAny(declaration, anyType); return anyType; } @@ -50794,26 +51448,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 786432 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* 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) || emptyObjectType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || + 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 */) || 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 & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || - contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || - contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || - contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */) && 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 false; } @@ -50829,7 +51485,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -50840,7 +51496,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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -50871,14 +51527,14 @@ var ts; var 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 (expr.kind === 189 /* CallExpression */ && expr.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (expr.kind === 191 /* CallExpression */ && expr.expression.kind !== 98 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var funcType = checkNonNullExpression(expr.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - else if (expr.kind === 192 /* TypeAssertionExpression */ || expr.kind === 210 /* AsExpression */) { + else if (expr.kind === 194 /* TypeAssertionExpression */ || expr.kind === 212 /* AsExpression */) { return getTypeFromTypeNode(expr.type); } // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions @@ -50913,7 +51569,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode, forceTuple) { var type; - if (node.kind === 146 /* QualifiedName */) { + if (node.kind === 148 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -50925,10 +51581,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 190 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 72 /* Identifier */ || node.kind === 148 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 167 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } @@ -50944,94 +51600,97 @@ var ts; } function checkExpressionWorker(node, checkMode, forceTuple) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return checkIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return checkThisExpression(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkSuperExpression(node); - case 95 /* NullKeyword */: + case 96 /* NullKeyword */: return nullWideningType; - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101 /* TrueKeyword */: + case 9 /* BigIntLiteral */: + checkGrammarBigIntLiteral(node); + return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); + case 102 /* TrueKeyword */: return trueType; - case 86 /* FalseKeyword */: + case 87 /* FalseKeyword */: return falseType; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return checkTemplateExpression(node); - case 12 /* RegularExpressionLiteral */: + case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 189 /* CallExpression */: - if (node.expression.kind === 91 /* ImportKeyword */) { + case 191 /* CallExpression */: + if (node.expression.kind === 92 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 190 /* NewExpression */: + case 192 /* NewExpression */: return checkCallExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return checkClassExpression(node); - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: return checkAssertion(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return checkNonNullAssertion(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return checkMetaProperty(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return checkDeleteExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return checkVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return checkAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return undefinedWideningType; - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return checkYieldExpression(node); - case 213 /* SyntheticExpression */: + case 215 /* SyntheticExpression */: return node.type; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return checkJsxElement(node, checkMode); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 262 /* JsxFragment */: - return checkJsxFragment(node, checkMode); - case 266 /* JsxAttributes */: + case 264 /* JsxFragment */: + return checkJsxFragment(node); + case 268 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -51069,7 +51728,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 157 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -51080,10 +51739,10 @@ 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 === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { + if (func.kind === 157 /* Constructor */ || func.kind === 161 /* ConstructSignature */ || func.kind === 166 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 195 /* ArrowFunction */) { + if (func.kind === 197 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -51138,13 +51797,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 195 /* ArrowFunction */: - case 158 /* CallSignature */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 163 /* FunctionType */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 197 /* ArrowFunction */: + case 160 /* CallSignature */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 165 /* FunctionType */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -51158,11 +51817,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 71 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 72 /* 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 === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { + else if (name.kind === 185 /* ArrayBindingPattern */ || name.kind === 184 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -51171,13 +51830,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* 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 === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || - node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || - node.kind === 159 /* ConstructSignature */) { + else if (node.kind === 165 /* FunctionType */ || node.kind === 239 /* FunctionDeclaration */ || node.kind === 166 /* ConstructorType */ || + node.kind === 160 /* CallSignature */ || node.kind === 157 /* Constructor */ || + node.kind === 161 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -51207,10 +51866,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -51240,7 +51899,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { + if (node.kind !== 162 /* IndexSignature */ && node.kind !== 289 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -51257,7 +51916,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 155 /* Constructor */) { + if (member.kind === 157 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -51272,16 +51931,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: addName(names, name, memberName, 1 /* Getter */); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: addName(names, name, memberName, 2 /* Setter */); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* Property */); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: addName(names, name, memberName, 4 /* Method */); break; } @@ -51344,15 +52003,15 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* PropertySignature */) { + if (member.kind === 153 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: case 8 /* NumericLiteral */: memberName = name.text; break; - case 71 /* Identifier */: + case 72 /* Identifier */: memberName = ts.idText(name); break; default: @@ -51369,7 +52028,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* 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 @@ -51389,7 +52048,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -51397,7 +52056,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -51424,7 +52083,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 156 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -51449,7 +52108,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 152 /* PropertyDeclaration */ && + return n.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -51479,7 +52138,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -51504,7 +52163,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -51514,13 +52173,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -51538,7 +52197,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -51586,7 +52245,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 164 /* 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); } var type = getTypeFromTypeReference(node); @@ -51634,7 +52293,7 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 170 /* RestType */) { + if (e.kind === 172 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; @@ -51643,7 +52302,7 @@ var ts; error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 169 /* OptionalType */) { + else if (e.kind === 171 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -51658,14 +52317,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 2097152 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* 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 === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 190 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -51673,7 +52332,7 @@ 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. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -51705,7 +52364,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 175 /* 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); @@ -51722,9 +52381,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 239 /* InterfaceDeclaration */ && - n.parent.kind !== 238 /* ClassDeclaration */ && - n.parent.kind !== 207 /* ClassExpression */ && + if (n.parent.kind !== 241 /* InterfaceDeclaration */ && + n.parent.kind !== 240 /* ClassDeclaration */ && + n.parent.kind !== 209 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* 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 @@ -51815,7 +52474,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && + var reportError = (node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -51854,7 +52513,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 241 /* InterfaceDeclaration */ || node.parent.kind === 168 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -51865,7 +52524,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 239 /* FunctionDeclaration */ || node.kind === 156 /* MethodDeclaration */ || node.kind === 155 /* MethodSignature */ || node.kind === 157 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -51917,8 +52576,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_7 = signatures; _a < signatures_7.length; _a++) { - var signature = signatures_7[_a]; + for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { + var signature = signatures_6[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -51994,22 +52653,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 277 /* SourceFile */: + case 279 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -52017,17 +52676,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 248 /* ImportClause */: + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 250 /* ImportClause */: var result_4 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_4 |= getDeclarationSpaces(d); }); return result_4; - case 235 /* VariableDeclaration */: - case 184 /* BindingElement */: - case 237 /* FunctionDeclaration */: - case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 237 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 239 /* FunctionDeclaration */: + case 253 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -52074,7 +52733,7 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } @@ -52105,7 +52764,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 262144 /* Union */) { + if (type.flags & 1048576 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -52256,7 +52915,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 71 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 72 /* 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 { @@ -52295,24 +52954,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 149 /* Parameter */: + case 151 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -52333,7 +52992,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 71 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 72 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -52358,50 +53017,55 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 172 /* IntersectionType */: - case 171 /* UnionType */: - var commonEntityName = void 0; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { - typeNode = typeNode.type; // Skip parens if need be - } - if (typeNode.kind === 131 /* NeverKeyword */) { - continue; // Always elide `never` from the union/intersection if possible - } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* 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); - if (!individualEntityName) { - // Individual is something like string number - // So it would be serialized to either that type or object - // Safe to return here - return undefined; - } - if (commonEntityName) { - // Note this is in sync with the transformation that happens for type node. - // Keep this in sync with serializeUnionOrIntersectionType - // Verify if they refer to same entity and is identifier - // return undefined if they dont match because we would emit object - if (!ts.isIdentifier(commonEntityName) || - !ts.isIdentifier(individualEntityName) || - commonEntityName.escapedText !== individualEntityName.escapedText) { - return undefined; - } - } - else { - commonEntityName = individualEntityName; - } - } - return commonEntityName; - case 175 /* ParenthesizedType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return getEntityNameForDecoratorMetadataFromTypeList(node.types); + case 175 /* ConditionalType */: + return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + case 177 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return node.typeName; } } } + function getEntityNameForDecoratorMetadataFromTypeList(types) { + var commonEntityName; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var typeNode = types_16[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { + typeNode = typeNode.type; // Skip parens if need be + } + if (typeNode.kind === 132 /* NeverKeyword */) { + continue; // Always elide `never` from the union/intersection if possible + } + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); + if (!individualEntityName) { + // Individual is something like string number + // So it would be serialized to either that type or object + // Safe to return here + return undefined; + } + if (commonEntityName) { + // Note this is in sync with the transformation that happens for type node. + // Keep this in sync with serializeUnionOrIntersectionType + // Verify if they refer to same entity and is identifier + // return undefined if they dont match because we would emit object + if (!ts.isIdentifier(commonEntityName) || + !ts.isIdentifier(individualEntityName) || + commonEntityName.escapedText !== individualEntityName.escapedText) { + return undefined; + } + } + else { + commonEntityName = individualEntityName; + } + } + return commonEntityName; + } function getParameterTypeNodeForDecoratorCheck(node) { var typeNode = ts.getEffectiveTypeAnnotationNode(node); return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode; @@ -52421,14 +53085,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 149 /* Parameter */) { + if (node.kind === 151 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -52437,23 +53101,23 @@ var ts; } } break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + var otherKind = node.kind === 158 /* GetAccessor */ ? 159 /* SetAccessor */ : 158 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 154 /* MethodDeclaration */: + case 156 /* 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 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 149 /* Parameter */: + case 151 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -52506,16 +53170,22 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 148 /* QualifiedName */ ? node.name.right : node.name)); } } } } + function checkJSDocFunctionType(node) { + if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) { + reportImplicitAny(node, anyType); + } + checkSignatureDeclaration(node); + } function checkJSDocAugmentsTag(node) { var classLike = ts.getJSDocHost(node); if (!ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { @@ -52538,9 +53208,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -52553,7 +53223,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 === 147 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 149 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -52582,7 +53252,7 @@ var ts; } } } - var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 155 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function var returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); @@ -52627,42 +53297,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 277 /* SourceFile */: - case 242 /* ModuleDeclaration */: - case 216 /* Block */: - case 244 /* CaseBlock */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 279 /* SourceFile */: + case 244 /* ModuleDeclaration */: + case 218 /* Block */: + case 246 /* CaseBlock */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 155 /* Constructor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 157 /* Constructor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 240 /* TypeAliasDeclaration */: - case 174 /* InferType */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 242 /* TypeAliasDeclaration */: + case 176 /* InferType */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -52683,11 +53353,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 154 /* MethodDeclaration */: - case 152 /* PropertyDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 156 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + if (member.kind === 159 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -52696,7 +53366,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -52704,8 +53374,8 @@ var ts; } } break; - case 160 /* IndexSignature */: - case 215 /* SemicolonClassElement */: + case 162 /* IndexSignature */: + case 217 /* SemicolonClassElement */: // Can't be private break; default: @@ -52717,9 +53387,9 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (node.flags & 4194304 /* Ambient */ || node.kind !== 174 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) + if (node.flags & 4194304 /* Ambient */ || node.kind !== 176 /* InferType */ && ts.last(getSymbolOfNode(node).declarations) !== node) return; - if (node.kind === 174 /* InferType */) { + if (node.kind === 176 /* InferType */) { 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))); @@ -52734,7 +53404,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 174 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 176 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -52820,7 +53490,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 251 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -52838,7 +53508,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 237 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 238 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -52859,7 +53529,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 219 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -52871,24 +53541,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.idText(name); - case 183 /* ArrayBindingPattern */: - case 182 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; + return node.kind === 250 /* ImportClause */ || node.kind === 253 /* ImportSpecifier */ || node.kind === 251 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 250 /* ImportClause */ ? decl : decl.kind === 251 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 216 /* Block */) { + if (node.kind === 218 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -52918,12 +53588,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 152 /* PropertyDeclaration */ || - node.kind === 151 /* PropertySignature */ || - node.kind === 154 /* MethodDeclaration */ || - node.kind === 153 /* MethodSignature */ || - node.kind === 156 /* GetAccessor */ || - node.kind === 157 /* SetAccessor */) { + if (node.kind === 154 /* PropertyDeclaration */ || + node.kind === 153 /* PropertySignature */ || + node.kind === 156 /* MethodDeclaration */ || + node.kind === 155 /* MethodSignature */ || + node.kind === 158 /* GetAccessor */ || + node.kind === 159 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -52932,7 +53602,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 151 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -52942,7 +53612,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 71 /* Identifier */; + var isDeclaration_1 = node.kind !== 72 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -52957,7 +53627,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 71 /* Identifier */; + var isDeclaration_2 = node.kind !== 72 /* 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); } @@ -52983,7 +53653,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -52998,7 +53668,7 @@ var ts; } // 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 === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 279 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -53033,7 +53703,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 237 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -53045,17 +53715,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 217 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 238 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 219 /* 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 === 216 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 243 /* ModuleBlock */ || - container.kind === 242 /* ModuleDeclaration */ || - container.kind === 277 /* SourceFile */); + (container.kind === 218 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 245 /* ModuleBlock */ || + container.kind === 244 /* ModuleDeclaration */ || + container.kind === 279 /* 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 @@ -53070,7 +53740,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 151 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -53081,11 +53751,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 187 /* PropertyAccessExpression */) { + if (n.kind === 189 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 71 /* Identifier */) { + else if (n.kind === 72 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.escapedText, 67220415 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -53100,8 +53770,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 184 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 151 /* Parameter */ || + symbol.valueDeclaration.kind === 186 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -53115,7 +53785,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 152 /* PropertyDeclaration */ && + (current.parent.kind === 154 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -53148,18 +53818,18 @@ 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 === 147 /* ComputedPropertyName */) { + if (node.name.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 184 /* BindingElement */) { - if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 186 /* BindingElement */) { + if (node.parent.kind === 184 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 149 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -53172,27 +53842,27 @@ var ts; var property = getPropertyOfType(parentType, nameText); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { - checkPropertyAccessibility(parent, parent.initializer.kind === 97 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, parent.initializer.kind === 98 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 185 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 151 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 226 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -53215,11 +53885,16 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 226 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } + if (symbol.declarations.length > 1) { + if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { + error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); + } + } } else { // Node is a secondary declaration, check that type is identical to primary declaration and check that @@ -53234,14 +53909,13 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { - error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { + if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -53250,14 +53924,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* PropertySignature */ + var message = nextDeclaration.kind === 154 /* PropertyDeclaration */ || nextDeclaration.kind === 153 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || - (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 151 /* Parameter */ && right.kind === 237 /* VariableDeclaration */) || + (left.kind === 237 /* VariableDeclaration */ && right.kind === 151 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -53296,7 +53970,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkTruthinessExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 218 /* EmptyStatement */) { + if (node.thenStatement.kind === 220 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -53315,7 +53989,7 @@ var ts; } function checkTruthinessExpression(node, checkMode) { var type = checkExpression(node, checkMode); - if (type.flags & 4096 /* Void */) { + if (type.flags & 16384 /* Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -53323,12 +53997,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 238 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -53362,14 +54036,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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. @@ -53395,13 +54069,13 @@ var ts; function checkForInStatement(node) { // Grammar checking checkGrammarForInOrForOfStatement(node); - var rightType = checkNonNullExpression(node.expression); + var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); // TypeScript 1.0 spec (April 2014): 5.4 // In a 'for-in' statement of the form // 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 === 236 /* VariableDeclarationList */) { + if (node.initializer.kind === 238 /* 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); @@ -53415,7 +54089,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 === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* ObjectLiteralExpression */) { + if (varExpr.kind === 187 /* ArrayLiteralExpression */ || varExpr.kind === 188 /* 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)) { @@ -53428,7 +54102,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, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* 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); @@ -53483,16 +54157,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 262144 /* Union */) { + if (arrayType.flags & 1048576 /* 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 & 68 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 68 /* StringLike */) { + else if (arrayType.flags & 132 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -53505,7 +54179,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 & 32768 /* Never */) { + if (arrayType.flags & 131072 /* Never */) { return stringType; } } @@ -53536,7 +54210,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 68 /* StringLike */) { + if (arrayElementType.flags & 132 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -53750,7 +54424,7 @@ var ts; var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -53766,7 +54440,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -53775,12 +54449,12 @@ var ts; // for generators. return; } - else if (func.kind === 157 /* SetAccessor */) { + else if (func.kind === 159 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 155 /* Constructor */) { + else if (func.kind === 157 /* 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); } @@ -53801,7 +54475,7 @@ var ts; } } } - else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 157 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -53830,7 +54504,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 === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 272 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -53842,7 +54516,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 271 /* 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. @@ -53871,7 +54545,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 233 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -53978,8 +54652,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 202 /* BinaryExpression */ || - name.kind === 147 /* ComputedPropertyName */ || + (propDeclaration.kind === 204 /* BinaryExpression */ || + name.kind === 149 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -54008,6 +54682,7 @@ var ts; case "any": case "unknown": case "number": + case "bigint": case "boolean": case "string": case "symbol": @@ -54187,10 +54862,10 @@ var ts; // 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 & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 8650752 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { + 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. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -54285,7 +54960,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; + return d.kind === 240 /* ClassDeclaration */ || d.kind === 241 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -54324,7 +54999,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 207 /* ClassExpression */) { + if (derivedClassDecl.kind === 209 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -54374,8 +55049,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { - var prop = properties_8[_a]; + for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { + var prop = properties_7[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -54406,7 +55081,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* 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)); } @@ -54416,7 +55091,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 152 /* PropertyDeclaration */ && + return node.kind === 154 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -54427,7 +55102,7 @@ var ts; reference.parent = constructor; reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 8192 /* Undefined */); + return !(getFalsyFlags(flowType) & 32768 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -54440,7 +55115,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 241 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -54545,60 +55220,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 37 /* PlusToken */: return value_2; - case 38 /* MinusToken */: return -value_2; - case 52 /* TildeToken */: return ~value_2; + case 38 /* PlusToken */: return value_2; + case 39 /* MinusToken */: return -value_2; + case 53 /* TildeToken */: return ~value_2; } } break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 49 /* BarToken */: return left | right; - case 48 /* AmpersandToken */: return left & right; - case 46 /* GreaterThanGreaterThanToken */: return left >> right; - case 47 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 45 /* LessThanLessThanToken */: return left << right; - case 50 /* CaretToken */: return left ^ right; - case 39 /* AsteriskToken */: return left * right; - case 41 /* SlashToken */: return left / right; - case 37 /* PlusToken */: return left + right; - case 38 /* MinusToken */: return left - right; - case 42 /* PercentToken */: return left % right; - case 40 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 50 /* BarToken */: return left | right; + case 49 /* AmpersandToken */: return left & right; + case 47 /* GreaterThanGreaterThanToken */: return left >> right; + case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 46 /* LessThanLessThanToken */: return left << right; + case 51 /* CaretToken */: return left ^ right; + case 40 /* AsteriskToken */: return left * right; + case 42 /* SlashToken */: return left / right; + case 38 /* PlusToken */: return left + right; + case 39 /* MinusToken */: return left - right; + case 43 /* PercentToken */: return left % right; + case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 37 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { return left + right; } break; - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 71 /* Identifier */: + case 72 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 187 /* PropertyAccessExpression */) { + if (ex.kind === 189 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -54629,10 +55304,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 71 /* Identifier */ || - node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 9 /* StringLiteral */; + return node.kind === 72 /* Identifier */ || + node.kind === 189 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 190 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.argumentExpression.kind === 10 /* StringLiteral */; } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -54669,7 +55344,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 !== 241 /* EnumDeclaration */) { + if (declaration.kind !== 243 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -54692,8 +55367,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 238 /* ClassDeclaration */ || - (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 240 /* ClassDeclaration */ || + (declaration.kind === 239 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -54730,7 +55405,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 9 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -54756,7 +55431,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 240 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -54806,23 +55481,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 184 /* BindingElement */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 237 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -54833,12 +55508,12 @@ var ts; break; } // falls through - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 237 /* FunctionDeclaration */: - case 239 /* InterfaceDeclaration */: - case 242 /* ModuleDeclaration */: - case 240 /* TypeAliasDeclaration */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 241 /* InterfaceDeclaration */: + case 244 /* ModuleDeclaration */: + case 242 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -54851,7 +55526,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -54859,17 +55534,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return node; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 71 /* Identifier */); + } while (node.kind !== 72 /* Identifier */); return node; } } @@ -54883,9 +55558,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 253 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 255 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -54918,14 +55593,14 @@ var ts; (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 255 /* ExportSpecifier */ ? + var message = node.kind === 257 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 255 /* ExportSpecifier */ + && node.kind === 257 /* ExportSpecifier */ && !(target.flags & 67220415 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -54952,7 +55627,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 251 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -54976,7 +55651,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 259 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67220415 /* Value */) { @@ -55012,10 +55687,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 245 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 245 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 279 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -55032,7 +55707,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 279 /* SourceFile */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 244 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -55061,8 +55736,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 === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -55075,7 +55750,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { markExportAsReferenced(node); if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); @@ -55150,7 +55825,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 239 /* FunctionDeclaration */ && declaration.kind !== 156 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -55168,158 +55843,158 @@ 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 242 /* ModuleDeclaration */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 237 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 239 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return checkTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return checkParameter(node); - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return checkPropertyDeclaration(node); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 158 /* CallSignature */: - case 159 /* ConstructSignature */: - case 160 /* IndexSignature */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 160 /* CallSignature */: + case 161 /* ConstructSignature */: + case 162 /* IndexSignature */: return checkSignatureDeclaration(node); - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: return checkMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return checkConstructorDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return checkAccessorDeclaration(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return checkTypeReferenceNode(node); - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return checkTypePredicate(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return checkTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return checkTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return checkArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return checkTupleType(node); - case 171 /* UnionType */: - case 172 /* IntersectionType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 175 /* ParenthesizedType */: - case 169 /* OptionalType */: - case 170 /* RestType */: + case 177 /* ParenthesizedType */: + case 171 /* OptionalType */: + case 172 /* RestType */: return checkSourceElement(node.type); - case 176 /* ThisType */: + case 178 /* ThisType */: return checkThisType(node); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return checkTypeOperator(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return checkConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return checkInferType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return checkImportType(node); - case 293 /* JSDocAugmentsTag */: + case 295 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 302 /* JSDocTypedefTag */: - case 295 /* JSDocCallbackTag */: + case 304 /* JSDocTypedefTag */: + case 297 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 301 /* JSDocTemplateTag */: + case 303 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 300 /* JSDocTypeTag */: + case 302 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 297 /* JSDocParameterTag */: + case 299 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 287 /* JSDocFunctionType */: - checkSignatureDeclaration(node); + case 289 /* JSDocFunctionType */: + checkJSDocFunctionType(node); // falls through - case 285 /* JSDocNonNullableType */: - case 284 /* JSDocNullableType */: - case 282 /* JSDocAllType */: - case 283 /* JSDocUnknownType */: - case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocNonNullableType */: + case 286 /* JSDocNullableType */: + case 284 /* JSDocAllType */: + case 285 /* JSDocUnknownType */: + case 292 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 288 /* JSDocVariadicType */: + case 290 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 281 /* JSDocTypeExpression */: + case 283 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return checkMappedType(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 216 /* Block */: - case 243 /* ModuleBlock */: + case 218 /* Block */: + case 245 /* ModuleBlock */: return checkBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return checkVariableStatement(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return checkExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return checkIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return checkDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return checkWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return checkForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return checkForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return checkForOfStatement(node); - case 226 /* ContinueStatement */: - case 227 /* BreakStatement */: + case 228 /* ContinueStatement */: + case 229 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return checkReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return checkWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return checkSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return checkLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return checkThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return checkTryStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return checkBindingElement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return checkClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return checkImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return checkExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return checkExportAssignment(node); - case 218 /* EmptyStatement */: - case 234 /* DebuggerStatement */: + case 220 /* EmptyStatement */: + case 236 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -55410,23 +56085,23 @@ var ts; } links.deferredNodes.forEach(function (node) { switch (node.kind) { - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 258 /* JsxElement */: + case 260 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -55463,6 +56138,7 @@ var ts; ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); ts.forEach(node.statements, checkSourceElement); + checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); if (ts.isExternalOrCommonJsModule(node)) { registerForUnusedIdentifiersCheck(node); @@ -55555,13 +56231,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 242 /* ModuleDeclaration */: + case 279 /* SourceFile */: + if (!ts.isExternalOrCommonJsModule(location)) + break; + // falls through + case 244 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -55569,8 +56249,8 @@ var ts; // falls through // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 241 /* 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. @@ -55579,7 +56259,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); } break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -55621,17 +56301,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 71 /* Identifier */ && + return name.kind === 72 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 148 /* TypeParameter */: - case 238 /* ClassDeclaration */: - case 239 /* InterfaceDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 150 /* TypeParameter */: + case 240 /* ClassDeclaration */: + case 241 /* InterfaceDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return true; default: return false; @@ -55639,16 +56319,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 146 /* QualifiedName */) { + while (node.parent.kind === 148 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 162 /* TypeReference */; + return node.parent.kind === 164 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 187 /* PropertyAccessExpression */) { + while (node.parent.kind === 189 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 209 /* ExpressionWithTypeArguments */; + return node.parent.kind === 211 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -55676,13 +56356,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 148 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 248 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 254 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -55708,7 +56388,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 183 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -55718,7 +56398,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 187 /* PropertyAccessExpression */ && + entityName.parent.kind === 189 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -55726,7 +56406,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 254 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -55736,7 +56416,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 248 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -55754,7 +56434,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 211 /* ExpressionWithTypeArguments */) { meaning = 67897832 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -55770,10 +56450,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 297 /* JSDocParameterTag */) { + if (entityName.parent.kind === 299 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 301 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 150 /* TypeParameter */ && entityName.parent.parent.kind === 303 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -55783,19 +56463,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 71 /* Identifier */) { + if (entityName.kind === 72 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 67220415 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 189 /* PropertyAccessExpression */ || entityName.kind === 148 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 187 /* PropertyAccessExpression */) { + if (entityName.kind === 189 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -55805,20 +56485,17 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 164 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 265 /* JsxAttribute */) { - return getJsxAttributePropertySymbol(entityName.parent); - } - if (entityName.parent.kind === 161 /* TypePredicate */) { + if (entityName.parent.kind === 163 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -55834,12 +56511,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 184 /* BindingElement */ && - grandParent.kind === 182 /* ObjectBindingPattern */ && + else if (parent.kind === 186 /* BindingElement */ && + grandParent.kind === 184 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -55849,11 +56526,11 @@ var ts; } } switch (node.kind) { - case 71 /* Identifier */: - case 187 /* PropertyAccessExpression */: - case 146 /* QualifiedName */: + case 72 /* Identifier */: + case 189 /* PropertyAccessExpression */: + case 148 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -55865,29 +56542,32 @@ var ts; return checkExpression(node).symbol; } // falls through - case 176 /* ThisType */: + case 178 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return checkExpression(node).symbol; - case 123 /* ConstructorKeyword */: + case 124 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 157 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 9 /* StringLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 10 /* StringLiteral */: + case 14 /* 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 === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 249 /* ImportDeclaration */ || node.parent.kind === 255 /* 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); } + if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) { + return getSymbolOfNode(parent); + } // falls through case 8 /* NumericLiteral */: // index access @@ -55897,19 +56577,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 79 /* DefaultKeyword */: - case 89 /* FunctionKeyword */: - case 36 /* EqualsGreaterThanToken */: - case 75 /* ClassKeyword */: + case 80 /* DefaultKeyword */: + case 90 /* FunctionKeyword */: + case 37 /* EqualsGreaterThanToken */: + case 76 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; + case 85 /* ExportKeyword */: + return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 276 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -55977,28 +56659,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 188 /* ObjectLiteralExpression */ || expr.kind === 187 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 225 /* ForOfStatement */) { + if (expr.parent.kind === 227 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 202 /* BinaryExpression */) { + if (expr.parent.kind === 204 /* 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 === 273 /* PropertyAssignment */) { + if (expr.parent.kind === 275 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 187 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -56034,14 +56716,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return getLiteralType(name.text); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: ts.Debug.fail("Unsupported property name."); return errorType; @@ -56096,7 +56778,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 189 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -56152,7 +56834,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 279 /* 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. @@ -56207,7 +56889,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 218 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -56248,18 +56930,18 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: - case 248 /* ImportClause */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 248 /* ImportEqualsDeclaration */: + case 250 /* ImportClause */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return node.expression - && node.expression.kind === 71 /* Identifier */ + && node.expression.kind === 72 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -56267,7 +56949,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 279 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -56294,7 +56976,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 - if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67220415 /* Value */) { + if (target && ts.getModifierFlags(node) & 1 /* Export */ && + target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -56367,15 +57050,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 276 /* EnumMember */: - case 187 /* PropertyAccessExpression */: - case 188 /* ElementAccessExpression */: + case 278 /* EnumMember */: + case 189 /* PropertyAccessExpression */: + case 190 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 276 /* EnumMember */) { + if (node.kind === 278 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -56389,7 +57072,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. @@ -56426,22 +57109,25 @@ var ts; else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + return ts.TypeReferenceSerializationKind.BigIntLikeType; + } + else if (isTypeAssignableToKind(type, 132 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -56457,14 +57143,14 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* 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 */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 2048 /* UniqueESSymbol */ && + if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -56476,7 +57162,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56484,7 +57170,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(119 /* AnyKeyword */); + return ts.createToken(120 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -56522,19 +57208,18 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 448 /* Literal */ && type.flags & 33554432 /* FreshLiteral */); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } - function literalTypeToNode(type, enclosing) { - var enumResult = type.flags & 512 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing) + function literalTypeToNode(type, enclosing, tracker) { + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } - function createLiteralConstValue(node) { + function createLiteralConstValue(node, tracker) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return literalTypeToNode(type, node); + return literalTypeToNode(type, node, tracker); } function createResolver() { // this variable and functions that use it are deliberately moved here from the outer scope @@ -56607,12 +57292,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* SetAccessor */; + var otherKind = accessor.kind === 159 /* SetAccessor */ ? 158 /* GetAccessor */ : 159 /* 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 === 157 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 159 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 158 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -56628,7 +57313,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; + return node.parent && node.parent.kind === 211 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 273 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -56640,7 +57325,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 72 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 189 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -56691,7 +57376,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 279 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -56706,12 +57391,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 244 /* 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, 277 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 279 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -56889,14 +57574,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 154 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 156 /* 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 === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */) { + else if (node.kind === 158 /* GetAccessor */ || node.kind === 159 /* 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); @@ -56913,23 +57598,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { + if (modifier.kind !== 133 /* ReadonlyKeyword */) { + if (node.kind === 153 /* PropertySignature */ || node.kind === 155 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 160 /* IndexSignature */) { + if (node.kind === 162 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 76 /* ConstKeyword */: - if (node.kind !== 241 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); + case 77 /* ConstKeyword */: + if (node.kind !== 243 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(77 /* ConstKeyword */)); } break; - case 114 /* PublicKeyword */: - case 113 /* ProtectedKeyword */: - case 112 /* PrivateKeyword */: + case 115 /* PublicKeyword */: + case 114 /* ProtectedKeyword */: + case 113 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -56943,11 +57628,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* 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 === 112 /* PrivateKeyword */) { + if (modifier.kind === 113 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -56956,7 +57641,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -56966,10 +57651,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + else if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -56978,18 +57663,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 132 /* ReadonlyKeyword */: + case 133 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { + else if (node.kind !== 154 /* PropertyDeclaration */ && node.kind !== 153 /* PropertySignature */ && node.kind !== 162 /* IndexSignature */ && node.kind !== 151 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 84 /* ExportKeyword */: + case 85 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -57002,52 +57687,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 79 /* DefaultKeyword */: - var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 80 /* DefaultKeyword */: + var container = node.parent.kind === 279 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 244 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 124 /* DeclareKeyword */: + case 125 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 245 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 117 /* AbstractKeyword */: + case 118 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 238 /* ClassDeclaration */) { - if (node.kind !== 154 /* MethodDeclaration */ && - node.kind !== 152 /* PropertyDeclaration */ && - node.kind !== 156 /* GetAccessor */ && - node.kind !== 157 /* SetAccessor */) { + if (node.kind !== 240 /* ClassDeclaration */) { + if (node.kind !== 156 /* MethodDeclaration */ && + node.kind !== 154 /* PropertyDeclaration */ && + node.kind !== 158 /* GetAccessor */ && + node.kind !== 159 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 240 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -57059,14 +57744,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 149 /* Parameter */) { + else if (node.kind === 151 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -57074,7 +57759,7 @@ var ts; break; } } - if (node.kind === 155 /* Constructor */) { + if (node.kind === 157 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -57089,13 +57774,13 @@ var ts; } return false; } - else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 249 /* ImportDeclaration */ || node.kind === 248 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 151 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -57116,38 +57801,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 155 /* Constructor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 160 /* IndexSignature */: - case 242 /* ModuleDeclaration */: - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: - case 149 /* Parameter */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 157 /* Constructor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 162 /* IndexSignature */: + case 244 /* ModuleDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: + case 151 /* Parameter */: return false; default: - if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { return false; } switch (node.kind) { - case 237 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 238 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 239 /* InterfaceDeclaration */: - case 217 /* VariableStatement */: - case 240 /* TypeAliasDeclaration */: + case 239 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AsyncKeyword */); + case 240 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 118 /* AbstractKeyword */); + case 241 /* InterfaceDeclaration */: + case 219 /* VariableStatement */: + case 242 /* TypeAliasDeclaration */: return true; - case 241 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); + case 243 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 77 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -57159,10 +57844,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 154 /* MethodDeclaration */: - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: - case 195 /* ArrowFunction */: + case 156 /* MethodDeclaration */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: + case 197 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -57280,12 +57965,12 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { + if (parameter.type.kind !== 138 /* StringKeyword */ && parameter.type.kind !== 135 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(getTypeFromTypeNode(node.type))); } - if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -57316,7 +58001,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 208 /* OmittedExpression */) { + if (arg.kind === 210 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -57346,7 +58031,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 === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -57359,7 +58044,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -57375,14 +58060,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 85 /* ExtendsKeyword */) { + if (heritageClause.token === 86 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 109 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -57393,20 +58078,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 147 /* ComputedPropertyName */) { + if (node.kind !== 149 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 204 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 237 /* FunctionDeclaration */ || - node.kind === 194 /* FunctionExpression */ || - node.kind === 154 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 239 /* FunctionDeclaration */ || + node.kind === 196 /* FunctionExpression */ || + node.kind === 156 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -57432,15 +58117,15 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 275 /* SpreadAssignment */) { + if (prop.kind === 277 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 147 /* ComputedPropertyName */) { + if (name.kind === 149 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 274 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 276 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -57449,7 +58134,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { + if (mod.kind !== 121 /* AsyncKeyword */ || prop.kind !== 156 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -57464,23 +58149,23 @@ 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 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); /* tslint:disable:no-switch-case-fall-through */ - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: @@ -57517,7 +58202,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 267 /* JsxSpreadAttribute */) { + if (attr.kind === 269 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -57527,7 +58212,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 270 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -57536,12 +58221,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 227 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 238 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -57556,20 +58241,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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 === 224 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 226 /* 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); @@ -57596,11 +58281,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 158 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 157 /* SetAccessor */) { + else if (kind === 159 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -57624,23 +58309,23 @@ 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 === 156 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 158 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 141 /* UniqueKeyword */) { - if (node.type.kind !== 138 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(138 /* SymbolKeyword */)); + if (node.operator === 142 /* UniqueKeyword */) { + if (node.type.kind !== 139 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(139 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 71 /* Identifier */) { + if (decl.name.kind !== 72 /* 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)) { @@ -57650,13 +58335,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { 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 151 /* PropertySignature */: + case 153 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* 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); } @@ -57675,10 +58360,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 186 /* ObjectLiteralExpression */) { + if (node.kind === 156 /* MethodDeclaration */) { + if (node.parent.kind === 188 /* 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 === 120 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 121 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -57704,14 +58389,14 @@ var ts; if (node.flags & 4194304 /* 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 === 154 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 156 /* 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 === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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 === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* 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); } } @@ -57722,11 +58407,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 231 /* LabeledStatement */: + case 233 /* 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 === 226 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 228 /* 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); @@ -57734,8 +58419,8 @@ var ts; return false; } break; - case 230 /* SwitchStatement */: - if (node.kind === 227 /* BreakStatement */ && !node.label) { + case 232 /* SwitchStatement */: + if (node.kind === 229 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -57750,13 +58435,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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 === 227 /* BreakStatement */ + var message = node.kind === 229 /* 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); @@ -57779,34 +58464,43 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } + function isBigIntLiteralExpression(expr) { + return expr.kind === 9 /* BigIntLiteral */ || + expr.kind === 202 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.operand.kind === 9 /* BigIntLiteral */; + } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) - return !!(checkExpressionCached(expr).flags & 512 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); } function checkAmbientInitializer(node) { - if (node.initializer) { - var isInvalidInitializer = !(isStringOrNumberLiteralExpression(node.initializer) || isSimpleLiteralEnumReference(node.initializer) || node.initializer.kind === 101 /* TrueKeyword */ || node.initializer.kind === 86 /* FalseKeyword */); + var initializer = node.initializer; + if (initializer) { + var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || + isSimpleLiteralEnumReference(initializer) || + initializer.kind === 102 /* TrueKeyword */ || initializer.kind === 87 /* FalseKeyword */ || + isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { if (isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); + return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); } } else { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); + return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { + if (node.parent.parent.kind !== 226 /* ForInStatement */ && node.parent.parent.kind !== 227 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { checkAmbientInitializer(node); } @@ -57819,7 +58513,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 219 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -57836,7 +58530,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -57853,8 +58547,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 71 /* Identifier */) { - if (name.originalKeywordKind === 110 /* LetKeyword */) { + if (name.kind === 72 /* Identifier */) { + if (name.originalKeywordKind === 111 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -57881,15 +58575,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 220 /* IfStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 229 /* WithStatement */: - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 222 /* IfStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: return false; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -57907,12 +58601,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 94 /* NewKeyword */: + case 95 /* 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 91 /* ImportKeyword */: + case 92 /* 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"); } @@ -57967,7 +58661,7 @@ var ts; return true; } } - else if (node.parent.kind === 239 /* InterfaceDeclaration */) { + else if (node.parent.kind === 241 /* 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; } @@ -57975,7 +58669,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 166 /* TypeLiteral */) { + else if (node.parent.kind === 168 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -58004,13 +58698,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 239 /* InterfaceDeclaration */ || - node.kind === 240 /* TypeAliasDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 246 /* ImportEqualsDeclaration */ || - node.kind === 253 /* ExportDeclaration */ || - node.kind === 252 /* ExportAssignment */ || - node.kind === 245 /* NamespaceExportDeclaration */ || + if (node.kind === 241 /* InterfaceDeclaration */ || + node.kind === 242 /* TypeAliasDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 248 /* ImportEqualsDeclaration */ || + node.kind === 255 /* ExportDeclaration */ || + node.kind === 254 /* ExportAssignment */ || + node.kind === 247 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -58019,7 +58713,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 === 217 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 219 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -58046,7 +58740,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 === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { + if (node.parent.kind === 218 /* Block */ || node.parent.kind === 245 /* ModuleBlock */ || node.parent.kind === 279 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -58068,20 +58762,32 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 182 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 278 /* 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 === 38 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } return false; } + function checkGrammarBigIntLiteral(node) { + var literalType = ts.isLiteralTypeNode(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); + if (!literalType) { + if (languageVersion < 6 /* ESNext */) { + if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ESNext)) { + return true; + } + } + } + return false; + } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -58126,8 +58832,8 @@ var ts; /** 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 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -58135,14 +58841,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 248 /* ImportClause */: // For default import - case 246 /* ImportEqualsDeclaration */: - case 249 /* NamespaceImport */: - case 251 /* ImportSpecifier */: // For rename import `x as y` + case 250 /* ImportClause */: // For default import + case 248 /* ImportEqualsDeclaration */: + case 251 /* NamespaceImport */: + case 253 /* ImportSpecifier */: // For rename import `x as y` return true; - case 71 /* Identifier */: + case 72 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 251 /* ImportSpecifier */; + return decl.parent.kind === 253 /* ImportSpecifier */; default: return false; } @@ -58162,7 +58868,7 @@ var ts; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function typeIsLiteralType(type) { - return !!(type.flags & 448 /* Literal */); + return !!(type.flags & 2944 /* Literal */); } })(ts || (ts = {})); var ts; @@ -58226,6 +58932,9 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt + return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); + } if (typeof value === "boolean") { return value ? createTrue() : createFalse(); } @@ -58245,14 +58954,20 @@ var ts; return node; } ts.createNumericLiteral = createNumericLiteral; + function createBigIntLiteral(value) { + var node = createSynthesizedNode(9 /* BigIntLiteral */); + node.text = value; + return node; + } + ts.createBigIntLiteral = createBigIntLiteral; function createStringLiteral(text) { - var node = createSynthesizedNode(9 /* StringLiteral */); + var node = createSynthesizedNode(10 /* StringLiteral */); node.text = text; return node; } ts.createStringLiteral = createStringLiteral; function createRegularExpressionLiteral(text) { - var node = createSynthesizedNode(12 /* RegularExpressionLiteral */); + var node = createSynthesizedNode(13 /* RegularExpressionLiteral */); node.text = text; return node; } @@ -58263,7 +58978,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(71 /* Identifier */); + var node = createSynthesizedNode(72 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -58344,23 +59059,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(97 /* SuperKeyword */); + return createSynthesizedNode(98 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(99 /* ThisKeyword */); + return createSynthesizedNode(100 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(95 /* NullKeyword */); + return createSynthesizedNode(96 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(101 /* TrueKeyword */); + return createSynthesizedNode(102 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(86 /* FalseKeyword */); + return createSynthesizedNode(87 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -58371,44 +59086,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(84 /* ExportKeyword */)); + result.push(createModifier(85 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(124 /* DeclareKeyword */)); + result.push(createModifier(125 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(79 /* DefaultKeyword */)); + result.push(createModifier(80 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(76 /* ConstKeyword */)); + result.push(createModifier(77 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(114 /* PublicKeyword */)); + result.push(createModifier(115 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(112 /* PrivateKeyword */)); + result.push(createModifier(113 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(113 /* ProtectedKeyword */)); + result.push(createModifier(114 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(117 /* AbstractKeyword */)); + result.push(createModifier(118 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(115 /* StaticKeyword */)); + result.push(createModifier(116 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(132 /* ReadonlyKeyword */)); + result.push(createModifier(133 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(120 /* AsyncKeyword */)); + result.push(createModifier(121 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(146 /* QualifiedName */); + var node = createSynthesizedNode(148 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -58427,7 +59142,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(147 /* ComputedPropertyName */); + var node = createSynthesizedNode(149 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -58440,7 +59155,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(148 /* TypeParameter */); + var node = createSynthesizedNode(150 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -58456,7 +59171,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(149 /* Parameter */); + var node = createSynthesizedNode(151 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -58480,7 +59195,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(150 /* Decorator */); + var node = createSynthesizedNode(152 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -58493,7 +59208,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertySignature */); + var node = createSynthesizedNode(153 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -58513,12 +59228,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(152 /* PropertyDeclaration */); + var node = createSynthesizedNode(154 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -58528,8 +59243,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 55 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 51 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -58537,7 +59252,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(155 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -58554,7 +59269,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(154 /* MethodDeclaration */); + var node = createSynthesizedNode(156 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -58582,7 +59297,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(155 /* Constructor */); + var node = createSynthesizedNode(157 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -58602,7 +59317,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(156 /* GetAccessor */); + var node = createSynthesizedNode(158 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58625,7 +59340,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(157 /* SetAccessor */); + var node = createSynthesizedNode(159 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -58646,7 +59361,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(160 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -58654,7 +59369,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(161 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -58662,7 +59377,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(160 /* IndexSignature */); + var node = createSynthesizedNode(162 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -58702,7 +59417,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(161 /* TypePredicate */); + var node = createSynthesizedNode(163 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -58716,7 +59431,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(162 /* TypeReference */); + var node = createSynthesizedNode(164 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -58730,7 +59445,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -58738,7 +59453,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(166 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -58746,7 +59461,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(165 /* TypeQuery */); + var node = createSynthesizedNode(167 /* TypeQuery */); node.exprName = exprName; return node; } @@ -58758,7 +59473,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(166 /* TypeLiteral */); + var node = createSynthesizedNode(168 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -58770,7 +59485,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(167 /* ArrayType */); + var node = createSynthesizedNode(169 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -58782,7 +59497,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(168 /* TupleType */); + var node = createSynthesizedNode(170 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -58794,7 +59509,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(169 /* OptionalType */); + var node = createSynthesizedNode(171 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -58806,7 +59521,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(170 /* RestType */); + var node = createSynthesizedNode(172 /* RestType */); node.type = type; return node; } @@ -58818,7 +59533,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(173 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -58826,7 +59541,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(174 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -58845,7 +59560,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(173 /* ConditionalType */); + var node = createSynthesizedNode(175 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -58863,7 +59578,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(174 /* InferType */); + var node = createSynthesizedNode(176 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -58875,7 +59590,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(181 /* ImportType */); + var node = createSynthesizedNode(183 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -58893,7 +59608,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(175 /* ParenthesizedType */); + var node = createSynthesizedNode(177 /* ParenthesizedType */); node.type = type; return node; } @@ -58905,12 +59620,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(176 /* ThisType */); + return createSynthesizedNode(178 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(177 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; + var node = createSynthesizedNode(179 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 129 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -58920,7 +59635,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(178 /* IndexedAccessType */); + var node = createSynthesizedNode(180 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -58934,7 +59649,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(179 /* MappedType */); + var node = createSynthesizedNode(181 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -58952,7 +59667,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(180 /* LiteralType */); + var node = createSynthesizedNode(182 /* LiteralType */); node.literal = literal; return node; } @@ -58965,7 +59680,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(182 /* ObjectBindingPattern */); + var node = createSynthesizedNode(184 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58977,7 +59692,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(183 /* ArrayBindingPattern */); + var node = createSynthesizedNode(185 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -58989,7 +59704,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(184 /* BindingElement */); + var node = createSynthesizedNode(186 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -59008,7 +59723,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(187 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -59022,7 +59737,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(188 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -59036,7 +59751,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(187 /* PropertyAccessExpression */); + var node = createSynthesizedNode(189 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -59053,7 +59768,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(188 /* ElementAccessExpression */); + var node = createSynthesizedNode(190 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -59067,7 +59782,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(189 /* CallExpression */); + var node = createSynthesizedNode(191 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -59083,7 +59798,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(190 /* NewExpression */); + var node = createSynthesizedNode(192 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -59099,7 +59814,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(193 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -59122,7 +59837,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(192 /* TypeAssertionExpression */); + var node = createSynthesizedNode(194 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -59136,7 +59851,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(193 /* ParenthesizedExpression */); + var node = createSynthesizedNode(195 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -59148,7 +59863,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(194 /* FunctionExpression */); + var node = createSynthesizedNode(196 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -59172,12 +59887,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(195 /* ArrowFunction */); + var node = createSynthesizedNode(197 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -59194,7 +59909,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(196 /* DeleteExpression */); + var node = createSynthesizedNode(198 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59206,7 +59921,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(197 /* TypeOfExpression */); + var node = createSynthesizedNode(199 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59218,7 +59933,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(198 /* VoidExpression */); + var node = createSynthesizedNode(200 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59230,7 +59945,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(199 /* AwaitExpression */); + var node = createSynthesizedNode(201 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -59242,7 +59957,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(202 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -59255,7 +59970,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(203 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -59268,7 +59983,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(202 /* BinaryExpression */); + var node = createSynthesizedNode(204 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -59285,11 +60000,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(203 /* ConditionalExpression */); + var node = createSynthesizedNode(205 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(56 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -59305,7 +60020,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(204 /* TemplateExpression */); + var node = createSynthesizedNode(206 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -59319,33 +60034,33 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createTemplateHead(text) { - var node = createSynthesizedNode(14 /* TemplateHead */); + var node = createSynthesizedNode(15 /* TemplateHead */); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; function createTemplateMiddle(text) { - var node = createSynthesizedNode(15 /* TemplateMiddle */); + var node = createSynthesizedNode(16 /* TemplateMiddle */); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; function createTemplateTail(text) { - var node = createSynthesizedNode(16 /* TemplateTail */); + var node = createSynthesizedNode(17 /* TemplateTail */); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(13 /* NoSubstitutionTemplateLiteral */); + var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); node.text = text; return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(205 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(207 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -59357,7 +60072,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(206 /* SpreadElement */); + var node = createSynthesizedNode(208 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -59369,7 +60084,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(207 /* ClassExpression */); + var node = createSynthesizedNode(209 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59390,11 +60105,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(208 /* OmittedExpression */); + return createSynthesizedNode(210 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(211 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -59408,7 +60123,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(210 /* AsExpression */); + var node = createSynthesizedNode(212 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -59422,7 +60137,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(211 /* NonNullExpression */); + var node = createSynthesizedNode(213 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -59434,7 +60149,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(212 /* MetaProperty */); + var node = createSynthesizedNode(214 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -59448,7 +60163,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(214 /* TemplateSpan */); + var node = createSynthesizedNode(216 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -59462,12 +60177,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(215 /* SemicolonClassElement */); + return createSynthesizedNode(217 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(216 /* Block */); + var block = createSynthesizedNode(218 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -59481,7 +60196,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(217 /* VariableStatement */); + var node = createSynthesizedNode(219 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -59496,11 +60211,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(218 /* EmptyStatement */); + return createSynthesizedNode(220 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(219 /* ExpressionStatement */); + var node = createSynthesizedNode(221 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -59516,7 +60231,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(220 /* IfStatement */); + var node = createSynthesizedNode(222 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -59532,7 +60247,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(221 /* DoStatement */); + var node = createSynthesizedNode(223 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -59546,7 +60261,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(222 /* WhileStatement */); + var node = createSynthesizedNode(224 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -59560,7 +60275,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(223 /* ForStatement */); + var node = createSynthesizedNode(225 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -59578,7 +60293,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(224 /* ForInStatement */); + var node = createSynthesizedNode(226 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -59594,7 +60309,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(225 /* ForOfStatement */); + var node = createSynthesizedNode(227 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -59612,7 +60327,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(226 /* ContinueStatement */); + var node = createSynthesizedNode(228 /* ContinueStatement */); node.label = asName(label); return node; } @@ -59624,7 +60339,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(227 /* BreakStatement */); + var node = createSynthesizedNode(229 /* BreakStatement */); node.label = asName(label); return node; } @@ -59636,7 +60351,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(228 /* ReturnStatement */); + var node = createSynthesizedNode(230 /* ReturnStatement */); node.expression = expression; return node; } @@ -59648,7 +60363,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(229 /* WithStatement */); + var node = createSynthesizedNode(231 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -59662,7 +60377,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(230 /* SwitchStatement */); + var node = createSynthesizedNode(232 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -59676,7 +60391,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(231 /* LabeledStatement */); + var node = createSynthesizedNode(233 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -59690,7 +60405,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(232 /* ThrowStatement */); + var node = createSynthesizedNode(234 /* ThrowStatement */); node.expression = expression; return node; } @@ -59702,7 +60417,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(233 /* TryStatement */); + var node = createSynthesizedNode(235 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -59718,11 +60433,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(234 /* DebuggerStatement */); + return createSynthesizedNode(236 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(235 /* VariableDeclaration */); + var node = createSynthesizedNode(237 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -59739,7 +60454,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(236 /* VariableDeclarationList */); + var node = createSynthesizedNode(238 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -59752,7 +60467,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(237 /* FunctionDeclaration */); + var node = createSynthesizedNode(239 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -59778,7 +60493,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(238 /* ClassDeclaration */); + var node = createSynthesizedNode(240 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59800,7 +60515,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(239 /* InterfaceDeclaration */); + var node = createSynthesizedNode(241 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59822,7 +60537,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(242 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59842,7 +60557,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(241 /* EnumDeclaration */); + var node = createSynthesizedNode(243 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59861,7 +60576,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(242 /* ModuleDeclaration */); + var node = createSynthesizedNode(244 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -59880,7 +60595,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(243 /* ModuleBlock */); + var node = createSynthesizedNode(245 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -59892,7 +60607,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(244 /* CaseBlock */); + var node = createSynthesizedNode(246 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -59904,7 +60619,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(247 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -59916,7 +60631,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(248 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -59934,7 +60649,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(247 /* ImportDeclaration */); + var node = createSynthesizedNode(249 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -59952,7 +60667,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(248 /* ImportClause */); + var node = createSynthesizedNode(250 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -59966,7 +60681,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(249 /* NamespaceImport */); + var node = createSynthesizedNode(251 /* NamespaceImport */); node.name = name; return node; } @@ -59978,7 +60693,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(250 /* NamedImports */); + var node = createSynthesizedNode(252 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -59990,7 +60705,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ImportSpecifier */); + var node = createSynthesizedNode(253 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -60004,11 +60719,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(252 /* ExportAssignment */); + var node = createSynthesizedNode(254 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(58 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(59 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -60021,7 +60736,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(253 /* ExportDeclaration */); + var node = createSynthesizedNode(255 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -60039,7 +60754,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(254 /* NamedExports */); + var node = createSynthesizedNode(256 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -60051,7 +60766,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(255 /* ExportSpecifier */); + var node = createSynthesizedNode(257 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -60066,7 +60781,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(257 /* ExternalModuleReference */); + var node = createSynthesizedNode(259 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -60077,9 +60792,57 @@ var ts; : node; } ts.updateExternalModuleReference = updateExternalModuleReference; + // JSDoc + /* @internal */ + function createJSDocTypeExpression(type) { + var node = createSynthesizedNode(283 /* JSDocTypeExpression */); + node.type = type; + return node; + } + ts.createJSDocTypeExpression = createJSDocTypeExpression; + /* @internal */ + function createJSDocTypeTag(typeExpression, comment) { + var tag = createJSDocTag(302 /* JSDocTypeTag */, "type"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocTypeTag = createJSDocTypeTag; + /* @internal */ + function createJSDocReturnTag(typeExpression, comment) { + var tag = createJSDocTag(300 /* JSDocReturnTag */, "returns"); + tag.typeExpression = typeExpression; + tag.comment = comment; + return tag; + } + ts.createJSDocReturnTag = createJSDocReturnTag; + /* @internal */ + function createJSDocParamTag(name, isBracketed, typeExpression, comment) { + var tag = createJSDocTag(299 /* JSDocParameterTag */, "param"); + tag.typeExpression = typeExpression; + tag.name = name; + tag.isBracketed = isBracketed; + tag.comment = comment; + return tag; + } + ts.createJSDocParamTag = createJSDocParamTag; + /* @internal */ + function createJSDocComment(comment, tags) { + var node = createSynthesizedNode(291 /* JSDocComment */); + node.comment = comment; + node.tags = tags; + return node; + } + ts.createJSDocComment = createJSDocComment; + /* @internal */ + function createJSDocTag(kind, tagName) { + var node = createSynthesizedNode(kind); + node.tagName = createIdentifier(tagName); + return node; + } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(258 /* JsxElement */); + var node = createSynthesizedNode(260 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -60095,7 +60858,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(261 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60111,7 +60874,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(260 /* JsxOpeningElement */); + var node = createSynthesizedNode(262 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -60127,7 +60890,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(261 /* JsxClosingElement */); + var node = createSynthesizedNode(263 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -60139,7 +60902,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(262 /* JsxFragment */); + var node = createSynthesizedNode(264 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -60155,7 +60918,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(265 /* JsxAttribute */); + var node = createSynthesizedNode(267 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -60169,7 +60932,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(266 /* JsxAttributes */); + var node = createSynthesizedNode(268 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -60181,7 +60944,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(269 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -60193,7 +60956,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(268 /* JsxExpression */); + var node = createSynthesizedNode(270 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -60207,7 +60970,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(269 /* CaseClause */); + var node = createSynthesizedNode(271 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -60221,7 +60984,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(270 /* DefaultClause */); + var node = createSynthesizedNode(272 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -60233,7 +60996,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(271 /* HeritageClause */); + var node = createSynthesizedNode(273 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -60246,7 +61009,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(272 /* CatchClause */); + var node = createSynthesizedNode(274 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -60261,7 +61024,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(273 /* PropertyAssignment */); + var node = createSynthesizedNode(275 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -60276,7 +61039,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(276 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -60290,7 +61053,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(275 /* SpreadAssignment */); + var node = createSynthesizedNode(277 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -60303,7 +61066,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(276 /* EnumMember */); + var node = createSynthesizedNode(278 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -60324,7 +61087,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(277 /* SourceFile */); + var updated = createSynthesizedNode(279 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -60408,7 +61171,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(305 /* NotEmittedStatement */); + var node = createSynthesizedNode(307 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -60420,7 +61183,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(309 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(311 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60432,7 +61195,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(308 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(310 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -60447,7 +61210,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(306 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(308 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -60463,17 +61226,17 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 307 /* CommaListExpression */) { + if (node.kind === 309 /* CommaListExpression */) { return node.elements; } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { return [node.left, node.right]; } } return node; } function createCommaList(elements) { - var node = createSynthesizedNode(307 /* CommaListExpression */); + var node = createSynthesizedNode(309 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -60486,14 +61249,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(278 /* Bundle */); + var node = ts.createNode(280 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(279 /* UnparsedSource */); + var node = ts.createNode(281 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -60501,7 +61264,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(280 /* InputFiles */); + var node = ts.createNode(282 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -60543,47 +61306,47 @@ var ts; } ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { - return createBinary(left, 26 /* CommaToken */, right); + return createBinary(left, 27 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 27 /* LessThanToken */, right); + return createBinary(left, 28 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 58 /* EqualsToken */, right); + return createBinary(left, 59 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 34 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 35 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 37 /* PlusToken */, right); + return createBinary(left, 38 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 38 /* MinusToken */, right); + return createBinary(left, 39 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 43 /* PlusPlusToken */); + return createPostfix(operand, 44 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 53 /* AmpersandAmpersandToken */, right); + return createBinary(left, 54 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 54 /* BarBarToken */, right); + return createBinary(left, 55 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(51 /* ExclamationToken */, operand); + return createPrefix(52 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -60644,7 +61407,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 === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -61155,7 +61918,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 233 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -61167,19 +61930,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return cacheIdentifiers; - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: case 8 /* NumericLiteral */: - case 9 /* StringLiteral */: + case 9 /* BigIntLiteral */: + case 10 /* StringLiteral */: return false; - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -61194,7 +61958,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 97 /* SuperKeyword */) { + else if (callee.kind === 98 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -61206,7 +61970,7 @@ var ts; } else { switch (callee.kind) { - case 187 /* PropertyAccessExpression */: { + case 189 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61219,7 +61983,7 @@ var ts; } break; } - case 188 /* ElementAccessExpression */: { + case 190 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -61276,14 +62040,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -61291,7 +62055,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_9 = []; + var properties_8 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -61302,7 +62066,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_9.push(getter); + properties_8.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -61314,15 +62078,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_9.push(setter); + properties_8.push(setter); } - properties_9.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_9.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); + properties_8.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_9, multiLine) + ts.createObjectLiteral(properties_8, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -61609,7 +62373,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 === 193 /* ParenthesizedExpression */) { + if (skipped.kind === 195 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -61643,10 +62407,10 @@ 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(202 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(204 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 195 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 197 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -61658,7 +62422,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 205 /* YieldExpression */) { + && operand.kind === 207 /* YieldExpression */) { return false; } return true; @@ -61695,7 +62459,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 37 /* PlusToken */) { + if (binaryOperator === 38 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -61730,10 +62494,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 === 39 /* AsteriskToken */ - || binaryOperator === 49 /* BarToken */ - || binaryOperator === 48 /* AmpersandToken */ - || binaryOperator === 50 /* CaretToken */; + return binaryOperator === 40 /* AsteriskToken */ + || binaryOperator === 50 /* BarToken */ + || binaryOperator === 49 /* AmpersandToken */ + || binaryOperator === 51 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -61746,7 +62510,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -61761,7 +62525,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(205 /* ConditionalExpression */, 56 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -61796,8 +62560,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 207 /* ClassExpression */: - case 194 /* FunctionExpression */: + case 209 /* ClassExpression */: + case 196 /* FunctionExpression */: needsParens = true; } } @@ -61813,9 +62577,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.createParen(expression); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -61838,7 +62602,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 192 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -61876,7 +62640,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(204 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -61887,29 +62651,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { + if (kind === 196 /* FunctionExpression */ || kind === 197 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { + if (leftmostExpressionKind === 188 /* ObjectLiteralExpression */ || leftmostExpressionKind === 196 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 175 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -61917,9 +62681,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 174 /* InferType */: + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 176 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -61945,28 +62709,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: node = node.operand; continue; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: node = node.left; continue; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: node = node.condition; continue; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: node = node.tag; continue; - case 189 /* CallExpression */: + case 191 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 210 /* AsExpression */: - case 188 /* ElementAccessExpression */: - case 187 /* PropertyAccessExpression */: - case 211 /* NonNullExpression */: - case 306 /* PartiallyEmittedExpression */: + case 212 /* AsExpression */: + case 190 /* ElementAccessExpression */: + case 189 /* PropertyAccessExpression */: + case 213 /* NonNullExpression */: + case 308 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -61974,15 +62738,15 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 188 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || - node.kind === 307 /* CommaListExpression */; + return node.kind === 204 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 309 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -61995,13 +62759,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: - case 211 /* NonNullExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: + case 213 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -62026,7 +62790,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 213 /* NonNullExpression */) { node = node.expression; } return node; @@ -62034,11 +62798,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 306 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 195 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 212 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -62056,7 +62820,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 193 /* ParenthesizedExpression */ + return node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -62121,10 +62885,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 249 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 255 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -62140,7 +62904,7 @@ var ts; */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 - if (moduleName.kind === 9 /* StringLiteral */) { + if (moduleName.kind === 10 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) || ts.getSynthesizedClone(moduleName); @@ -62243,7 +63007,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -62255,11 +63019,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -62291,12 +63055,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 149 /* Parameter */: - case 184 /* BindingElement */: + case 151 /* Parameter */: + case 186 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 206 /* SpreadElement */: - case 275 /* SpreadAssignment */: + case 208 /* SpreadElement */: + case 277 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -62308,7 +63072,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 184 /* BindingElement */: + case 186 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -62320,7 +63084,7 @@ var ts; : propertyName; } break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -62332,7 +63096,7 @@ var ts; : propertyName; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -62347,7 +63111,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 9 /* StringLiteral */ + return kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */; } /** @@ -62355,13 +63119,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -62401,11 +63165,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 183 /* ArrayBindingPattern */: - case 185 /* ArrayLiteralExpression */: + case 185 /* ArrayBindingPattern */: + case 187 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 182 /* ObjectBindingPattern */: - case 186 /* ObjectLiteralExpression */: + case 184 /* ObjectBindingPattern */: + case 188 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -62566,276 +63330,276 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */) || kind === 178 /* ThisType */) { return node; } switch (kind) { // Names - case 71 /* Identifier */: + case 72 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 149 /* Parameter */: + case 151 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 150 /* Decorator */: + case 152 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 155 /* Constructor */: + case 157 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 168 /* TupleType */: + case 170 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 170 /* RestType */: + case 172 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 171 /* UnionType */: + case 173 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 174 /* InferType */: + case 176 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 181 /* ImportType */: + case 183 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 179 /* MappedType */: + case 181 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* AsExpression */: + case 212 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 216 /* Block */: + case 218 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 260 /* JsxOpeningElement */: + case 262 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -62877,58 +63641,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 147 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { + if ((kind >= 163 /* TypePredicate */ && kind <= 182 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 215 /* SemicolonClassElement */: - case 218 /* EmptyStatement */: - case 208 /* OmittedExpression */: - case 234 /* DebuggerStatement */: - case 305 /* NotEmittedStatement */: + case 217 /* SemicolonClassElement */: + case 220 /* EmptyStatement */: + case 210 /* OmittedExpression */: + case 236 /* DebuggerStatement */: + case 307 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 149 /* Parameter */: + case 151 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 150 /* Decorator */: + case 152 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62937,12 +63701,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* Constructor */: + case 157 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62950,7 +63714,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -62958,49 +63722,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* BindingElement */: + case 186 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 189 /* CallExpression */: + case 191 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 190 /* NewExpression */: + case 192 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -63008,123 +63773,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ParenthesizedExpression */: - case 196 /* DeleteExpression */: - case 197 /* TypeOfExpression */: - case 198 /* VoidExpression */: - case 199 /* AwaitExpression */: - case 205 /* YieldExpression */: - case 206 /* SpreadElement */: - case 211 /* NonNullExpression */: + case 195 /* ParenthesizedExpression */: + case 198 /* DeleteExpression */: + case 199 /* TypeOfExpression */: + case 200 /* VoidExpression */: + case 201 /* AwaitExpression */: + case 207 /* YieldExpression */: + case 208 /* SpreadElement */: + case 213 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 210 /* AsExpression */: + case 212 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 216 /* Block */: + case 218 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 221 /* DoStatement */: + case 223 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 222 /* WhileStatement */: - case 229 /* WithStatement */: + case 224 /* WhileStatement */: + case 231 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 223 /* ForStatement */: + case 225 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 228 /* ReturnStatement */: - case 232 /* ThrowStatement */: + case 230 /* ReturnStatement */: + case 234 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63133,7 +63898,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -63141,139 +63906,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 250 /* NamedImports */: - case 254 /* NamedExports */: + case 252 /* NamedImports */: + case 256 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 251 /* ImportSpecifier */: - case 255 /* ExportSpecifier */: + case 253 /* ImportSpecifier */: + case 257 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); + result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 261 /* JsxClosingElement */: + case 263 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 277 /* SourceFile */: + case 279 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -63346,7 +64112,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 211 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -63396,7 +64162,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -63433,288 +64199,623 @@ var ts; /* @internal */ var ts; (function (ts) { - function createSourceFileLikeCache(host) { - var cached = ts.createMap(); + function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) { + var _a = generatorOptions.extendedDiagnostics + ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap") + : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit; + // Current source map file and its index in the sources list + var rawSources = []; + var sources = []; + var sourceToSourceIndexMap = ts.createMap(); + var sourcesContent; + var names = []; + var nameToNameIndexMap; + var mappings = ""; + // Last recorded and encoded mappings + var lastGeneratedLine = 0; + var lastGeneratedCharacter = 0; + var lastSourceIndex = 0; + var lastSourceLine = 0; + var lastSourceCharacter = 0; + var lastNameIndex = 0; + var hasLast = false; + var pendingGeneratedLine = 0; + var pendingGeneratedCharacter = 0; + var pendingSourceIndex = 0; + var pendingSourceLine = 0; + var pendingSourceCharacter = 0; + var pendingNameIndex = 0; + var hasPending = false; + var hasPendingSource = false; + var hasPendingName = false; return { - get: function (path) { - if (cached.has(path)) { - return cached.get(path); + getSources: function () { return rawSources; }, + addSource: addSource, + setSourceContent: setSourceContent, + addName: addName, + addMapping: addMapping, + appendSourceMap: appendSourceMap, + toJSON: toJSON, + toString: function () { return JSON.stringify(toJSON()); } + }; + function addSource(fileName) { + enter(); + var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + var sourceIndex = sourceToSourceIndexMap.get(source); + if (sourceIndex === undefined) { + sourceIndex = sources.length; + sources.push(source); + rawSources.push(fileName); + sourceToSourceIndexMap.set(source, sourceIndex); + } + exit(); + return sourceIndex; + } + function setSourceContent(sourceIndex, content) { + enter(); + if (content !== null) { + if (!sourcesContent) + sourcesContent = []; + while (sourcesContent.length < sourceIndex) { + // tslint:disable-next-line:no-null-keyword boolean-trivia + sourcesContent.push(null); } - if (!host.fileExists || !host.readFile || !host.fileExists(path)) - return; - // And failing that, check the disk - var text = host.readFile(path); // TODO: GH#18217 - var file = { - text: text, - lineMap: undefined, - getLineAndCharacterOfPosition: function (pos) { - return ts.computeLineAndCharacterOfPosition(ts.getLineStarts(this), pos); + sourcesContent[sourceIndex] = content; + } + exit(); + } + function addName(name) { + enter(); + if (!nameToNameIndexMap) + nameToNameIndexMap = ts.createMap(); + var nameIndex = nameToNameIndexMap.get(name); + if (nameIndex === undefined) { + nameIndex = names.length; + names.push(name); + nameToNameIndexMap.set(name, nameIndex); + } + exit(); + return nameIndex; + } + function isNewGeneratedPosition(generatedLine, generatedCharacter) { + return !hasPending + || pendingGeneratedLine !== generatedLine + || pendingGeneratedCharacter !== generatedCharacter; + } + function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) { + return sourceIndex !== undefined + && sourceLine !== undefined + && sourceCharacter !== undefined + && pendingSourceIndex === sourceIndex + && (pendingSourceLine > sourceLine + || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter); + } + function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) { + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative"); + ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative"); + ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative"); + enter(); + // If this location wasn't recorded or the location in source is going backwards, record the mapping + if (isNewGeneratedPosition(generatedLine, generatedCharacter) || + isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) { + commitPendingMapping(); + pendingGeneratedLine = generatedLine; + pendingGeneratedCharacter = generatedCharacter; + hasPendingSource = false; + hasPendingName = false; + hasPending = true; + } + if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) { + pendingSourceIndex = sourceIndex; + pendingSourceLine = sourceLine; + pendingSourceCharacter = sourceCharacter; + hasPendingSource = true; + if (nameIndex !== undefined) { + pendingNameIndex = nameIndex; + hasPendingName = true; + } + } + exit(); + } + function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath) { + var _a; + ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack"); + ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative"); + enter(); + // First, decode the old component sourcemap + var sourceIndexToNewSourceIndexMap = []; + var nameIndexToNewNameIndexMap; + var mappingIterator = decodeMappings(map.mappings); + for (var _b = mappingIterator.next(), raw = _b.value, done = _b.done; !done; _a = mappingIterator.next(), raw = _a.value, done = _a.done, _a) { + // Then reencode all the updated mappings into the overall map + var newSourceIndex = void 0; + var newSourceLine = void 0; + var newSourceCharacter = void 0; + var newNameIndex = void 0; + if (raw.sourceIndex !== undefined) { + newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex]; + if (newSourceIndex === undefined) { + // Apply offsets to each position and fixup source entries + var rawPath = map.sources[raw.sourceIndex]; + var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath); + sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath); + if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") { + setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]); + } } - }; - cached.set(path, file); - return file; + newSourceLine = raw.sourceLine; + newSourceCharacter = raw.sourceCharacter; + if (map.names && raw.nameIndex !== undefined) { + if (!nameIndexToNewNameIndexMap) + nameIndexToNewNameIndexMap = []; + newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex]; + if (newNameIndex === undefined) { + nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]); + } + } + } + var newGeneratedLine = raw.generatedLine + generatedLine; + var newGeneratedCharacter = raw.generatedLine === 0 ? raw.generatedCharacter + generatedCharacter : raw.generatedCharacter; + addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex); + } + exit(); + } + function shouldCommitMapping() { + return !hasLast + || lastGeneratedLine !== pendingGeneratedLine + || lastGeneratedCharacter !== pendingGeneratedCharacter + || lastSourceIndex !== pendingSourceIndex + || lastSourceLine !== pendingSourceLine + || lastSourceCharacter !== pendingSourceCharacter + || lastNameIndex !== pendingNameIndex; + } + function commitPendingMapping() { + if (!hasPending || !shouldCommitMapping()) { + return; + } + enter(); + // Line/Comma delimiters + if (lastGeneratedLine < pendingGeneratedLine) { + // Emit line delimiters + do { + mappings += ";"; + lastGeneratedLine++; + lastGeneratedCharacter = 0; + } while (lastGeneratedLine < pendingGeneratedLine); + } + else { + ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); + // Emit comma to separate the entry + if (hasLast) { + mappings += ","; + } + } + // 1. Relative generated character + mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + lastGeneratedCharacter = pendingGeneratedCharacter; + if (hasPendingSource) { + // 2. Relative sourceIndex + mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + lastSourceIndex = pendingSourceIndex; + // 3. Relative source line + mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + lastSourceLine = pendingSourceLine; + // 4. Relative source character + mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + lastSourceCharacter = pendingSourceCharacter; + if (hasPendingName) { + // 5. Relative nameIndex + mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + lastNameIndex = pendingNameIndex; + } + } + hasLast = true; + exit(); + } + function toJSON() { + commitPendingMapping(); + return { + version: 3, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings, + sourcesContent: sourcesContent, + }; + } + } + ts.createSourceMapGenerator = createSourceMapGenerator; + // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + /** + * Tries to find the sourceMappingURL comment at the end of a file. + * @param text The source text of the file. + * @param lineStarts The line starts of the file. + */ + function tryGetSourceMappingURL(text, lineStarts) { + if (lineStarts === void 0) { lineStarts = ts.computeLineStarts(text); } + for (var index = lineStarts.length - 1; index >= 0; index--) { + var line = text.substring(lineStarts[index], lineStarts[index + 1]); + var comment = sourceMapCommentRegExp.exec(line); + if (comment) { + return comment[1]; + } + // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!line.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + function isStringOrNull(x) { + // tslint:disable-next-line:no-null-keyword + return typeof x === "string" || x === null; + } + function isRawSourceMap(x) { + // tslint:disable-next-line:no-null-keyword + return x !== null + && typeof x === "object" + && x.version === 3 + && typeof x.file === "string" + && typeof x.mappings === "string" + && ts.isArray(x.sources) && ts.every(x.sources, ts.isString) + && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string") + && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull)) + && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); + } + ts.isRawSourceMap = isRawSourceMap; + function tryParseRawSourceMap(text) { + try { + var parsed = JSON.parse(text); + if (isRawSourceMap(parsed)) { + return parsed; + } + } + catch (_a) { + // empty + } + return undefined; + } + ts.tryParseRawSourceMap = tryParseRawSourceMap; + function decodeMappings(mappings) { + var done = false; + var pos = 0; + var generatedLine = 0; + var generatedCharacter = 0; + var sourceIndex = 0; + var sourceLine = 0; + var sourceCharacter = 0; + var nameIndex = 0; + var error; + return { + get pos() { return pos; }, + get error() { return error; }, + get state() { return captureMapping(/*hasSource*/ true, /*hasName*/ true); }, + next: function () { + while (!done && pos < mappings.length) { + var ch = mappings.charCodeAt(pos); + if (ch === 59 /* semicolon */) { + // new line + generatedLine++; + generatedCharacter = 0; + pos++; + continue; + } + if (ch === 44 /* comma */) { + // Next entry is on same line - no action needed + pos++; + continue; + } + var hasSource = false; + var hasName = false; + generatedCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (generatedCharacter < 0) + return setErrorAndStopIterating("Invalid generatedCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasSource = true; + sourceIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceIndex < 0) + return setErrorAndStopIterating("Invalid sourceIndex found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex"); + sourceLine += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceLine < 0) + return setErrorAndStopIterating("Invalid sourceLine found"); + if (isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine"); + sourceCharacter += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (sourceCharacter < 0) + return setErrorAndStopIterating("Invalid sourceCharacter found"); + if (!isSourceMappingSegmentEnd()) { + hasName = true; + nameIndex += base64VLQFormatDecode(); + if (hasReportedError()) + return stopIterating(); + if (nameIndex < 0) + return setErrorAndStopIterating("Invalid nameIndex found"); + if (!isSourceMappingSegmentEnd()) + return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex"); + } + } + return { value: captureMapping(hasSource, hasName), done: done }; + } + return stopIterating(); } }; + function captureMapping(hasSource, hasName) { + return { + generatedLine: generatedLine, + generatedCharacter: generatedCharacter, + sourceIndex: hasSource ? sourceIndex : undefined, + sourceLine: hasSource ? sourceLine : undefined, + sourceCharacter: hasSource ? sourceCharacter : undefined, + nameIndex: hasName ? nameIndex : undefined + }; + } + function stopIterating() { + done = true; + return { value: undefined, done: true }; + } + function setError(message) { + if (error === undefined) { + error = message; + } + } + function setErrorAndStopIterating(message) { + setError(message); + return stopIterating(); + } + function hasReportedError() { + return error !== undefined; + } + function isSourceMappingSegmentEnd() { + return (pos === mappings.length || + mappings.charCodeAt(pos) === 44 /* comma */ || + mappings.charCodeAt(pos) === 59 /* semicolon */); + } + function base64VLQFormatDecode() { + var moreDigits = true; + var shiftCount = 0; + var value = 0; + for (; moreDigits; pos++) { + if (pos >= mappings.length) + return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1; + // 6 digit number + var currentByte = base64FormatDecode(mappings.charCodeAt(pos)); + if (currentByte === -1) + return setError("Invalid character in VLQ"), -1; + // If msb is set, we still have more bits to continue + moreDigits = (currentByte & 32) !== 0; + // least significant 5 bits are the next msbs in the final value. + value = value | ((currentByte & 31) << shiftCount); + shiftCount += 5; + } + // Least significant bit if 1 represents negative and rest of the msb is actual absolute value + if ((value & 1) === 0) { + // + number + value = value >> 1; + } + else { + // - number + value = value >> 1; + value = -value; + } + return value; + } } - ts.createSourceFileLikeCache = createSourceFileLikeCache; -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - var sourcemaps; - (function (sourcemaps) { - sourcemaps.identitySourceMapper = { getOriginalPosition: ts.identity, getGeneratedPosition: ts.identity }; - function decode(host, mapPath, map, program, fallbackCache) { - if (fallbackCache === void 0) { fallbackCache = ts.createSourceFileLikeCache(host); } - var currentDirectory = ts.getDirectoryPath(mapPath); - var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory; - var decodedMappings; - var generatedOrderedMappings; - var sourceOrderedMappings; - return { - getOriginalPosition: getOriginalPosition, - getGeneratedPosition: getGeneratedPosition - }; - function getGeneratedPosition(loc) { - var maps = getSourceOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { sourcePath: loc.fileName, sourcePosition: loc.position }, ts.identity, compareProcessedPositionSourcePositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - if (!maps[targetIndex] || ts.comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot) !== 0) { - return loc; - } - return { fileName: ts.toPath(map.file, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].emittedPosition }; // Closest pos - } - function getOriginalPosition(loc) { - var maps = getGeneratedOrderedMappings(); - if (!ts.length(maps)) - return loc; - var targetIndex = ts.binarySearch(maps, { emittedPosition: loc.position }, ts.identity, compareProcessedPositionEmittedPositions); - if (targetIndex < 0 && maps.length > 0) { - // if no exact match, closest is 2's compliment of result - targetIndex = ~targetIndex; - } - return { fileName: ts.toPath(maps[targetIndex].sourcePath, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].sourcePosition }; // Closest pos - } - function getSourceFileLike(fileName, location) { - // Lookup file in program, if provided - var path = ts.toPath(fileName, location, host.getCanonicalFileName); - var file = program && program.getSourceFile(path); - // file returned here could be .d.ts when asked for .ts file if projectReferences and module resolution created this source file - if (!file || file.resolvedPath !== path) { - // Otherwise check the cache (which may hit disk) - return fallbackCache.get(path); - } - return file; - } - function getPositionOfLineAndCharacterUsingName(fileName, directory, line, character) { - var file = getSourceFileLike(fileName, directory); - if (!file) { - return -1; - } - return ts.getPositionOfLineAndCharacter(file, line, character); - } - function getDecodedMappings() { - return decodedMappings || (decodedMappings = calculateDecodedMappings(map, processPosition, host)); - } - function getSourceOrderedMappings() { - return sourceOrderedMappings || (sourceOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionSourcePositions)); - } - function getGeneratedOrderedMappings() { - return generatedOrderedMappings || (generatedOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionEmittedPositions)); - } - function compareProcessedPositionSourcePositions(a, b) { - return ts.comparePaths(a.sourcePath, b.sourcePath, sourceRoot) || - ts.compareValues(a.sourcePosition, b.sourcePosition); - } - function compareProcessedPositionEmittedPositions(a, b) { - return ts.compareValues(a.emittedPosition, b.emittedPosition); - } - function processPosition(position) { - var sourcePath = map.sources[position.sourceIndex]; - return { - emittedPosition: getPositionOfLineAndCharacterUsingName(map.file, currentDirectory, position.emittedLine, position.emittedColumn), - sourcePosition: getPositionOfLineAndCharacterUsingName(sourcePath, sourceRoot, position.sourceLine, position.sourceColumn), - sourcePath: sourcePath, - }; - } + ts.decodeMappings = decodeMappings; + function sameMapping(left, right) { + return left === right + || left.generatedLine === right.generatedLine + && left.generatedCharacter === right.generatedCharacter + && left.sourceIndex === right.sourceIndex + && left.sourceLine === right.sourceLine + && left.sourceCharacter === right.sourceCharacter + && left.nameIndex === right.nameIndex; + } + ts.sameMapping = sameMapping; + function isSourceMapping(mapping) { + return mapping.sourceIndex !== undefined + && mapping.sourceLine !== undefined + && mapping.sourceCharacter !== undefined; + } + 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 */ : + ts.Debug.fail(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 : + -1; + } + function base64VLQFormatEncode(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; } - sourcemaps.decode = decode; - /*@internal*/ - function decodeMappings(map) { - var state = { - encodedText: map.mappings, - currentNameIndex: undefined, - sourceMapNamesLength: map.names ? map.names.length : undefined, - currentEmittedColumn: 0, - currentEmittedLine: 0, - currentSourceColumn: 0, - currentSourceLine: 0, - currentSourceIndex: 0, - decodingIndex: 0 - }; - function captureSpan() { - return { - emittedColumn: state.currentEmittedColumn, - emittedLine: state.currentEmittedLine, - sourceColumn: state.currentSourceColumn, - sourceIndex: state.currentSourceIndex, - sourceLine: state.currentSourceLine, - nameIndex: state.currentNameIndex - }; + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + return encodedStr; + } + function isSourceMappedPosition(value) { + return value.sourceIndex !== undefined + && value.sourcePosition !== undefined; + } + function sameMappedPosition(left, right) { + return left.generatedPosition === right.generatedPosition + && left.sourceIndex === right.sourceIndex + && left.sourcePosition === right.sourcePosition; + } + function compareSourcePositions(left, right) { + return ts.compareValues(left.sourceIndex, right.sourceIndex); + } + function compareGeneratedPositions(left, right) { + return ts.compareValues(left.generatedPosition, right.generatedPosition); + } + function getSourcePositionOfMapping(value) { + return value.sourcePosition; + } + function getGeneratedPositionOfMapping(value) { + return value.generatedPosition; + } + function createDocumentPositionMapper(host, map, mapPath) { + var mapDirectory = ts.getDirectoryPath(mapPath); + var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory; + var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory); + var generatedCanonicalFilePath = host.getCanonicalFileName(generatedAbsoluteFilePath); + var generatedFile = host.getSourceFileLike(generatedCanonicalFilePath); + var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); }); + var sourceFileCanonicalPaths = sourceFileAbsolutePaths.map(function (source) { return host.getCanonicalFileName(source); }); + var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileCanonicalPaths.map(function (source, i) { return [source, i]; })); + var decodedMappings; + var generatedMappings; + var sourceMappings; + return { + getSourcePosition: getSourcePosition, + getGeneratedPosition: getGeneratedPosition + }; + function processMapping(mapping) { + var generatedPosition = generatedFile !== undefined + ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter) + : -1; + var source; + var sourcePosition; + if (isSourceMapping(mapping)) { + var sourceFilePath = sourceFileCanonicalPaths[mapping.sourceIndex]; + var sourceFile = host.getSourceFileLike(sourceFilePath); + source = map.sources[mapping.sourceIndex]; + sourcePosition = sourceFile !== undefined + ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter) + : -1; } return { - get decodingIndex() { return state.decodingIndex; }, - get error() { return state.error; }, - get lastSpan() { return captureSpan(); }, - next: function () { - if (hasCompletedDecoding(state) || state.error) - return { done: true, value: undefined }; - if (!decodeSinglePosition(state)) - return { done: true, value: undefined }; - return { done: false, value: captureSpan() }; - } + generatedPosition: generatedPosition, + source: source, + sourceIndex: mapping.sourceIndex, + sourcePosition: sourcePosition, + nameIndex: mapping.nameIndex }; } - sourcemaps.decodeMappings = decodeMappings; - function calculateDecodedMappings(map, processPosition, host) { - var decoder = decodeMappings(map); - var positions = ts.arrayFrom(decoder, processPosition); - if (decoder.error) { - if (host && host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); - } - return []; - } - return positions; - } - function hasCompletedDecoding(state) { - return state.decodingIndex === state.encodedText.length; - } - function decodeSinglePosition(state) { - while (state.decodingIndex < state.encodedText.length) { - var char = state.encodedText.charCodeAt(state.decodingIndex); - if (char === 59 /* semicolon */) { - // New line - state.currentEmittedLine++; - state.currentEmittedColumn = 0; - state.decodingIndex++; - continue; - } - if (char === 44 /* comma */) { - // Next entry is on same line - no action needed - state.decodingIndex++; - continue; - } - // Read the current position - // 1. Column offset from prev read jsColumn - state.currentEmittedColumn += base64VLQFormatDecode(); - // Incorrect emittedColumn dont support this map - if (createErrorIfCondition(state.currentEmittedColumn < 0, "Invalid emittedColumn found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted column")) { - return false; - } - // 2. Relative sourceIndex - state.currentSourceIndex += base64VLQFormatDecode(); - // Incorrect sourceIndex dont support this map - if (createErrorIfCondition(state.currentSourceIndex < 0, "Invalid sourceIndex found")) { - return false; - } - // Dont support reading mappings that dont have information about original source position - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after sourceIndex")) { - return false; - } - // 3. Relative sourceLine 0 based - state.currentSourceLine += base64VLQFormatDecode(); - // Incorrect sourceLine dont support this map - if (createErrorIfCondition(state.currentSourceLine < 0, "Invalid sourceLine found")) { - return false; - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: No entries after emitted Line")) { - return false; - } - // 4. Relative sourceColumn 0 based - state.currentSourceColumn += base64VLQFormatDecode(); - // Incorrect sourceColumn dont support this map - if (createErrorIfCondition(state.currentSourceColumn < 0, "Invalid sourceLine found")) { - return false; - } - // 5. Check if there is name: - if (!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex)) { - if (state.currentNameIndex === undefined) { - state.currentNameIndex = 0; + function getDecodedMappings() { + if (decodedMappings === undefined) { + var decoder = decodeMappings(map.mappings); + var mappings = ts.arrayFrom(decoder, processMapping); + if (decoder.error !== undefined) { + if (host.log) { + host.log("Encountered error while decoding sourcemap: " + decoder.error); } - state.currentNameIndex += base64VLQFormatDecode(); - // Incorrect nameIndex dont support this map - // TODO: If we start using `name`s, issue errors when they aren't correct in the sourcemap - // if (createErrorIfCondition(state.currentNameIndex < 0 || state.currentNameIndex >= state.sourceMapNamesLength, "Invalid name index for the source map entry")) { - // return; - // } - } - // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(!isSourceMappingSegmentEnd(state.encodedText, state.decodingIndex), "Unsupported Error Format: There are more entries after " + (state.currentNameIndex === undefined ? "sourceColumn" : "nameIndex"))) { - return false; - } - // Entry should be complete - return true; - } - createErrorIfCondition(/*condition*/ true, "No encoded entry found"); - return false; - function createErrorIfCondition(condition, errormsg) { - if (state.error) { - // An error was already reported - return true; - } - if (condition) { - state.error = errormsg; - } - return condition; - } - function base64VLQFormatDecode() { - var moreDigits = true; - var shiftCount = 0; - var value = 0; - for (; moreDigits; state.decodingIndex++) { - if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return undefined; // TODO: GH#18217 - } - // 6 digit number - var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); - // If msb is set, we still have more bits to continue - moreDigits = (currentByte & 32) !== 0; - // least significant 5 bits are the next msbs in the final value. - value = value | ((currentByte & 31) << shiftCount); - shiftCount += 5; - } - // Least significant bit if 1 represents negative and rest of the msb is actual absolute value - if ((value & 1) === 0) { - // + number - value = value >> 1; + decodedMappings = ts.emptyArray; } else { - // - number - value = value >> 1; - value = -value; + decodedMappings = mappings; } - return value; } + return decodedMappings; } - function base64FormatDecode(char) { - return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(char); + function getSourceMappings(sourceIndex) { + if (sourceMappings === undefined) { + var lists = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + if (!isSourceMappedPosition(mapping)) + continue; + var list = lists[mapping.sourceIndex]; + if (!list) + lists[mapping.sourceIndex] = list = []; + list.push(mapping); + } + sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); }); + } + return sourceMappings[sourceIndex]; } - function isSourceMappingSegmentEnd(encodedText, pos) { - return (pos === encodedText.length || - encodedText.charCodeAt(pos) === 44 /* comma */ || - encodedText.charCodeAt(pos) === 59 /* semicolon */); + function getGeneratedMappings() { + if (generatedMappings === undefined) { + var list = []; + for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) { + var mapping = _a[_i]; + list.push(mapping); + } + generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition); + } + return generatedMappings; } - })(sourcemaps = ts.sourcemaps || (ts.sourcemaps = {})); + function getGeneratedPosition(loc) { + var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName)); + if (sourceIndex === undefined) + return loc; + var sourceMappings = getSourceMappings(sourceIndex); + if (!ts.some(sourceMappings)) + return loc; + var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = sourceMappings[targetIndex]; + if (mapping === undefined || mapping.sourceIndex !== sourceIndex) { + return loc; + } + return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition }; // Closest pos + } + function getSourcePosition(loc) { + var generatedMappings = getGeneratedMappings(); + if (!ts.some(generatedMappings)) + return loc; + var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues); + if (targetIndex < 0) { + // if no exact match, closest is 2's complement of result + targetIndex = ~targetIndex; + } + var mapping = generatedMappings[targetIndex]; + if (mapping === undefined || !isSourceMappedPosition(mapping)) { + return loc; + } + return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition }; // Closest pos + } + } + ts.createDocumentPositionMapper = createDocumentPositionMapper; + ts.identitySourceMapConsumer = { + getSourcePosition: ts.identity, + getGeneratedPosition: ts.identity + }; })(ts || (ts = {})); /* @internal */ var ts; @@ -63737,7 +64838,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 279 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -63783,7 +64884,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -63791,13 +64892,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 246 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { + case 248 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 259 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -63827,13 +64928,13 @@ var ts; } } break; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -63841,7 +64942,7 @@ var ts; } } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -63861,7 +64962,7 @@ var ts; } } break; - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -64477,8 +65578,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -64508,14 +65609,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -64564,16 +65665,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 277 /* SourceFile */: - case 244 /* CaseBlock */: - case 243 /* ModuleBlock */: - case 216 /* Block */: + case 279 /* SourceFile */: + case 246 /* CaseBlock */: + case 245 /* ModuleBlock */: + case 218 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 238 /* ClassDeclaration */: - case 237 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 239 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -64585,7 +65686,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 === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 240 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -64633,10 +65734,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 252 /* ExportAssignment */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 254 /* ExportAssignment */: + case 255 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -64657,13 +65758,13 @@ var ts; return node; } switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -64683,11 +65784,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 253 /* ExportDeclaration */ || - node.kind === 247 /* ImportDeclaration */ || - node.kind === 248 /* ImportClause */ || - (node.kind === 246 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 257 /* ExternalModuleReference */)) { + if (node.kind === 255 /* ExportDeclaration */ || + node.kind === 249 /* ImportDeclaration */ || + node.kind === 250 /* ImportClause */ || + (node.kind === 248 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 259 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -64717,19 +65818,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 152 /* PropertyDeclaration */: - case 160 /* IndexSignature */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 154 /* MethodDeclaration */: + case 154 /* PropertyDeclaration */: + case 162 /* IndexSignature */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 156 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -64739,7 +65840,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 84 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 85 /* ExportKeyword */) { return undefined; } return node; @@ -64756,67 +65857,67 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 117 /* AbstractKeyword */: - case 76 /* ConstKeyword */: - case 124 /* DeclareKeyword */: - case 132 /* ReadonlyKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 118 /* AbstractKeyword */: + case 77 /* ConstKeyword */: + case 125 /* DeclareKeyword */: + case 133 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 167 /* ArrayType */: - case 168 /* TupleType */: - case 169 /* OptionalType */: - case 170 /* RestType */: - case 166 /* TypeLiteral */: - case 161 /* TypePredicate */: - case 148 /* TypeParameter */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 122 /* BooleanKeyword */: - case 137 /* StringKeyword */: - case 134 /* NumberKeyword */: - case 131 /* NeverKeyword */: - case 105 /* VoidKeyword */: - case 138 /* SymbolKeyword */: - case 164 /* ConstructorType */: - case 163 /* FunctionType */: - case 165 /* TypeQuery */: - case 162 /* TypeReference */: - case 171 /* UnionType */: - case 172 /* IntersectionType */: - case 173 /* ConditionalType */: - case 175 /* ParenthesizedType */: - case 176 /* ThisType */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 180 /* LiteralType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: + case 171 /* OptionalType */: + case 172 /* RestType */: + case 168 /* TypeLiteral */: + case 163 /* TypePredicate */: + case 150 /* TypeParameter */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 123 /* BooleanKeyword */: + case 138 /* StringKeyword */: + case 135 /* NumberKeyword */: + case 132 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 139 /* SymbolKeyword */: + case 166 /* ConstructorType */: + case 165 /* FunctionType */: + case 167 /* TypeQuery */: + case 164 /* TypeReference */: + case 173 /* UnionType */: + case 174 /* IntersectionType */: + case 175 /* ConditionalType */: + case 177 /* ParenthesizedType */: + case 178 /* ThisType */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 182 /* LiteralType */: // TypeScript type nodes are elided. - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: // TypeScript index signatures are elided. - case 150 /* Decorator */: + case 152 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 152 /* PropertyDeclaration */: + case 154 /* 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 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructor(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64827,7 +65928,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -64838,35 +65939,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -64876,35 +65977,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 192 /* TypeAssertionExpression */: - case 210 /* AsExpression */: + case 194 /* TypeAssertionExpression */: + case 212 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -64941,7 +66042,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -65010,7 +66111,7 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -65212,7 +66313,7 @@ var ts; pendingExpressions = undefined; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85 /* ExtendsKeyword */; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 86 /* ExtendsKeyword */; })); var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); @@ -65388,7 +66489,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -65459,7 +66560,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 152 /* PropertyDeclaration */ + return member.kind === 154 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -65470,8 +66571,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { - var property = properties_10[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -65487,8 +66588,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_11 = properties; _i < properties_11.length; _i++) { - var property = properties_11[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); ts.startOnNewLine(expression); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -65599,12 +66700,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -65757,7 +66858,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 152 /* PropertyDeclaration */ + ? member.kind === 154 /* 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`. ? ts.createVoidZero() @@ -65858,13 +66959,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -65880,10 +66981,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */ - || kind === 152 /* PropertyDeclaration */; + return kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */ + || kind === 154 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -65893,7 +66994,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 154 /* MethodDeclaration */; + return node.kind === 156 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -65904,12 +67005,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return true; } return false; @@ -65926,15 +67027,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 149 /* Parameter */: + case 154 /* PropertyDeclaration */: + case 151 /* Parameter */: return serializeTypeNode(node.type); - case 157 /* SetAccessor */: - case 156 /* GetAccessor */: + case 159 /* SetAccessor */: + case 158 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 238 /* ClassDeclaration */: - case 207 /* ClassExpression */: - case 154 /* MethodDeclaration */: + case 240 /* ClassDeclaration */: + case 209 /* ClassExpression */: + case 156 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -65971,7 +67072,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 156 /* GetAccessor */) { + if (container && node.kind === 158 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -66016,77 +67117,83 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 105 /* VoidKeyword */: - case 140 /* UndefinedKeyword */: - case 95 /* NullKeyword */: - case 131 /* NeverKeyword */: + case 106 /* VoidKeyword */: + case 141 /* UndefinedKeyword */: + case 96 /* NullKeyword */: + case 132 /* NeverKeyword */: return ts.createVoidZero(); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 163 /* FunctionType */: - case 164 /* ConstructorType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: return ts.createIdentifier("Function"); - case 167 /* ArrayType */: - case 168 /* TupleType */: + case 169 /* ArrayType */: + case 170 /* TupleType */: return ts.createIdentifier("Array"); - case 161 /* TypePredicate */: - case 122 /* BooleanKeyword */: + case 163 /* TypePredicate */: + case 123 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 137 /* StringKeyword */: + case 138 /* StringKeyword */: return ts.createIdentifier("String"); - case 135 /* ObjectKeyword */: + case 136 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 180 /* LiteralType */: + case 182 /* LiteralType */: switch (node.literal.kind) { - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: + case 9 /* BigIntLiteral */: + return getGlobalBigIntNameWithFallback(); + case 102 /* TrueKeyword */: + case 87 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 134 /* NumberKeyword */: + case 135 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 138 /* SymbolKeyword */: + case 146 /* BigIntKeyword */: + return getGlobalBigIntNameWithFallback(); + case 139 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return serializeTypeReferenceNode(node); - case 172 /* IntersectionType */: - case 171 /* UnionType */: - return serializeUnionOrIntersectionType(node); - case 165 /* TypeQuery */: - case 177 /* TypeOperator */: - case 178 /* IndexedAccessType */: - case 179 /* MappedType */: - case 166 /* TypeLiteral */: - case 119 /* AnyKeyword */: - case 142 /* UnknownKeyword */: - case 176 /* ThisType */: - case 181 /* ImportType */: + case 174 /* IntersectionType */: + case 173 /* UnionType */: + return serializeTypeList(node.types); + case 175 /* ConditionalType */: + return serializeTypeList([node.trueType, node.falseType]); + case 167 /* TypeQuery */: + case 179 /* TypeOperator */: + case 180 /* IndexedAccessType */: + case 181 /* MappedType */: + case 168 /* TypeLiteral */: + case 120 /* AnyKeyword */: + case 143 /* UnknownKeyword */: + case 178 /* ThisType */: + case 183 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); } return ts.createIdentifier("Object"); } - function serializeUnionOrIntersectionType(node) { + function serializeTypeList(types) { // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, _a = node.types; _i < _a.length; _i++) { - var typeNode = _a[_i]; - while (typeNode.kind === 175 /* ParenthesizedType */) { + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var typeNode = types_17[_i]; + while (typeNode.kind === 177 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 131 /* NeverKeyword */) { + if (typeNode.kind === 132 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 95 /* NullKeyword */ || typeNode.kind === 140 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 96 /* NullKeyword */ || typeNode.kind === 141 /* 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); @@ -66122,6 +67229,10 @@ var ts; var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: + // From conditional type type reference that cannot be resolved is Similar to any or unknown + if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) { + return ts.createIdentifier("Object"); + } var serialized = serializeEntityNameAsExpressionFallback(node.typeName); var temp = ts.createTempVariable(hoistVariableDeclaration); return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object")); @@ -66129,6 +67240,8 @@ var ts; return serializeEntityNameAsExpression(node.typeName); case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.createVoidZero(); + case ts.TypeReferenceSerializationKind.BigIntLikeType: + return getGlobalBigIntNameWithFallback(); case ts.TypeReferenceSerializationKind.BooleanType: return ts.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -66160,12 +67273,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 71 /* Identifier */) { + if (node.left.kind === 72 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -66181,7 +67294,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* 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.getMutableClone(node); @@ -66189,7 +67302,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -66210,6 +67323,15 @@ var ts; function getGlobalSymbolNameWithFallback() { return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object")); } + /** + * Gets an expression that points to the global "BigInt" constructor at runtime if it is + * available. + */ + function getGlobalBigIntNameWithFallback() { + return languageVersion < 6 /* ESNext */ + ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object")) + : ts.createIdentifier("BigInt"); + } /** * A simple inlinable expression is an expression which can be copied into multiple locations * without risk of repeating any sideeffects and whose value could not possibly change between @@ -66290,9 +67412,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 85 /* ExtendsKeyword */) { + if (node.token === 86 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(85 /* ExtendsKeyword */, types), node); + return ts.setTextRange(ts.createHeritageClause(86 /* ExtendsKeyword */, types), node); } return undefined; } @@ -66688,7 +67810,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -66769,12 +67891,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 279 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 241 /* EnumDeclaration */) { + if (node.kind === 243 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -66899,7 +68021,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 243 /* ModuleBlock */) { + if (body.kind === 245 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -66945,13 +68067,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 243 /* ModuleBlock */) { + if (body.kind !== 245 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 244 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -66992,7 +68114,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 249 /* NamespaceImport */) { + if (node.kind === 251 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -67205,7 +68327,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -67213,7 +68335,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -67223,17 +68345,17 @@ var ts; enabledSubstitutions |= 2 /* 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(71 /* Identifier */); - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); + context.enableSubstitution(72 /* Identifier */); + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(242 /* ModuleDeclaration */); + context.enableEmitNotification(244 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 244 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 243 /* EnumDeclaration */; } /** * Hook for node emit. @@ -67292,11 +68414,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -67334,9 +68456,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 !== 277 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); + if (container && container.kind !== 279 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 244 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 243 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -67476,26 +68598,26 @@ var ts; return node; } switch (node.kind) { - case 120 /* AsyncKeyword */: + case 121 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -67506,27 +68628,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 216 /* Block */: - case 230 /* SwitchStatement */: - case 244 /* CaseBlock */: - case 269 /* CaseClause */: - case 270 /* DefaultClause */: - case 233 /* TryStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: - case 220 /* IfStatement */: - case 229 /* WithStatement */: - case 231 /* LabeledStatement */: + case 218 /* Block */: + case 232 /* SwitchStatement */: + case 246 /* CaseBlock */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: + case 235 /* TryStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: + case 222 /* IfStatement */: + case 231 /* WithStatement */: + case 233 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -67727,7 +68849,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 195 /* ArrowFunction */; + var isArrowFunction = node.kind === 197 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -67812,17 +68934,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -67870,23 +68992,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -67906,11 +69028,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -67977,7 +69099,7 @@ var ts; function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -68045,7 +69167,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 120 /* AsyncKeyword */) { + if (node.kind === 121 /* AsyncKeyword */) { return undefined; } return node; @@ -68055,55 +69177,55 @@ var ts; return node; } switch (node.kind) { - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return visitAwaitExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return visitVoidExpression(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return visitConstructorDeclaration(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: + case 158 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 157 /* SetAccessor */: + case 159 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 187 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 97 /* SuperKeyword */) { + case 189 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 98 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 188 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 97 /* SuperKeyword */) { + case 190 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 98 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); @@ -68139,7 +69261,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 227 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -68151,7 +69273,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 275 /* SpreadAssignment */) { + if (e.kind === 277 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -68160,7 +69282,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 275 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -68178,7 +69300,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 188 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -68206,7 +69328,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 262144 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -68434,7 +69556,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); @@ -68503,17 +69625,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(189 /* CallExpression */); - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(188 /* ElementAccessExpression */); + context.enableSubstitution(191 /* CallExpression */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(190 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(238 /* ClassDeclaration */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(240 /* ClassDeclaration */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(157 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(217 /* VariableStatement */); + context.enableEmitNotification(219 /* VariableStatement */); } } /** @@ -68561,23 +69683,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -68597,11 +69719,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 238 /* ClassDeclaration */ - || kind === 155 /* Constructor */ - || kind === 154 /* MethodDeclaration */ - || kind === 156 /* GetAccessor */ - || kind === 157 /* SetAccessor */; + return kind === 240 /* ClassDeclaration */ + || kind === 157 /* Constructor */ + || kind === 156 /* MethodDeclaration */ + || kind === 158 /* GetAccessor */ + || kind === 159 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -68710,13 +69832,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -68724,15 +69846,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 10 /* JsxText */: + case 11 /* JsxText */: return visitJsxText(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return visitJsxExpression(node); - case 258 /* JsxElement */: + case 260 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -68800,14 +69922,14 @@ var ts; if (node === undefined) { return ts.createTrue(); } - else if (node.kind === 9 /* StringLiteral */) { + else if (node.kind === 10 /* 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 literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text); literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 268 /* JsxExpression */) { + else if (node.kind === 270 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -68901,7 +70023,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 258 /* JsxElement */) { + if (node.kind === 260 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -69207,7 +70329,7 @@ var ts; return node; } switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69215,9 +70337,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 62 /* AsteriskAsteriskEqualsToken */: + case 63 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 40 /* AsteriskAsteriskToken */: + case 41 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69445,13 +70567,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 228 /* ReturnStatement */ + && node.kind === 230 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 218 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -69470,104 +70592,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 97 /* SuperKeyword */) { + if (node.kind === 98 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 115 /* StaticKeyword */: + case 116 /* StaticKeyword */: return undefined; // elide static keyword - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return visitClassExpression(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return visitParameter(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return visitArrowFunction(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 71 /* Identifier */: + case 72 /* Identifier */: return visitIdentifier(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 227 /* BreakStatement */: - case 226 /* ContinueStatement */: + case 229 /* BreakStatement */: + case 228 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return visitExpressionStatement(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 13 /* NoSubstitutionTemplateLiteral */: - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return visitTemplateLiteral(node); - case 9 /* StringLiteral */: + case 10 /* StringLiteral */: return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return visitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return visitSpreadElement(node); - case 97 /* SuperKeyword */: + case 98 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return visitThisKeyword(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return visitMetaProperty(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -69654,14 +70776,14 @@ 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 === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 229 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -69672,7 +70794,7 @@ var ts; } } else { - if (node.kind === 227 /* BreakStatement */) { + if (node.kind === 229 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -69691,10 +70813,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 26 /* CommaToken */, copyExpr); + expr = ts.createBinary(expr, 27 /* CommaToken */, copyExpr); } } - returnExpression = ts.createBinary(expr, 26 /* CommaToken */, returnExpression); + returnExpression = ts.createBinary(expr, 27 /* CommaToken */, returnExpression); } return ts.createReturn(returnExpression); } @@ -69828,7 +70950,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -69933,7 +71055,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 96 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -69972,11 +71094,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 228 /* ReturnStatement */) { + if (statement.kind === 230 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 220 /* IfStatement */) { + else if (statement.kind === 222 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -69984,7 +71106,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 216 /* Block */) { + else if (statement.kind === 218 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -70042,7 +71164,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 221 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -70052,8 +71174,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (8192 /* ContainsLexicalThis */ | 16384 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 202 /* BinaryExpression */ - || superCallExpression.left.kind !== 189 /* CallExpression */) { + if (superCallExpression.kind !== 204 /* BinaryExpression */ + || superCallExpression.left.kind !== 191 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -70198,7 +71320,7 @@ var ts; * synthesized call to `super` */ function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 71 /* Identifier */ && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 72 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** * Adds statements to the body of a function-like node if it contains a rest parameter. @@ -70250,7 +71372,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { + if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 197 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -70269,25 +71391,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return statements; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 237 /* FunctionDeclaration */: - case 194 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 196 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 94 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70315,20 +71437,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 155 /* Constructor */: + case 157 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -70520,7 +71642,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 239 /* FunctionDeclaration */ || node.kind === 196 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -70565,7 +71687,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 195 /* ArrowFunction */); + ts.Debug.assert(node.kind === 197 /* 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 @@ -70603,7 +71725,7 @@ var ts; ts.setEmitFlags(block, 1 /* SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 18 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -70633,9 +71755,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -70654,9 +71776,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -70691,7 +71813,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 58 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 59 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -70865,14 +71987,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -71056,7 +72178,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 147 /* ComputedPropertyName */) { + if (property.name.kind === 149 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -71111,7 +72233,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -71177,11 +72299,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 223 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 224 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 225 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 221 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 222 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 225 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 226 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 227 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 223 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 224 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -71206,11 +72328,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 223 /* ForStatement */: - case 224 /* ForInStatement */: - case 225 /* ForOfStatement */: + case 225 /* ForStatement */: + case 226 /* ForInStatement */: + case 227 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 238 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -71361,7 +72483,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -71423,7 +72545,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(51 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -71461,7 +72583,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -71472,7 +72594,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 58 /* EqualsToken */, source); + return ts.createBinary(target, 59 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -71485,7 +72607,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -71499,7 +72621,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -71520,10 +72642,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -71609,20 +72731,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -71733,7 +72855,7 @@ var ts; var body = node.transformFlags & (16384 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 156 /* GetAccessor */) { + if (node.kind === 158 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -71910,10 +73032,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 131072 /* ContainsRestOrSpread */ || - node.expression.kind === 97 /* SuperKeyword */ || + node.expression.kind === 98 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -71946,7 +73068,7 @@ var ts; resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 97 /* SuperKeyword */) { + if (node.expression.kind === 98 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -72011,7 +73133,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 187 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -72128,7 +73250,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 === 13 /* NoSubstitutionTemplateLiteral */ || node.kind === 16 /* TemplateTail */; + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's @@ -72226,7 +73348,7 @@ var ts; : ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 94 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 95 /* NewKeyword */ && node.name.escapedText === "target") { if (hierarchyFacts & 8192 /* ComputedPropertyName */) { hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; } @@ -72263,7 +73385,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } } /** @@ -72273,14 +73395,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(155 /* Constructor */); - context.enableEmitNotification(154 /* MethodDeclaration */); - context.enableEmitNotification(156 /* GetAccessor */); - context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(195 /* ArrowFunction */); - context.enableEmitNotification(194 /* FunctionExpression */); - context.enableEmitNotification(237 /* FunctionDeclaration */); + context.enableSubstitution(100 /* ThisKeyword */); + context.enableEmitNotification(157 /* Constructor */); + context.enableEmitNotification(156 /* MethodDeclaration */); + context.enableEmitNotification(158 /* GetAccessor */); + context.enableEmitNotification(159 /* SetAccessor */); + context.enableEmitNotification(197 /* ArrowFunction */); + context.enableEmitNotification(196 /* FunctionExpression */); + context.enableEmitNotification(239 /* FunctionDeclaration */); } } /** @@ -72321,10 +73443,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: - case 241 /* EnumDeclaration */: - case 235 /* VariableDeclaration */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: + case 243 /* EnumDeclaration */: + case 237 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -72337,9 +73459,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 99 /* ThisKeyword */: + case 100 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -72406,19 +73528,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 221 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 191 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 98 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 208 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -72471,15 +73593,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(260 /* JsxOpeningElement */); - context.enableEmitNotification(261 /* JsxClosingElement */); - context.enableEmitNotification(259 /* JsxSelfClosingElement */); + context.enableEmitNotification(262 /* JsxOpeningElement */); + context.enableEmitNotification(263 /* JsxClosingElement */); + context.enableEmitNotification(261 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(187 /* PropertyAccessExpression */); - context.enableSubstitution(273 /* PropertyAssignment */); + context.enableSubstitution(189 /* PropertyAccessExpression */); + context.enableSubstitution(275 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -72498,9 +73620,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 260 /* JsxOpeningElement */: - case 261 /* JsxClosingElement */: - case 259 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: + case 263 /* JsxClosingElement */: + case 261 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -72557,7 +73679,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 73 /* FirstReservedWord */ && token <= 108 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -72832,13 +73954,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -72851,24 +73973,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return visitAccessorDeclaration(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return visitBreakStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return visitContinueStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 4194304 /* ContainsYield */) { @@ -72889,21 +74011,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return visitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return visitConditionalExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return visitYieldExpression(node); - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return visitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -72916,9 +74038,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -73117,23 +74239,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 59 /* FirstCompoundAssignment */ - && kind <= 70 /* LastCompoundAssignment */; + return kind >= 60 /* FirstCompoundAssignment */ + && kind <= 71 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 59 /* PlusEqualsToken */: return 37 /* PlusToken */; - case 60 /* MinusEqualsToken */: return 38 /* MinusToken */; - case 61 /* AsteriskEqualsToken */: return 39 /* AsteriskToken */; - case 62 /* AsteriskAsteriskEqualsToken */: return 40 /* AsteriskAsteriskToken */; - case 63 /* SlashEqualsToken */: return 41 /* SlashToken */; - case 64 /* PercentEqualsToken */: return 42 /* PercentToken */; - case 65 /* LessThanLessThanEqualsToken */: return 45 /* LessThanLessThanToken */; - case 66 /* GreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanToken */; - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanGreaterThanToken */; - case 68 /* AmpersandEqualsToken */: return 48 /* AmpersandToken */; - case 69 /* BarEqualsToken */: return 49 /* BarToken */; - case 70 /* CaretEqualsToken */: return 50 /* CaretToken */; + case 60 /* PlusEqualsToken */: return 38 /* PlusToken */; + case 61 /* MinusEqualsToken */: return 39 /* MinusToken */; + case 62 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; + case 63 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; + case 64 /* SlashEqualsToken */: return 42 /* SlashToken */; + case 65 /* PercentEqualsToken */: return 43 /* PercentToken */; + case 66 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; + case 67 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; + case 68 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; + case 69 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; + case 70 /* BarEqualsToken */: return 50 /* BarToken */; + case 71 /* CaretEqualsToken */: return 51 /* CaretToken */; } } /** @@ -73146,7 +74268,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -73158,7 +74280,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -73190,7 +74312,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 26 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -73245,7 +74367,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 === 53 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -73276,7 +74398,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -73534,35 +74656,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: return transformAndEmitBlock(node); - case 219 /* ExpressionStatement */: + case 221 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return transformAndEmitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return transformAndEmitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return transformAndEmitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return transformAndEmitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -73992,7 +75114,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 272 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -74005,7 +75127,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 269 /* CaseClause */) { + if (clause.kind === 271 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -74317,7 +75439,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(72 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -75233,12 +76355,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(279 /* 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. @@ -75566,23 +76688,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return visitExportDeclaration(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -75609,24 +76731,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -76104,7 +77226,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -76159,10 +77281,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -76344,8 +77466,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -76361,7 +77483,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -76423,12 +77545,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 201 /* PostfixUnaryExpression */: - case 200 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -76449,7 +77571,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -76517,15 +77639,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 203 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 60 /* PlusEqualsToken */ : 61 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -76599,12 +77721,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(277 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(72 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(276 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(204 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(202 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(203 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(279 /* 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. @@ -76825,7 +77947,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 255 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -76850,7 +77972,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 253 /* ExportDeclaration */) { + if (externalImport.kind !== 255 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -76928,19 +78050,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -76990,15 +78112,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return visitImportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -77174,7 +78296,7 @@ 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 === 277 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 279 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -77238,7 +78360,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 219 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -77300,10 +78422,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -77483,43 +78605,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return visitClassDeclaration(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return visitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return visitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return visitForOfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return visitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return visitWhileStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return visitLabeledStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return visitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return visitSwitchStatement(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return visitCaseBlock(node); - case 269 /* CaseClause */: + case 271 /* CaseClause */: return visitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return visitDefaultClause(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return visitTryStatement(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return visitCatchClause(node); - case 216 /* Block */: + case 218 /* Block */: return visitBlock(node); - case 308 /* MergeDeclarationMarker */: + case 310 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 309 /* EndOfDeclarationMarker */: + case 311 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -77702,7 +78824,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 202 /* BinaryExpression */) { + && node.kind === 204 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -77767,7 +78889,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 277 /* SourceFile */; + return container !== undefined && container.kind === 279 /* SourceFile */; } else { return false; @@ -77783,8 +78905,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: return undefined; } return node; @@ -77800,7 +78922,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 277 /* SourceFile */) { + if (node.kind === 279 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -77848,7 +78970,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -77882,12 +79004,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return substituteExpressionIdentifier(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return substituteBinaryExpression(node); - case 200 /* PrefixUnaryExpression */: - case 201 /* PostfixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -77973,22 +79095,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) + if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 201 /* PostfixUnaryExpression */ + var expression = node.kind === 203 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 201 /* PostfixUnaryExpression */) { - expression = node.operator === 43 /* PlusPlusToken */ + if (node.kind === 203 /* PostfixUnaryExpression */) { + expression = node.operator === 44 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -78009,7 +79131,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 279 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -78048,8 +79170,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(277 /* SourceFile */); - context.enableSubstitution(71 /* Identifier */); + context.enableEmitNotification(279 /* SourceFile */); + context.enableSubstitution(72 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -78077,10 +79199,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -78187,7 +79309,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78216,7 +79338,7 @@ var ts; 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 === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78263,7 +79385,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78272,8 +79394,8 @@ var ts; } // 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 === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || - (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 154 /* PropertyDeclaration */ || node.kind === 153 /* PropertySignature */ || + (node.kind === 151 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -78282,7 +79404,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 240 /* ClassDeclaration */ || node.kind === 151 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78307,7 +79429,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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.hasModifier(node, 32 /* Static */)) { @@ -78346,26 +79468,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 159 /* ConstructSignature */: + case 161 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78373,7 +79495,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.kind === 240 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78387,7 +79509,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -78412,30 +79534,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 155 /* Constructor */: + case 157 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 159 /* ConstructSignature */: - case 164 /* ConstructorType */: + case 161 /* ConstructSignature */: + case 166 /* 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 158 /* CallSignature */: + case 160 /* 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 160 /* IndexSignature */: + case 162 /* 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 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -78443,7 +79565,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78456,8 +79578,8 @@ 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 237 /* FunctionDeclaration */: - case 163 /* FunctionType */: + case 239 /* FunctionDeclaration */: + case 165 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -78471,34 +79593,34 @@ 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 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* CallSignature */: + case 160 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 240 /* 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 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -78513,9 +79635,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 238 /* ClassDeclaration */) { + if (node.parent.parent.kind === 240 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 108 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 109 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -78680,10 +79802,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 279 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { return node; } - if (node.kind === 278 /* Bundle */) { + if (node.kind === 280 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); @@ -78706,14 +79828,14 @@ 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_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(124 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(125 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 280 /* InputFiles */) { + if (prepend.kind === 282 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -78827,11 +79949,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 71 /* Identifier */) { + if (name.kind === 72 /* Identifier */) { return name; } else { - if (name.kind === 183 /* ArrayBindingPattern */) { + if (name.kind === 185 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -78839,7 +79961,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 208 /* OmittedExpression */) { + if (elem.kind === 210 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -78852,7 +79974,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(55 /* QuestionToken */)) : undefined, ensureType(p, 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 || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -78864,7 +79986,7 @@ var ts; } function ensureNoInitializer(node) { if (shouldPrintWithInitializer(node)) { - return resolver.createLiteralConstValue(ts.getParseTreeNode(node)); // TODO: Make safe + return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker); // TODO: Make safe } return undefined; } @@ -78877,19 +79999,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 149 /* Parameter */ && + var shouldUseResolverType = node.kind === 151 /* 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) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(120 /* AnyKeyword */); } - if (node.kind === 157 /* SetAccessor */) { + if (node.kind === 159 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); + return ts.createKeywordTypeNode(120 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -78897,12 +80019,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { + if (node.kind === 237 /* VariableDeclaration */ || node.kind === 186 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 149 /* Parameter */ - || node.kind === 152 /* PropertyDeclaration */ - || node.kind === 151 /* PropertySignature */) { + if (node.kind === 151 /* Parameter */ + || node.kind === 154 /* PropertyDeclaration */ + || node.kind === 153 /* 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)); @@ -78913,26 +80035,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(119 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(120 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 246 /* ImportEqualsDeclaration */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 248 /* ImportEqualsDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return false; } return false; @@ -78986,7 +80108,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 244 /* ModuleDeclaration */ && parent.kind !== 183 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -79006,7 +80128,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 259 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -79033,7 +80155,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 251 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -79138,68 +80260,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 168 /* TypeLiteral */ || input.kind === 181 /* MappedType */) && input.parent.kind !== 242 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 209 /* ExpressionWithTypeArguments */: { + case 211 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 162 /* TypeReference */: { + case 164 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 155 /* Constructor */: { + case 157 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(157 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 154 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 156 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(155 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 156 /* GetAccessor */: { + case 158 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 157 /* SetAccessor */: { + case 159 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 153 /* MethodSignature */: { + case 155 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 158 /* CallSignature */: { + case 160 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 160 /* IndexSignature */: { + case 162 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(120 /* AnyKeyword */))); } - case 235 /* VariableDeclaration */: { + case 237 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -79207,13 +80329,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 148 /* TypeParameter */: { + case 150 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 173 /* ConditionalType */: { + case 175 /* 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); @@ -79225,13 +80347,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 163 /* FunctionType */: { + case 165 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 164 /* ConstructorType */: { + case 166 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 181 /* ImportType */: { + case 183 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -79260,7 +80382,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 156 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -79270,7 +80392,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 253 /* ExportDeclaration */: { + case 255 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -79279,13 +80401,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 252 /* ExportAssignment */: { + case 254 /* 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 === 71 /* Identifier */) { + if (input.expression.kind === 72 /* Identifier */) { return input; } else { @@ -79295,7 +80417,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -79309,10 +80431,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 246 /* ImportEqualsDeclaration */: { + case 248 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 247 /* ImportDeclaration */: { + case 249 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -79333,14 +80455,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 242 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 239 /* InterfaceDeclaration */: { + case 241 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 237 /* FunctionDeclaration */: { + case 239 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), @@ -79362,10 +80484,10 @@ var ts; return clean; } } - case 242 /* ModuleDeclaration */: { + case 244 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 243 /* ModuleBlock */) { + if (inner && inner.kind === 245 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -79386,7 +80508,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 238 /* ClassDeclaration */: { + case 240 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -79397,7 +80519,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 71 /* Identifier */) { + if (param.name.kind === 72 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -79427,7 +80549,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 96 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ @@ -79436,16 +80558,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(124 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(125 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 85 /* ExtendsKeyword */) { + if (clause.token === 86 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 96 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -79456,10 +80578,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 217 /* VariableStatement */: { + case 219 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 241 /* EnumDeclaration */: { + case 243 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -79478,7 +80600,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 242 /* ModuleDeclaration */) { + if (input.kind === 244 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -79499,7 +80621,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 208 /* OmittedExpression */) { + if (e.kind === 210 /* OmittedExpression */) { return; } if (e.name) { @@ -79562,7 +80684,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 277 /* SourceFile */; + var parentIsFile = node.parent.kind === 279 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) || hasScopeMarker(node.parent) ? 0 : 1 /* Export */) | 2 /* Ambient */); additions = 0 /* None */; @@ -79604,13 +80726,13 @@ var ts; } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 85 /* ExtendsKeyword */ && t.expression.kind === 95 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 86 /* ExtendsKeyword */ && t.expression.kind === 96 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 239 /* InterfaceDeclaration */) { + if (node.kind === 241 /* InterfaceDeclaration */) { return true; } return false; @@ -79635,7 +80757,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 156 /* GetAccessor */ + return accessor.kind === 158 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -79644,52 +80766,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 149 /* Parameter */: - case 235 /* VariableDeclaration */: + case 151 /* Parameter */: + case 237 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 237 /* FunctionDeclaration */: - case 242 /* ModuleDeclaration */: - case 246 /* ImportEqualsDeclaration */: - case 239 /* InterfaceDeclaration */: - case 238 /* ClassDeclaration */: - case 240 /* TypeAliasDeclaration */: - case 241 /* EnumDeclaration */: - case 217 /* VariableStatement */: - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 244 /* ModuleDeclaration */: + case 248 /* ImportEqualsDeclaration */: + case 241 /* InterfaceDeclaration */: + case 240 /* ClassDeclaration */: + case 242 /* TypeAliasDeclaration */: + case 243 /* EnumDeclaration */: + case 219 /* VariableStatement */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: + case 254 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 159 /* ConstructSignature */: - case 155 /* Constructor */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 152 /* PropertyDeclaration */: - case 151 /* PropertySignature */: - case 153 /* MethodSignature */: - case 158 /* CallSignature */: - case 160 /* IndexSignature */: - case 235 /* VariableDeclaration */: - case 148 /* TypeParameter */: - case 209 /* ExpressionWithTypeArguments */: - case 162 /* TypeReference */: - case 173 /* ConditionalType */: - case 163 /* FunctionType */: - case 164 /* ConstructorType */: - case 181 /* ImportType */: + case 161 /* ConstructSignature */: + case 157 /* Constructor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 154 /* PropertyDeclaration */: + case 153 /* PropertySignature */: + case 155 /* MethodSignature */: + case 160 /* CallSignature */: + case 162 /* IndexSignature */: + case 237 /* VariableDeclaration */: + case 150 /* TypeParameter */: + case 211 /* ExpressionWithTypeArguments */: + case 164 /* TypeReference */: + case 175 /* ConditionalType */: + case 165 /* FunctionType */: + case 166 /* ConstructorType */: + case 183 /* ImportType */: return true; } return false; @@ -79754,6 +80876,14 @@ var ts; return transformers; } ts.getTransformers = getTransformers; + function noEmitSubstitution(_hint, node) { + return node; + } + ts.noEmitSubstitution = noEmitSubstitution; + function noEmitNotification(hint, node, callback) { + callback(hint, node); + } + ts.noEmitNotification = noEmitNotification; /** * Transforms an array of SourceFiles by passing them through each transformer. * @@ -79765,7 +80895,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(310 /* Count */); + var enabledSyntaxKindFeatures = new Array(312 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -79773,8 +80903,8 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; - var onSubstituteNode = function (_, node) { return node; }; - var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var onSubstituteNode = noEmitSubstitution; + var onEmitNode = noEmitNotification; var state = 0 /* Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer @@ -80023,825 +81153,11 @@ var ts; } ts.transformNodes = transformNodes; })(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans - var defaultLastEncodedSourceMapSpan = { - emittedLine: 0, - emittedColumn: 0, - sourceLine: 0, - sourceColumn: 0, - sourceIndex: 0 - }; - function createSourceMapWriter(host, writer, compilerOptions) { - if (compilerOptions === void 0) { compilerOptions = host.getCompilerOptions(); } - var extendedDiagnostics = compilerOptions.extendedDiagnostics; - var currentSource; - var currentSourceText; - var sourceMapDir; // The directory in which sourcemap will be - // Current source map file and its index in the sources list - var sourceMapSourceIndex; - // Last recorded and encoded spans - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan; - var lastEncodedNameIndex; - // Source map data - var sourceMapData; - var sourceMapDataList; - var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); - return { - initialize: initialize, - reset: reset, - setSourceFile: setSourceFile, - emitPos: emitPos, - emitNodeWithSourceMap: emitNodeWithSourceMap, - emitTokenWithSourceMap: emitTokenWithSourceMap, - getText: getText, - getSourceMappingURL: getSourceMappingURL, - }; - /** - * Skips trivia such as comments and white-space that can optionally overriden by the source map source - */ - function skipSourceTrivia(pos) { - return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); - } - /** - * Initialize the SourceMapWriter for a new output file. - * - * @param filePath The path to the generated output file. - * @param sourceMapFilePath The path to the output source map file. - * @param sourceFileOrBundle The input source file or bundle for the program. - */ - function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { - return; - } - if (sourceMapData) { - reset(); - } - sourceMapDataList = outputSourceMapDataList; - currentSource = undefined; - currentSourceText = undefined; - // Current source map file and its index in the sources list - sourceMapSourceIndex = -1; - // Last recorded and encoded spans - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; - lastEncodedNameIndex = 0; - // Initialize source map data - sourceMapData = { - sourceMapFilePath: sourceMapFilePath, - jsSourceMappingURL: !compilerOptions.inlineSourceMap ? ts.getBaseFileName(ts.normalizeSlashes(sourceMapFilePath)) : undefined, - sourceMapFile: ts.getBaseFileName(ts.normalizeSlashes(filePath)), - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - }; - // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the - // relative paths of the sources list in the sourcemap - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 277 /* SourceFile */) { // emitting single module file - // For modules or multiple emit files the mapRoot will have directory structure like the sources - // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map - sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle.fileName, host, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - // The relative paths are relative to the common directory - sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath - ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap - host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(filePath)); - } - } - /** - * Reset the SourceMapWriter to an empty state. - */ - function reset() { - if (disabled) { - return; - } - // Record source map data for the test harness. - if (sourceMapDataList) { - sourceMapDataList.push(sourceMapData); - } - currentSource = undefined; - sourceMapDir = undefined; - sourceMapSourceIndex = undefined; - lastRecordedSourceMapSpan = undefined; - lastEncodedSourceMapSpan = undefined; - lastEncodedNameIndex = undefined; - sourceMapData = undefined; - sourceMapDataList = undefined; - } - function captureSection() { - return { - version: 3, - file: sourceMapData.sourceMapFile, - sourceRoot: sourceMapData.sourceMapSourceRoot, - sources: sourceMapData.sourceMapSources, - names: sourceMapData.sourceMapNames, - mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent, - }; - } - // Encoding for sourcemap span - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - ts.Debug.assert(lastRecordedSourceMapSpan.emittedColumn >= 0, "lastEncodedSourceMapSpan.emittedColumn was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceIndex >= 0, "lastEncodedSourceMapSpan.sourceIndex was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceLine >= 0, "lastEncodedSourceMapSpan.sourceLine was negative"); - ts.Debug.assert(lastRecordedSourceMapSpan.sourceColumn >= 0, "lastEncodedSourceMapSpan.sourceColumn was negative"); - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Line/Comma delimiters - if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) { - // Emit comma to separate the entry - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - // Emit line delimiters - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 0; - } - // 1. Relative Column 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - // 2. Relative sourceIndex - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - // 3. Relative sourceLine 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - // 4. Relative sourceColumn 0 based - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - // 5. Relative namePosition 0 based - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - ts.Debug.assert(false, "We do not support name index right now, Make sure to update updateLastEncodedAndRecordedSpans when we start using this"); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - } - /** - * Emits a mapping. - * - * If the position is synthetic (undefined or a negative value), no mapping will be - * created. - * - * @param pos The position. - */ - function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeSourcemap"); - } - var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSource, pos); - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - // If this location wasn't recorded or the location in source is going backwards, record the span - if (!lastRecordedSourceMapSpan || - lastRecordedSourceMapSpan.emittedLine !== emittedLine || - lastRecordedSourceMapSpan.emittedColumn !== emittedColumn || - (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && - (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || - (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - // Encode the last recordedSpan before assigning new - encodeLastRecordedSourceMapSpan(); - // New span - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - sourceIndex: sourceMapSourceIndex - }; - } - else { - // Take the new pos instead since there is no change in emittedLine and column since last location - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - if (extendedDiagnostics) { - ts.performance.mark("afterSourcemap"); - ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); - } - } - function isPossiblySourceMap(x) { - return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; - } - /** - * Emits a node with possible leading and trailing source maps. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to emit. - * @param emitCallback The callback used to emit the node. - */ - function emitNodeWithSourceMap(hint, node, emitCallback) { - var _a; - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(hint, node); - } - if (node) { - if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { - var text = node.sourceMapText; - var parsed = void 0; - try { - parsed = JSON.parse(text); - } - catch (_b) { - // empty - } - if (!parsed || !isPossiblySourceMap(parsed)) { - return emitCallback(hint, node); - } - var offsetLine = writer.getLine(); - var firstLineColumnOffset = writer.getColumn(); - // First, decode the old component sourcemap - var originalMap = parsed; - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache = ts.createMap(); - var absolutePathCache = ts.createMap(); - var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); - for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { - var pathCacheKey = "" + raw.sourceIndex; - // Apply offsets to each position and fixup source entries - if (!resolvedPathCache.has(pathCacheKey)) { - var rawPath = originalMap.sources[raw.sourceIndex]; - var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - resolvedPathCache.set(pathCacheKey, resolvedPath_1); - absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); - } - var resolvedPath = resolvedPathCache.get(pathCacheKey); - var absolutePath = absolutePathCache.get(pathCacheKey); - // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? - var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); - // Then reencode all the updated spans into the overall map - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); - } - // And actually emit the text these sourcemaps are for - return emitCallback(hint, node); - } - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.sourceMapRange; - var _d = range || node, pos = _d.pos, end = _d.end; - var source = range && range.source; - var oldSource = currentSource; - if (source === oldSource) - source = undefined; - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitPos(skipSourceTrivia(pos)); - } - if (source) - setSourceFile(oldSource); - if (emitFlags & 64 /* NoNestedSourceMaps */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - if (source) - setSourceFile(source); - if (node.kind !== 305 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitPos(end); - } - if (source) - setSourceFile(oldSource); - } - } - /** - * Emits a token of a node with possible leading and trailing source maps. - * - * @param node The node containing the token. - * @param token The token to emit. - * @param tokenStartPos The start pos of the token. - * @param emitCallback The callback used to emit the token. - */ - function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled || ts.isInJsonFile(node)) { - return emitCallback(token, writer, tokenPos); - } - var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; - var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; - tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - tokenPos = emitCallback(token, writer, tokenPos); - if (range) - tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { - emitPos(tokenPos); - } - return tokenPos; - } - function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); - } - /** - * Set the current source file. - * - * @param sourceFile The source file. - */ - function setSourceFile(sourceFile) { - if (disabled) { - return; - } - currentSource = sourceFile; - currentSourceText = currentSource.text; - if (isJsonSourceMapSource(sourceFile)) { - return; - } - setupSourceEntry(sourceFile.fileName, sourceFile.text); - } - function setupSourceEntry(fileName, content, source) { - if (!source) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); - } - sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); - if (sourceMapSourceIndex === -1) { - sourceMapSourceIndex = sourceMapData.sourceMapSources.length; - sourceMapData.sourceMapSources.push(source); - // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(fileName); - if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent.push(content); - } - } - } - /** - * Gets the text for the source map. - */ - function getText() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - encodeLastRecordedSourceMapSpan(); - return JSON.stringify(captureSection()); - } - /** - * Gets the SourceMappingURL for the source map. - */ - function getSourceMappingURL() { - if (disabled || isJsonSourceMapSource(currentSource)) { - return undefined; // TODO: GH#18217 - } - if (compilerOptions.inlineSourceMap) { - // Encode the sourceMap into the sourceMap url - var base64SourceMapText = ts.base64encode(ts.sys, getText()); - return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; - } - else { - return sourceMapData.jsSourceMappingURL; - } - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - function base64FormatEncode(inValue) { - if (inValue < 64) { - return base64Chars.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - function createCommentWriter(printerOptions, emitPos) { - var extendedDiagnostics = printerOptions.extendedDiagnostics; - var newLine = ts.getNewLineCharacter(printerOptions); - var writer; - var containerPos = -1; - var containerEnd = -1; - var declarationListContainerEnd = -1; - var currentSourceFile; - var currentText; - var currentLineMap; - var detachedCommentsInfo; - var hasWrittenComment = false; - var disabled = !!printerOptions.removeComments; - return { - reset: reset, - setWriter: setWriter, - setSourceFile: setSourceFile, - emitNodeWithComments: emitNodeWithComments, - emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, - emitLeadingCommentsOfPosition: emitLeadingCommentsOfPosition, - }; - function emitNodeWithComments(hint, node, emitCallback) { - if (disabled) { - emitCallback(hint, node); - return; - } - if (node) { - hasWrittenComment = false; - var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0; - var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; - if ((pos < 0 && end < 0) || (pos === end)) { - // Both pos and end are synthesized, so just emit the node without comments. - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - } - else { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithComment"); - } - var isEmittedNode = node.kind !== 305 /* NotEmittedStatement */; - // 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 === 10 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 10 /* JsxText */; - // 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); - } - // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { - // Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments. - containerPos = pos; - } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* 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 === 236 /* VariableDeclarationList */) { - declarationListContainerEnd = end; - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithComment"); - } - emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithComment"); - } - // Restore previous container state. - containerPos = savedContainerPos; - containerEnd = savedContainerEnd; - 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 && isEmittedNode) { - emitTrailingComments(end); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithComment"); - } - } - } - } - function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { - var leadingComments = emitNode && emitNode.leadingComments; - if (ts.some(leadingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitNodeWithSynthesizedComments"); - } - ts.forEach(leadingComments, emitLeadingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); - } - } - emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); - var trailingComments = emitNode && emitNode.trailingComments; - if (ts.some(trailingComments)) { - if (extendedDiagnostics) { - ts.performance.mark("postEmitNodeWithSynthesizedComments"); - } - ts.forEach(trailingComments, emitTrailingSynthesizedComment); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); - } - } - } - function emitLeadingSynthesizedComment(comment) { - if (comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function emitTrailingSynthesizedComment(comment) { - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - } - function writeSynthesizedComment(comment) { - var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; - ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); - } - function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; - } - function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } - } - function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { - if (extendedDiagnostics) { - ts.performance.mark("preEmitBodyWithDetachedComments"); - } - var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = disabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; - if (!skipLeadingComments) { - emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); - } - if (emitFlags & 2048 /* NoNestedComments */ && !disabled) { - disabled = true; - emitCallback(node); - disabled = false; - } - else { - emitCallback(node); - } - if (extendedDiagnostics) { - ts.performance.mark("beginEmitBodyWithDetachedComments"); - } - if (!skipTrailingComments) { - emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); - if (hasWrittenComment && !writer.isAtStartOfLine()) { - writer.writeLine(); - } - } - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitBodyWithDetachedComments"); - } - } - function emitLeadingComments(pos, isEmittedNode) { - hasWrittenComment = false; - if (isEmittedNode) { - forEachLeadingCommentToEmit(pos, emitLeadingComment); - } - else if (pos === 0) { - // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, - // unless it is a triple slash comment at the top of the file. - // For Example: - // /// - // declare var x; - // /// - // interface F {} - // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted - forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); - } - } - function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); - } - } - function shouldWriteComment(text, pos) { - if (printerOptions.onlyPrintJsDocStyle) { - return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); - } - return true; - } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (!hasWrittenComment) { - ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); - hasWrittenComment = true; - } - // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else if (kind === 3 /* MultiLineCommentTrivia */) { - writer.write(" "); - } - } - function emitLeadingCommentsOfPosition(pos) { - if (disabled || pos === -1) { - return; - } - emitLeadingComments(pos, /*isEmittedNode*/ true); - } - function emitTrailingComments(pos) { - forEachTrailingCommentToEmit(pos, emitTrailingComment); - } - function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ - if (!writer.isAtStartOfLine()) { - writer.write(" "); - } - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - } - function emitTrailingCommentsOfPosition(pos, prefixSpace) { - if (disabled) { - return; - } - if (extendedDiagnostics) { - ts.performance.mark("beforeEmitTrailingCommentsOfPosition"); - } - forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); - if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); - } - } - function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { - // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - if (hasTrailingNewLine) { - writer.writeLine(); - } - else { - writer.write(" "); - } - } - function forEachLeadingCommentToEmit(pos, cb) { - // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments - if (containerPos === -1 || pos !== containerPos) { - if (hasDetachedComments(pos)) { - forEachLeadingCommentWithoutDetachedComments(cb); - } - else { - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - } - } - function forEachTrailingCommentToEmit(end, cb) { - // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments - if (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd)) { - ts.forEachTrailingCommentRange(currentText, end, cb); - } - } - function reset() { - currentSourceFile = undefined; - currentText = undefined; - currentLineMap = undefined; - detachedCommentsInfo = undefined; - } - function setWriter(output) { - writer = output; - } - function setSourceFile(sourceFile) { - currentSourceFile = sourceFile; - currentText = currentSourceFile.text; - currentLineMap = ts.getLineStarts(currentSourceFile); - detachedCommentsInfo = undefined; - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; - } - function forEachLeadingCommentWithoutDetachedComments(cb) { - // get the leading comments from detachedPos - var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - ts.forEachLeadingCommentRange(currentText, pos, cb, /*state*/ pos); - } - function emitDetachedCommentsAndUpdateCommentsInfo(range) { - var currentDetachedCommentInfo = ts.emitDetachedComments(currentText, currentLineMap, writer, writeComment, range, newLine, disabled); - if (currentDetachedCommentInfo) { - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - function writeComment(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (!shouldWriteComment(currentText, commentPos)) - return; - if (emitPos) - emitPos(commentPos); - ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); - if (emitPos) - emitPos(commentEnd); - } - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - */ - function isTripleSlashComment(commentPos, commentEnd) { - return ts.isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); - } - } - ts.createCommentWriter = createCommentWriter; -})(ts || (ts = {})); var ts; (function (ts) { var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); + var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ /** * Iterates over the source files that are expected to have an emit output. @@ -80879,7 +81195,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 278 /* Bundle */) { + if (sourceFile.kind === 280 /* Bundle */) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); @@ -80941,22 +81257,16 @@ var ts; var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); - var newLine = host.getNewLine(); + var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); }); var writer = ts.createTextWriter(newLine); - var sourceMap = ts.createSourceMapWriter(host, writer); - var declarationSourceMap = ts.createSourceMapWriter(host, writer, { - sourceMap: compilerOptions.declarationMap, - sourceRoot: compilerOptions.sourceRoot, - mapRoot: compilerOptions.mapRoot, - extendedDiagnostics: compilerOptions.extendedDiagnostics, - }); + var _a = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _a.enter, exit = _a.exit; var bundleInfo = createDefaultBundleInfo(); var emitSkipped = false; var exportedModulesFromDeclarationEmit; // Emit each output file - ts.performance.mark("beforePrint"); + enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles); - ts.performance.measure("printTime", "beforePrint"); + exit(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -80999,22 +81309,27 @@ var ts; } // Transform the source files var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], transformers, /*allowDtsFiles*/ false); + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: compilerOptions.noEmitHelpers, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + inlineSources: compilerOptions.inlineSources, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }; // Create a printer to print the nodes - var printer = createPrinter(__assign({}, compilerOptions, { noEmitHelpers: compilerOptions.noEmitHelpers }), { + var printer = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, // transform hooks onEmitNode: transform.emitNodeWithNotification, substituteNode: transform.substituteNode, - // sourcemap hooks - onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: sourceMap.emitPos, - // emitter hooks - onSetSourceFile: setSourceFile, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, sourceMap); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleInfoPath, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); } @@ -81038,14 +81353,20 @@ var ts; emitterDiagnostics.add(diagnostic); } } - var declarationPrinter = createPrinter(__assign({}, compilerOptions, { onlyPrintJsDocStyle: true, noEmitHelpers: true }), { + var printerOptions = { + removeComments: compilerOptions.removeComments, + newLine: compilerOptions.newLine, + noEmitHelpers: true, + module: compilerOptions.module, + target: compilerOptions.target, + sourceMap: compilerOptions.sourceMap, + inlineSourceMap: compilerOptions.inlineSourceMap, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + onlyPrintJsDocStyle: true, + }; + var declarationPrinter = createPrinter(printerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, - // sourcemap hooks - onEmitSourceMapOfNode: declarationSourceMap.emitNodeWithSourceMap, - onEmitSourceMapOfToken: declarationSourceMap.emitTokenWithSourceMap, - onEmitSourceMapOfPosition: declarationSourceMap.emitPos, - onSetSourceFile: setSourceFileForDeclarationSourceMaps, // transform hooks onEmitNode: declarationTransform.emitNodeWithNotification, substituteNode: declarationTransform.substituteNode, @@ -81054,8 +81375,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || emitOnlyDtsFiles) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, declarationSourceMap); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 277 /* SourceFile */) { + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], /* bundleInfopath*/ undefined, declarationPrinter, { + sourceMap: compilerOptions.declarationMap, + sourceRoot: compilerOptions.sourceRoot, + mapRoot: compilerOptions.mapRoot, + extendedDiagnostics: compilerOptions.extendedDiagnostics, + }); + if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 279 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -81064,7 +81390,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 71 /* Identifier */) { + if (node.expression.kind === 72 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -81075,25 +81401,41 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapOptions) { + var bundle = sourceFileOrBundle.kind === 280 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 279 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; - mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); + var sourceMapGenerator; + if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { + sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions); + } if (bundle) { - printer.writeBundle(bundle, writer, bundleInfo); + printer.writeBundle(bundle, bundleInfo, writer, sourceMapGenerator); } else { - printer.writeFile(sourceFile, writer); + printer.writeFile(sourceFile, writer, sourceMapGenerator); } - writer.writeLine(); - var sourceMappingURL = mapRecorder.getSourceMappingURL(); - if (sourceMappingURL) { - writer.write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Sometimes tools can sometimes see this line as a source mapping url comment + if (sourceMapGenerator) { + if (sourceMapDataList) { + sourceMapDataList.push({ + inputSourceFileNames: sourceMapGenerator.getSources(), + sourceMap: sourceMapGenerator.toJSON() + }); + } + var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile); + if (sourceMappingURL) { + if (!writer.isAtStartOfLine()) + writer.rawWrite(newLine); + writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + } + // Write the source map + if (sourceMapFilePath) { + var sourceMap = sourceMapGenerator.toString(); + ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); + } } - // Write the source map - if (sourceMapFilePath) { - ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); + else { + writer.writeLine(); } // Write the output file ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); @@ -81103,32 +81445,84 @@ var ts; ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false); } // Reset state - mapRecorder.reset(); writer.clear(); bundleInfo = createDefaultBundleInfo(); } - function setSourceFile(node) { - sourceMap.setSourceFile(node); + function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { + return (mapOptions.sourceMap || mapOptions.inlineSourceMap) + && (sourceFileOrBundle.kind !== 279 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } - function setSourceFileForDeclarationSourceMaps(node) { - declarationSourceMap.setSourceFile(node); + function getSourceRoot(mapOptions) { + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); + return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot; + } + function getSourceMapDirectory(mapOptions, filePath, sourceFile) { + if (mapOptions.sourceRoot) + return host.getCommonSourceDirectory(); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + } + return sourceMapDir; + } + return ts.getDirectoryPath(ts.normalizePath(filePath)); + } + function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) { + if (mapOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + var sourceMapText = sourceMapGenerator.toString(); + var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); + return "data:application/json;base64," + base64SourceMapText; + } + var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath))); + if (mapOptions.mapRoot) { + var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); + if (sourceFile) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir)); + } + if (ts.getRootLength(sourceMapDir) === 0) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapFile), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + return ts.combinePaths(sourceMapDir, sourceMapFile); + } + } + return sourceMapFile; } } ts.emitFiles = emitFiles; var PipelinePhase; (function (PipelinePhase) { PipelinePhase[PipelinePhase["Notification"] = 0] = "Notification"; - PipelinePhase[PipelinePhase["Comments"] = 1] = "Comments"; - PipelinePhase[PipelinePhase["SourceMaps"] = 2] = "SourceMaps"; - PipelinePhase[PipelinePhase["Emit"] = 3] = "Emit"; + PipelinePhase[PipelinePhase["Substitution"] = 1] = "Substitution"; + PipelinePhase[PipelinePhase["Comments"] = 2] = "Comments"; + PipelinePhase[PipelinePhase["SourceMaps"] = 3] = "SourceMaps"; + PipelinePhase[PipelinePhase["Emit"] = 4] = "Emit"; })(PipelinePhase || (PipelinePhase = {})); function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); - var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); - var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; + var moduleKind = ts.getEmitModuleKind(printerOptions); + var bundledHelpers = ts.createMap(); var currentSourceFile; var nodeIdToGeneratedName; // Map of generated names for specific nodes. var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables. @@ -81138,19 +81532,23 @@ var ts; var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes. var reservedNames; // TempFlags to reserve in nested name generation scopes. var writer; - var ownWriter; + var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; - var commitPendingSemicolon = ts.noop; - var writeSemicolon = writeSemicolonInternal; - var pendingSemicolon = false; - if (printerOptions.omitTrailingSemicolon) { - commitPendingSemicolon = commitPendingSemicolonInternal; - writeSemicolon = deferWriteSemicolon; - } - var syntheticParent = { pos: -1, end: -1 }; - var moduleKind = ts.getEmitModuleKind(printerOptions); - var bundledHelpers = ts.createMap(); var isOwnFileEmit; + // Source Maps + var sourceMapsDisabled = true; + var sourceMapGenerator; + var sourceMapSource; + var sourceMapSourceIndex = -1; + // Comments + var containerPos = -1; + var containerEnd = -1; + var declarationListContainerEnd = -1; + var currentLineMap; + var detachedCommentsInfo; + var hasWrittenComment = false; + var commentsDisabled = !!printerOptions.removeComments; + var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { // public API @@ -81177,9 +81575,9 @@ var ts; break; } switch (node.kind) { - case 277 /* SourceFile */: return printFile(node); - case 278 /* Bundle */: return printBundle(node); - case 279 /* UnparsedSource */: return printUnparsedSource(node); + case 279 /* SourceFile */: return printFile(node); + case 280 /* Bundle */: return printBundle(node); + case 281 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -81189,11 +81587,11 @@ var ts; return endPrint(); } function printBundle(bundle) { - writeBundle(bundle, beginPrint()); + writeBundle(bundle, /*bundleInfo*/ undefined, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printFile(sourceFile) { - writeFile(sourceFile, beginPrint()); + writeFile(sourceFile, beginPrint(), /*sourceMapEmitter*/ undefined); return endPrint(); } function printUnparsedSource(unparsed) { @@ -81202,14 +81600,14 @@ var ts; } function writeNode(hint, node, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(hint, node, sourceFile); reset(); writer = previousWriter; } function writeList(format, nodes, sourceFile, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); if (sourceFile) { setSourceFile(sourceFile); } @@ -81217,18 +81615,18 @@ var ts; reset(); writer = previousWriter; } - function writeBundle(bundle, output, bundleInfo) { + function writeBundle(bundle, bundleInfo, output, sourceMapGenerator) { isOwnFileEmit = false; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(bundle); emitPrologueDirectivesIfNeeded(bundle); emitHelpers(bundle); emitSyntheticTripleSlashReferencesIfNeeded(bundle); for (var _a = 0, _b = bundle.prepends; _a < _b.length; _a++) { var prepend = _b[_a]; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); writeLine(); + print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); } if (bundleInfo) { bundleInfo.originalOffset = writer.getTextPos(); @@ -81242,15 +81640,15 @@ var ts; } function writeUnparsedSource(unparsed, output) { var previousWriter = writer; - setWriter(output); + setWriter(output, /*_sourceMapGenerator*/ undefined); print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } - function writeFile(sourceFile, output) { + function writeFile(sourceFile, output, sourceMapGenerator) { isOwnFileEmit = true; var previousWriter = writer; - setWriter(output); + setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); print(0 /* SourceFile */, sourceFile, sourceFile); @@ -81269,19 +81667,24 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, hint); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; - comments.setSourceFile(sourceFile); - if (onSetSourceFile) { - onSetSourceFile(sourceFile); + currentLineMap = undefined; + detachedCommentsInfo = undefined; + if (sourceFile) { + setSourceMapSource(sourceFile); } } - function setWriter(output) { - writer = output; // TODO: GH#18217 - comments.setWriter(output); + function setWriter(_writer, _sourceMapGenerator) { + if (_writer && printerOptions.omitTrailingSemicolon) { + _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + } + writer = _writer; // TODO: GH#18217 + sourceMapGenerator = _sourceMapGenerator; + sourceMapsDisabled = !writer || !sourceMapGenerator; } function reset() { nodeIdToGeneratedName = []; @@ -81290,68 +81693,66 @@ var ts; tempFlagsStack = []; tempFlags = 0 /* Auto */; reservedNamesStack = []; - comments.reset(); - setWriter(/*output*/ undefined); + currentSourceFile = undefined; + currentLineMap = undefined; + detachedCommentsInfo = undefined; + setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); + } + function getCurrentLineMap() { + return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } function emit(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 4 /* Unspecified */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(4 /* Unspecified */, node); } function emitIdentifierName(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 2 /* IdentifierName */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(2 /* IdentifierName */, node); } function emitExpression(node) { - if (!node) + if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); pipelinePhase(1 /* Expression */, node); } - function getPipelinePhase(phase, hint) { + function getPipelinePhase(phase, node) { switch (phase) { case 0 /* Notification */: - if (onEmitNode) { + if (onEmitNode !== ts.noEmitNotification) { return pipelineEmitWithNotification; } // falls through - case 1 /* Comments */: - if (emitNodeWithComments && hint !== 0 /* SourceFile */) { + case 1 /* Substitution */: + if (substituteNode !== ts.noEmitSubstitution) { + return pipelineEmitWithSubstitution; + } + // falls through + case 2 /* Comments */: + if (!commentsDisabled && node.kind !== 279 /* SourceFile */) { return pipelineEmitWithComments; } - return pipelineEmitWithoutComments; - case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { + // falls through + case 3 /* SourceMaps */: + if (!sourceMapsDisabled && node.kind !== 279 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through - case 3 /* Emit */: + case 4 /* Emit */: return pipelineEmitWithHint; default: - return ts.Debug.assertNever(phase, "Unexpected value for PipelinePhase: " + phase); + return ts.Debug.assertNever(phase); } } - function getNextPipelinePhase(currentPhase, hint) { - return getPipelinePhase(currentPhase + 1, hint); + function getNextPipelinePhase(currentPhase, node) { + return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); - } - function pipelineEmitWithComments(hint, node) { - ts.Debug.assertDefined(emitNodeWithComments); - ts.Debug.assert(hint !== 0 /* SourceFile */); - emitNodeWithComments(hint, trySubstituteNode(hint, node), getNextPipelinePhase(1 /* Comments */, hint)); - } - function pipelineEmitWithoutComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Comments */, hint); - pipelinePhase(hint, trySubstituteNode(hint, node)); - } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */); - ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); + var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); + onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -81360,254 +81761,285 @@ var ts; return emitIdentifier(ts.cast(node, ts.isIdentifier)); if (hint === 3 /* MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + if (hint === 5 /* EmbeddedStatement */) { + ts.Debug.assertNode(node, ts.isEmptyStatement); + return emitEmptyStatement(/*isEmbeddedStatement*/ true); + } if (hint === 4 /* Unspecified */) { if (ts.isKeyword(node.kind)) return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals - case 14 /* TemplateHead */: - case 15 /* TemplateMiddle */: - case 16 /* TemplateTail */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: return emitLiteral(node); - case 279 /* UnparsedSource */: + case 281 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 146 /* QualifiedName */: + case 148 /* QualifiedName */: return emitQualifiedName(node); - case 147 /* ComputedPropertyName */: + case 149 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 148 /* TypeParameter */: + case 150 /* TypeParameter */: return emitTypeParameter(node); - case 149 /* Parameter */: + case 151 /* Parameter */: return emitParameter(node); - case 150 /* Decorator */: + case 152 /* Decorator */: return emitDecorator(node); // Type members - case 151 /* PropertySignature */: + case 153 /* PropertySignature */: return emitPropertySignature(node); - case 152 /* PropertyDeclaration */: + case 154 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 153 /* MethodSignature */: + case 155 /* MethodSignature */: return emitMethodSignature(node); - case 154 /* MethodDeclaration */: + case 156 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 155 /* Constructor */: + case 157 /* Constructor */: return emitConstructor(node); - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return emitAccessorDeclaration(node); - case 158 /* CallSignature */: + case 160 /* CallSignature */: return emitCallSignature(node); - case 159 /* ConstructSignature */: + case 161 /* ConstructSignature */: return emitConstructSignature(node); - case 160 /* IndexSignature */: + case 162 /* IndexSignature */: return emitIndexSignature(node); // Types - case 161 /* TypePredicate */: + case 163 /* TypePredicate */: return emitTypePredicate(node); - case 162 /* TypeReference */: + case 164 /* TypeReference */: return emitTypeReference(node); - case 163 /* FunctionType */: + case 165 /* FunctionType */: return emitFunctionType(node); - case 287 /* JSDocFunctionType */: + case 289 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 164 /* ConstructorType */: + case 166 /* ConstructorType */: return emitConstructorType(node); - case 165 /* TypeQuery */: + case 167 /* TypeQuery */: return emitTypeQuery(node); - case 166 /* TypeLiteral */: + case 168 /* TypeLiteral */: return emitTypeLiteral(node); - case 167 /* ArrayType */: + case 169 /* ArrayType */: return emitArrayType(node); - case 168 /* TupleType */: + case 170 /* TupleType */: return emitTupleType(node); - case 169 /* OptionalType */: + case 171 /* OptionalType */: return emitOptionalType(node); - case 171 /* UnionType */: + case 173 /* UnionType */: return emitUnionType(node); - case 172 /* IntersectionType */: + case 174 /* IntersectionType */: return emitIntersectionType(node); - case 173 /* ConditionalType */: + case 175 /* ConditionalType */: return emitConditionalType(node); - case 174 /* InferType */: + case 176 /* InferType */: return emitInferType(node); - case 175 /* ParenthesizedType */: + case 177 /* ParenthesizedType */: return emitParenthesizedType(node); - case 209 /* ExpressionWithTypeArguments */: + case 211 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 176 /* ThisType */: + case 178 /* ThisType */: return emitThisType(); - case 177 /* TypeOperator */: + case 179 /* TypeOperator */: return emitTypeOperator(node); - case 178 /* IndexedAccessType */: + case 180 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 179 /* MappedType */: + case 181 /* MappedType */: return emitMappedType(node); - case 180 /* LiteralType */: + case 182 /* LiteralType */: return emitLiteralType(node); - case 181 /* ImportType */: + case 183 /* ImportType */: return emitImportTypeNode(node); - case 282 /* JSDocAllType */: - write("*"); + case 284 /* JSDocAllType */: + writePunctuation("*"); return; - case 283 /* JSDocUnknownType */: - write("?"); + case 285 /* JSDocUnknownType */: + writePunctuation("?"); return; - case 284 /* JSDocNullableType */: + case 286 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 285 /* JSDocNonNullableType */: + case 287 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 286 /* JSDocOptionalType */: + case 288 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 170 /* RestType */: - case 288 /* JSDocVariadicType */: + case 172 /* RestType */: + case 290 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 182 /* ObjectBindingPattern */: + case 184 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 183 /* ArrayBindingPattern */: + case 185 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 184 /* BindingElement */: + case 186 /* BindingElement */: return emitBindingElement(node); // Misc - case 214 /* TemplateSpan */: + case 216 /* TemplateSpan */: return emitTemplateSpan(node); - case 215 /* SemicolonClassElement */: + case 217 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 216 /* Block */: + case 218 /* Block */: return emitBlock(node); - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: return emitVariableStatement(node); - case 218 /* EmptyStatement */: - return emitEmptyStatement(); - case 219 /* ExpressionStatement */: + case 220 /* EmptyStatement */: + return emitEmptyStatement(/*isEmbeddedStatement*/ false); + case 221 /* ExpressionStatement */: return emitExpressionStatement(node); - case 220 /* IfStatement */: + case 222 /* IfStatement */: return emitIfStatement(node); - case 221 /* DoStatement */: + case 223 /* DoStatement */: return emitDoStatement(node); - case 222 /* WhileStatement */: + case 224 /* WhileStatement */: return emitWhileStatement(node); - case 223 /* ForStatement */: + case 225 /* ForStatement */: return emitForStatement(node); - case 224 /* ForInStatement */: + case 226 /* ForInStatement */: return emitForInStatement(node); - case 225 /* ForOfStatement */: + case 227 /* ForOfStatement */: return emitForOfStatement(node); - case 226 /* ContinueStatement */: + case 228 /* ContinueStatement */: return emitContinueStatement(node); - case 227 /* BreakStatement */: + case 229 /* BreakStatement */: return emitBreakStatement(node); - case 228 /* ReturnStatement */: + case 230 /* ReturnStatement */: return emitReturnStatement(node); - case 229 /* WithStatement */: + case 231 /* WithStatement */: return emitWithStatement(node); - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: return emitSwitchStatement(node); - case 231 /* LabeledStatement */: + case 233 /* LabeledStatement */: return emitLabeledStatement(node); - case 232 /* ThrowStatement */: + case 234 /* ThrowStatement */: return emitThrowStatement(node); - case 233 /* TryStatement */: + case 235 /* TryStatement */: return emitTryStatement(node); - case 234 /* DebuggerStatement */: + case 236 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 235 /* VariableDeclaration */: + case 237 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 238 /* ClassDeclaration */: + case 240 /* ClassDeclaration */: return emitClassDeclaration(node); - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 243 /* ModuleBlock */: + case 245 /* ModuleBlock */: return emitModuleBlock(node); - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: return emitCaseBlock(node); - case 245 /* NamespaceExportDeclaration */: + case 247 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: return emitImportDeclaration(node); - case 248 /* ImportClause */: + case 250 /* ImportClause */: return emitImportClause(node); - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: return emitNamespaceImport(node); - case 250 /* NamedImports */: + case 252 /* NamedImports */: return emitNamedImports(node); - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: return emitImportSpecifier(node); - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: return emitExportAssignment(node); - case 253 /* ExportDeclaration */: + case 255 /* ExportDeclaration */: return emitExportDeclaration(node); - case 254 /* NamedExports */: + case 256 /* NamedExports */: return emitNamedExports(node); - case 255 /* ExportSpecifier */: + case 257 /* ExportSpecifier */: return emitExportSpecifier(node); - case 256 /* MissingDeclaration */: + case 258 /* MissingDeclaration */: return; // Module references - case 257 /* ExternalModuleReference */: + case 259 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 10 /* JsxText */: + case 11 /* JsxText */: return emitJsxText(node); - case 260 /* JsxOpeningElement */: - case 263 /* JsxOpeningFragment */: + case 262 /* JsxOpeningElement */: + case 265 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 261 /* JsxClosingElement */: - case 264 /* JsxClosingFragment */: + case 263 /* JsxClosingElement */: + case 266 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 265 /* JsxAttribute */: + case 267 /* JsxAttribute */: return emitJsxAttribute(node); - case 266 /* JsxAttributes */: + case 268 /* JsxAttributes */: return emitJsxAttributes(node); - case 267 /* JsxSpreadAttribute */: + case 269 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 268 /* JsxExpression */: + case 270 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 269 /* CaseClause */: + case 271 /* CaseClause */: return emitCaseClause(node); - case 270 /* DefaultClause */: + case 272 /* DefaultClause */: return emitDefaultClause(node); - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: return emitHeritageClause(node); - case 272 /* CatchClause */: + case 274 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 273 /* PropertyAssignment */: + case 275 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 274 /* ShorthandPropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 275 /* SpreadAssignment */: + case 277 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 276 /* EnumMember */: + case 278 /* EnumMember */: return emitEnumMember(node); - // JSDoc nodes (ignored) + // JSDoc nodes (only used in codefixes currently) + case 299 /* JSDocParameterTag */: + case 305 /* JSDocPropertyTag */: + return emitJSDocPropertyLikeTag(node); + case 300 /* JSDocReturnTag */: + case 302 /* JSDocTypeTag */: + case 301 /* JSDocThisTag */: + case 298 /* JSDocEnumTag */: + return emitJSDocSimpleTypedTag(node); + case 295 /* JSDocAugmentsTag */: + return emitJSDocAugmentsTag(node); + case 303 /* JSDocTemplateTag */: + return emitJSDocTemplateTag(node); + case 304 /* JSDocTypedefTag */: + return emitJSDocTypedefTag(node); + case 297 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + case 293 /* JSDocSignature */: + return emitJSDocSignature(node); + case 292 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 296 /* JSDocClassTag */: + case 294 /* JSDocTag */: + return emitJSDocSimpleTag(node); + case 291 /* JSDocComment */: + return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; - node = trySubstituteNode(1 /* Expression */, node); + if (substituteNode !== ts.noEmitSubstitution) { + node = substituteNode(hint, node); + } } else if (ts.isToken(node)) { return writeTokenNode(node, writePunctuation); @@ -81617,89 +82049,90 @@ var ts; switch (node.kind) { // Literals case 8 /* NumericLiteral */: - return emitNumericLiteral(node); - case 9 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NoSubstitutionTemplateLiteral */: + case 9 /* BigIntLiteral */: + return emitNumericOrBigIntLiteral(node); + case 10 /* StringLiteral */: + case 13 /* RegularExpressionLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 71 /* Identifier */: + case 72 /* Identifier */: return emitIdentifier(node); // Reserved words - case 86 /* FalseKeyword */: - case 95 /* NullKeyword */: - case 97 /* SuperKeyword */: - case 101 /* TrueKeyword */: - case 99 /* ThisKeyword */: - case 91 /* ImportKeyword */: + case 87 /* FalseKeyword */: + case 96 /* NullKeyword */: + case 98 /* SuperKeyword */: + case 102 /* TrueKeyword */: + case 100 /* ThisKeyword */: + case 92 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 185 /* ArrayLiteralExpression */: + case 187 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 186 /* ObjectLiteralExpression */: + case 188 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 187 /* PropertyAccessExpression */: + case 189 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 188 /* ElementAccessExpression */: + case 190 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 189 /* CallExpression */: + case 191 /* CallExpression */: return emitCallExpression(node); - case 190 /* NewExpression */: + case 192 /* NewExpression */: return emitNewExpression(node); - case 191 /* TaggedTemplateExpression */: + case 193 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 193 /* ParenthesizedExpression */: + case 195 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 194 /* FunctionExpression */: + case 196 /* FunctionExpression */: return emitFunctionExpression(node); - case 195 /* ArrowFunction */: + case 197 /* ArrowFunction */: return emitArrowFunction(node); - case 196 /* DeleteExpression */: + case 198 /* DeleteExpression */: return emitDeleteExpression(node); - case 197 /* TypeOfExpression */: + case 199 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 198 /* VoidExpression */: + case 200 /* VoidExpression */: return emitVoidExpression(node); - case 199 /* AwaitExpression */: + case 201 /* AwaitExpression */: return emitAwaitExpression(node); - case 200 /* PrefixUnaryExpression */: + case 202 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 201 /* PostfixUnaryExpression */: + case 203 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 202 /* BinaryExpression */: + case 204 /* BinaryExpression */: return emitBinaryExpression(node); - case 203 /* ConditionalExpression */: + case 205 /* ConditionalExpression */: return emitConditionalExpression(node); - case 204 /* TemplateExpression */: + case 206 /* TemplateExpression */: return emitTemplateExpression(node); - case 205 /* YieldExpression */: + case 207 /* YieldExpression */: return emitYieldExpression(node); - case 206 /* SpreadElement */: + case 208 /* SpreadElement */: return emitSpreadExpression(node); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return emitClassExpression(node); - case 208 /* OmittedExpression */: + case 210 /* OmittedExpression */: return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: return emitAsExpression(node); - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: return emitNonNullExpression(node); - case 212 /* MetaProperty */: + case 214 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 258 /* JsxElement */: + case 260 /* JsxElement */: return emitJsxElement(node); - case 259 /* JsxSelfClosingElement */: + case 261 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 262 /* JsxFragment */: + case 264 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 306 /* PartiallyEmittedExpression */: + case 308 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 307 /* CommaListExpression */: + case 309 /* CommaListExpression */: return emitCommaList(node); } } @@ -81711,12 +82144,13 @@ var ts; writeSpace(); emit(node.constraint); } - function trySubstituteNode(hint, node) { - return node && substituteNode && substituteNode(hint, node) || node; + function pipelineEmitWithSubstitution(hint, node) { + var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); + pipelinePhase(hint, substituteNode(hint, node)); } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 278 /* Bundle */ ? node : undefined; + var bundle = node.kind === 280 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -81765,7 +82199,8 @@ var ts; // Literals/Pseudo-literals // // SyntaxKind.NumericLiteral - function emitNumericLiteral(node) { + // SyntaxKind.BigIntLiteral + function emitNumericOrBigIntLiteral(node) { emitLiteral(node); } // SyntaxKind.StringLiteral @@ -81777,7 +82212,7 @@ var ts; function emitLiteral(node) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -81795,7 +82230,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 26896 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -81806,7 +82241,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -81842,7 +82277,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 289 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -81864,7 +82299,7 @@ var ts; emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitPropertyDeclaration(node) { emitDecorators(node, node.decorators); @@ -81874,7 +82309,7 @@ var ts; emit(node.exclamationToken); emitTypeAnnotation(node.type); emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node); - writeSemicolon(); + writeTrailingSemicolon(); } function emitMethodSignature(node) { pushNameGenerationScope(node); @@ -81885,7 +82320,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitMethodDeclaration(node) { @@ -81904,7 +82339,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 158 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -81916,7 +82351,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitConstructSignature(node) { @@ -81928,7 +82363,7 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); popNameGenerationScope(node); } function emitIndexSignature(node) { @@ -81936,10 +82371,10 @@ var ts; emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitSemicolonClassElement() { - writeSemicolon(); + writeTrailingSemicolon(); } // // Types @@ -81966,22 +82401,22 @@ var ts; popNameGenerationScope(node); } function emitJSDocFunctionType(node) { - write("function"); + writeKeyword("function"); emitParameters(node, node.parameters); - write(":"); + writePunctuation(":"); emit(node.type); } function emitJSDocNullableType(node) { - write("?"); + writePunctuation("?"); emit(node.type); } function emitJSDocNonNullableType(node) { - write("!"); + writePunctuation("!"); emit(node.type); } function emitJSDocOptionalType(node) { emit(node.type); - write("="); + writePunctuation("="); } function emitConstructorType(node) { pushNameGenerationScope(node); @@ -82002,8 +82437,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineTypeLiteralMembers */ : 16449 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 262144 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -82012,23 +82447,23 @@ var ts; writePunctuation("]"); } function emitRestOrJSDocVariadicType(node) { - write("..."); + writePunctuation("..."); emit(node.type); } function emitTupleType(node) { writePunctuation("["); - emitList(node, node.elementTypes, 272 /* TupleTypeElements */); + emitList(node, node.elementTypes, 528 /* TupleTypeElements */); writePunctuation("]"); } function emitOptionalType(node) { emit(node.type); - write("?"); + writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 260 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */); } function emitIntersectionType(node) { - emitList(node, node.types, 264 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */); } function emitConditionalType(node) { emit(node.checkType); @@ -82081,25 +82516,25 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 132 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 133 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 3 /* MappedTypeParameter */); + var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 55 /* QuestionToken */) { + if (node.questionToken.kind !== 56 /* QuestionToken */) { writePunctuation("?"); } } writePunctuation(":"); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); if (emitFlags & 1 /* SingleLine */) { writeSpace(); } @@ -82132,12 +82567,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 262448 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -82155,8 +82590,8 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -82164,9 +82599,9 @@ var ts; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + 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); if (indentedFlag) { decreaseIndent(); } @@ -82177,20 +82612,20 @@ var ts; if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = ts.createToken(23 /* DotToken */); + var dotToken = ts.createToken(24 /* DotToken */); dotToken.pos = dotRangeStart; dotToken.end = dotRangeEnd; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } emitExpression(node.expression); - increaseIndentIf(indentBeforeDot); + increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(23 /* DotToken */, node.expression.end, writePunctuation, node); - increaseIndentIf(indentAfterDot); + emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } @@ -82202,7 +82637,7 @@ var ts; // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); return !expression.numericLiteralFlags - && !ts.stringContains(text, ts.tokenToString(23 /* DotToken */)); + && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -82215,21 +82650,21 @@ var ts; } function emitElementAccessExpression(node) { emitExpression(node.expression); - emitTokenWithComment(21 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(22 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(94 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(95 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { emitExpression(node.tag); @@ -82244,9 +82679,9 @@ var ts; emitExpression(node.expression); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(19 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -82265,22 +82700,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(80 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(103 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(105 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(121 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(122 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -82305,24 +82740,24 @@ 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 === 200 /* PrefixUnaryExpression */ - && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) - || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); + return operand.kind === 202 /* PrefixUnaryExpression */ + && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) + || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator, writeOperator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 26 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); - increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); + increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 93 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - increaseIndentIf(indentAfterOperator, " "); + increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); } @@ -82332,23 +82767,23 @@ var ts; var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken); var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); - increaseIndentIf(indentBeforeQuestion, " "); + increaseIndentIf(indentBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); - increaseIndentIf(indentAfterQuestion, " "); + increaseIndentIf(indentAfterQuestion, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); - increaseIndentIf(indentBeforeColon, " "); + increaseIndentIf(indentBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); - increaseIndentIf(indentAfterColon, " "); + increaseIndentIf(indentAfterColon, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 131072 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(116 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(117 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -82396,38 +82831,45 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineBlockStatements */ : 65 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(18 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); emit(node.declarationList); - writeSemicolon(); + writeTrailingSemicolon(); } - function emitEmptyStatement() { - writeSemicolon(); + function emitEmptyStatement(isEmbeddedStatement) { + // While most trailing semicolons are possibly insignificant, an embedded "empty" + // statement is significant and cannot be elided by a trailing-semicolon-omitting writer. + if (isEmbeddedStatement) { + writePunctuation(";"); + } + else { + writeTrailingSemicolon(); + } } function emitExpressionStatement(node) { emitExpression(node.expression); // 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)) { - writeSemicolon(); + writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(91 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 220 /* IfStatement */) { + emitTokenWithComment(83 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 222 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -82437,14 +82879,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(106 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(81 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -82460,45 +82902,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(25 /* SemicolonToken */, node.condition ? node.condition.end : pos, writeSemicolon, node); + pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(20 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(92 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(93 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(88 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(89 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(147 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 236 /* VariableDeclarationList */) { + if (node.kind === 238 /* VariableDeclarationList */) { emit(node); } else { @@ -82507,14 +82949,14 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(77 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(78 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(72 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(73 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) { var node = ts.getParseTreeNode(contextNode); @@ -82540,40 +82982,40 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(96 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(97 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(107 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(108 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(98 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(56 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(100 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(101 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(102 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -82582,14 +83024,14 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(87 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(88 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(78 /* DebuggerKeyword */, node.pos, writeKeyword); - writeSemicolon(); + writeToken(79 /* DebuggerKeyword */, node.pos, writeKeyword); + writeTrailingSemicolon(); } // // Declarations @@ -82602,7 +83044,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 272 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -82650,7 +83092,7 @@ var ts; } else { emitSignatureHead(node); - writeSemicolon(); + writeTrailingSemicolon(); } } function emitSignatureHead(node) { @@ -82702,7 +83144,7 @@ var ts; emitBlockFunctionBody(body); } decreaseIndent(); - writeToken(18 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -82714,7 +83156,7 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 384 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); increaseIndent(); } else { @@ -82741,7 +83183,7 @@ var ts; emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* ClassMembers */); + emitList(node, node.members, 129 /* ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -82754,10 +83196,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 256 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 65 /* InterfaceMembers */); + emitList(node, node.members, 129 /* InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -82771,7 +83213,7 @@ var ts; writePunctuation("="); writeSpace(); emit(node.type); - writeSemicolon(); + writeTrailingSemicolon(); } function emitEnumDeclaration(node) { emitModifiers(node, node.modifiers); @@ -82780,7 +83222,7 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 81 /* EnumMembers */); + emitList(node, node.members, 145 /* EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { @@ -82792,8 +83234,8 @@ var ts; emit(node.name); var body = node.body; if (!body) - return writeSemicolon(); - while (body.kind === 242 /* ModuleDeclaration */) { + return writeTrailingSemicolon(); + while (body.kind === 244 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -82808,23 +83250,23 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(17 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 65 /* CaseBlockClauses */); - emitTokenWithComment(18 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* CaseBlockClauses */); + emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(59 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); - writeSemicolon(); + writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -82833,29 +83275,29 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(91 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(92 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); - writeSemicolon(); + writeTrailingSemicolon(); } function emitImportClause(node) { emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(26 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(39 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -82866,45 +83308,45 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(58 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(59 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(79 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(80 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); - writeSemicolon(); + writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(39 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(144 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(84 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(85 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(118 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(119 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(130 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(131 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); - writeSemicolon(); + writeTrailingSemicolon(); } function emitNamedExports(node) { emitNamedImportsOrExports(node); @@ -82914,14 +83356,14 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 262576 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(118 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(119 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -82940,7 +83382,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -82952,7 +83394,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 131072 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -82967,7 +83409,6 @@ var ts; writePunctuation(">"); } function emitJsxText(node) { - commitPendingSemicolon(); writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); } function emitJsxClosingElementOrFragment(node) { @@ -82978,7 +83419,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 131328 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -82998,7 +83439,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 71 /* Identifier */) { + if (node.kind === 72 /* Identifier */) { emitExpression(node); } else { @@ -83009,13 +83450,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(73 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(74 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(79 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(80 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -83025,14 +83466,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 81985 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 64 /* Indented */); + format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(56 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -83040,15 +83481,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 272 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(74 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(75 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(20 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -83097,6 +83538,142 @@ var ts; emitInitializer(node.initializer, node.name.end, node); } // + // JSDoc + // + function emitJSDoc(node) { + write("/**"); + if (node.comment) { + var lines = node.comment.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } + } + if (node.tags) { + if (node.tags.length === 1 && node.tags[0].kind === 302 /* JSDocTypeTag */ && !node.comment) { + writeSpace(); + emit(node.tags[0]); + } + else { + emitList(node, node.tags, 33 /* JSDocComment */); + } + } + writeSpace(); + write("*/"); + } + function emitJSDocSimpleTypedTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.typeExpression); + emitJSDocComment(tag.comment); + } + function emitJSDocAugmentsTag(tag) { + emitJSDocTagName(tag.tagName); + writeSpace(); + writePunctuation("{"); + emit(tag.class); + writePunctuation("}"); + emitJSDocComment(tag.comment); + } + function emitJSDocTemplateTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocTypeExpression(tag.constraint); + writeSpace(); + emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitJSDocComment(tag.comment); + } + function emitJSDocTypedefTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.typeExpression) { + if (tag.typeExpression.kind === 283 /* JSDocTypeExpression */) { + emitJSDocTypeExpression(tag.typeExpression); + } + else { + writeSpace(); + writePunctuation("{"); + write("Object"); + if (tag.typeExpression.isArrayType) { + writePunctuation("["); + writePunctuation("]"); + } + writePunctuation("}"); + } + } + if (tag.fullName) { + writeSpace(); + emit(tag.fullName); + } + emitJSDocComment(tag.comment); + if (tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeLiteral */) { + emitJSDocTypeLiteral(tag.typeExpression); + } + } + function emitJSDocCallbackTag(tag) { + emitJSDocTagName(tag.tagName); + if (tag.name) { + writeSpace(); + emit(tag.name); + } + emitJSDocComment(tag.comment); + emitJSDocSignature(tag.typeExpression); + } + function emitJSDocSimpleTag(tag) { + emitJSDocTagName(tag.tagName); + emitJSDocComment(tag.comment); + } + function emitJSDocTypeLiteral(lit) { + emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + } + function emitJSDocSignature(sig) { + if (sig.typeParameters) { + emitList(sig, ts.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + } + if (sig.parameters) { + emitList(sig, ts.createNodeArray(sig.parameters), 33 /* JSDocComment */); + } + if (sig.type) { + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + emit(sig.type); + } + } + function emitJSDocPropertyLikeTag(param) { + emitJSDocTagName(param.tagName); + emitJSDocTypeExpression(param.typeExpression); + writeSpace(); + if (param.isBracketed) { + writePunctuation("["); + } + emit(param.name); + if (param.isBracketed) { + writePunctuation("]"); + } + emitJSDocComment(param.comment); + } + function emitJSDocTagName(tagName) { + writePunctuation("@"); + emit(tagName); + } + function emitJSDocComment(comment) { + if (comment) { + writeSpace(); + write(comment); + } + } + function emitJSDocTypeExpression(typeExpression) { + if (typeExpression) { + writeSpace(); + writePunctuation("{"); + emit(typeExpression.type); + writePunctuation("}"); + } + } + // // Top-level nodes // function emitSourceFile(node) { @@ -83124,38 +83701,38 @@ var ts; } function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) { if (hasNoDefaultLib) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - write("/// "); + writeComment("/// "); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - write("/// "); + writeComment("/// "); } else { - write("/// "); + writeComment("/// "); } writeLine(); } } for (var _c = 0, files_1 = files; _c < files_1.length; _c++) { var directive = files_1[_c]; - write("/// "); + writeComment("/// "); writeLine(); } - for (var _d = 0, types_16 = types; _d < types_16.length; _d++) { - var directive = types_16[_d]; - write("/// "); + for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { + var directive = types_18[_d]; + writeComment("/// "); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; - write("/// "); + writeComment("/// "); writeLine(); } } @@ -83174,7 +83751,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 272 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -83214,13 +83791,14 @@ var ts; setSourceFile(sourceFile); emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); } + setSourceFile(undefined); } } function emitShebangIfNeeded(sourceFileOrBundle) { if (ts.isSourceFile(sourceFileOrBundle)) { var shebang = ts.getShebang(sourceFileOrBundle.text); if (shebang) { - write(shebang); + writeComment(shebang); writeLine(); return true; } @@ -83248,7 +83826,7 @@ var ts; } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { - emitList(node, modifiers, 131328 /* Modifiers */); + emitList(node, modifiers, 262656 /* Modifiers */); writeSpace(); } } @@ -83262,7 +83840,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(58 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(59 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -83299,24 +83877,30 @@ var ts; else { writeLine(); increaseIndent(); - emit(node); + if (ts.isEmptyStatement(node)) { + var pipelinePhase = getPipelinePhase(0 /* Notification */, node); + pipelinePhase(5 /* EmbeddedStatement */, node); + } + else { + emit(node); + } decreaseIndent(); } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 24577 /* Decorators */); + emitList(parentNode, decorators, 49153 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 26896 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */); } 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, 26896 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 1296 /* Parameters */); + emitList(parentNode, parameters, 2576 /* Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -83337,14 +83921,14 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 1296 /* Parameters */ & ~1024 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 4432 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } function emitList(parentNode, children, format, start, count) { emitNodeList(emit, parentNode, children, format, start, count); @@ -83353,7 +83937,7 @@ var ts; emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { - switch (format & 28 /* DelimitersMask */) { + switch (format & 60 /* DelimitersMask */) { case 0 /* None */: break; case 16 /* CommaDelimited */: @@ -83363,6 +83947,11 @@ var ts; writeSpace(); writePunctuation("|"); break; + case 32 /* AsteriskDelimited */: + writeSpace(); + writePunctuation("*"); + writeSpace(); + break; case 8 /* AmpersandDelimited */: writeSpace(); writePunctuation("&"); @@ -83373,11 +83962,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 & 8192 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 16384 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); } @@ -83386,7 +83975,7 @@ var ts; } return; } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { // TODO: GH#18217 @@ -83401,23 +83990,23 @@ var ts; if (format & 1 /* MultiLine */) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */ && !(format & 262144 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { writeSpace(); } } else { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { increaseIndent(); } // Emit each child. @@ -83426,14 +84015,19 @@ 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 (previousSibling) { + if (format & 32 /* AsteriskDelimited */) { + // always write JSDoc in the format "\n *" + writeLine(); + writeDelimiter(format); + } + else if (previousSibling) { // i.e // function commentedParameters( // /* Parameter a */ // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -83441,14 +84035,14 @@ var ts; if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 64 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 256 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { writeSpace(); } } @@ -83470,7 +84064,7 @@ var ts; previousSibling = child; } // Write a trailing comma, if requested. - var hasTrailingComma = (format & 32 /* AllowTrailingComma */) && children.hasTrailingComma; + var hasTrailingComma = (format & 64 /* AllowTrailingComma */) && children.hasTrailingComma; if (format & 16 /* CommaDelimited */ && hasTrailingComma) { writePunctuation(","); } @@ -83480,25 +84074,25 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && format & 28 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { + if (previousSibling && format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { emitLeadingCommentsOfPosition(previousSibling.end); } // Decrease the indent, if requested. - if (format & 64 /* Indented */) { + if (format & 128 /* Indented */) { decreaseIndent(); } // Write the closing line terminator or closing whitespace. if (shouldWriteClosingLineTerminator(parentNode, children, format)) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 256 /* SpaceBetweenBraces */) { writeSpace(); } } if (onAfterEmitNodeArray) { onAfterEmitNodeArray(children); } - if (format & 7680 /* BracketsMask */) { + if (format & 15360 /* BracketsMask */) { if (isEmpty && !isUndefined) { // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists @@ -83506,73 +84100,55 @@ var ts; writePunctuation(getClosingBracket(format)); } } - function commitPendingSemicolonInternal() { - if (pendingSemicolon) { - writeSemicolonInternal(); - pendingSemicolon = false; - } - } + // Writers function writeLiteral(s) { - commitPendingSemicolon(); writer.writeLiteral(s); } function writeStringLiteral(s) { - commitPendingSemicolon(); writer.writeStringLiteral(s); } function writeBase(s) { - commitPendingSemicolon(); writer.write(s); } function writeSymbol(s, sym) { - commitPendingSemicolon(); writer.writeSymbol(s, sym); } function writePunctuation(s) { - commitPendingSemicolon(); writer.writePunctuation(s); } - function deferWriteSemicolon() { - pendingSemicolon = true; - } - function writeSemicolonInternal() { - writer.writePunctuation(";"); + function writeTrailingSemicolon() { + writer.writeTrailingSemicolon(";"); } function writeKeyword(s) { - commitPendingSemicolon(); writer.writeKeyword(s); } function writeOperator(s) { - commitPendingSemicolon(); writer.writeOperator(s); } function writeParameter(s) { - commitPendingSemicolon(); writer.writeParameter(s); } + function writeComment(s) { + writer.writeComment(s); + } function writeSpace() { - commitPendingSemicolon(); writer.writeSpace(" "); } function writeProperty(s) { - commitPendingSemicolon(); writer.writeProperty(s); } function writeLine() { - commitPendingSemicolon(); writer.writeLine(); } function increaseIndent() { - commitPendingSemicolon(); writer.increaseIndent(); } function decreaseIndent() { - commitPendingSemicolon(); writer.decreaseIndent(); } function writeToken(token, pos, writer, contextNode) { - return onEmitSourceMapOfToken - ? onEmitSourceMapOfToken(contextNode, token, writer, pos, writeTokenText) + return !sourceMapsDisabled + ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText) : writeTokenText(token, writer, pos); } function writeTokenNode(node, writer) { @@ -83600,23 +84176,23 @@ var ts; function writeLines(text) { var lines = text.split(/\r\n?|\n/g); var indentation = ts.guessIndentation(lines); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var lineText = lines_2[_a]; + for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) { + var lineText = lines_3[_a]; var line = indentation ? lineText.slice(indentation) : lineText; if (line.length) { writeLine(); write(line); - writeLine(); + writer.rawWrite(newLine); } } } - function increaseIndentIf(value, valueToWriteWhenNotIndenting) { + function increaseIndentIf(value, writeSpaceIfNotIndenting) { if (value) { increaseIndent(); writeLine(); } - else if (valueToWriteWhenNotIndenting) { - write(valueToWriteWhenNotIndenting); + else if (writeSpaceIfNotIndenting) { + writeSpace(); } } // Helper function to decrease the indent if we previously indented. Allows multiple @@ -83636,7 +84212,7 @@ var ts; return true; } if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var firstChild = children[0]; @@ -83675,10 +84251,10 @@ var ts; } function shouldWriteClosingLineTerminator(parentNode, children, format) { if (format & 1 /* MultiLine */) { - return (format & 65536 /* NoTrailingNewLine */) === 0; + return (format & 131072 /* NoTrailingNewLine */) === 0; } else if (format & 2 /* PreserveLines */) { - if (format & 32768 /* PreferNewLine */) { + if (format & 65536 /* PreferNewLine */) { return true; } var lastChild = ts.lastOrUndefined(children); @@ -83700,11 +84276,11 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 32768 /* PreferNewLine */) !== 0; + return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { parent = skipSynthesizedParentheses(parent); @@ -83724,7 +84300,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 195 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -83736,7 +84312,7 @@ var ts; else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) { return ts.idText(node); } - else if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { return getTextOfNode(node.textSourceNode, includeTrivia); } else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { @@ -83745,7 +84321,7 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape) { - if (node.kind === 9 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode)) { return neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? @@ -83789,81 +84365,81 @@ var ts; if (!node) return; switch (node.kind) { - case 216 /* Block */: + case 218 /* Block */: ts.forEach(node.statements, generateNames); break; - case 231 /* LabeledStatement */: - case 229 /* WithStatement */: - case 221 /* DoStatement */: - case 222 /* WhileStatement */: + case 233 /* LabeledStatement */: + case 231 /* WithStatement */: + case 223 /* DoStatement */: + case 224 /* WhileStatement */: generateNames(node.statement); break; - case 220 /* IfStatement */: + case 222 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 223 /* ForStatement */: - case 225 /* ForOfStatement */: - case 224 /* ForInStatement */: + case 225 /* ForStatement */: + case 227 /* ForOfStatement */: + case 226 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 230 /* SwitchStatement */: + case 232 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 244 /* CaseBlock */: + case 246 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 269 /* CaseClause */: - case 270 /* DefaultClause */: + case 271 /* CaseClause */: + case 272 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 233 /* TryStatement */: + case 235 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 272 /* CatchClause */: + case 274 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: generateNames(node.declarationList); break; - case 236 /* VariableDeclarationList */: + case 238 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 235 /* VariableDeclaration */: - case 149 /* Parameter */: - case 184 /* BindingElement */: - case 238 /* ClassDeclaration */: + case 237 /* VariableDeclaration */: + case 151 /* Parameter */: + case 186 /* BindingElement */: + case 240 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 237 /* FunctionDeclaration */: + case 239 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 182 /* ObjectBindingPattern */: - case 183 /* ArrayBindingPattern */: + case 184 /* ObjectBindingPattern */: + case 185 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportDeclaration */: + case 249 /* ImportDeclaration */: generateNames(node.importClause); break; - case 248 /* ImportClause */: + case 250 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 249 /* NamespaceImport */: + case 251 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 250 /* NamedImports */: + case 252 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 251 /* ImportSpecifier */: + case 253 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -83872,12 +84448,12 @@ var ts; if (!node) return; switch (node.kind) { - case 273 /* PropertyAssignment */: - case 274 /* ShorthandPropertyAssignment */: - case 152 /* PropertyDeclaration */: - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 275 /* PropertyAssignment */: + case 276 /* ShorthandPropertyAssignment */: + case 154 /* PropertyDeclaration */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -84057,23 +84633,23 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 71 /* Identifier */: + case 72 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 242 /* ModuleDeclaration */: - case 241 /* EnumDeclaration */: + case 244 /* ModuleDeclaration */: + case 243 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 247 /* ImportDeclaration */: - case 253 /* ExportDeclaration */: + case 249 /* ImportDeclaration */: + case 255 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 237 /* FunctionDeclaration */: - case 238 /* ClassDeclaration */: - case 252 /* ExportAssignment */: + case 239 /* FunctionDeclaration */: + case 240 /* ClassDeclaration */: + case 254 /* ExportAssignment */: return generateNameForExportDefault(); - case 207 /* ClassExpression */: + case 209 /* ClassExpression */: return generateNameForClassExpression(); - case 154 /* MethodDeclaration */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: + case 156 /* MethodDeclaration */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -84114,21 +84690,396 @@ var ts; // otherwise, return the original node for the source; return node; } + // Comments + function pipelineEmitWithComments(hint, node) { + enterComment(); + hasWrittenComment = false; + var emitFlags = ts.getEmitFlags(node); + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var isEmittedNode = node.kind !== 307 /* NotEmittedStatement */; + // 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 */; + // Save current container state on the stack. + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + 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); + } + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* 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)) { + // 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 === 238 /* VariableDeclarationList */) { + declarationListContainerEnd = end; + } + } + } + ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); + exitComment(); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, node); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + pipelinePhase(hint, node); + commentsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + enterComment(); + ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); + if ((pos > 0 || end > 0) && pos !== end) { + // Restore previous container state. + containerPos = savedContainerPos; + containerEnd = savedContainerEnd; + 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 && isEmittedNode) { + emitTrailingComments(end); + } + } + exitComment(); + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 /* MultiLineCommentTrivia */ + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { + 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; + if (!skipLeadingComments) { + emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); + } + exitComment(); + if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + commentsDisabled = true; + emitCallback(node); + commentsDisabled = false; + } + else { + emitCallback(node); + } + enterComment(); + if (!skipTrailingComments) { + emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true); + if (hasWrittenComment && !writer.isAtStartOfLine()) { + writer.writeLine(); + } + } + exitComment(); + } + function emitLeadingComments(pos, isEmittedNode) { + hasWrittenComment = false; + if (isEmittedNode) { + forEachLeadingCommentToEmit(pos, emitLeadingComment); + } + else if (pos === 0) { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed even though both node will not be emitted + forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment); + } + } + function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (isTripleSlashComment(commentPos, commentEnd)) { + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + } + } + function shouldWriteComment(text, pos) { + if (printerOptions.onlyPrintJsDocStyle) { + return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos)); + } + return true; + } + function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + if (!hasWrittenComment) { + ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos); + hasWrittenComment = true; + } + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + else if (kind === 3 /* MultiLineCommentTrivia */) { + writer.writeSpace(" "); + } + } + function emitLeadingCommentsOfPosition(pos) { + if (commentsDisabled || pos === -1) { + return; + } + emitLeadingComments(pos, /*isEmittedNode*/ true); + } + function emitTrailingComments(pos) { + forEachTrailingCommentToEmit(pos, emitTrailingComment); + } + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ + if (!writer.isAtStartOfLine()) { + writer.writeSpace(" "); + } + emitPos(commentPos); + ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + if (hasTrailingNewLine) { + writer.writeLine(); + } + } + function emitTrailingCommentsOfPosition(pos, prefixSpace) { + if (commentsDisabled) { + return; + } + enterComment(); + forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition); + exitComment(); + } + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { + // 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 (hasTrailingNewLine) { + writer.writeLine(); + } + else { + writer.writeSpace(" "); + } + } + function forEachLeadingCommentToEmit(pos, cb) { + // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) { + if (hasDetachedComments(pos)) { + forEachLeadingCommentWithoutDetachedComments(cb); + } + else { + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + } + } + function forEachTrailingCommentToEmit(end, cb) { + // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments + if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) { + ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; + } + function forEachLeadingCommentWithoutDetachedComments(cb) { + // get the leading comments from detachedPos + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos); + } + function emitDetachedCommentsAndUpdateCommentsInfo(range) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (!shouldWriteComment(currentSourceFile.text, commentPos)) + return; + emitPos(commentPos); + ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine); + emitPos(commentEnd); + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + */ + function isTripleSlashComment(commentPos, commentEnd) { + return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd); + } + // Source Maps + function pipelineEmitWithSourceMap(hint, node) { + var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); + if (ts.isUnparsedSource(node) && node.sourceMapText !== undefined) { + var parsed = ts.tryParseRawSourceMap(node.sourceMapText); + if (parsed) { + sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.sourceMapPath); + } + pipelinePhase(hint, node); + } + else { + var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; + var emitFlags = ts.getEmitFlags(node); + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + && pos >= 0) { + emitSourcePos(source, skipSourceTrivia(source, pos)); + } + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = true; + pipelinePhase(hint, node); + sourceMapsDisabled = false; + } + else { + pipelinePhase(hint, node); + } + if (node.kind !== 307 /* NotEmittedStatement */ + && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + && end >= 0) { + emitSourcePos(source, end); + } + } + } + /** + * Skips trivia such as comments and white-space that can optionally overriden by the source map source + */ + function skipSourceTrivia(source, pos) { + return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(sourceMapSource.text, pos); + } + /** + * Emits a mapping. + * + * If the position is synthetic (undefined or a negative value), no mapping will be + * created. + * + * @param pos The position. + */ + function emitPos(pos) { + if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) { + return; + } + var _a = ts.getLineAndCharacterOfPosition(currentSourceFile, pos), sourceLine = _a.line, sourceCharacter = _a.character; + sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, + /*nameIndex*/ undefined); + } + function emitSourcePos(source, pos) { + if (source !== sourceMapSource) { + var savedSourceMapSource = sourceMapSource; + setSourceMapSource(source); + emitPos(pos); + setSourceMapSource(savedSourceMapSource); + } + else { + emitPos(pos); + } + } + /** + * Emits a token of a node with possible leading and trailing source maps. + * + * @param node The node containing the token. + * @param token The token to emit. + * @param tokenStartPos The start pos of the token. + * @param emitCallback The callback used to emit the token. + */ + function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { + if (sourceMapsDisabled || node && ts.isInJsonFile(node)) { + return emitCallback(token, writer, tokenPos); + } + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags || 0 /* 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) { + emitSourcePos(source, tokenPos); + } + tokenPos = emitCallback(token, writer, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + emitSourcePos(source, tokenPos); + } + return tokenPos; + } + function setSourceMapSource(source) { + if (sourceMapsDisabled) { + return; + } + sourceMapSource = source; + if (isJsonSourceMapSource(source)) { + return; + } + sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName); + if (printerOptions.inlineSources) { + sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text); + } + } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[512 /* Braces */] = ["{", "}"]; - brackets[1024 /* Parenthesis */] = ["(", ")"]; - brackets[2048 /* AngleBrackets */] = ["<", ">"]; - brackets[4096 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* Braces */] = ["{", "}"]; + brackets[2048 /* Parenthesis */] = ["(", ")"]; + brackets[4096 /* AngleBrackets */] = ["<", ">"]; + brackets[8192 /* SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 7680 /* BracketsMask */][0]; + return brackets[format & 15360 /* BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 7680 /* BracketsMask */][1]; + return brackets[format & 15360 /* BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -84823,7 +85774,7 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function loadWithLocalCache(names, containingFile, loader) { + function loadWithLocalCache(names, containingFile, redirectedReference, loader) { if (names.length === 0) { return []; } @@ -84836,7 +85787,7 @@ var ts; result = cache.get(name); } else { - cache.set(name, result = loader(name, containingFile)); + cache.set(name, result = loader(name, containingFile, redirectedReference)); } resolutions.push(result); } @@ -84855,6 +85806,7 @@ var ts; if (program.getRootFileNames().length !== rootFileNames.length) { return false; } + var seenResolvedRefs; // If project references dont match if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { return false; @@ -84880,7 +85832,7 @@ var ts; return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || - hasInvalidatedResolution(sourceFile.resolvedPath); + hasInvalidatedResolution(sourceFile.path); } function sourceFileVersionUptoDate(sourceFile) { return sourceFile.version === getSourceVersion(sourceFile.resolvedPath); @@ -84889,10 +85841,24 @@ var ts; if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { return false; } - var oldResolvedRef = program.getResolvedProjectReferences()[index]; + return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + } + function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { + if (ts.contains(seenResolvedRefs, oldResolvedRef)) { + // Assume true + return true; + } // If sourceFile for the oldResolvedRef existed, check the version for uptodate - return sourceFileVersionUptoDate(oldResolvedRef.sourceFile); + if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + return false; + } + // Add to seen before checking the referenced paths of this config file + (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); + // If child project references are upto date, this project reference is uptodate + return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) { + return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]); + }); } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. @@ -84939,7 +85905,7 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; - var modifiedFilePaths; + var ambientModuleNameToUnmodifiedFileName = ts.createMap(); var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -84971,12 +85937,11 @@ var ts; // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = ts.createMap(); var _compilerOptionsObjectLiteralSyntax; - var _referencesArrayLiteralSyntax; var moduleResolutionCache; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -84988,16 +85953,16 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 - resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; + var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 + resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, 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). @@ -85013,7 +85978,7 @@ var ts; // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined; // A parallel array to projectReferences storing the results of reading in the referenced tsconfig files - var resolvedProjectReferences = projectReferences ? [] : undefined; + var resolvedProjectReferences; var projectReferenceRedirects; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); var structuralIsReused = tryReuseStructureFromOldProgram(); @@ -85021,23 +85986,25 @@ var ts; processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { - for (var _i = 0, projectReferences_1 = projectReferences; _i < projectReferences_1.length; _i++) { - var ref = projectReferences_1[_i]; - var parsedRef = parseProjectReferenceConfigFile(ref); - resolvedProjectReferences.push(parsedRef); - if (parsedRef) { - var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - var dtsOutfile = ts.changeExtension(out, ".d.ts"); - processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (!resolvedProjectReferences) { + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + } + if (rootNames.length) { + for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { + var parsedRef = resolvedProjectReferences_1[_i]; + if (parsedRef) { + var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; + if (out) { + var dtsOutfile = ts.changeExtension(out, ".d.ts"); + processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } - addProjectReferenceRedirects(parsedRef.commandLine); } } } ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false); }); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); @@ -85051,7 +86018,7 @@ var ts; // - The '--noLib' flag is used. // - A 'no-default-lib' reference comment is encountered in // processing the root files. - if (!skipDefaultLib) { + if (rootNames.length && !skipDefaultLib) { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file var defaultLibraryFileName = getDefaultLibraryFileName(); @@ -85076,10 +86043,18 @@ var ts; var oldSourceFiles = oldProgram.getSourceFiles(); for (var _a = 0, oldSourceFiles_1 = oldSourceFiles; _a < oldSourceFiles_1.length; _a++) { var oldSourceFile = oldSourceFiles_1[_a]; - if (!getSourceFile(oldSourceFile.path) || shouldCreateNewSourceFile) { - host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions()); + var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); + if (shouldCreateNewSourceFile || !newFile || + // old file wasnt redirect but new file is + (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { + host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) { + if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; @@ -85120,7 +86095,10 @@ var ts; getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, getProjectReferences: getProjectReferences, getResolvedProjectReferences: getResolvedProjectReferences, - getProjectReferenceRedirect: getProjectReferenceRedirect + getProjectReferenceRedirect: getProjectReferenceRedirect, + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, + forEachResolvedProjectReference: forEachResolvedProjectReference }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -85183,13 +86161,13 @@ var ts; } return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) { if (structuralIsReused === 0 /* 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, containingFile); + return resolveModuleNamesWorker(moduleNames, containingFile, /*reusedNames*/ undefined, getResolvedProjectReferenceToRedirect(file.originalFileName)); } - var oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile); + var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile); if (oldSourceFile !== file && file.resolvedModules) { // `file` was created for the new program. // @@ -85252,7 +86230,7 @@ var ts; } } else { - resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName); } if (resolvesToAmbientModuleInNonModifiedFile) { (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; @@ -85263,7 +86241,7 @@ var ts; } } var resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames) + ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName)) : ts.emptyArray; // Combine results of resolutions and predicted results if (!result) { @@ -85289,12 +86267,9 @@ var ts; return result; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. - function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - if (!oldProgramState.program) { - return false; - } - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 - var resolvedFile = resolutionToFile && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) { + var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName); + var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same // place as we expected to find an actual module file. @@ -85303,16 +86278,34 @@ var ts; return false; } // at least one of declarations should come from non-modified source file - var firstUnmodifiedFile = oldProgramState.program.getSourceFiles().find(function (f) { return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && ts.contains(f.ambientModuleNames, moduleName); }); - if (!firstUnmodifiedFile) { + var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName); + if (!unmodifiedFile) { return false; } if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile); } return true; } } + function canReuseProjectReferences() { + return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) { + var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var newResolvedRef = parseProjectReferenceConfigFile(newRef); + if (oldResolvedRef) { + // Resolved project reference has gone missing or changed + return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + } + else { + // A previously-unresolved reference may be resolved now + return newResolvedRef !== undefined; + } + }, function (oldProjectReferences, parent) { + // If array of references is changed, we cant resue old program + var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences; + return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo); + }); + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return 0 /* Not */; @@ -85333,40 +86326,14 @@ var ts; return oldProgram.structureIsReused = 0 /* Not */; } // Check if any referenced project tsconfig files are different - // If array of references is changed, we cant resue old program - var oldProjectReferences = oldProgram.getProjectReferences(); - if (!ts.arrayIsEqualTo(oldProjectReferences, projectReferences, ts.projectReferenceIsEqualTo)) { + if (!canReuseProjectReferences()) { return oldProgram.structureIsReused = 0 /* Not */; } - // Check the json files for the project references - var oldRefs = oldProgram.getResolvedProjectReferences(); if (projectReferences) { - // Resolved project referenced should be array if projectReferences provided are array - ts.Debug.assert(!!oldRefs); - for (var i = 0; i < projectReferences.length; i++) { - var oldRef = oldRefs[i]; - var newRef = parseProjectReferenceConfigFile(projectReferences[i]); - if (oldRef) { - if (!newRef || newRef.sourceFile !== oldRef.sourceFile) { - // Resolved project reference has gone missing or changed - return oldProgram.structureIsReused = 0 /* Not */; - } - } - else { - // A previously-unresolved reference may be resolved now - if (newRef !== undefined) { - return oldProgram.structureIsReused = 0 /* Not */; - } - } - } - } - else { - // Resolved project referenced should be undefined if projectReferences is undefined - ts.Debug.assert(!oldRefs); + resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var filePaths = []; var modifiedSourceFiles = []; oldProgram.structureIsReused = 2 /* Completely */; // If the missing file paths are now present, it can change the progam structure, @@ -85417,7 +86384,6 @@ var ts; newSourceFile.originalFileName = oldSourceFile.originalFileName; newSourceFile.resolvedPath = oldSourceFile.resolvedPath; newSourceFile.fileName = oldSourceFile.fileName; - filePaths.push(newSourceFile.path); 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, @@ -85478,15 +86444,23 @@ var ts; if (oldProgram.structureIsReused !== 2 /* Completely */) { return oldProgram.structureIsReused; } - modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); + for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) { + var oldFile = oldSourceFiles_3[_a]; + if (!ts.contains(modifiedFiles, oldFile)) { + for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) { + var moduleName = _c[_b]; + ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); + } + } + } // try to verify results of module resolution - for (var _a = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _a < modifiedSourceFiles_1.length; _a++) { - var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; + for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { + var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); if (resolveModuleNamesWorker) { var moduleNames = getModuleNames(newSourceFile); - var oldProgramState = { program: oldProgram, oldSourceFile: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { @@ -85500,7 +86474,7 @@ var ts; if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); if (resolutionsChanged) { @@ -85520,28 +86494,22 @@ var ts; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping - for (var i = 0; i < newSourceFiles.length; i++) { - filesByName.set(filePaths[i], newSourceFiles[i]); + for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { + var newSourceFile = newSourceFiles_1[_f]; + var filePath = newSourceFile.path; + addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); // Set the file as found during node modules search if it was found that way in old progra, - if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) { - sourceFilesFoundSearchingNodeModules.set(filePaths[i], true); + if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePath))) { + sourceFilesFoundSearchingNodeModules.set(filePath, true); } } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _c = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _c < modifiedSourceFiles_2.length; _c++) { - var modifiedFile = modifiedSourceFiles_2[_c]; + for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) { + var modifiedFile = modifiedSourceFiles_2[_g]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - resolvedProjectReferences = oldProgram.getResolvedProjectReferences(); - if (resolvedProjectReferences) { - resolvedProjectReferences.forEach(function (ref) { - if (ref) { - addProjectReferenceRedirects(ref.commandLine); - } - }); - } sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; return oldProgram.structureIsReused = 2 /* Completely */; @@ -85804,22 +86772,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 149 /* Parameter */: - case 152 /* PropertyDeclaration */: + case 151 /* Parameter */: + case 154 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: - case 235 /* VariableDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: + case 237 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -85827,41 +86795,41 @@ var ts; } } switch (node.kind) { - case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 252 /* ExportAssignment */: + case 254 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 271 /* HeritageClause */: + case 273 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 108 /* ImplementsKeyword */) { + if (heritageClause.token === 109 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 239 /* InterfaceDeclaration */: + case 241 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 242 /* ModuleDeclaration */: + case 244 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 240 /* TypeAliasDeclaration */: + case 242 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 241 /* EnumDeclaration */: + case 243 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 211 /* NonNullExpression */: + case 213 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 210 /* AsExpression */: + case 212 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 192 /* TypeAssertionExpression */: + case 194 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -85874,51 +86842,51 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } switch (parent.kind) { - case 238 /* ClassDeclaration */: - case 154 /* MethodDeclaration */: - case 153 /* MethodSignature */: - case 155 /* Constructor */: - case 156 /* GetAccessor */: - case 157 /* SetAccessor */: - case 194 /* FunctionExpression */: - case 237 /* FunctionDeclaration */: - case 195 /* ArrowFunction */: + case 240 /* ClassDeclaration */: + case 156 /* MethodDeclaration */: + case 155 /* MethodSignature */: + case 157 /* Constructor */: + case 158 /* GetAccessor */: + case 159 /* SetAccessor */: + case 196 /* FunctionExpression */: + case 239 /* FunctionDeclaration */: + case 197 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 217 /* VariableStatement */: + case 219 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 219 /* VariableStatement */); } break; - case 152 /* PropertyDeclaration */: + case 154 /* 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 !== 115 /* StaticKeyword */) { + if (modifier.kind !== 116 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 149 /* Parameter */: + case 151 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 189 /* CallExpression */: - case 190 /* NewExpression */: - case 209 /* ExpressionWithTypeArguments */: - case 259 /* JsxSelfClosingElement */: - case 260 /* JsxOpeningElement */: + case 191 /* CallExpression */: + case 192 /* NewExpression */: + case 211 /* ExpressionWithTypeArguments */: + case 261 /* JsxSelfClosingElement */: + case 262 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -85935,24 +86903,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 76 /* ConstKeyword */: + case 77 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 114 /* PublicKeyword */: - case 112 /* PrivateKeyword */: - case 113 /* ProtectedKeyword */: - case 132 /* ReadonlyKeyword */: - case 124 /* DeclareKeyword */: - case 117 /* AbstractKeyword */: + case 115 /* PublicKeyword */: + case 113 /* PrivateKeyword */: + case 114 /* ProtectedKeyword */: + case 133 /* ReadonlyKeyword */: + case 125 /* DeclareKeyword */: + case 118 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 115 /* StaticKeyword */: - case 84 /* ExportKeyword */: - case 79 /* DefaultKeyword */: + case 116 /* StaticKeyword */: + case 85 /* ExportKeyword */: + case 80 /* DefaultKeyword */: } } } @@ -86000,10 +86968,22 @@ var ts; return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } function getOptionsDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), options.configFile ? programDiagnostics.getDiagnostics(options.configFile.fileName) : []))); + return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile()))); + } + function getOptionsDiagnosticsOfConfigFile() { + if (!options.configFile) { + return ts.emptyArray; + } + var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); + } + }); + return diagnostics; } function getGlobalDiagnostics() { - return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); + return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray; } function getConfigFileParsingDiagnostics() { return configFileParsingDiagnostics || ts.emptyArray; @@ -86015,9 +86995,9 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 71 /* Identifier */ - ? b.kind === 71 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 9 /* StringLiteral */ && a.text === b.text; + return a.kind === 72 /* Identifier */ + ? b.kind === 72 /* Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -86045,12 +87025,9 @@ var ts; for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(node); - } } if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { - collectDynamicImportOrRequireCalls(file.endOfFileToken); + collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; file.moduleAugmentations = moduleAugmentations || ts.emptyArray; @@ -86098,24 +87075,37 @@ var ts; } } } - function collectDynamicImportOrRequireCalls(node) { - if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { - imports = ts.append(imports, node.arguments[0]); - } - // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. - else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { - imports = ts.append(imports, node.arguments[0]); - } - else if (ts.isLiteralImportTypeNode(node)) { - imports = ts.append(imports, node.argument.literal); - } - collectDynamicImportOrRequireCallsForEachChild(node); - if (ts.hasJSDocNodes(node)) { - ts.forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild); + function collectDynamicImportOrRequireCalls(file) { + var r = /import|require/g; + while (r.exec(file.text) !== null) { + var node = getNodeAtPosition(file, r.lastIndex); + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { + imports = ts.append(imports, node.arguments[0]); + } + // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. + else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { + imports = ts.append(imports, node.arguments[0]); + } + else if (ts.isLiteralImportTypeNode(node)) { + imports = ts.append(imports, node.argument.literal); + } } } - function collectDynamicImportOrRequireCallsForEachChild(node) { - ts.forEachChild(node, collectDynamicImportOrRequireCalls); + /** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */ + 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 */)))) { + return child; + } + }; + while (true) { + var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild); + if (!child) { + return current; + } + current = child; + } } } function getLibFileFromReference(ref) { @@ -86277,7 +87267,7 @@ var ts; // Instead of creating a duplicate, just redirect to the existing one. var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 redirectTargetsMap.add(fileFromPackageId.path, fileName); - filesByName.set(path, dupFile); + addFileToFilesByName(dupFile, path, redirectedPath); sourceFileToPackageName.set(path, packageId.name); processingOtherFiles.push(dupFile); return dupFile; @@ -86288,10 +87278,7 @@ var ts; sourceFileToPackageName.set(path, packageId.name); } } - filesByName.set(path, file); - if (redirectedPath) { - filesByName.set(redirectedPath, file); - } + addFileToFilesByName(file, path, redirectedPath); if (file) { sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); file.path = path; @@ -86325,24 +87312,82 @@ var ts; } return file; } + function addFileToFilesByName(file, path, redirectedPath) { + filesByName.set(path, file); + if (redirectedPath) { + filesByName.set(redirectedPath, file); + } + } function getProjectReferenceRedirect(fileName) { // Ignore dts or any of the non ts files - if (!projectReferenceRedirects || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to // look in the output folder of the referenced project rather than the input - return ts.forEach(projectReferenceRedirects, function (referencedProject) { + var referencedProject = getResolvedProjectReferenceToRedirect(fileName); + if (!referencedProject) { + return undefined; + } + var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out; + return out ? + ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine); + } + /** + * Get the referenced project if the file is input file from that reference project + */ + function getResolvedProjectReferenceToRedirect(fileName) { + return forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) { // not input file from the referenced project, ignore - if (!ts.contains(referencedProject.fileNames, fileName, isSameFile)) { + if (!referencedProject || + toPath(options.configFilePath) === referenceProjectPath || + !ts.contains(referencedProject.commandLine.fileNames, fileName, isSameFile)) { return undefined; } - var out = referencedProject.options.outFile || referencedProject.options.out; - return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : - ts.getOutputDeclarationFileName(fileName, referencedProject); + return referencedProject; }); } + function forEachResolvedProjectReference(cb) { + return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var resolvedRefPath = toPath(resolveProjectReferencePath(ref)); + return cb(resolvedRef, resolvedRefPath); + }); + } + function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { + var seenResolvedRefs; + return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); + function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) { + // Visit project references first + if (cbRef) { + var result = cbRef(projectReferences, parent); + if (result) { + return result; + } + } + return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { + if (ts.contains(seenResolvedRefs, resolvedRef)) { + // ignore recursives + return undefined; + } + var result = cbResolvedRef(resolvedRef, index, parent); + if (result) { + return result; + } + if (!resolvedRef) + return undefined; + (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef); + return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef); + }); + } + } + function getResolvedProjectReferenceByPath(projectReferencePath) { + if (!projectReferenceRedirects) { + return undefined; + } + return projectReferenceRedirects.get(projectReferencePath) || undefined; + } function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); @@ -86355,7 +87400,7 @@ var ts; if (!typeDirectives) { return; } - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName)); for (var i = 0; i < typeDirectives.length; i++) { var ref = file.typeReferenceDirectives[i]; var resolvedTypeReferenceDirective = resolutions[i]; @@ -86373,6 +87418,8 @@ var ts; } var saveResolution = true; if (resolvedTypeReferenceDirective) { + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 @@ -86397,6 +87444,8 @@ var ts; processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } + if (resolvedTypeReferenceDirective.isExternalLibraryImport) + currentNodeModulesDepth--; } else { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 @@ -86441,8 +87490,7 @@ var ts; if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); - var oldProgramState = { program: oldProgram, oldSourceFile: oldProgram && oldProgram.getSourceFile(file.fileName), modifiedFilePaths: modifiedFilePaths }; - var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file, oldProgramState); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file); ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; @@ -86510,20 +87558,34 @@ var ts; return allFilesBelongToPath; } function parseProjectReferenceConfigFile(ref) { + if (!projectReferenceRedirects) { + projectReferenceRedirects = ts.createMap(); + } // The actual filename (i.e. add "/tsconfig.json" if necessary) var refPath = resolveProjectReferencePath(ref); + var sourceFilePath = toPath(refPath); + var fromCache = projectReferenceRedirects.get(sourceFilePath); + if (fromCache !== undefined) { + return fromCache || undefined; + } // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { + projectReferenceRedirects.set(sourceFilePath, false); return undefined; } - sourceFile.path = toPath(refPath); + sourceFile.path = sourceFilePath; + sourceFile.resolvedPath = sourceFilePath; + sourceFile.originalFileName = refPath; var commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, /*existingOptions*/ undefined, refPath); - return { commandLine: commandLine, sourceFile: sourceFile }; - } - function addProjectReferenceRedirects(referencedProject) { - (projectReferenceRedirects || (projectReferenceRedirects = [])).push(referencedProject); + var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile }; + projectReferenceRedirects.set(sourceFilePath, resolvedRef); + if (commandLine.projectReferences) { + resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile); + } + return resolvedRef; } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { @@ -86559,30 +87621,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration"); } } - if (projectReferences) { - for (var i = 0; i < projectReferences.length; i++) { - var ref = projectReferences[i]; - var resolvedRefOpts = resolvedProjectReferences[i] && resolvedProjectReferences[i].commandLine.options; - if (resolvedRefOpts === undefined) { - createDiagnosticForReference(i, ts.Diagnostics.File_0_does_not_exist, ref.path); - continue; - } - if (!resolvedRefOpts.composite) { - createDiagnosticForReference(i, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); - } - if (ref.prepend) { - var out = resolvedRefOpts.outFile || resolvedRefOpts.out; - if (out) { - if (!host.fileExists(out)) { - createDiagnosticForReference(i, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); - } - } - else { - createDiagnosticForReference(i, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); - } - } - } - } + verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }); @@ -86661,12 +87700,12 @@ var ts; } var languageVersion = options.target || 0 /* ES3 */; var outFile = options.outFile || options.out; - var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + 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 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } - var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile ? f : undefined; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); @@ -86704,7 +87743,7 @@ var ts; // Precalculate and cache the common source directory var dir = getCommonSourceDirectory(); // If we failed to find a good common directory, but outDir is specified and at least one of our files is on a windows drive/URL/other resource, add a failure - if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { + if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) { createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } @@ -86774,6 +87813,35 @@ var ts; } } } + function verifyProjectReferences() { + forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { + var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; + var parentFile = parent && parent.sourceFile; + if (!resolvedRef) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path); + return; + } + var options = resolvedRef.commandLine.options; + if (!options.composite) { + // ok to not have composite if the current program is container only + var inputs = parent ? parent.commandLine.fileNames : rootNames; + if (inputs.length) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path); + } + } + if (ref.prepend) { + var out = options.outFile || options.out; + if (out) { + if (!host.fileExists(out)) { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path); + } + } + else { + createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); + } + } + }); + } function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) { var needCompilerDiagnostic = true; var pathsSyntax = getOptionPathsSyntax(); @@ -86824,10 +87892,10 @@ var ts; function createOptionValueDiagnostic(option1, message, arg0) { createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0); } - function createDiagnosticForReference(index, message, arg0, arg1) { - var referencesSyntax = getProjectReferencesSyntax(); + function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) { + var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; }); if (referencesSyntax && referencesSyntax.elements.length > index) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1)); } else { programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1)); @@ -86841,22 +87909,6 @@ var ts; programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2)); } } - function getProjectReferencesSyntax() { - if (_referencesArrayLiteralSyntax === undefined) { - _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword - if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 - for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { - var prop = _a[_i]; - if (ts.isArrayLiteralExpression(prop.initializer)) { - _referencesArrayLiteralSyntax = prop.initializer; - break; - } - } - } - } - return _referencesArrayLiteralSyntax; - } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword @@ -86931,7 +87983,8 @@ var ts; readFile: function (f) { return host.readFile(f); }, useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(), getCurrentDirectory: function () { return host.getCurrentDirectory(); }, - onUnRecoverableConfigFileDiagnostic: function () { return undefined; } + onUnRecoverableConfigFileDiagnostic: function () { return undefined; }, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; } ts.parseConfigHostFromCompilerHost = parseConfigHostFromCompilerHost; @@ -86981,7 +88034,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 === 9 /* StringLiteral */) { + if (aug.kind === 10 /* StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -87206,6 +88259,11 @@ var ts; var latestSignature; if (sourceFile.isDeclarationFile) { latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.path) : undefined; + exportedModulesMapCache.set(sourceFile.path, references || false); + } } else { var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); @@ -87271,7 +88329,7 @@ var ts; return getAllFileNames(state, programOfThisState); } // If this is non module emit, or its a global file, it depends on all the source files - if (!state.referencedMap || (!ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile))) { + if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) { return getAllFileNames(state, programOfThisState); } // Get the references, traversing deep from the referenceMap @@ -87330,6 +88388,20 @@ var ts; } return true; } + /** + * Return true if file contains anything that augments to global scope we need to build them as if + * they are global files as well as module + */ + function containsGlobalScopeAugmentation(sourceFile) { + return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); }); + } + /** + * Return true if the file will invalidate all files because it affectes global scope + */ + function isFileAffectingGlobalScope(sourceFile) { + return containsGlobalScopeAugmentation(sourceFile) || + !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + } /** * Gets all files of the program excluding the default library file */ @@ -87370,7 +88442,7 @@ var ts; * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) { - if (!ts.isExternalModule(sourceFileWithUpdatedShape) && !containsOnlyAmbientModules(sourceFileWithUpdatedShape)) { + if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } var compilerOptions = programOfThisState.getCompilerOptions(); @@ -87420,8 +88492,9 @@ var ts; } state.changedFilesSet = ts.createMap(); var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); + var oldCompilerOptions = useOldState ? oldState.program.getCompilerOptions() : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && - !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldState.program.getCompilerOptions()); + !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions); if (useOldState) { // Verify the sanity of old state if (!oldState.currentChangedFilePath) { @@ -87436,6 +88509,8 @@ var ts; // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; + var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck; + var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -87453,6 +88528,13 @@ var ts; state.changedFilesSet.set(sourceFilePath, true); } else if (canCopySemanticDiagnostics) { + var sourceFile = state.program.getSourceFileByPath(sourceFilePath); + if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { + return; + } + if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { + return; + } // Unchanged file copy diagnostics var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath); if (diagnostics) { @@ -87536,18 +88618,31 @@ var ts; // If there are no more diagnostics from old cache, done return; } + // Clean lib file diagnostics if its all files excluding default files to emit + if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles && !state.cleanedDiagnosticsOfLibFiles) { + state.cleanedDiagnosticsOfLibFiles = true; + var options_2 = state.program.getCompilerOptions(); + if (ts.forEach(state.program.getSourceFiles(), function (f) { + return state.program.isSourceFileDefaultLibrary(f) && + !ts.skipTypeChecking(f, options_2) && + removeSemanticDiagnosticsOf(state, f.path); + })) { + return; + } + } // If there was change in signature for the changed file, // then delete the semantic diagnostics for files that are affected by using exports of this module if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { return; } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); + var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { return exportedModules && exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); })) { return; } @@ -87555,16 +88650,44 @@ var ts; ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it exportedModules.has(affectedFile.path) && - removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath); + removeSemanticDiagnosticsOfFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** * removes the semantic diagnostics of files referencing referencedPath and * returns true if there are no more semantic diagnostics from old state */ - function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath) { + function removeSemanticDiagnosticsOfFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile) { return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) { - return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOf(state, filePath); + return referencesInFile.has(referencedPath) && removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile); + }); + } + /** + * Removes semantic diagnostics of file and anything that exports this file + */ + function removeSemanticDiagnosticsOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile) { + if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) { + return false; + } + if (removeSemanticDiagnosticsOf(state, filePath)) { + // If there are no more diagnostics from old cache, done + return true; + } + 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 + if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { + return exportedModules && + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); + })) { + return true; + } + // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected + return !!ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) { + return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) && // If we already iterated this through cache, ignore it + exportedModules.has(filePath) && + removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile); }); } /** @@ -87573,7 +88696,7 @@ var ts; */ function removeSemanticDiagnosticsOf(state, path) { if (!state.semanticDiagnosticsFromOldState) { - return false; + return true; } state.semanticDiagnosticsFromOldState.delete(path); state.semanticDiagnosticsPerFile.delete(path); @@ -87846,6 +88969,10 @@ var ts; /*@internal*/ var ts; (function (ts) { + function isPathInNodeModulesStartingWithDot(path) { + return ts.stringContains(path, "/node_modules/."); + } + ts.isPathInNodeModulesStartingWithDot = isPathInNodeModulesStartingWithDot; ts.maxNumberOfFilesToIterateForInvalidation = 256; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; @@ -87859,11 +88986,11 @@ var ts; // The key in the map is source file's path. // The values are Map of resolutions with key being name lookedup. var resolvedModuleNames = ts.createMap(); - var perDirectoryResolvedModuleNames = ts.createMap(); - var nonRelaticeModuleNameCache = ts.createMap(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelaticeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); + var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); + var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); var resolvedTypeReferenceDirectives = ts.createMap(); - var perDirectoryResolvedTypeReferenceDirectives = ts.createMap(); + var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -87887,6 +89014,7 @@ var ts; resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives: resolveTypeReferenceDirectives, + removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects, removeResolutionsOfFile: removeResolutionsOfFile, invalidateResolutionOfFile: invalidateResolutionOfFile, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, @@ -87948,7 +89076,7 @@ var ts; } function clearPerDirectoryResolutions() { perDirectoryResolvedModuleNames.clear(); - nonRelaticeModuleNameCache.clear(); + nonRelativeModuleNameCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); @@ -87964,8 +89092,8 @@ var ts; } }); } - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache); + function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference); // 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; @@ -87983,10 +89111,11 @@ var ts; // Default return the result from the first pass return primaryResult; } - function resolveNamesWithLocalCache(names, containingFile, cache, perDirectoryCache, loader, getResolutionWithResolvedFileName, reusedNames, logChanges) { + function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) { var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); + var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); var perDirectoryResolution = perDirectoryCache.get(dirPath); if (!perDirectoryResolution) { perDirectoryResolution = ts.createMap(); @@ -87995,22 +89124,28 @@ var ts; var resolvedModules = []; var compilerOptions = resolutionHost.getCompilationSettings(); var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path); + // All the resolutions in this file are invalidated if this file wasnt resolved using same redirect + var program = resolutionHost.getCurrentProgram(); + var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile); + var unmatchedRedirects = oldRedirect ? + !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : + !!redirectedReference; var seenNamesInFile = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { var name = names_2[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && - allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated || + allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate - (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && !getResolutionWithResolvedFileName(resolution))) { + (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; } else { - resolution = loader(name, containingFile, compilerOptions, resolutionHost); + resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -88026,7 +89161,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -88054,12 +89189,14 @@ var ts; return oldResult.resolvedFileName === newResult.resolvedFileName; } } - function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile) { - return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) { + return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, + /*shouldRetryResolution*/ function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, /*reusedNames*/ undefined, /*logChanges*/ false); } - function resolveModuleNames(moduleNames, containingFile, reusedNames) { - return resolveNamesWithLocalCache(moduleNames, containingFile, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, reusedNames, logChangesWhenResolvingModule); + function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { + return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, + /*shouldRetryResolution*/ function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule); } function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); @@ -88102,12 +89239,6 @@ var ts; } return true; } - function filterFSRootDirectoriesToWatch(watchPath, dirPath) { - if (!canWatchDirectory(dirPath)) { - watchPath.ignore = true; - } - return watchPath; - } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path @@ -88127,13 +89258,13 @@ var ts; } function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) { // If directory path contains node module, get the most parent node_modules directory for watching - while (ts.stringContains(dirPath, ts.nodeModulesPathPart)) { + while (ts.pathContainsNodeModules(dirPath)) { dir = ts.getDirectoryPath(dir); dirPath = ts.getDirectoryPath(dirPath); } // If the directory is node_modules use it to watch, always watch it recursively if (isNodeModulesDirectory(dirPath)) { - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); + return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -88151,7 +89282,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive }, dirPath); + return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -88180,8 +89311,9 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, nonRecursive = _a.nonRecursive, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive; // If the failed lookup location path is not one of the supported extensions, // store it in the custom path if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { @@ -88234,8 +89366,9 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; - if (!ignore) { + var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + var dirPath = toWatch.dirPath; var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { if (refCount === 1) { @@ -88283,6 +89416,22 @@ var ts; cache.delete(filePath); } } + function removeResolutionsFromProjectReferenceRedirects(filePath) { + if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) { + return; + } + var program = resolutionHost.getCurrentProgram(); + if (!program) { + return; + } + // If this file is input file for the referenced project, get it + var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath); + if (!resolvedProjectReference) { + return; + } + // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution + resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); + } function removeResolutionsOfFile(filePath) { removeResolutionsOfFileFromCache(resolvedModuleNames, filePath); removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath); @@ -88344,6 +89493,9 @@ var ts; isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); }; } else { + // If something to do with folder/file starting with "." in node_modules folder, skip it + if (isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return false; // Some file or directory in the watching directory is created // Return early if it does not have any of the watching extension or not the custom failed lookup path var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); @@ -88384,8 +89536,8 @@ var ts; if (isInDirectoryPath(rootPath, typeRootPath)) { return rootPath; } - var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; + var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath); + return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -88873,7 +90025,6 @@ var ts; } return false; } - /** @internal */ ts.screenStartingMessageCodes = [ ts.Diagnostics.Starting_compilation_in_watch_mode.code, ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code, @@ -88914,6 +90065,23 @@ var ts; return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; + function getErrorCountForSummary(diagnostics) { + return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }); + } + ts.getErrorCountForSummary = getErrorCountForSummary; + function getWatchErrorSummaryDiagnosticMessage(errorCount) { + return errorCount === 1 ? + ts.Diagnostics.Found_1_error_Watching_for_file_changes : + ts.Diagnostics.Found_0_errors_Watching_for_file_changes; + } + ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage; + function getErrorSummaryText(errorCount, newLine) { + if (errorCount === 0) + return ""; + var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount); + return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine; + } + ts.getErrorSummaryText = getErrorSummaryText; /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ @@ -88952,7 +90120,7 @@ var ts; } } if (reportSummary) { - reportSummary(diagnostics.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length); + reportSummary(getErrorCountForSummary(diagnostics)); } if (emitSkipped && diagnostics.length > 0) { // If the emitter didn't emit anything, then pass that value along. @@ -89031,15 +90199,7 @@ var ts; function emitFilesAndReportErrorUsingBuilder(builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - var reportSummary = function (errorCount) { - if (errorCount === 1) { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_1_error_Watching_for_file_changes, errorCount), newLine, compilerOptions); - } - else { - onWatchStatusChange(ts.createCompilerDiagnostic(ts.Diagnostics.Found_0_errors_Watching_for_file_changes, errorCount, errorCount), newLine, compilerOptions); - } - }; - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, reportSummary); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); } } /** @@ -89115,7 +90275,8 @@ var ts; fileExists: function (path) { return host.fileExists(path); }, readFile: readFile, getCurrentDirectory: getCurrentDirectory, - onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic + onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic, + trace: host.trace ? function (s) { return host.trace(s); } : undefined }; // From tsc we want to get already parsed result and hence check for rootFileNames var newLine = updateNewLine(); @@ -89183,11 +90344,11 @@ var ts; /*logChangesWhenResolvingModule*/ false); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames); }) : - (function (moduleNames, containingFile, reusedNames) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); }); + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }) : - (function (typeDirectiveNames, containingFile) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }); + (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; synchronizeProgram(); // Update the wild card directory watch @@ -89361,8 +90522,8 @@ var ts; var hostSourceFile = sourceFilesCache.get(path); return !hostSourceFile || isFileMissingOnHost(hostSourceFile) ? undefined : hostSourceFile.version.toString(); } - function onReleaseOldSourceFile(oldSourceFile, _oldOptions) { - var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.path); + function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { + var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); // If this is the source file thats in the cache and new program doesnt need it, // remove the cached entry. // Note we arent deleting entry if file became missing in new program or @@ -89376,8 +90537,10 @@ var ts; if (hostSourceFileInfo.fileWatcher) { hostSourceFileInfo.fileWatcher.close(); } - sourceFilesCache.delete(oldSourceFile.path); - resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + sourceFilesCache.delete(oldSourceFile.resolvedPath); + if (!hasSourceFileByPath) { + resolutionCache.removeResolutionsOfFile(oldSourceFile.path); + } } } } @@ -89457,6 +90620,7 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.get(path)) { resolutionCache.invalidateResolutionOfFile(path); } + resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -89497,6 +90661,8 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } nextSourceFileVersion(fileOrDirectoryPath); + if (ts.isPathInNodeModulesStartingWithDot(fileOrDirectoryPath)) + return; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) { @@ -89699,7 +90865,7 @@ var ts; }; } ts.createBuilderStatusReporter = createBuilderStatusReporter; - function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus) { + function createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus) { if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker({}, /*setParentNodes*/ undefined, system); host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : function () { return undefined; }; @@ -89709,10 +90875,15 @@ var ts; host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system); return host; } + function createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) { + if (system === void 0) { system = ts.sys; } + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); + host.reportErrorSummary = reportErrorSummary; + return host; + } ts.createSolutionBuilderHost = createSolutionBuilderHost; function createSolutionBuilderWithWatchHost(system, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) { - if (system === void 0) { system = ts.sys; } - var host = createSolutionBuilderHost(system, reportDiagnostic, reportSolutionBuilderStatus); + var host = createSolutionBuilderHostBase(system, reportDiagnostic, reportSolutionBuilderStatus); var watchHost = ts.createWatchHost(system, reportWatchStatus); host.onWatchStatusChange = watchHost.onWatchStatusChange; host.watchFile = watchHost.watchFile; @@ -89729,12 +90900,6 @@ var ts; }); return result; } - /** - * A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but - * can dynamically add/remove other projects based on changes on the rootNames' references - * TODO: use SolutionBuilderWithWatchHost => watchedSolution - * use SolutionBuilderHost => Solution - */ function createSolutionBuilder(host, rootNames, defaultOptions) { var hostWithWatch = host; var currentDirectory = host.getCurrentDirectory(); @@ -90093,9 +91258,7 @@ var ts; globalDependencyGraph = undefined; } projectStatus.removeKey(resolved); - if (options.watch) { - diagnostics.removeKey(resolved); - } + diagnostics.removeKey(resolved); addProjToQueue(resolved, reloadLevel); } /** @@ -90157,7 +91320,7 @@ var ts; } } function reportErrorSummary() { - if (options.watch) { + if (options.watch || host.reportErrorSummary) { // Report errors from the other projects getGlobalDependencyGraph().buildQueue.forEach(function (project) { if (!projectErrorsReported.hasKey(project)) { @@ -90165,8 +91328,13 @@ var ts; } }); var totalErrors_1 = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += singleProjectErrors.filter(function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; }).length; }); - reportWatchStatus(totalErrors_1 === 1 ? ts.Diagnostics.Found_1_error_Watching_for_file_changes : ts.Diagnostics.Found_0_errors_Watching_for_file_changes, totalErrors_1); + diagnostics.forEach(function (singleProjectErrors) { return totalErrors_1 += ts.getErrorCountForSummary(singleProjectErrors); }); + if (options.watch) { + reportWatchStatus(ts.getWatchErrorSummaryDiagnosticMessage(totalErrors_1), totalErrors_1); + } + else { + host.reportErrorSummary(totalErrors_1); + } } } function buildSingleInvalidatedProject(resolved, reloadLevel) { @@ -90330,9 +91498,7 @@ var ts; type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime }; - if (options.watch) { - diagnostics.removeKey(proj); - } + diagnostics.removeKey(proj); projectStatus.setValue(proj, status); return resultFlags; function buildErrors(diagnostics, errorFlags, errorType) { @@ -90458,10 +91624,8 @@ var ts; } function reportAndStoreErrors(proj, errors) { reportErrors(errors); - if (options.watch) { - projectErrorsReported.setValue(proj, true); - diagnostics.setValue(proj, errors); - } + projectErrorsReported.setValue(proj, true); + diagnostics.setValue(proj, errors); } function reportErrors(errors) { errors.forEach(function (err) { return host.reportDiagnostic(err); }); @@ -90583,10 +91747,12 @@ var ts; if (builtin !== undefined) return builtin; var entries = getEntriesOfObject(value); - return { kind: 3 /* Object */, name: name, members: ts.flatMap(entries, function (_a) { - var key = _a.key, value = _a.value; - return getValueInfo(key, value, recurser); - }) }; + var hasNontrivialPrototype = Object.getPrototypeOf(value) !== Object.prototype; + var members = ts.flatMap(entries, function (_a) { + var key = _a.key, value = _a.value; + return getValueInfo(key, value, recurser); + }); + return { kind: 3 /* Object */, name: name, hasNontrivialPrototype: hasNontrivialPrototype, members: members }; } return { kind: 0 /* Const */, name: name, typeName: isNullOrUndefined(value) ? "any" : typeof value }; }, function (isCircularReference, keyStack) { return anyValue(name, " " + (isCircularReference ? "Circular reference" : "Too-deep object hierarchy") + " from " + keyStack.join(".")); }); @@ -90717,7 +91883,6 @@ var ts; : undefined; } server.findArgument = findArgument; - /*@internal*/ function nowString() { // E.g. "12:34:56.789" var d = new Date(); @@ -90731,13 +91896,11 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - /* @internal */ function isTypingUpToDate(cachedTyping, availableTypingVersions) { var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; - /* @internal */ JsTyping.nodeCoreModuleList = [ "assert", "async_hooks", @@ -90776,7 +91939,6 @@ var ts; "vm", "zlib" ]; - /* @internal */ JsTyping.nodeCoreModules = ts.arrayToSet(JsTyping.nodeCoreModuleList); function loadSafeList(host, safeListPath) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index 0ffe456d728..bc7bc2fccf4 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -406,11 +406,11 @@ "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521": "運算式會解析成變數宣告 '{0}',而編譯器會使用此宣告支援非同步函式。", "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544": "運算式將解析成變數宣告 '_newTarget',而供編譯器用來擷取 'new.target' 中繼屬性參考。", "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400": "運算式會解析成變數宣告 '_this',而編譯器會使用此宣告來擷取 'this' 參考 。", - "Extract_constant_95006": "解壓縮常數", - "Extract_function_95005": "解壓縮函式", - "Extract_to_0_in_1_95004": "解壓縮至 {1} 中的 {0}", - "Extract_to_0_in_1_scope_95008": "解壓縮至 {1} 範圍中的 {0}", - "Extract_to_0_in_enclosing_scope_95007": "解壓縮至封閉式範圍中的 {0}", + "Extract_constant_95006": "擷取常數", + "Extract_function_95005": "擷取函式", + "Extract_to_0_in_1_95004": "擷取至 {1} 中的 {0}", + "Extract_to_0_in_1_scope_95008": "擷取至 {1} 範圍中的 {0}", + "Extract_to_0_in_enclosing_scope_95007": "擷取至封閉式範圍中的 {0}", "FILE_6035": "檔案", "FILE_OR_DIRECTORY_6040": "檔案或目錄", "Failed_to_parse_file_0_Colon_1_5014": "無法剖析檔案 '{0}': {1}。", @@ -584,7 +584,7 @@ "Module_name_0_was_successfully_resolved_to_1_6089": "======== 模組名稱 '{0}' 已成功解析為 '{1}'。========", "Module_resolution_kind_is_not_specified_using_0_6088": "未指定模組解析種類,將使用 '{0}'。", "Module_resolution_using_rootDirs_has_failed_6111": "使用 'rootDirs' 解析模組失敗。", - "Move_to_a_new_file_95049": "移至新行", + "Move_to_a_new_file_95049": "移至新檔", "Multiple_consecutive_numeric_separators_are_not_permitted_6189": "不允許多個連續的數字分隔符號。", "Multiple_constructor_implementations_are_not_allowed_2392": "不允許多個建構函式實作。", "NEWLINE_6061": "新行",